From 43da826fa4a632353ecfd2b3475e73e0fa5b50a4 Mon Sep 17 00:00:00 2001 From: maxxkim Date: Wed, 6 Mar 2024 12:32:58 +0300 Subject: [PATCH] refactor(diary): Refactoring done for profille_screen --- .../my_profile_screen/my_profile_screen.dart | 124 ++++++++++-------- 1 file changed, 68 insertions(+), 56 deletions(-) diff --git a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart index 9f94f9a7..cb11557c 100644 --- a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart @@ -788,51 +788,58 @@ class MyProfileScreen extends StatelessWidget { showDialog( context: context, builder: (context) { - final digitsOnly = FilteringTextInputFormatter.digitsOnly; + //final digitsOnly = FilteringTextInputFormatter.digitsOnly; return AlertDialog( title: Center(child: Text("Добавить замер")), - content: SingleChildScrollView( - child: Column( - children: [ - Text("chest_circumference".tr, + content: ListView( + children: [ + Padding( + padding: EdgeInsets.symmetric(vertical: 5.v), + child: Text("chest_circumference".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 5.v), - CustomTextFormField( - controller: state.chestCircumferenceController, - keyboardType: TextInputType.number, - inputFormatters: [ - digitsOnly // Ограничение ввода только цифрами - ], - ), - SizedBox(height: 15.v), - Text("waist_circumference".tr, + ), + SizedBox(height: 5.v), + CustomTextFormField( + controller: state.chestCircumferenceController, + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter + .digitsOnly, // Ограничение ввода только цифрами + ], + ), + Padding( + padding: EdgeInsets.symmetric(vertical: 15.v), + child: Text("waist_circumference".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 5.v), - CustomTextFormField( - controller: state.waistCircumferenceController, - keyboardType: TextInputType.number, - inputFormatters: [ - digitsOnly // Ограничение ввода только цифрами - ], - ), - SizedBox(height: 15.v), - Text("hip_circumference".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 5.v), - CustomTextFormField( - controller: state.hipCircumferenceController, - keyboardType: TextInputType.number, - inputFormatters: [ - digitsOnly // Ограничение ввода только цифрами - ], - ), - ], - ), + ), + SizedBox(height: 5.v), + CustomTextFormField( + controller: state.waistCircumferenceController, + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter + .digitsOnly, // Ограничение ввода только цифрами + ], + ), + Padding( + padding: EdgeInsets.symmetric(vertical: 15.v), + child: Text("hip_circumference".tr, + style: theme.textTheme.bodyLarge), + ), + SizedBox(height: 5.v), + CustomTextFormField( + controller: state.hipCircumferenceController, + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter + .digitsOnly, // Ограничение ввода только цифрами + ], + ), + ], ), actions: [ TextButton( - onPressed: () { - Navigator.pop(context); - }, + onPressed: onTapOk(context), child: Text("Отмена", style: theme.textTheme.bodyLarge), ), TextButton( @@ -895,29 +902,28 @@ class MyProfileScreen extends StatelessWidget { showDialog( context: context, builder: (context) { - final digitsOnly = FilteringTextInputFormatter.digitsOnly; return AlertDialog( title: Center(child: Text("add_measure".tr)), - content: SingleChildScrollView( - child: Column( - children: [ - Text("weight".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 5.v), - CustomTextFormField( - controller: state.weightController, - keyboardType: TextInputType.number, - inputFormatters: [ - digitsOnly // Ограничение ввода только цифрами - ], - ), - ], - ), + content: ListView( + children: [ + Padding( + padding: EdgeInsets.symmetric(vertical: 5.v), + child: Text("weight".tr, style: theme.textTheme.bodyLarge), + ), + SizedBox(height: 5.v), + CustomTextFormField( + controller: state.weightController, + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter + .digitsOnly, // Ограничение ввода только цифрами + ], + ), + ], ), actions: [ TextButton( - onPressed: () { - Navigator.pop(context); - }, + onPressed: onTapOk(context), child: Text("Отмена", style: theme.textTheme.bodyLarge), ), TextButton( @@ -936,6 +942,12 @@ class MyProfileScreen extends StatelessWidget { ); } + onTapOk(BuildContext context) { + return () { + Navigator.pop(context); + }; + } + addWeight(MyProfileLoadedState state, BuildContext context) { return () async { Map data = {