From 715559d384c818874c44875d36049701ab5211c2 Mon Sep 17 00:00:00 2001 From: maxxkim Date: Tue, 23 Jan 2024 13:00:16 +0300 Subject: [PATCH] Fixed dialog layout --- .../my_profile_screen/my_profile_screen.dart | 127 +++++++++--------- lib/widgets/custom_text_form_field.dart | 5 +- 2 files changed, 66 insertions(+), 66 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 803734f8..cb7c15fe 100644 --- a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart @@ -11,13 +11,12 @@ import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:carousel_slider/carousel_slider.dart'; import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; +import 'package:flutter/services.dart'; import 'dart:math'; import 'package:intl/intl.dart'; import 'package:fl_chart/fl_chart.dart'; class MyProfileScreen extends StatelessWidget { - const MyProfileScreen({Key? key}) : super(key: key); - static Widget builder(BuildContext context) { return BlocProvider( create: (context) => @@ -28,6 +27,7 @@ class MyProfileScreen extends StatelessWidget { @override Widget build(BuildContext context) { + mediaQueryData = MediaQuery.of(context); return BlocBuilder( builder: (context, state) { return SafeArea( @@ -107,78 +107,67 @@ class MyProfileScreen extends StatelessWidget { showDialog( context: context, builder: (context) { + final digitsOnly = + FilteringTextInputFormatter + .digitsOnly; return AlertDialog( - title: Text("Добавить замер"), - content: Column( - children: [ - BlocSelector< - MyProfileBloc, - MyProfileState, - TextEditingController?>( - selector: (state) => state + title: Center( + child: Text("Добавить замер")), + content: SingleChildScrollView( + child: Column( + children: [ + Text("chest_circumference".tr, + style: theme + .textTheme.bodyLarge), + SizedBox(height: 5.v), + CustomTextFormField( + controller: state .chestCircumferenceController, - builder: (context, - chestCircumferenceController) { - return TextField( - controller: - chestCircumferenceController, - keyboardType: - TextInputType - .number, - decoration: InputDecoration( - labelText: - "chest_circumference" - .tr), - ); - }), - BlocSelector< - MyProfileBloc, - MyProfileState, - TextEditingController?>( - selector: (state) => state + keyboardType: + TextInputType.number, + inputFormatters: [ + digitsOnly // Ограничение ввода только цифрами + ], + ), + SizedBox(height: 15.v), + Text("waist_circumference".tr, + style: theme + .textTheme.bodyLarge), + SizedBox(height: 5.v), + CustomTextFormField( + controller: state .waistCircumferenceController, - builder: (context, - waistCircumferenceController) { - return TextField( - controller: - waistCircumferenceController, - keyboardType: - TextInputType - .number, - decoration: InputDecoration( - labelText: - "waist_circumference" - .tr), - ); - }), - BlocSelector< - MyProfileBloc, - MyProfileState, - TextEditingController?>( - selector: (state) => state + 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, - builder: (context, - hipCircumferenceController) { - return TextField( - controller: - hipCircumferenceController, - keyboardType: - TextInputType - .number, - decoration: InputDecoration( - labelText: - "hip_circumference" - .tr), - ); - }), - ], + keyboardType: + TextInputType.number, + inputFormatters: [ + digitsOnly // Ограничение ввода только цифрами + ], + ), + ], + ), ), actions: [ TextButton( onPressed: () { Navigator.pop(context); }, - child: Text("Отмена"), + child: Text("Отмена", + style: theme + .textTheme.bodyLarge), ), TextButton( onPressed: () { @@ -186,9 +175,17 @@ class MyProfileScreen extends StatelessWidget { // Закрытие диалогового окна Navigator.pop(context); }, - child: Text("Изменить"), + child: Text("Изменить", + style: CustomTextStyles + .titleMediumBlack + .copyWith( + color: Colors.blue, + )), ), ], + backgroundColor: Colors.white, + titlePadding: EdgeInsets.all( + 20.0), // Можете настроить отступы по вашему желанию ); }, ); diff --git a/lib/widgets/custom_text_form_field.dart b/lib/widgets/custom_text_form_field.dart index 00bfdf3c..a96c5a1c 100644 --- a/lib/widgets/custom_text_form_field.dart +++ b/lib/widgets/custom_text_form_field.dart @@ -27,6 +27,7 @@ class CustomTextFormField extends StatelessWidget { this.fillColor, this.filled = true, this.validator, + this.keyboardType, this.onSaved, }) : super( key: key, @@ -74,6 +75,8 @@ class CustomTextFormField extends StatelessWidget { final bool? filled; + final TextInputType? keyboardType; + final FormFieldValidator? validator; final void Function(String?)? onSaved; @@ -97,10 +100,10 @@ class CustomTextFormField extends StatelessWidget { style: textStyle ?? theme.textTheme.titleMedium, obscureText: obscureText!, textInputAction: textInputAction, - keyboardType: textInputType, maxLines: maxLines ?? 1, decoration: decoration, validator: validator, + keyboardType: keyboardType, onSaved: onSaved, inputFormatters: inputFormatters, ),