Fixed keyboard overflow for credentials

This commit is contained in:
2023-12-28 13:05:29 +03:00
parent 885fa08f30
commit d2e1bc087e

View File

@@ -26,133 +26,132 @@ class CredentialsScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: false,
appBar: _buildAppBar(context),
body: Container(
width: double.maxFinite,
padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v),
child: Column(children: [
SizedBox(height: 7.v),
Container(
height: 16.v,
width: 343.h,
decoration: BoxDecoration(
color: theme.colorScheme.onPrimary,
borderRadius: BorderRadius.circular(8.h),
border: Border.all(
color: theme.colorScheme.primary, width: 1.h)),
child: ClipRRect(
borderRadius: BorderRadius.circular(8.h),
child: LinearProgressIndicator(
value: 0.05,
backgroundColor: theme.colorScheme.onPrimary,
valueColor: AlwaysStoppedAnimation<Color>(
appTheme.blueA400)))),
SizedBox(height: 39.v),
Text("user_registration".tr,
style: theme.textTheme.headlineSmall),
SizedBox(height: 93.v),
Text("email".tr, style: theme.textTheme.bodyLarge),
SizedBox(height: 3.v),
BlocSelector<CredentialsBloc, CredentialsState,
TextEditingController?>(
selector: (state) => state.emailController,
builder: (context, emailController) {
return CustomTextFormField(
controller: emailController,
textInputAction: TextInputAction.done);
}),
SizedBox(height: 22.v),
Text("username".tr, style: theme.textTheme.bodyLarge),
SizedBox(height: 3.v),
BlocSelector<CredentialsBloc, CredentialsState,
TextEditingController?>(
selector: (state) => state.nameController,
builder: (context, nameController) {
return CustomTextFormField(
controller: nameController,
textInputAction: TextInputAction.done);
}),
SizedBox(height: 19.v),
Text("password".tr, style: theme.textTheme.bodyLarge),
SizedBox(height: 5.v),
BlocSelector<CredentialsBloc, CredentialsState,
TextEditingController?>(
selector: (state) => state.passwordController,
builder: (context, passwordController) {
return CustomTextFormField(
obscureText: true,
controller: passwordController,
);
}),
SizedBox(height: 21.v),
Text("password_confirmation".tr,
style: theme.textTheme.bodyLarge),
SizedBox(height: 3.v),
BlocSelector<CredentialsBloc, CredentialsState,
TextEditingController?>(
selector: (state) => state.passwordConfirmationController,
builder: (context, passwordConfirmationController) {
return CustomTextFormField(
obscureText: true,
controller: passwordConfirmationController,
textInputAction: TextInputAction.done);
}),
Spacer(),
BlocBuilder<CredentialsBloc, CredentialsState>(
builder: (context, state) {
return NextStepButton(
text: "continue".tr.toUpperCase(),
margin: EdgeInsets.only(
left: 16.h, right: 16.h, bottom: 50.v),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: () {
List<String> errors = validateFields(
state.emailController!.text,
state.nameController!.text,
state.passwordController!.text,
state.passwordConfirmationController!.text);
if (errors.isEmpty) {
UserRegistrationSheet sheet = state
.credentialsModelObj!.userRegistrationSheet;
sheet.email = state.emailController!.text;
sheet.name = state.nameController!.text;
sheet.password = state.passwordController!.text;
sheet.passwordConfirmation =
state.passwordConfirmationController!.text;
Navigator.pushNamed(
context,
AppRoutes.nameScreen,
arguments: sheet,
);
} else {
String errorMessage = '';
for (var error in errors) {
errorMessage += error + '\n\n';
}
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text('Ошибка'),
content: Text(errorMessage),
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: Text('OK'),
),
],
),
);
}
});
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: _buildAppBar(context),
body: Container(
width: double.maxFinite,
padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v),
child: Column(children: [
SizedBox(height: 7.v),
Container(
height: 16.v,
width: 343.h,
decoration: BoxDecoration(
color: theme.colorScheme.onPrimary,
borderRadius: BorderRadius.circular(8.h),
border: Border.all(
color: theme.colorScheme.primary, width: 1.h)),
child: ClipRRect(
borderRadius: BorderRadius.circular(8.h),
child: LinearProgressIndicator(
value: 0.05,
backgroundColor: theme.colorScheme.onPrimary,
valueColor: AlwaysStoppedAnimation<Color>(
appTheme.blueA400)))),
SizedBox(height: 39.v),
Text("user_registration".tr,
style: theme.textTheme.headlineSmall),
SizedBox(height: 16.v),
Text("email".tr, style: theme.textTheme.bodyLarge),
SizedBox(height: 3.v),
BlocSelector<CredentialsBloc, CredentialsState,
TextEditingController?>(
selector: (state) => state.emailController,
builder: (context, emailController) {
return CustomTextFormField(
controller: emailController,
textInputAction: TextInputAction.done);
}),
]))));
SizedBox(height: 22.v),
Text("username".tr, style: theme.textTheme.bodyLarge),
SizedBox(height: 3.v),
BlocSelector<CredentialsBloc, CredentialsState,
TextEditingController?>(
selector: (state) => state.nameController,
builder: (context, nameController) {
return CustomTextFormField(
controller: nameController,
textInputAction: TextInputAction.done);
}),
SizedBox(height: 19.v),
Text("password".tr, style: theme.textTheme.bodyLarge),
SizedBox(height: 5.v),
BlocSelector<CredentialsBloc, CredentialsState,
TextEditingController?>(
selector: (state) => state.passwordController,
builder: (context, passwordController) {
return CustomTextFormField(
obscureText: true,
controller: passwordController,
);
}),
SizedBox(height: 21.v),
Text("password_confirmation".tr,
style: theme.textTheme.bodyLarge),
SizedBox(height: 3.v),
BlocSelector<CredentialsBloc, CredentialsState,
TextEditingController?>(
selector: (state) => state.passwordConfirmationController,
builder: (context, passwordConfirmationController) {
return CustomTextFormField(
obscureText: true,
controller: passwordConfirmationController,
textInputAction: TextInputAction.done);
}),
Spacer(),
BlocBuilder<CredentialsBloc, CredentialsState>(
builder: (context, state) {
return NextStepButton(
text: "continue".tr.toUpperCase(),
margin:
EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: () {
List<String> errors = validateFields(
state.emailController!.text,
state.nameController!.text,
state.passwordController!.text,
state.passwordConfirmationController!.text);
if (errors.isEmpty) {
UserRegistrationSheet sheet =
state.credentialsModelObj!.userRegistrationSheet;
sheet.email = state.emailController!.text;
sheet.name = state.nameController!.text;
sheet.password = state.passwordController!.text;
sheet.passwordConfirmation =
state.passwordConfirmationController!.text;
Navigator.pushNamed(
context,
AppRoutes.nameScreen,
arguments: sheet,
);
} else {
String errorMessage = '';
for (var error in errors) {
errorMessage += error + '\n\n';
}
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text('Ошибка'),
content: Text(errorMessage),
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: Text('OK'),
),
],
),
);
}
});
}),
])));
}
/// Section Widget