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 NameScreen extends StatefulWidget { final UserRegistrationSheet sheet; const NameScreen({required this.sheet, super.key}); @override State createState() => _NameScreenState(); } class _NameScreenState extends State { final firstNameController = TextEditingController(); final lastNameController = TextEditingController(); final nameFocus = FocusNode(); @override void initState() { super.initState(); firstNameController.text = widget.sheet.firstName; lastNameController.text = widget.sheet.lastName; nameFocus.requestFocus(); } @override Widget build(BuildContext context) { final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, top: 16, left: 16, right: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(s.first_name), SizedBox(height: 4), CustomTextFormField( controller: firstNameController, focusNode: nameFocus, textInputAction: TextInputAction.next, hintText: 'Введите имя', onChanged: (newValue) { final registrationCubit = context.read(); registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(firstName: newValue)); }, ), SizedBox(height: 16), Text(s.last_name), SizedBox(height: 4), CustomTextFormField( controller: lastNameController, textInputAction: TextInputAction.done, hintText: 'Введите фамилию', onChanged: (newValue) { final registrationCubit = context.read(); registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(lastName: newValue)); }, ), ], ), ); } }