diff --git a/lib/core/initialization_cubit/initialization_cubit.dart b/lib/core/initialization_cubit/initialization_cubit.dart index 2052a25a..4a1bcaf2 100644 --- a/lib/core/initialization_cubit/initialization_cubit.dart +++ b/lib/core/initialization_cubit/initialization_cubit.dart @@ -9,7 +9,7 @@ import 'package:eatvio_app/locator_service.dart'; class InitializationCubit extends Cubit { final ChatRepository chatRepository; - bool wasInitializated = false; + bool wasInitialized = false; InitializationCubit({required this.chatRepository}) : super(const InitializationState.loading()); @@ -50,8 +50,8 @@ class InitializationCubit extends Cubit { } Future runInitialization() async { - if (!wasInitializated) { - wasInitializated = true; + if (!wasInitialized) { + wasInitialized = true; try { await TokenStorage.haveTokenInStorage(); final wsUrl = await chatRepository.getWebsocket(); diff --git a/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart b/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart index 4d06c950..f9e767fc 100644 --- a/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart +++ b/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart @@ -19,11 +19,11 @@ class RegistrationCubit extends Cubit { email: '', password: '', passwordConfirmation: '', - birthdate: DateTime.now().toString(), + birthdate: '', gender: '', country: '', city: '', - lang: 'Русский', + lang: '', weight: 0, height: 0, chestCircumference: 0, diff --git a/lib/features/registration/presentation/pages/additional_information_screen.dart b/lib/features/registration/presentation/pages/additional_information_screen.dart index b1838fdd..159a599f 100644 --- a/lib/features/registration/presentation/pages/additional_information_screen.dart +++ b/lib/features/registration/presentation/pages/additional_information_screen.dart @@ -15,46 +15,42 @@ class AdditionalInformationScreen extends StatefulWidget { class _AdditionalInformationScreenState extends State { final editTextController = TextEditingController(); + final editFocusNode = FocusNode(); @override void initState() { super.initState(); editTextController.text = widget.sheet.additionalInfo; + editFocusNode.requestFocus(); } @override Widget build(BuildContext context) { return SingleChildScrollView( - padding: EdgeInsets.only(bottom: 80), - child: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column( - children: [ - Container( - width: 294.h, - margin: EdgeInsets.only(left: 24.h, right: 23.h), - child: Text( - "enter_additional_information".tr, - maxLines: 2, - overflow: TextOverflow.ellipsis, - textAlign: TextAlign.center, - style: CustomTextStyles.titleMediumSegoeUI, - ), - ), - SizedBox(height: 10.v), - CustomTextFormField( - controller: editTextController, - hintText: "У меня крепкое здоровье, но последнее время часто утомляюсь, однако, это мне не мешает радоваться жизни", - textInputAction: TextInputAction.done, - maxLines: 8, - onChanged: (newValue) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(additionalInfo: newValue)); - }, - ), - ], - ), + padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Дополнительная информация', + maxLines: 2, + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.start, + ), + SizedBox(height: 4), + CustomTextFormField( + controller: editTextController, + hintText: "У меня крепкое здоровье, но последнее время часто утомляюсь, однако, это мне не мешает радоваться жизни", + textInputAction: TextInputAction.done, + maxLines: 8, + focusNode: editFocusNode, + autofocus: true, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(additionalInfo: newValue)); + }, + ), + ], ), ); } diff --git a/lib/features/registration/presentation/pages/allergies_screen.dart b/lib/features/registration/presentation/pages/allergies_screen.dart index 3261c92f..5a4e4bc3 100644 --- a/lib/features/registration/presentation/pages/allergies_screen.dart +++ b/lib/features/registration/presentation/pages/allergies_screen.dart @@ -15,38 +15,38 @@ class AllergiesScreen extends StatefulWidget { class _AllergiesScreenState extends State { final enterInformationController = TextEditingController(); + final infoFocusNode = FocusNode(); @override void initState() { super.initState(); enterInformationController.text = widget.sheet.aboutAllergy; + infoFocusNode.requestFocus(); } @override Widget build(BuildContext context) { return SingleChildScrollView( - padding: EdgeInsets.only(bottom: 80), - child: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column( - children: [ - Text("allergies_presence".tr, style: theme.textTheme.headlineSmall), - SizedBox(height: 22.v), - Text("fill_in_information".tr, style: CustomTextStyles.titleMediumSegoeUI), - SizedBox(height: 2.v), - CustomTextFormField( - controller: enterInformationController, - hintText: "enter_information".tr, - textInputAction: TextInputAction.done, - maxLines: 8, - onChanged: (newValue) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(aboutAllergy: newValue)); - }, - ), - ], - ), + padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("allergies_presence".tr), + SizedBox(height: 4), + CustomTextFormField( + controller: enterInformationController, + hintText: 'Например: орехи, мёд и т.д.', + textInputAction: TextInputAction.done, + focusNode: infoFocusNode, + autofocus: true, + minLines: 2, + maxLines: 8, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(aboutAllergy: newValue)); + }, + ), + ], ), ); } diff --git a/lib/features/registration/presentation/pages/blood_pressure_screen.dart b/lib/features/registration/presentation/pages/blood_pressure_screen.dart index ef69278b..d22cf321 100644 --- a/lib/features/registration/presentation/pages/blood_pressure_screen.dart +++ b/lib/features/registration/presentation/pages/blood_pressure_screen.dart @@ -33,125 +33,93 @@ class _BloodPressureScreenState extends State { final digitsOnly = FilteringTextInputFormatter.digitsOnly; final upPressureController = TextEditingController(); final downPressureController = TextEditingController(); + final upFocusNode = FocusNode(); @override void initState() { super.initState(); selectedPopupHypo = selectionPopupList[1]; selectedPopupHyper = selectionPopupList[1]; - upPressureController.text = widget.sheet.bloodPressureUp.toString(); - downPressureController.text = widget.sheet.bloodPressureDown.toString(); - widget.sheet.hasHyper == '1' ? selectedPopupHyper = selectionPopupList[0] : selectedPopupHyper = selectionPopupList[1]; - widget.sheet.hasHypo == '1' ? selectedPopupHypo = selectionPopupList[0] : selectedPopupHypo = selectionPopupList[1]; + if (widget.sheet.bloodPressureUp != 0) upPressureController.text = widget.sheet.bloodPressureUp.toString(); + if (widget.sheet.bloodPressureDown != 0) downPressureController.text = widget.sheet.bloodPressureDown.toString(); + widget.sheet.hasHyper == 1 ? selectedPopupHyper = selectionPopupList[0] : selectedPopupHyper = selectionPopupList[1]; + widget.sheet.hasHypo == 1 ? selectedPopupHypo = selectionPopupList[0] : selectedPopupHypo = selectionPopupList[1]; + upFocusNode.requestFocus(); } @override Widget build(BuildContext context) { return SingleChildScrollView( - padding: EdgeInsets.only(bottom: 80), - child: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 12.h, vertical: 9.v), - child: Column( - children: [ - SizedBox( - width: 224.h, - child: Text( - "your_blood_pressure".tr, - maxLines: 2, - overflow: TextOverflow.ellipsis, - textAlign: TextAlign.center, - style: theme.textTheme.headlineSmall, - ), + padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("up_pressure".tr), + SizedBox(height: 4), + CustomTextFormField( + inputFormatters: [digitsOnly], + controller: upPressureController, + autofocus: true, + focusNode: upFocusNode, + hintText: "90".tr, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(bloodPressureUp: int.parse(newValue))); + }, + ), + SizedBox(height: 16), + Text("down_pressure".tr), + SizedBox(height: 4), + CustomTextFormField( + inputFormatters: [digitsOnly], + controller: downPressureController, + hintText: "90".tr, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(bloodPressureDown: int.parse(newValue))); + }, + ), + SizedBox(height: 16), + Text("do_you_have_hypotension_tendency".tr), + SizedBox(height: 4), + CustomDropDown( + icon: Container( + margin: EdgeInsets.fromLTRB(30.h, 11.v, 13.h, 11.v), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(1.h)), + child: CustomImageView(imagePath: ImageConstant.imgFavorite, height: 12.adaptSize, width: 12.adaptSize), ), - SizedBox(height: 21.v), - Container( - margin: EdgeInsets.only(right: 1.h), - padding: EdgeInsets.symmetric(horizontal: 3.h), - child: Column( - children: [ - Text("up_pressure".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 2.v), - CustomTextFormField( - inputFormatters: [digitsOnly], - controller: upPressureController, - hintText: "90".tr, - onChanged: (newValue) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(bloodPressureUp: int.parse(newValue))); - }, - ), - ], - ), + hintText: "Не выбрано".tr, + items: selectionPopupList, + value: selectedPopupHypo, + onChanged: (newPopup) { + setState(() { + selectedPopupHypo = newPopup; + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(hasHypo: selectedPopupHypo.id!)); + }); + }, + ), + SizedBox(height: 16), + Text("do_you_have_hypertension_tendency".tr), + SizedBox(height: 4), + CustomDropDown( + icon: Container( + margin: EdgeInsets.fromLTRB(30.h, 11.v, 13.h, 11.v), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(1.h)), + child: CustomImageView(imagePath: ImageConstant.imgFavorite, height: 12.adaptSize, width: 12.adaptSize), ), - SizedBox(height: 21.v), - Container( - margin: EdgeInsets.only(right: 1.h), - padding: EdgeInsets.symmetric(horizontal: 3.h), - child: Column( - children: [ - Text("down_pressure".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 2.v), - CustomTextFormField( - inputFormatters: [digitsOnly], - controller: downPressureController, - hintText: "90".tr, - onChanged: (newValue) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(bloodPressureDown: int.parse(newValue))); - }, - ), - ], - ), - ), - SizedBox(height: 22.v), - Text("do_you_have_hypotension_tendency".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 2.v), - Padding( - padding: EdgeInsets.symmetric(horizontal: 4.h), - child: CustomDropDown( - icon: Container( - margin: EdgeInsets.fromLTRB(30.h, 11.v, 13.h, 11.v), - decoration: BoxDecoration(borderRadius: BorderRadius.circular(1.h)), - child: CustomImageView(imagePath: ImageConstant.imgFavorite, height: 12.adaptSize, width: 12.adaptSize), - ), - hintText: "Не выбрано".tr, - items: selectionPopupList, - value: selectedPopupHypo, - onChanged: (newPopup) { - setState(() { - selectedPopupHypo = newPopup; - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(hasHypo: selectedPopupHypo.id!)); - }); - }, - ), - ), - SizedBox(height: 22.v), - Text("do_you_have_hypertension_tendency".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 2.v), - Padding( - padding: EdgeInsets.symmetric(horizontal: 4.h), - child: CustomDropDown( - icon: Container( - margin: EdgeInsets.fromLTRB(30.h, 11.v, 13.h, 11.v), - decoration: BoxDecoration(borderRadius: BorderRadius.circular(1.h)), - child: CustomImageView(imagePath: ImageConstant.imgFavorite, height: 12.adaptSize, width: 12.adaptSize), - ), - hintText: "Не выбрано".tr, - items: selectionPopupList, - value: selectedPopupHyper, - onChanged: (newPopup) { - setState(() { - selectedPopupHyper = newPopup; - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(hasHyper: selectedPopupHyper.id!)); - }); - }, - ), - ), - ], - ), + hintText: "Не выбрано".tr, + items: selectionPopupList, + value: selectedPopupHyper, + onChanged: (newPopup) { + setState(() { + selectedPopupHyper = newPopup; + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(hasHyper: selectedPopupHyper.id!)); + }); + }, + ), + ], ), ); } diff --git a/lib/features/registration/presentation/pages/body_circumferences_screen.dart b/lib/features/registration/presentation/pages/body_circumferences_screen.dart index c5370843..a086da35 100644 --- a/lib/features/registration/presentation/pages/body_circumferences_screen.dart +++ b/lib/features/registration/presentation/pages/body_circumferences_screen.dart @@ -19,6 +19,7 @@ class _BodyCircumferencesScreenState extends State { final chestCircumferenceController = TextEditingController(); final waistCircumferenceController = TextEditingController(); final hipCircumferenceController = TextEditingController(); + final chestFocus = FocusNode(); @override void initState() { @@ -26,61 +27,55 @@ class _BodyCircumferencesScreenState extends State { if (widget.sheet.chestCircumference != 0) chestCircumferenceController.text = widget.sheet.chestCircumference.toString(); if (widget.sheet.waistCircumference != 0) waistCircumferenceController.text = widget.sheet.waistCircumference.toString(); if (widget.sheet.hipCircumference != 0) hipCircumferenceController.text = widget.sheet.hipCircumference.toString(); + chestFocus.requestFocus(); } @override Widget build(BuildContext context) { return SingleChildScrollView( - padding: EdgeInsets.only(bottom: 80), - child: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column( - children: [ - Text("initial_measurements".tr, style: theme.textTheme.headlineSmall), - SizedBox(height: 16.v), - Column( - children: [ - Text("chest_circumference".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 3.v), - CustomTextFormField( - inputFormatters: [digitsOnly], - controller: chestCircumferenceController, - hintText: "90".tr, - onChanged: (value) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(chestCircumference: int.parse(value))); - }, - ), - ], - ), - SizedBox(height: 19.v), - Text("waist_circumference".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 5.v), - CustomTextFormField( - inputFormatters: [digitsOnly], - controller: waistCircumferenceController, - hintText: "60".tr, - onChanged: (value) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(waistCircumference: int.parse(value))); - }, - ), - SizedBox(height: 21.v), - Text("hip_circumference".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 3.v), - CustomTextFormField( - inputFormatters: [digitsOnly], - controller: hipCircumferenceController, - hintText: "90".tr, - textInputAction: TextInputAction.done, - onChanged: (value) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(hipCircumference: int.parse(value))); - }, - ), - ], - ), + padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("chest_circumference".tr), + SizedBox(height: 4), + CustomTextFormField( + inputFormatters: [digitsOnly], + autofocus: true, + focusNode: chestFocus, + controller: chestCircumferenceController, + hintText: "90".tr, + onChanged: (value) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(chestCircumference: int.parse(value))); + }, + ), + SizedBox(height: 16), + Text("waist_circumference".tr), + SizedBox(height: 4), + CustomTextFormField( + inputFormatters: [digitsOnly], + controller: waistCircumferenceController, + hintText: "60".tr, + onChanged: (value) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(waistCircumference: int.parse(value))); + }, + ), + SizedBox(height: 16), + Text("hip_circumference".tr), + SizedBox(height: 4), + CustomTextFormField( + inputFormatters: [digitsOnly], + controller: hipCircumferenceController, + hintText: "90".tr, + textInputAction: TextInputAction.done, + onChanged: (value) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(hipCircumference: int.parse(value))); + }, + ), + ], ), ); } diff --git a/lib/features/registration/presentation/pages/city_of_living_screen.dart b/lib/features/registration/presentation/pages/city_of_living_screen.dart index 0372d8b5..02e5c65e 100644 --- a/lib/features/registration/presentation/pages/city_of_living_screen.dart +++ b/lib/features/registration/presentation/pages/city_of_living_screen.dart @@ -3,6 +3,7 @@ import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_m import 'package:eatvio_app/features/registration/consts/cities_list.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; import 'package:eatvio_app/widgets/custom_drop_down.dart'; +import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart'; import 'package:flutter/material.dart'; import 'package:flutter_typeahead/flutter_typeahead.dart'; @@ -26,62 +27,82 @@ class _CityOfLivingScreenState extends State { @override void initState() { super.initState(); - selectedItem = dropdownItemList[0]; - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(country: selectedItem.title)); + if (widget.sheet.country.isNotEmpty) { + selectedItem = dropdownItemList.firstWhere((item) => item.title == widget.sheet.country); + } else { + selectedItem = dropdownItemList.first; + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(country: selectedItem.title)); + } + if (widget.sheet.city.isNotEmpty) { + cityController.text = widget.sheet.city; + } } @override Widget build(BuildContext context) { return SingleChildScrollView( - padding: EdgeInsets.only(bottom: 80), - child: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column( - children: [ - Text("place_of_living".tr, style: theme.textTheme.headlineSmall), - SizedBox(height: 39.v), - Text("country".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 2.v), - CustomDropDown( - icon: Container( - margin: EdgeInsets.fromLTRB(30.h, 11.v, 17.h, 11.v), - decoration: BoxDecoration(borderRadius: BorderRadius.circular(1.h)), - child: CustomImageView(imagePath: ImageConstant.imgFavorite, height: 12.adaptSize, width: 12.adaptSize), - ), - hintText: "Не выбрано".tr, - items: dropdownItemList, - value: selectedItem, - onChanged: (newValue) { - setState(() { - selectedItem = newValue; - }); - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(country: newValue.title)); - }, + padding: EdgeInsets.only(bottom: 80, right: 16, left: 16, top: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("country".tr), + SizedBox(height: 4), + CustomDropDown( + icon: Container( + margin: EdgeInsets.fromLTRB(30.h, 11.v, 17.h, 11.v), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(1.h)), + child: CustomImageView(imagePath: ImageConstant.imgFavorite, height: 12.adaptSize, width: 12.adaptSize), ), - SizedBox(height: 22.v), - Text("Населенный пункт", style: theme.textTheme.bodyLarge), - SizedBox(height: 2.v), - TypeAheadField( + hintText: "Не выбрано".tr, + items: dropdownItemList, + value: selectedItem, + onChanged: (newValue) { + setState(() { + selectedItem = newValue; + }); + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(country: newValue.title)); + }, + ), + SizedBox(height: 16), + Text("Населенный пункт"), + SizedBox(height: 4), + TypeAheadField( + debounceDuration: Duration.zero, + controller: cityController, + builder: (context, controller, focus) => CustomTextFormField( controller: cityController, - itemBuilder: (BuildContext context, String item) { - return Text(item); - }, - onSelected: (item) { - setState(() { - cityController.text = item; - }); - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(city: item)); - }, - suggestionsCallback: (query) { - return citiesList.where((country) => country.toLowerCase().contains(query.toLowerCase())).toList(); - }, + focusNode: focus, + textStyle: TextStyle( + fontSize: 16, + color: Colors.black, + ) ), - ], - ), + itemBuilder: (BuildContext context, String item) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Text(item, style: theme.textTheme.bodyLarge?.copyWith(color: Colors.black)), + ); + }, + decorationBuilder: (context, child) => Material( + type: MaterialType.card, + elevation: 4, + borderRadius: BorderRadius.circular(8), + child: child, + ), + onSelected: (item) { + setState(() { + cityController.text = item; + }); + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(city: item)); + }, + suggestionsCallback: (query) { + return citiesList.where((country) => country.toLowerCase().contains(query.toLowerCase())).toList(); + }, + ), + ], ), ); } diff --git a/lib/features/registration/presentation/pages/credentials_screen.dart b/lib/features/registration/presentation/pages/credentials_screen.dart index 3175b5c4..7fa37be7 100644 --- a/lib/features/registration/presentation/pages/credentials_screen.dart +++ b/lib/features/registration/presentation/pages/credentials_screen.dart @@ -34,61 +34,62 @@ class _CredentialsScreenState extends State { @override Widget build(BuildContext context) { return SingleChildScrollView( - padding: EdgeInsets.only(bottom: 80), - child: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text("user_registration".tr, style: theme.textTheme.headlineSmall), - SizedBox(height: 16.v), - Text("email".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 3.v), - CustomTextFormField( - controller: emailController, - textInputAction: TextInputAction.done, - onChanged: (newValue) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(email: newValue)); - }, - ), - SizedBox(height: 22.v), - Text("username".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 3.v), - CustomTextFormField( - controller: nameController, - textInputAction: TextInputAction.done, - onChanged: (newValue) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(name: newValue)); - }, - ), - SizedBox(height: 19.v), - Text("password".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 5.v), - CustomTextFormField( - obscureText: true, - controller: passwordController, - onChanged: (newValue) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(password: newValue)); - }, - ), - SizedBox(height: 21.v), - Text("password_confirmation".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 3.v), - CustomTextFormField( - obscureText: true, - controller: passwordConfirmationController, - textInputAction: TextInputAction.done, - onChanged: (newValue) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(passwordConfirmation: newValue)); - }, - ), - ], - ), + padding: EdgeInsets.only(bottom: 80, top: 16, left: 16, right: 16), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("email".tr), + SizedBox(height: 4), + CustomTextFormField( + controller: emailController, + textInputType: TextInputType.emailAddress, + hintText: 'Введите email', + textInputAction: TextInputAction.next, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(email: newValue)); + }, + ), + SizedBox(height: 16), + Text("username".tr), + SizedBox(height: 4), + CustomTextFormField( + controller: nameController, + hintText: 'Введите имя пользователя', + textInputAction: TextInputAction.next, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(name: newValue)); + }, + ), + SizedBox(height: 16), + Text("password".tr), + SizedBox(height: 4), + CustomTextFormField( + obscureText: true, + controller: passwordController, + hintText: 'Введите пароль', + textInputAction: TextInputAction.next, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(password: newValue)); + }, + ), + SizedBox(height: 16), + Text("password_confirmation".tr), + SizedBox(height: 4), + CustomTextFormField( + obscureText: true, + controller: passwordConfirmationController, + textInputAction: TextInputAction.done, + hintText: 'Подтвердите пароль', + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(passwordConfirmation: newValue)); + }, + ), + ], ), ); } diff --git a/lib/features/registration/presentation/pages/date_of_birth_screen.dart b/lib/features/registration/presentation/pages/date_of_birth_screen.dart index 54e1935d..8d510c15 100644 --- a/lib/features/registration/presentation/pages/date_of_birth_screen.dart +++ b/lib/features/registration/presentation/pages/date_of_birth_screen.dart @@ -2,6 +2,7 @@ import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; class DateOfBirthScreen extends StatefulWidget { @@ -23,48 +24,33 @@ class _DateOfBirthScreenState extends State { selectedDate = DateFormat('yyyy-mm-dd').parse(widget.sheet.birthdate); } else { selectedDate = DateTime.now(); + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(birthdate: DateTime.now().toString())); } } @override Widget build(BuildContext context) { return SingleChildScrollView( - padding: EdgeInsets.only(bottom: 80), - child: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column( - children: [ - Text("date_of_birth".tr, style: theme.textTheme.headlineSmall), - const SizedBox(height: 32), - _buildDateInput(context), - ], - ), - ), - ); - } - - /// Section Widget - _buildDateInput(BuildContext context) { - return Container( - width: 343.h, - padding: EdgeInsets.symmetric(horizontal: 4.h, vertical: 1.v), - decoration: AppDecoration.outlineBlueA.copyWith(borderRadius: BorderRadiusStyle.circleBorder8), + padding: EdgeInsets.only(bottom: 80, top: 16, left: 16, right: 16), child: Column( - mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, children: [ - CustomImageView(imagePath: ImageConstant.imgFavorite, height: 12.adaptSize, width: 12.adaptSize, radius: BorderRadius.circular(1.h)), - SizedBox(height: 6.v), - Align( - alignment: Alignment.center, - child: GestureDetector( - onTap: onTapCalendar(context), - child: Text('${selectedDate.day}.${selectedDate.month}.${selectedDate.year}', style: theme.textTheme.titleMedium), + Text("date_of_birth".tr), + SizedBox(height: 4), + ListTile( + onTap: onTapCalendar(context), + leading: Icon(Icons.calendar_month_rounded, color: appTheme.blueA400), + trailing: Icon(Icons.keyboard_arrow_down_rounded), + title: Text(selectedDate.format('dd MMMM yyyy', 'ru')), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + side: BorderSide( + color: Colors.grey.shade400, + width: 1, + ), ), ), - SizedBox(height: 6.v), ], ), ); @@ -74,7 +60,9 @@ class _DateOfBirthScreenState extends State { return () { _showDialog( CupertinoDatePicker( - initialDateTime: DateTime.now(), + initialDateTime: selectedDate, + maximumDate: DateTime.now(), + minimumDate: DateTime(1900), mode: CupertinoDatePickerMode.date, onDateTimeChanged: (DateTime newDateTime) { setState(() { diff --git a/lib/features/registration/presentation/pages/favorite_foods_screen.dart b/lib/features/registration/presentation/pages/favorite_foods_screen.dart index d17b5e11..bab999ab 100644 --- a/lib/features/registration/presentation/pages/favorite_foods_screen.dart +++ b/lib/features/registration/presentation/pages/favorite_foods_screen.dart @@ -16,61 +16,52 @@ class FavoriteFoodsScreen extends StatefulWidget { class _FavoriteFoodsScreenState extends State { final favoriteFoodsController = TextEditingController(); final unFavoriteFoodsController = TextEditingController(); + final favoriteFocusNode = FocusNode(); @override void initState() { super.initState(); favoriteFoodsController.text = widget.sheet.favoriteFoods; unFavoriteFoodsController.text = widget.sheet.unfavoriteFoods; + favoriteFocusNode.requestFocus(); } @override Widget build(BuildContext context) { return SingleChildScrollView( - padding: EdgeInsets.only(bottom: 80), - child: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column( - children: [ - Container( - width: 327.h, - margin: EdgeInsets.only(left: 8.h, right: 7.h), - child: Text( - "favorite_unfavorite_foods".tr, - maxLines: 2, - overflow: TextOverflow.ellipsis, - textAlign: TextAlign.center, - style: theme.textTheme.headlineSmall, - ), - ), - SizedBox(height: 13.v), - Text("favorite_foods".tr, style: CustomTextStyles.titleMediumSegoeUI), - SizedBox(height: 2.v), - CustomTextFormField( - controller: favoriteFoodsController, - hintText: "enter_information".tr, - maxLines: 7, - onChanged: (newValue) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(favoriteFoods: newValue)); - }, - ), - SizedBox(height: 12.v), - Text("unfavorite_foods".tr, style: CustomTextStyles.titleMediumSegoeUI), - SizedBox(height: 2.v), - CustomTextFormField( - controller: unFavoriteFoodsController, - hintText: "enter_information".tr, - textInputAction: TextInputAction.done, - maxLines: 7, - onChanged: (newValue) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(unfavoriteFoods: newValue)); - }, - ), - ], - ), + padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("favorite_foods".tr), + SizedBox(height: 4), + CustomTextFormField( + controller: favoriteFoodsController, + hintText: "enter_information".tr, + maxLines: 7, + minLines: 2, + focusNode: favoriteFocusNode, + autofocus: true, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(favoriteFoods: newValue)); + }, + ), + SizedBox(height: 16), + Text("unfavorite_foods".tr), + SizedBox(height: 4), + CustomTextFormField( + controller: unFavoriteFoodsController, + hintText: "enter_information".tr, + textInputAction: TextInputAction.done, + maxLines: 7, + minLines: 2, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(unfavoriteFoods: newValue)); + }, + ), + ], ), ); } diff --git a/lib/features/registration/presentation/pages/favorite_sports_screen.dart b/lib/features/registration/presentation/pages/favorite_sports_screen.dart index 55273ec7..2856ea75 100644 --- a/lib/features/registration/presentation/pages/favorite_sports_screen.dart +++ b/lib/features/registration/presentation/pages/favorite_sports_screen.dart @@ -15,40 +15,37 @@ class FavoriteSportsScreen extends StatefulWidget { class _FavoriteSportsScreenState extends State { final enterInformationController = TextEditingController(); + final infoFocusNode = FocusNode(); @override void initState() { super.initState(); enterInformationController.text = widget.sheet.aboutSportHobbies; + infoFocusNode.requestFocus(); } @override Widget build(BuildContext context) { return SingleChildScrollView( - padding: EdgeInsets.only(bottom: 80), - child: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 5.v), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text("your_favorite_sports".tr, style: theme.textTheme.headlineSmall), - SizedBox(height: 22.v), - Text("fill_in_information".tr, style: CustomTextStyles.titleMediumSegoeUI), - SizedBox(height: 2.v), - CustomTextFormField( - controller: enterInformationController, - hintText: - "Я занимаюсь плаванием , почти каждый вечер прогулки на свежем воздухе, пару раз в месяц играю в волейбол. Стараюсь не сидеть на месте!", - textInputAction: TextInputAction.done, - maxLines: 8, - onChanged: (newValue) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(aboutSportHobbies: newValue)); - }, - ), - ], - ), + padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("your_favorite_sports".tr), + SizedBox(height: 4), + CustomTextFormField( + controller: enterInformationController, + hintText: "Я занимаюсь плаванием , почти каждый вечер прогулки на свежем воздухе, пару раз в месяц играю в волейбол. Стараюсь не сидеть на месте!", + textInputAction: TextInputAction.done, + focusNode: infoFocusNode, + autofocus: true, + maxLines: 8, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(aboutSportHobbies: newValue)); + }, + ), + ], ), ); } diff --git a/lib/features/registration/presentation/pages/gender_screen.dart b/lib/features/registration/presentation/pages/gender_screen.dart index 62258260..d1bec2f7 100644 --- a/lib/features/registration/presentation/pages/gender_screen.dart +++ b/lib/features/registration/presentation/pages/gender_screen.dart @@ -24,55 +24,53 @@ class _GenderScreenState extends State { @override Widget build(BuildContext context) { return SingleChildScrollView( - padding: EdgeInsets.only(bottom: 80), - child: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column( - children: [ - Text("your_gender".tr, style: theme.textTheme.headlineSmall), - RadioListTile( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(16), - ), - title: Text('Мужской'), - value: 'male', - groupValue: currentValue, - onChanged: (newValue) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(gender: 'male')); - setState(() { - currentValue = 'male'; - }); - }, - secondary: Image.asset( - 'assets/images/img_male.png', - width: 40, - height: 40, - ), + padding: EdgeInsets.only(bottom: 80, top: 16, left: 16, right: 16), + child: Column( + children: [ + RadioListTile( + contentPadding: EdgeInsets.zero, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), ), - RadioListTile( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(16), - ), - title: Text('Женский'), - value: 'female', - groupValue: currentValue, - onChanged: (newValue) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(gender: 'female')); - setState(() { - currentValue = 'female'; - }); - }, - secondary: Image.asset( - 'assets/images/img_female.png', - width: 40, - height: 40, - ), + title: Text('Мужской'), + value: 'male', + groupValue: currentValue, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(gender: 'male')); + setState(() { + currentValue = 'male'; + }); + }, + secondary: Image.asset( + 'assets/images/img_male.png', + width: 40, + height: 40, ), - ], - ), + ), + SizedBox(height: 16), + RadioListTile( + contentPadding: EdgeInsets.zero, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + title: Text('Женский'), + value: 'female', + groupValue: currentValue, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(gender: 'female')); + setState(() { + currentValue = 'female'; + }); + }, + secondary: Image.asset( + 'assets/images/img_female.png', + width: 40, + height: 40, + ), + ), + ], ), ); } diff --git a/lib/features/registration/presentation/pages/height_screen.dart b/lib/features/registration/presentation/pages/height_screen.dart index 98fc71fa..2aea3690 100644 --- a/lib/features/registration/presentation/pages/height_screen.dart +++ b/lib/features/registration/presentation/pages/height_screen.dart @@ -16,51 +16,40 @@ class HeightScreen extends StatefulWidget { class _HeightScreenState extends State { final heightController = TextEditingController(); + final heightFocus = FocusNode(); @override void initState() { super.initState(); if (widget.sheet.height != 0) heightController.text = widget.sheet.height.toString(); + heightFocus.requestFocus(); } @override Widget build(BuildContext context) { return SingleChildScrollView( - padding: EdgeInsets.only(bottom: 80), - child: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column( - children: [ - Text( - "height_measurements".tr, - style: theme.textTheme.headlineSmall, - ), - SizedBox(height: 16.v), - Column( - children: [ - Text( - "your_height".tr, - style: theme.textTheme.bodyLarge, - ), - SizedBox(height: 4.v), - CustomTextFormField( - width: 150.h, - textInputAction: TextInputAction.done, - controller: heightController, - keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - ], - onChanged: (newValue) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(height: int.parse(newValue))); - }, - ), - ], - ), - ], - ), + padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("your_height".tr), + SizedBox(height: 4), + CustomTextFormField( + textInputAction: TextInputAction.done, + autofocus: true, + focusNode: heightFocus, + hintText: 'см', + controller: heightController, + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + ], + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(height: int.parse(newValue))); + }, + ), + ], ), ); } diff --git a/lib/features/registration/presentation/pages/language_select_screen.dart b/lib/features/registration/presentation/pages/language_select_screen.dart index c770c0c7..4d95033e 100644 --- a/lib/features/registration/presentation/pages/language_select_screen.dart +++ b/lib/features/registration/presentation/pages/language_select_screen.dart @@ -18,34 +18,31 @@ class _LanguageSelectScreenState extends State { SelectionPopupModel(id: 1, title: "Русский", isSelected: true), ]; - SelectionPopupModel? value; + late SelectionPopupModel value; @override void initState() { super.initState(); if (widget.sheet.lang.isNotEmpty) { + value = dropdownItemList.firstWhere((item) => item.title == widget.sheet.lang); + } else { value = dropdownItemList.first; + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(lang: value.title)); } } @override Widget build(BuildContext context) { return SingleChildScrollView( - padding: EdgeInsets.only(bottom: 80), + padding: EdgeInsets.only(bottom: 80, right: 16, left: 16, top: 16), child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - width: 262.h, - margin: EdgeInsets.only(left: 41.h, right: 39.h), - child: Text( - "preferred_language".tr, - maxLines: 2, - overflow: TextOverflow.ellipsis, - textAlign: TextAlign.center, - style: theme.textTheme.headlineSmall, - ), + Text( + "preferred_language".tr, ), - const SizedBox(height: 32), + const SizedBox(height: 4), CustomDropDown( value: value, hintText: "Не выбрано".tr, @@ -53,7 +50,7 @@ class _LanguageSelectScreenState extends State { onChanged: (SelectionPopupModel newValue) => setState(() { value = newValue; final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(lang: value!.title)); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(lang: value.title)); }), ), ], diff --git a/lib/features/registration/presentation/pages/medicine_intake_screen.dart b/lib/features/registration/presentation/pages/medicine_intake_screen.dart index d6ea9fbb..fc09d084 100644 --- a/lib/features/registration/presentation/pages/medicine_intake_screen.dart +++ b/lib/features/registration/presentation/pages/medicine_intake_screen.dart @@ -15,48 +15,38 @@ class MedicineIntakeScreen extends StatefulWidget { class _MedicineIntakeScreenState extends State { final enterInformationController = TextEditingController(); + final infoFocusNode = FocusNode(); @override void initState() { super.initState(); enterInformationController.text = widget.sheet.aboutTakingPils; + infoFocusNode.requestFocus(); } @override Widget build(BuildContext context) { return SingleChildScrollView( - padding: EdgeInsets.only(bottom: 80), - child: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column( - children: [ - Container( - width: 271.h, - margin: EdgeInsets.only(left: 35.h, right: 36.h), - child: Text( - "do_you_take_pills".tr, - maxLines: 2, - overflow: TextOverflow.ellipsis, - textAlign: TextAlign.center, - style: theme.textTheme.headlineSmall, - ), - ), - SizedBox(height: 16.v), - Text("fill_in_information".tr, style: CustomTextStyles.titleMediumSegoeUI), - SizedBox(height: 2.v), - CustomTextFormField( - controller: enterInformationController, - hintText: "enter_information".tr, - textInputAction: TextInputAction.done, - maxLines: 8, - onChanged: (newValue) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(aboutTakingPils: newValue)); - }, - ), - ], - ), + padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("do_you_take_pills".tr), + SizedBox(height: 4), + CustomTextFormField( + controller: enterInformationController, + hintText: "enter_information".tr, + textInputAction: TextInputAction.done, + focusNode: infoFocusNode, + autofocus: true, + minLines: 2, + maxLines: 8, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(aboutTakingPils: newValue)); + }, + ), + ], ), ); } diff --git a/lib/features/registration/presentation/pages/name_screen.dart b/lib/features/registration/presentation/pages/name_screen.dart index 2f1e4c5f..ae817ed8 100644 --- a/lib/features/registration/presentation/pages/name_screen.dart +++ b/lib/features/registration/presentation/pages/name_screen.dart @@ -16,47 +16,48 @@ class NameScreen extends StatefulWidget { class _NameScreenState extends State { final firstNameController = TextEditingController(); final lastNameController = TextEditingController(); + final nameFocus = FocusNode(); @override void initState() { super.initState(); firstNameController.text = widget.sheet.firstName; lastNameController.text = widget.sheet.lastName; + nameFocus.requestFocus(); } @override Widget build(BuildContext context) { return SingleChildScrollView( - padding: EdgeInsets.only(bottom: 80), - child: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column( - children: [ - Text("what_is_your_name".tr, style: theme.textTheme.headlineSmall), - SizedBox(height: 16.v), - Text("first_name".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 3.v), - CustomTextFormField( - controller: firstNameController, - textInputAction: TextInputAction.done, - onChanged: (newValue) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(firstName: newValue)); - }, - ), - SizedBox(height: 19.v), - Text("last_name".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 5.v), - CustomTextFormField( - controller: lastNameController, - onChanged: (newValue) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(lastName: newValue)); - }, - ) - ], - ), + padding: EdgeInsets.only(bottom: 80, top: 16, left: 16, right: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("first_name".tr), + SizedBox(height: 4), + CustomTextFormField( + controller: firstNameController, + focusNode: nameFocus, + textInputAction: TextInputAction.next, + hintText: 'Введите имя', + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(firstName: newValue)); + }, + ), + SizedBox(height: 16), + Text("last_name".tr), + SizedBox(height: 4), + CustomTextFormField( + controller: lastNameController, + textInputAction: TextInputAction.done, + hintText: 'Введите фамилию', + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(lastName: newValue)); + }, + ) + ], ), ); } diff --git a/lib/features/registration/presentation/pages/registration_screen.dart b/lib/features/registration/presentation/pages/registration_screen.dart index 93a5eae0..1688ef2c 100644 --- a/lib/features/registration/presentation/pages/registration_screen.dart +++ b/lib/features/registration/presentation/pages/registration_screen.dart @@ -18,9 +18,7 @@ import 'package:eatvio_app/features/registration/presentation/pages/name_screen. import 'package:eatvio_app/features/registration/presentation/pages/weight_screen.dart'; import 'package:eatvio_app/locator_service.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_title_image.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:go_router/go_router.dart'; import 'package:validators/validators.dart'; class RegistrationScreen extends StatefulWidget { @@ -36,160 +34,132 @@ class _RegistrationScreenState extends State { final pageController = PageController(); final RegistrationCubit registrationCubit = sl(); - _showPopDialog() { - showDialog( - context: context, - builder: (context) => CupertinoAlertDialog( - content: Text('Отменить регистрацию? Заполненные данные не будут сохранены.'), - actions: [ - CupertinoDialogAction( - onPressed: () { - Navigator.pop(context); - GoRouter.of(context).pop(); - }, - child: Text('Да'), - ), - CupertinoDialogAction( - onPressed: () { - Navigator.pop(context); - }, - isDefaultAction: true, - child: Text('Нет'), - ) - ], - ), - ); - } - @override Widget build(BuildContext context) { return BlocProvider( create: (BuildContext context) => registrationCubit, child: BlocBuilder( builder: (BuildContext context, RegistrationState state) { - return PopScope( - canPop: false, - onPopInvoked: (_) => _showPopDialog(), - child: Scaffold( - floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, - floatingActionButton: Row( - children: [ - Container( - height: 48, - width: MediaQuery.of(context).size.width * 0.2, - padding: EdgeInsets.only(left: 16, right: 4), - child: FloatingActionButton.extended( - heroTag: 'backButtonRegistration', - highlightElevation: 0, - elevation: 0, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(16), - ), - backgroundColor: Color(0xFFEAF2FD), - onPressed: () { - if (pageController.page == 0) _showPopDialog(); + return Scaffold( + floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, + floatingActionButton: Row( + children: [ + Container( + height: 48, + width: MediaQuery.of(context).size.width * 0.2, + padding: EdgeInsets.only(left: 16, right: 4), + child: FloatingActionButton.extended( + heroTag: 'backButtonRegistration', + highlightElevation: 0, + focusElevation: 0, + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + backgroundColor: Color(0xFFEAF2FD), + onPressed: () async { + setState(() { + pageController.previousPage( + duration: const Duration(milliseconds: 350), + curve: Curves.easeInOut, + ); + }); + }, + label: Icon( + Icons.arrow_back_ios_new_rounded, + color: appTheme.blueA400, + ), + ), + ), + Container( + height: 48, + width: MediaQuery.of(context).size.width * 0.8, + padding: EdgeInsets.only(left: 4, right: 16), + child: FloatingActionButton.extended( + heroTag: 'nextButtonRegistration', + highlightElevation: 0, + elevation: 0, + focusElevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + backgroundColor: appTheme.blueA400, + onPressed: () async { + if (await canGoNext(state)) { setState(() { - pageController.previousPage( + pageController.nextPage( duration: const Duration(milliseconds: 350), curve: Curves.easeInOut, ); }); - }, - label: Icon( - Icons.arrow_back_ios_new_rounded, - color: appTheme.blueA400, - ), + } + }, + label: Text( + 'Продолжить', + style: theme.textTheme.titleSmall, ), ), - Container( - height: 48, - width: MediaQuery.of(context).size.width * 0.8, - padding: EdgeInsets.only(left: 4, right: 16), - child: FloatingActionButton.extended( - heroTag: 'nextButtonRegistration', - highlightElevation: 0, - elevation: 0, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(16), - ), - backgroundColor: appTheme.blueA400, - onPressed: () async { - if (await canGoNext(state)) { - setState(() { - pageController.nextPage( - duration: const Duration(milliseconds: 350), - curve: Curves.easeInOut, - ); - }); - } - }, - label: Text( - 'Продолжить', - style: theme.textTheme.titleSmall, - ), + ), + ], + ), + appBar: AppBar( + automaticallyImplyLeading: true, + centerTitle: true, + title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio), + actions: [ + Padding( + padding: const EdgeInsets.only(right: 16), + child: Text('шаг $step из 15'), + ), + ], + bottom: PreferredSize( + preferredSize: Size(MediaQuery.of(context).size.width, 32), + child: Padding( + padding: const EdgeInsets.all(16), + child: TweenAnimationBuilder( + duration: const Duration(milliseconds: 350), + curve: Curves.easeInOut, + tween: Tween( + begin: 0, + end: progressValue, ), - ), - ], - ), - appBar: AppBar( - automaticallyImplyLeading: true, - centerTitle: true, - title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio), - actions: [ - Padding( - padding: const EdgeInsets.only(right: 16), - child: Text('шаг $step из 15'), - ), - ], - bottom: PreferredSize( - preferredSize: Size(MediaQuery.of(context).size.width, 32), - child: Padding( - padding: const EdgeInsets.all(16), - child: TweenAnimationBuilder( - duration: const Duration(milliseconds: 350), - curve: Curves.easeInOut, - tween: Tween( - begin: 0, - end: progressValue, - ), - builder: (context, value, _) => LinearProgressIndicator( - value: value, - borderRadius: BorderRadius.circular(16), - minHeight: 8, - backgroundColor: Colors.grey.shade100, - valueColor: AlwaysStoppedAnimation(appTheme.blueA400), - ), + builder: (context, value, _) => LinearProgressIndicator( + value: value, + borderRadius: BorderRadius.circular(16), + minHeight: 8, + backgroundColor: Colors.grey.shade100, + valueColor: AlwaysStoppedAnimation(appTheme.blueA400), ), ), ), ), - body: PageView( - physics: NeverScrollableScrollPhysics(), - controller: pageController, - onPageChanged: (index) { - setState(() { - step = index + 1; - progressValue = step / 15; - }); - }, - children: [ - LanguageSelectScreen(sheet: state.sheet), - CredentialsScreen(sheet: state.sheet), - NameScreen(sheet: state.sheet), - GenderScreen(sheet: state.sheet), - DateOfBirthScreen(sheet: state.sheet), - CityOfLivingScreen(sheet: state.sheet), // todo refactor - BodyCircumferencesScreen(sheet: state.sheet), - WeightScreen(sheet: state.sheet), - HeightScreen(sheet: state.sheet), - BloodPressureScreen(sheet: state.sheet), - AllergiesScreen(sheet: state.sheet), - MedicineIntakeScreen(sheet: state.sheet), - FavoriteSportsScreen(sheet: state.sheet), - FavoriteFoodsScreen(sheet: state.sheet), - AdditionalInformationScreen(sheet: state.sheet), - ], - ), + ), + body: PageView( + physics: NeverScrollableScrollPhysics(), + controller: pageController, + onPageChanged: (index) { + setState(() { + step = index + 1; + progressValue = step / 15; + }); + }, + children: [ + LanguageSelectScreen(sheet: state.sheet), + CredentialsScreen(sheet: state.sheet), + NameScreen(sheet: state.sheet), + GenderScreen(sheet: state.sheet), + DateOfBirthScreen(sheet: state.sheet), + CityOfLivingScreen(sheet: state.sheet), + BodyCircumferencesScreen(sheet: state.sheet), + WeightScreen(sheet: state.sheet), + HeightScreen(sheet: state.sheet), + BloodPressureScreen(sheet: state.sheet), + AllergiesScreen(sheet: state.sheet), + MedicineIntakeScreen(sheet: state.sheet), + FavoriteSportsScreen(sheet: state.sheet), + FavoriteFoodsScreen(sheet: state.sheet), + AdditionalInformationScreen(sheet: state.sheet), + ], ), ); }, @@ -197,7 +167,7 @@ class _RegistrationScreenState extends State { ); } - Future canGoNext(state) async { + Future canGoNext(RegistrationState state) async { switch (step) { case 2: List errors = validateCredentialsFields(state.sheet.email, state.sheet.name, state.sheet.password, state.sheet.passwordConfirmation); @@ -254,6 +224,44 @@ class _RegistrationScreenState extends State { ); return false; } + case 4: + if (state.sheet.gender.isNotEmpty) + return true; + else { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text('Ошибка'), + content: Text('Выберете пол'), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: Text('OK'), + ), + ], + ), + ); + return false; + } + case 6: + if (state.sheet.country.isNotEmpty && state.sheet.city.isNotEmpty) + return true; + else { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text('Ошибка'), + content: Text('Заполните все поля'), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: Text('OK'), + ), + ], + ), + ); + return false; + } case 7: List errors = validateCircumferencesFields( state.sheet.chestCircumference.toString(), diff --git a/lib/features/registration/presentation/pages/weight_screen.dart b/lib/features/registration/presentation/pages/weight_screen.dart index 855593e5..300296d6 100644 --- a/lib/features/registration/presentation/pages/weight_screen.dart +++ b/lib/features/registration/presentation/pages/weight_screen.dart @@ -16,51 +16,40 @@ class WeightScreen extends StatefulWidget { class _WeightScreenState extends State { final weightController = TextEditingController(); + final weightFocus = FocusNode(); @override void initState() { super.initState(); if (widget.sheet.weight != 0) weightController.text = widget.sheet.weight.toString(); + weightFocus.requestFocus(); } @override Widget build(BuildContext context) { return SingleChildScrollView( - padding: EdgeInsets.only(bottom: 80), - child: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column( - children: [ - Text( - "weight_measurements".tr, - style: theme.textTheme.headlineSmall, - ), - SizedBox(height: 16.v), - Column( - children: [ - Text( - "your_weight".tr, - style: theme.textTheme.bodyLarge, - ), - SizedBox(height: 4.v), - CustomTextFormField( - width: 150.h, - textInputAction: TextInputAction.done, - controller: weightController, - keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - ], - onChanged: (newValue) { - final registrationCubit = context.read(); - registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(weight: int.parse(newValue))); - }, - ), - ], - ), - ], - ), + padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("your_weight".tr), + SizedBox(height: 4), + CustomTextFormField( + autofocus: true, + hintText: 'кг', + focusNode: weightFocus, + textInputAction: TextInputAction.done, + controller: weightController, + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + ], + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(weight: int.parse(newValue))); + }, + ), + ], ), ); } diff --git a/lib/localization/en_us/en_us_translations.dart b/lib/localization/en_us/en_us_translations.dart index 4c0df242..c68f1315 100644 --- a/lib/localization/en_us/en_us_translations.dart +++ b/lib/localization/en_us/en_us_translations.dart @@ -50,7 +50,7 @@ final Map enUs = { // language_select Screen "lbl_english": "English", - "preferred_language": "Preferred Language?", + "preferred_language": "Preferred Language", // Common String "continue": "Continue", "skip": "Skip", diff --git a/lib/localization/ru/ru_translations.dart b/lib/localization/ru/ru_translations.dart index 8d7f708f..faf5359f 100644 --- a/lib/localization/ru/ru_translations.dart +++ b/lib/localization/ru/ru_translations.dart @@ -66,7 +66,7 @@ final Map ru = { // language_select Screen "lbl_english": "English", "finish": "Завершить", - "preferred_language": "Предпочитаемый язык общения?", + "preferred_language": "Предпочитаемый язык общения", // Common String "continue": "Продолжить", "skip": "Пропустить", diff --git a/lib/presentation/auth/auth_screen/auth_screen.dart b/lib/presentation/auth/auth_screen/auth_screen.dart index ec01a983..adf6cf50 100644 --- a/lib/presentation/auth/auth_screen/auth_screen.dart +++ b/lib/presentation/auth/auth_screen/auth_screen.dart @@ -3,13 +3,12 @@ import 'dart:convert'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_title_image.dart'; -import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; -import 'package:eatvio_app/widgets/next_step_button.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; +import 'package:url_launcher/url_launcher.dart'; import 'package:validators/validators.dart'; import 'bloc/auth_bloc.dart'; @@ -38,71 +37,111 @@ class _AuthScreenState extends State { @override Widget build(BuildContext context) { - mediaQueryData = MediaQuery.of(context); return Scaffold( - resizeToAvoidBottomInset: false, - appBar: _buildAppBar(context), - body: GestureDetector( - onTap: () => FocusScope.of(context).unfocus(), - child: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column( - children: [ - SizedBox(height: 36.v), - Text("user_authorization".tr, style: theme.textTheme.headlineSmall), - SizedBox(height: 60.v), - Text("email".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 3.v), - BlocSelector( - selector: (state) => state.emailController, - builder: (context, emailController) { - return CustomTextFormField(controller: emailController, textInputAction: TextInputAction.done); - }, - ), - SizedBox(height: 22.v), - Text("password".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 5.v), - BlocSelector( - selector: (state) => state.passwordController, - builder: (context, passwordController) { - return CustomTextFormField( - obscureText: true, - controller: passwordController, - ); - }, - ), - SizedBox(height: 50.v), - NextStepButton( - text: "no_account".tr.toUpperCase(), - margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: onTapNoAccount(context), - ), - /*NextStepButton( - text: "Тест дневника".toUpperCase(), - margin: - EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: onTapDiaryTest(context)), - NextStepButton( - text: "authentificate".tr.toUpperCase(), - margin: - EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: onTapProfileTest(context)),*/ - BlocBuilder( - builder: (context, state) { - return NextStepButton( - text: "authentificate".tr.toUpperCase(), - margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 16.v), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, + appBar: AppBar( + centerTitle: true, + title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio), + ), + body: Padding( + padding: EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("email".tr), + SizedBox(height: 4), + BlocSelector( + selector: (state) => state.emailController, + builder: (context, emailController) { + return CustomTextFormField( + controller: emailController, + textInputAction: TextInputAction.next, + textInputType: TextInputType.emailAddress, + hintText: 'Введите email', + ); + }, + ), + SizedBox(height: 16), + Text("password".tr), + SizedBox(height: 4), + BlocSelector( + selector: (state) => state.passwordController, + builder: (context, passwordController) { + return CustomTextFormField( + obscureText: true, + controller: passwordController, + hintText: 'Введите пароль', + ); + }, + ), + SizedBox(height: 16), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text('Нет аккаунта? '), + GestureDetector( + onTap: () => GoRouter.of(context).goNamed('registrationScreen'), + child: Text( + 'Зарегистрироваться', + style: TextStyle( + color: appTheme.blueA400, + decorationColor: appTheme.blueA400, + decoration: TextDecoration.underline, + ), + ), + ), + ], + ), + Spacer(), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'Нажимая "Войти", Вы соглашаетесь с ', + style: TextStyle( + fontSize: 12, + ), + ), + GestureDetector( + onTap: () async { + await launchUrl(Uri.parse(baseUrl + '/oferta_bs.pdf')); + }, + child: Text( + 'Публичной офертой', + style: TextStyle( + fontSize: 12, + color: appTheme.blueA400, + decorationColor: appTheme.blueA400, + decoration: TextDecoration.underline, + ), + ), + ), + ], + ), + SizedBox(height: 16), + BlocBuilder( + builder: (context, state) { + return Container( + height: 48, + width: MediaQuery.of(context).size.width - 32, + child: FloatingActionButton.extended( + heroTag: 'nextButtonRegistration', + highlightElevation: 0, + elevation: 0, + focusElevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + backgroundColor: appTheme.blueA400, onPressed: onTapAuth(state, context), - ); - }, - ), - ], - ), + label: Text( + 'Войти', + style: theme.textTheme.titleSmall, + ), + ), + ); + }, + ), + ], ), ), ); @@ -138,7 +177,7 @@ class _AuthScreenState extends State { content: Text('wrong_credentials'.tr), actions: [ TextButton( - onPressed: onTapOk(context), + onPressed: () => Navigator.pop(context), child: Text('OK'), ), ], @@ -159,7 +198,7 @@ class _AuthScreenState extends State { content: Text(errorMessage), actions: [ TextButton( - onPressed: onTapOk(context), + onPressed: () => Navigator.pop(context), child: Text('OK'), ), ], @@ -169,44 +208,6 @@ class _AuthScreenState extends State { }; } - onTapOk(BuildContext context) { - return () { - GoRouter.of(context).pop(context); - }; - } - - onTapDiaryTest(BuildContext context) { - return () { - GoRouter.of(context).goNamed('diaryScreen'); - }; - } - - onTapProfileTest(BuildContext context) { - return () { - GoRouter.of(context).goNamed('mySettingsScreen'); - }; - } - - onTapNoAccount(BuildContext context) { - return () { - GoRouter.of(context).goNamed('registrationScreen'); - }; - // return () { - // GoRouter.of(context).goNamed('languageSelectScreen'); - // }; - } - - /// Section Widget - _buildAppBar(BuildContext context) { - return CustomAppBar( - leadingWidth: 29.h, - centerTitle: true, - title: AppbarTitleImage( - imagePath: ImageConstant.imgLogoEatvio, - ), - ); - } - List validateFields(String email, String password) { List errors = []; diff --git a/lib/widgets/custom_drop_down.dart b/lib/widgets/custom_drop_down.dart index ff80bac9..fc166b20 100644 --- a/lib/widgets/custom_drop_down.dart +++ b/lib/widgets/custom_drop_down.dart @@ -79,28 +79,32 @@ class CustomDropDown extends StatelessWidget { } _buildDropDownWidget(BuildContext context) { - return SizedBox( - width: width ?? MediaQuery.of(context).size.width - 20, - child: DropdownButtonFormField( - focusNode: focusNode ?? FocusNode(), - icon: icon, - autofocus: autofocus!, - value: value, - isExpanded: true, - style: textStyle ?? Theme.of(context).textTheme.titleMedium, - items: items?.map((SelectionPopupModel item) { - return DropdownMenuItem( - value: item, - child: Text( - item.title, - style: hintStyle ?? Theme.of(context).textTheme.titleMedium, - ), - ); - }).toList(), - decoration: _buildInputDecoration(context), - validator: validator, - onChanged: onDropDownChanged, + return DropdownButtonFormField( + focusNode: focusNode ?? FocusNode(), + icon: Icon(Icons.keyboard_arrow_down_rounded), + autofocus: autofocus!, + value: value, + isExpanded: true, + style: textStyle ?? TextStyle( + fontSize: 16, + fontWeight: FontWeight.w400, ), + items: items?.map((SelectionPopupModel item) { + return DropdownMenuItem( + value: item, + child: Text( + item.title, + style: hintStyle ?? TextStyle( + fontSize: 16, + fontWeight: FontWeight.w400, + color: Colors.black, + ), + ), + ); + }).toList(), + decoration: _buildInputDecoration(context), + validator: validator, + onChanged: onDropDownChanged, ); } @@ -111,34 +115,42 @@ class CustomDropDown extends StatelessWidget { InputDecoration _buildInputDecoration(BuildContext context) { return InputDecoration( hintText: hintText ?? "", - hintStyle: hintStyle ?? Theme.of(context).textTheme.titleMedium, + hintStyle: hintStyle ?? TextStyle( + fontSize: 16, + fontWeight: FontWeight.w400, + color: Colors.grey.shade400, + ), prefixIcon: prefix, prefixIconConstraints: prefixConstraints, suffixIcon: suffix, suffixIconConstraints: suffixConstraints, isDense: true, - contentPadding: contentPadding ?? - EdgeInsets.only( - left: 6, - top: 6, - bottom: 6, - ), + contentPadding: contentPadding ?? EdgeInsets.all(8), fillColor: fillColor ?? Theme.of(context).colorScheme.onPrimary, filled: filled, border: borderDecoration ?? OutlineInputBorder( - borderRadius: const BorderRadius.all(Radius.circular(8)), - borderSide: BorderSide(color: appTheme.blueA400, width: 1), + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide( + color: Colors.grey.shade400, + width: 1, + ), ), enabledBorder: borderDecoration ?? OutlineInputBorder( - borderRadius: const BorderRadius.all(Radius.circular(8)), - borderSide: BorderSide(color: appTheme.blueA400, width: 1), + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide( + color: Colors.grey.shade400, + width: 1, + ), ), focusedBorder: borderDecoration ?? OutlineInputBorder( - borderRadius: const BorderRadius.all(Radius.circular(8)), - borderSide: BorderSide(color: appTheme.blueA400, width: 1), + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide( + color: appTheme.blueA400, + width: 1, + ), ), ); } diff --git a/lib/widgets/custom_text_form_field.dart b/lib/widgets/custom_text_form_field.dart index 862cc104..11aa7d4d 100644 --- a/lib/widgets/custom_text_form_field.dart +++ b/lib/widgets/custom_text_form_field.dart @@ -4,12 +4,11 @@ import 'package:flutter/services.dart'; class CustomTextFormField extends StatelessWidget { CustomTextFormField({ - Key? key, this.alignment, this.width, this.controller, this.focusNode, - this.autofocus = true, + this.autofocus = false, this.textStyle, this.obscureText = false, this.textInputAction = TextInputAction.next, @@ -32,21 +31,23 @@ class CustomTextFormField extends StatelessWidget { this.onSaved, this.initialValue, this.onChanged, - }) : super( - key: key, - ); + this.onEditingComplete, + this.minLines = 1, + super.key, + }); final Alignment? alignment; final double? width; final TextEditingController? controller; final FocusNode? focusNode; - final bool? autofocus; + final bool autofocus; final TextStyle? textStyle; final bool? obscureText; final List? inputFormatters; final TextInputAction? textInputAction; final TextInputType? textInputType; final int? maxLines; + final int minLines; final String? hintText; final TextStyle? hintStyle; final Widget? prefix; @@ -61,162 +62,74 @@ class CustomTextFormField extends StatelessWidget { final FormFieldValidator? validator; final String? initialValue; final Function(String)? onFieldSubmitted; + final Function()? onEditingComplete; final void Function(String?)? onSaved; final void Function(String)? onChanged; @override Widget build(BuildContext context) { - return alignment != null - ? Align( - alignment: alignment ?? Alignment.center, - child: SizedBox( - width: width ?? double.maxFinite, - child: TextFormField( - controller: controller, - focusNode: focusNode ?? null, - autofocus: autofocus!, - style: textStyle ?? theme.textTheme.titleMedium, - obscureText: obscureText!, - textInputAction: textInputAction, - maxLines: maxLines ?? 1, - onFieldSubmitted: onFieldSubmitted, - onChanged: onChanged, - decoration: InputDecoration( - hintText: hintText ?? "", - hintStyle: hintStyle ?? theme.textTheme.bodyLarge, - prefixIcon: prefix, - prefixIconConstraints: prefixConstraints, - suffixIcon: suffix, - suffixIconConstraints: suffixConstraints, - isDense: true, - contentPadding: contentPadding ?? EdgeInsets.all(6.h), - fillColor: fillColor ?? theme.colorScheme.onPrimary, - filled: filled, - border: borderDecoration ?? - OutlineInputBorder( - borderRadius: BorderRadius.circular(8.h), - borderSide: BorderSide( - color: appTheme.blueA400, - width: 1, - ), - ), - enabledBorder: borderDecoration ?? - OutlineInputBorder( - borderRadius: BorderRadius.circular(8.h), - borderSide: BorderSide( - color: appTheme.blueA400, - width: 1, - ), - ), - focusedBorder: borderDecoration ?? - OutlineInputBorder( - borderRadius: BorderRadius.circular(8.h), - borderSide: BorderSide( - color: appTheme.blueA400, - width: 1, - ), - ), + return Align( + alignment: alignment ?? Alignment.center, + child: TextFormField( + minLines: minLines, + onChanged: onChanged, + controller: controller, + focusNode: focusNode ?? null, + autofocus: autofocus, + style: TextStyle( + fontSize: 16, + color: Colors.black, + ), + obscureText: obscureText!, + textInputAction: textInputAction, + maxLines: maxLines ?? 1, + initialValue: initialValue, + cursorColor: appTheme.blueA400, + decoration: InputDecoration( + hintText: hintText ?? "", + hintStyle: TextStyle( + fontSize: 16, + color: Colors.grey.shade400, + fontWeight: FontWeight.w400, + ), + prefixIcon: prefix, + prefixIconConstraints: prefixConstraints, + suffixIcon: suffix, + suffixIconConstraints: suffixConstraints, + isDense: false, + contentPadding: EdgeInsets.all(8), + fillColor: fillColor ?? theme.colorScheme.onPrimary, + filled: filled, + border: borderDecoration ?? + OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide( + color: Colors.grey.shade400, + width: 1, ), - keyboardType: keyboardType, - validator: validator, - onSaved: onSaved, - inputFormatters: inputFormatters, - initialValue: initialValue, ), - ), - ) - : SizedBox( - width: width ?? double.maxFinite, - child: TextFormField( - onChanged: onChanged, - controller: controller, - focusNode: focusNode ?? null, - autofocus: autofocus!, - style: textStyle ?? theme.textTheme.titleMedium, - obscureText: obscureText!, - textInputAction: textInputAction, - maxLines: maxLines ?? 1, - initialValue: initialValue, - decoration: InputDecoration( - hintText: hintText ?? "", - hintStyle: hintStyle ?? theme.textTheme.bodyLarge, - prefixIcon: prefix, - prefixIconConstraints: prefixConstraints, - suffixIcon: suffix, - suffixIconConstraints: suffixConstraints, - isDense: true, - contentPadding: contentPadding ?? EdgeInsets.all(6.h), - fillColor: fillColor ?? theme.colorScheme.onPrimary, - filled: filled, - border: borderDecoration ?? - OutlineInputBorder( - borderRadius: BorderRadius.circular(8.h), - borderSide: BorderSide( - color: appTheme.blueA400, - width: 1, - ), - ), - enabledBorder: borderDecoration ?? - OutlineInputBorder( - borderRadius: BorderRadius.circular(8.h), - borderSide: BorderSide( - color: appTheme.blueA400, - width: 1, - ), - ), - focusedBorder: borderDecoration ?? - OutlineInputBorder( - borderRadius: BorderRadius.circular(8.h), - borderSide: BorderSide( - color: appTheme.blueA400, - width: 1, - ), - ), + enabledBorder: borderDecoration ?? + OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide( + color: Colors.grey.shade400, + width: 1, + ), ), - keyboardType: keyboardType, - validator: validator, - onSaved: onSaved, - inputFormatters: inputFormatters, - ), - ); - } -} -/* InputDecoration _buildInputDecoration() { - return InputDecoration( - hintText: hintText ?? "", - hintStyle: hintStyle ?? theme.textTheme.bodyLarge, - prefixIcon: prefix, - prefixIconConstraints: prefixConstraints, - suffixIcon: suffix, - suffixIconConstraints: suffixConstraints, - isDense: true, - contentPadding: contentPadding ?? EdgeInsets.all(6.h), - fillColor: fillColor ?? theme.colorScheme.onPrimary, - filled: filled, - border: borderDecoration ?? - OutlineInputBorder( - borderRadius: BorderRadius.circular(8.h), - borderSide: BorderSide( - color: appTheme.blueA400, - width: 1, - ), - ), - enabledBorder: borderDecoration ?? - OutlineInputBorder( - borderRadius: BorderRadius.circular(8.h), - borderSide: BorderSide( - color: appTheme.blueA400, - width: 1, - ), - ), - focusedBorder: borderDecoration ?? - OutlineInputBorder( - borderRadius: BorderRadius.circular(8.h), - borderSide: BorderSide( - color: appTheme.blueA400, - width: 1, - ), - ), + focusedBorder: borderDecoration ?? + OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide( + color: appTheme.blueA400, + width: 1, + ), + ), + ), + keyboardType: keyboardType, + validator: validator, + onSaved: onSaved, + inputFormatters: inputFormatters, + ), ); } -}*/ +}