forked from eatvio/eatvio_app
67 lines
2.3 KiB
Dart
67 lines
2.3 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 NameScreen extends StatefulWidget {
|
|
final UserRegistrationSheet sheet;
|
|
|
|
const NameScreen({required this.sheet, super.key});
|
|
|
|
@override
|
|
State<NameScreen> createState() => _NameScreenState();
|
|
}
|
|
|
|
class _NameScreenState extends State<NameScreen> {
|
|
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: const EdgeInsets.only(bottom: 80, top: 16, left: 16, right: 16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(s.first_name),
|
|
const SizedBox(height: 4),
|
|
CustomTextFormField(
|
|
controller: firstNameController,
|
|
focusNode: nameFocus,
|
|
textInputAction: TextInputAction.next,
|
|
hintText: 'Введите имя',
|
|
onChanged: (newValue) {
|
|
final registrationCubit = context.read<RegistrationCubit>();
|
|
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(firstName: newValue));
|
|
},
|
|
),
|
|
const SizedBox(height: 16),
|
|
Text(s.last_name),
|
|
const SizedBox(height: 4),
|
|
CustomTextFormField(
|
|
controller: lastNameController,
|
|
textInputAction: TextInputAction.done,
|
|
hintText: 'Введите фамилию',
|
|
onChanged: (newValue) {
|
|
final registrationCubit = context.read<RegistrationCubit>();
|
|
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(lastName: newValue));
|
|
},
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|