Files
eatvio_app/lib/features/registration/presentation/pages/credentials_screen.dart
2024-09-11 17:39:00 +03:00

85 lines
3.1 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/widgets/custom_text_form_field.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class CredentialsScreen extends StatefulWidget {
final UserRegistrationSheet sheet;
const CredentialsScreen({super.key, required this.sheet});
@override
State<CredentialsScreen> createState() => _CredentialsScreenState();
}
class _CredentialsScreenState extends State<CredentialsScreen> {
final emailController = TextEditingController();
final passwordController = TextEditingController();
final passwordConfirmationController = TextEditingController();
@override
void initState() {
super.initState();
emailController.text = widget.sheet.email;
passwordController.text = widget.sheet.password;
passwordConfirmationController.text = widget.sheet.passwordConfirmation;
}
@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(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(s.email),
SizedBox(height: 4),
CustomTextFormField(
controller: emailController,
textInputType: TextInputType.emailAddress,
keyboardType: TextInputType.emailAddress,
hintText: 'Введите email',
textInputAction: TextInputAction.next,
onChanged: (newValue) {
final registrationCubit = context.read<RegistrationCubit>();
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(email: newValue));
},
),
SizedBox(height: 16),
Text(s.password),
SizedBox(height: 4),
CustomTextFormField(
obscureText: true,
controller: passwordController,
hintText: 'Введите пароль',
textInputAction: TextInputAction.next,
onChanged: (newValue) {
final registrationCubit = context.read<RegistrationCubit>();
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(password: newValue));
},
),
SizedBox(height: 16),
Text(s.password_confirmation),
SizedBox(height: 4),
CustomTextFormField(
obscureText: true,
controller: passwordConfirmationController,
textInputAction: TextInputAction.done,
hintText: 'Подтвердите пароль',
onChanged: (newValue) {
final registrationCubit = context.read<RegistrationCubit>();
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(passwordConfirmation: newValue));
},
),
],
),
);
}
}