Files
eatvio_app/lib/features/registration/presentation/pages/language_select_screen.dart
2024-11-20 14:30:48 +03:00

64 lines
2.2 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:eatvio_app/core/data/selectionPopupModel/selection_popup_model.dart';
import 'package:eatvio_app/core/widgets/custom_drop_down.dart';
import 'package:eatvio_app/features/registration/models/user_registration_model.dart';
import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class LanguageSelectScreen extends StatefulWidget {
final UserRegistrationSheet sheet;
const LanguageSelectScreen({required this.sheet, super.key});
@override
State<LanguageSelectScreen> createState() => _LanguageSelectScreenState();
}
class _LanguageSelectScreenState extends State<LanguageSelectScreen> {
final List<SelectionPopupModel> dropdownItemList = [
SelectionPopupModel(id: 1, title: "Русский", isSelected: true),
];
late SelectionPopupModel value;
@override
void initState() {
super.initState();
if (widget.sheet.lang.isNotEmpty) {
value = dropdownItemList.firstWhere((item) => item.title == widget.sheet.lang);
} else {
value = dropdownItemList.first;
final registrationCubit = context.read<RegistrationCubit>();
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(lang: value.title));
}
}
@override
Widget build(BuildContext context) {
final s = S.of(context);
return SingleChildScrollView(
padding: EdgeInsets.only(bottom: 80, right: 16, left: 16, top: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
s.preferred_language,
),
const SizedBox(height: 4),
CustomDropDown(
value: value,
hintText: "Не выбрано",
items: dropdownItemList,
onChanged: (SelectionPopupModel newValue) => setState(() {
value = newValue;
final registrationCubit = context.read<RegistrationCubit>();
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(lang: value.title));
}),
),
],
),
);
}
}