import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; class CredentialsScreen extends StatefulWidget { final UserRegistrationSheet sheet; const CredentialsScreen({super.key, required this.sheet}); @override State createState() => _CredentialsScreenState(); } class _CredentialsScreenState extends State { final emailController = TextEditingController(); final nameController = TextEditingController(); final passwordController = TextEditingController(); final passwordConfirmationController = TextEditingController(); @override void initState() { super.initState(); emailController.text = widget.sheet.email; nameController.text = widget.sheet.name; passwordController.text = widget.sheet.password; passwordConfirmationController.text = widget.sheet.passwordConfirmation; } @override Widget build(BuildContext context) { return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80), child: Container( width: double.maxFinite, padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), child: Column( mainAxisSize: MainAxisSize.min, children: [ Text("user_registration".tr, style: theme.textTheme.headlineSmall), SizedBox(height: 16.v), Text("email".tr, style: theme.textTheme.bodyLarge), SizedBox(height: 3.v), CustomTextFormField( controller: emailController, textInputAction: TextInputAction.done, onChanged: (newValue) { final registrationCubit = context.read(); registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(email: newValue)); }, ), SizedBox(height: 22.v), Text("username".tr, style: theme.textTheme.bodyLarge), SizedBox(height: 3.v), CustomTextFormField( controller: nameController, textInputAction: TextInputAction.done, onChanged: (newValue) { final registrationCubit = context.read(); registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(name: newValue)); }, ), SizedBox(height: 19.v), Text("password".tr, style: theme.textTheme.bodyLarge), SizedBox(height: 5.v), CustomTextFormField( obscureText: true, controller: passwordController, onChanged: (newValue) { final registrationCubit = context.read(); registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(password: newValue)); }, ), SizedBox(height: 21.v), Text("password_confirmation".tr, style: theme.textTheme.bodyLarge), SizedBox(height: 3.v), CustomTextFormField( obscureText: true, controller: passwordConfirmationController, textInputAction: TextInputAction.done, onChanged: (newValue) { final registrationCubit = context.read(); registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(passwordConfirmation: newValue)); }, ), ], ), ), ); } }