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(
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: <TextInputFormatter>[
digitsOnly // Ограничение ввода только цифрами
],
),
SizedBox(height: 15.v),
Text("waist_circumference".tr,
),
SizedBox(height: 5.v),
CustomTextFormField(
controller: state.chestCircumferenceController,
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[
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: <TextInputFormatter>[
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: <TextInputFormatter>[
digitsOnly // Ограничение ввода только цифрами
],
),
],
),
),
SizedBox(height: 5.v),
CustomTextFormField(
controller: state.waistCircumferenceController,
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[
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: <TextInputFormatter>[
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: <TextInputFormatter>[
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: <TextInputFormatter>[
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<String, dynamic> data = {