Files
eatvio_app/lib/features/registration/presentation/pages/allergies_screen.dart
2025-04-04 20:21:31 +07:00

56 lines
1.9 KiB
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:eatvio_app/core/widgets/custom_text_form_field.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class AllergiesScreen extends StatefulWidget {
final UserRegistrationSheet sheet;
const AllergiesScreen({super.key, required this.sheet});
@override
State<AllergiesScreen> createState() => _AllergiesScreenState();
}
class _AllergiesScreenState extends State<AllergiesScreen> {
final enterInformationController = TextEditingController();
final infoFocusNode = FocusNode();
@override
void initState() {
super.initState();
enterInformationController.text = widget.sheet.aboutAllergy;
infoFocusNode.requestFocus();
}
@override
Widget build(BuildContext context) {
final s = S.of(context);
return SingleChildScrollView(
padding: const EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('${s.allergies_presence} (не обязательно)'),
const SizedBox(height: 4),
CustomTextFormField(
controller: enterInformationController,
hintText: 'Например: орехи, мёд и т.д.',
textInputAction: TextInputAction.done,
focusNode: infoFocusNode,
autofocus: true,
minLines: 2,
maxLines: 8,
onChanged: (newValue) {
final registrationCubit = context.read<RegistrationCubit>();
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(aboutAllergy: newValue));
},
),
],
),
);
}
}