refactor(diary): Refactoring done for profille_screen

This commit is contained in:
2024-03-06 12:32:58 +03:00
parent 47cf17c927
commit 43da826fa4

View File

@@ -788,51 +788,58 @@ class MyProfileScreen extends StatelessWidget {
showDialog( showDialog(
context: context, context: context,
builder: (context) { builder: (context) {
final digitsOnly = FilteringTextInputFormatter.digitsOnly; //final digitsOnly = FilteringTextInputFormatter.digitsOnly;
return AlertDialog( return AlertDialog(
title: Center(child: Text("Добавить замер")), title: Center(child: Text("Добавить замер")),
content: SingleChildScrollView( content: ListView(
child: Column( children: [
children: [ Padding(
Text("chest_circumference".tr, padding: EdgeInsets.symmetric(vertical: 5.v),
child: Text("chest_circumference".tr,
style: theme.textTheme.bodyLarge), style: theme.textTheme.bodyLarge),
SizedBox(height: 5.v), ),
CustomTextFormField( SizedBox(height: 5.v),
controller: state.chestCircumferenceController, CustomTextFormField(
keyboardType: TextInputType.number, controller: state.chestCircumferenceController,
inputFormatters: <TextInputFormatter>[ keyboardType: TextInputType.number,
digitsOnly // Ограничение ввода только цифрами inputFormatters: <TextInputFormatter>[
], FilteringTextInputFormatter
), .digitsOnly, // Ограничение ввода только цифрами
SizedBox(height: 15.v), ],
Text("waist_circumference".tr, ),
Padding(
padding: EdgeInsets.symmetric(vertical: 15.v),
child: Text("waist_circumference".tr,
style: theme.textTheme.bodyLarge), style: theme.textTheme.bodyLarge),
SizedBox(height: 5.v), ),
CustomTextFormField( SizedBox(height: 5.v),
controller: state.waistCircumferenceController, CustomTextFormField(
keyboardType: TextInputType.number, controller: state.waistCircumferenceController,
inputFormatters: <TextInputFormatter>[ keyboardType: TextInputType.number,
digitsOnly // Ограничение ввода только цифрами inputFormatters: <TextInputFormatter>[
], FilteringTextInputFormatter
), .digitsOnly, // Ограничение ввода только цифрами
SizedBox(height: 15.v), ],
Text("hip_circumference".tr, style: theme.textTheme.bodyLarge), ),
SizedBox(height: 5.v), Padding(
CustomTextFormField( padding: EdgeInsets.symmetric(vertical: 15.v),
controller: state.hipCircumferenceController, child: Text("hip_circumference".tr,
keyboardType: TextInputType.number, style: theme.textTheme.bodyLarge),
inputFormatters: <TextInputFormatter>[ ),
digitsOnly // Ограничение ввода только цифрами SizedBox(height: 5.v),
], CustomTextFormField(
), controller: state.hipCircumferenceController,
], keyboardType: TextInputType.number,
), inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter
.digitsOnly, // Ограничение ввода только цифрами
],
),
],
), ),
actions: [ actions: [
TextButton( TextButton(
onPressed: () { onPressed: onTapOk(context),
Navigator.pop(context);
},
child: Text("Отмена", style: theme.textTheme.bodyLarge), child: Text("Отмена", style: theme.textTheme.bodyLarge),
), ),
TextButton( TextButton(
@@ -895,29 +902,28 @@ class MyProfileScreen extends StatelessWidget {
showDialog( showDialog(
context: context, context: context,
builder: (context) { builder: (context) {
final digitsOnly = FilteringTextInputFormatter.digitsOnly;
return AlertDialog( return AlertDialog(
title: Center(child: Text("add_measure".tr)), title: Center(child: Text("add_measure".tr)),
content: SingleChildScrollView( content: ListView(
child: Column( children: [
children: [ Padding(
Text("weight".tr, style: theme.textTheme.bodyLarge), padding: EdgeInsets.symmetric(vertical: 5.v),
SizedBox(height: 5.v), child: Text("weight".tr, style: theme.textTheme.bodyLarge),
CustomTextFormField( ),
controller: state.weightController, SizedBox(height: 5.v),
keyboardType: TextInputType.number, CustomTextFormField(
inputFormatters: <TextInputFormatter>[ controller: state.weightController,
digitsOnly // Ограничение ввода только цифрами keyboardType: TextInputType.number,
], inputFormatters: <TextInputFormatter>[
), FilteringTextInputFormatter
], .digitsOnly, // Ограничение ввода только цифрами
), ],
),
],
), ),
actions: [ actions: [
TextButton( TextButton(
onPressed: () { onPressed: onTapOk(context),
Navigator.pop(context);
},
child: Text("Отмена", style: theme.textTheme.bodyLarge), child: Text("Отмена", style: theme.textTheme.bodyLarge),
), ),
TextButton( TextButton(
@@ -936,6 +942,12 @@ class MyProfileScreen extends StatelessWidget {
); );
} }
onTapOk(BuildContext context) {
return () {
Navigator.pop(context);
};
}
addWeight(MyProfileLoadedState state, BuildContext context) { addWeight(MyProfileLoadedState state, BuildContext context) {
return () async { return () async {
Map<String, dynamic> data = { Map<String, dynamic> data = {