forked from eatvio/eatvio_app
112 lines
4.0 KiB
Dart
112 lines
4.0 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 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();
|
|
final emailFocusNode = FocusNode();
|
|
bool hidePassword = true;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
emailController.text = widget.sheet.email;
|
|
passwordController.text = widget.sheet.password;
|
|
passwordConfirmationController.text = widget.sheet.passwordConfirmation;
|
|
emailFocusNode.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(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(s.email),
|
|
SizedBox(height: 4),
|
|
CustomTextFormField(
|
|
controller: emailController,
|
|
focusNode: emailFocusNode,
|
|
textInputType: TextInputType.emailAddress,
|
|
keyboardType: TextInputType.emailAddress,
|
|
hintText: 'Введите email',
|
|
autofocus: true,
|
|
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: hidePassword,
|
|
controller: passwordController,
|
|
hintText: 'Введите пароль',
|
|
textInputAction: TextInputAction.next,
|
|
suffix: IconButton(
|
|
onPressed: () {
|
|
setState(() {
|
|
hidePassword = !hidePassword;
|
|
});
|
|
},
|
|
icon: Icon(
|
|
hidePassword ? Icons.visibility_outlined : Icons.visibility_off_outlined,
|
|
color: Colors.grey,
|
|
),
|
|
),
|
|
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: hidePassword,
|
|
controller: passwordConfirmationController,
|
|
textInputAction: TextInputAction.done,
|
|
hintText: 'Подтвердите пароль',
|
|
suffix: IconButton(
|
|
onPressed: () {
|
|
setState(() {
|
|
hidePassword = !hidePassword;
|
|
});
|
|
},
|
|
icon: Icon(
|
|
hidePassword ? Icons.visibility_outlined : Icons.visibility_off_outlined,
|
|
color: Colors.grey,
|
|
),
|
|
),
|
|
onChanged: (newValue) {
|
|
final registrationCubit = context.read<RegistrationCubit>();
|
|
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(passwordConfirmation: newValue));
|
|
},
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|