From 901e23fa440396dbc88d584cbcf06971e6514d47 Mon Sep 17 00:00:00 2001 From: maxxkim Date: Tue, 30 Jan 2024 11:36:33 +0300 Subject: [PATCH] New inputs for profile edit form --- lib/localization/ru/ru_translations.dart | 5 +- .../my_profile_screen/my_profile_screen.dart | 8 +- .../my_profile_screen/my_settings_screen.dart | 261 ++++++++++-------- 3 files changed, 148 insertions(+), 126 deletions(-) diff --git a/lib/localization/ru/ru_translations.dart b/lib/localization/ru/ru_translations.dart index 57762bce..3408bb9d 100644 --- a/lib/localization/ru/ru_translations.dart +++ b/lib/localization/ru/ru_translations.dart @@ -40,12 +40,12 @@ final Map ru = { // blood_pressure Screen "no": "Нет", - "do_you_have_hypertension_tendency": "Есть ли у вас склонность к гипертонии?", + "do_you_have_hypertension_tendency": "Есть ли у вас гипертония?", "your_blood_pressure": "Ваше артериальное давление?", "average_pressure": "Средние показатели давления:", "up_pressure": "Верхние показатели давления:", "down_pressure": "Нижние показатели давления:", - "do_you_have_hypotension_tendency": "Есть ли у вас склонность к гипотонии?", + "do_you_have_hypotension_tendency": "Есть ли у вас гипотония?", // favorite_sports Screen "your_favorite_sports": "Ваши спортивные увлечения?", @@ -131,4 +131,5 @@ final Map ru = { "chat": "Чат", "admin": "Админ", "diary": "Дневник", + "save": "Сохранить", }; 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 a8d89708..0d68875d 100644 --- a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart @@ -151,7 +151,7 @@ class MyProfileScreen extends StatelessWidget { Widget _buildCarousel(BuildContext contex, MyProfileLoadedState state) { return CarouselSlider( - options: CarouselOptions(height: 375.0), + options: CarouselOptions(height: 340.0), items: [1, 2, 3].map((chartType) { return Builder( builder: (BuildContext context) { @@ -643,8 +643,8 @@ class MyProfileScreen extends StatelessWidget { Padding( padding: EdgeInsets.only(left: 15.h), child: Text("plans_complete".tr, - style: CustomTextStyles.titleMediumBlack.copyWith( - color: appTheme.black900))), + style: CustomTextStyles.titleMediumBlack + .copyWith(color: appTheme.black900))), SizedBox(height: 5.v), Container( decoration: AppDecoration.outlineBlueGray @@ -653,7 +653,7 @@ class MyProfileScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( - height: 94.v, + height: 120.v, width: 343.h, child: Stack(alignment: Alignment.bottomCenter, children: [ diff --git a/lib/presentation/profile/my_profile_screen/my_settings_screen.dart b/lib/presentation/profile/my_profile_screen/my_settings_screen.dart index 8cf4d561..51d5b078 100644 --- a/lib/presentation/profile/my_profile_screen/my_settings_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_settings_screen.dart @@ -8,6 +8,7 @@ import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart'; import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart'; import 'package:eatvio_app/widgets/custom_bottom_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'; class MySettingsScreen extends StatelessWidget { @@ -19,18 +20,18 @@ class MySettingsScreen extends StatelessWidget { child: MySettingsScreen()); } - Widget build(BuildContext context) { + Widget build(BuildContext context) { return BlocBuilder( builder: (context, state) { if (state is MyProfileInitialState) { // Это начальное состояние, данные ещё не загружены. - return CircularProgressIndicator(color: Colors.white, backgroundColor: Colors.white,); + return CircularProgressIndicator( + color: Colors.white, + backgroundColor: Colors.white, + ); } else if (state is MyProfileLoadedState) { // Данные загружены, можно строить экран. return _buildSetingsScreen(context, state); - } else if (state is MyProfileErrorState) { - // Произошла ошибка при загрузке данных. - return Center(child: Text(state.errorMessage)); } else { // Другие состояния, если они есть. return Container(); // Пустой контейнер для необработанных состояний. @@ -41,22 +42,22 @@ class MySettingsScreen extends StatelessWidget { Widget _buildSetingsScreen(BuildContext context, MyProfileLoadedState state) { mediaQueryData = MediaQuery.of(context); - final List userDetails = [ - state.userDetails!['first_name'], - state.userDetails!['last_name'], - state.userDetails!['weight'].toString(), - state.userDetails!['height'].toString(), - state.userDetails!['chest_circumference'].toString(), - state.userDetails!['waist_circumference'].toString(), - state.userDetails!['hip_circumference'].toString(), - ]; - return SafeArea( - child: Scaffold( - appBar: _buildAppBar(context, "my_settings".tr), - body: Padding( - padding: const EdgeInsets.all(16.0), + final List userDetails = [ + state.userDetails!['first_name'], + state.userDetails!['last_name'], + state.userDetails!['weight'].toString(), + state.userDetails!['height'].toString(), + state.userDetails!['chest_circumference'].toString(), + state.userDetails!['waist_circumference'].toString(), + state.userDetails!['hip_circumference'].toString(), + ]; + return SafeArea( + child: Scaffold( + appBar: _buildAppBar(context, "my_settings".tr), + body: Padding( + padding: const EdgeInsets.all(16.0), + child: SingleChildScrollView( child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, children: [ SectionTitle('Язык'), LanguageDropdown(), @@ -69,7 +70,8 @@ class MySettingsScreen extends StatelessWidget { ], ), ), - bottomNavigationBar: _buildBottomBar(context))); + ), + bottomNavigationBar: _buildBottomBar(context))); } /// Section Widget @@ -198,6 +200,45 @@ class _NotificationSwitchState extends State { } } +class HypoHyperSwitch extends StatefulWidget { + final String title; + + HypoHyperSwitch(this.title); + + @override + _HypoHyperState createState() => _HypoHyperState(); +} + +class _HypoHyperState extends State { + bool switchValue = false; + + @override + Widget build(BuildContext context) { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + widget.title, + style: TextStyle( + color: Colors.black, fontSize: 14, fontWeight: FontWeight.bold), + ), + Switch( + value: switchValue, + onChanged: (value) { + setState(() { + switchValue = value; + }); + }, + inactiveThumbColor: appTheme.blueA400, + inactiveTrackColor: Colors.white, + activeTrackColor: appTheme.blueA400, + activeColor: Colors.white, + ), + ], + ); + } +} + class ExpandableList extends StatefulWidget { final String title; final List items; @@ -213,7 +254,8 @@ class _ExpandableListState extends State { @override Widget build(BuildContext context) { - return ListView( + return Column( + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ GestureDetector( onTap: () { @@ -238,104 +280,83 @@ class _ExpandableListState extends State { if (isExpanded) Padding( padding: const EdgeInsets.only(left: 16.0), - child: Column( - children: [ - TextField( - decoration: InputDecoration(labelText: 'first_name'.tr), - ), - TextField( - decoration: InputDecoration(labelText: 'last_name'.tr), - ), - // Поле даты рождения, предполагается, что 'reg_form.date_of_birth' это функция для получения даты рождения - TextField( - decoration: InputDecoration(labelText: 'date_of_birth'.tr), - onTap: () { - // Вставьте здесь логику для отображения выбора даты - }, - ), - // Поле выбора пола - Row( - children: [ - Radio(value: 'male'.tr, groupValue: null, onChanged: null), - Text('Male'), - Radio(value: 'female'.tr, groupValue: null, onChanged: null), - Text('Female'), - ], - ), - TextField( - decoration: InputDecoration(labelText: 'country'.tr), - ), - TextField( - decoration: InputDecoration(labelText: 'place_of_living'.tr), - ), - // Поле выбора языка - DropdownButton( - value: null, - onChanged: (newValue) { - // Вставьте здесь логику для обработки выбора языка - }, - items: ['russian'.tr].map((String language) { - return DropdownMenuItem( - value: language, - child: Text(language), - ); - }).toList(), - ), - // Поля для ввода чисел - TextField( - decoration: InputDecoration(labelText: 'weight_measurements'.tr), - keyboardType: TextInputType.number, - ), - TextField( - decoration: InputDecoration(labelText: 'height_measurements'.tr), - keyboardType: TextInputType.number, - ), - TextField( - decoration: InputDecoration(labelText: 'chest_circumference'.tr), - keyboardType: TextInputType.number, - ), - TextField( - decoration: InputDecoration(labelText: 'waist_circumference'.tr), - keyboardType: TextInputType.number, - ), - TextField( - decoration: InputDecoration(labelText: 'hip_circumference'.tr), - keyboardType: TextInputType.number, - ), - TextField( - decoration: InputDecoration(labelText: 'up_pressure'.tr), - keyboardType: TextInputType.number, - ), - TextField( - decoration: InputDecoration(labelText: 'down_pressure'), - keyboardType: TextInputType.number, - ), - // Переключатели - Row( - children: [ - Switch(value: false, onChanged: null), - Text('do_you_have_hypotension_tendency'.tr), - ], - ), - Row( - children: [ - Switch(value: false, onChanged: null), - Text('do_you_have_hypertension_tendency'.tr), - ], - ), - // Поля для ввода текста - TextField( - decoration: InputDecoration(labelText: 'allergies_presence'.tr), - maxLines: null, - ), - TextField( - decoration: InputDecoration(labelText: 'do_you_take_pills'.tr), - maxLines: null, - ), - TextField( - decoration: InputDecoration(labelText: 'your_favorite_sports'.tr), - maxLines: null, - ),]), + child: Column(children: [ + TextField( + decoration: InputDecoration(labelText: 'first_name'.tr), + ), + TextField( + decoration: InputDecoration(labelText: 'last_name'.tr), + ), + TextField( + decoration: InputDecoration(labelText: 'date_of_birth'.tr), + onTap: () {}, + ), + TextField( + decoration: InputDecoration(labelText: 'country'.tr), + ), + TextField( + decoration: InputDecoration(labelText: 'place_of_living'.tr), + ), + TextField( + decoration: + InputDecoration(labelText: 'weight_measurements'.tr), + keyboardType: TextInputType.number, + ), + TextField( + decoration: + InputDecoration(labelText: 'height_measurements'.tr), + keyboardType: TextInputType.number, + ), + TextField( + decoration: + InputDecoration(labelText: 'chest_circumference'.tr), + keyboardType: TextInputType.number, + ), + TextField( + decoration: + InputDecoration(labelText: 'waist_circumference'.tr), + keyboardType: TextInputType.number, + ), + TextField( + decoration: InputDecoration(labelText: 'hip_circumference'.tr), + keyboardType: TextInputType.number, + ), + TextField( + decoration: InputDecoration(labelText: 'up_pressure'.tr), + keyboardType: TextInputType.number, + ), + TextField( + decoration: InputDecoration(labelText: 'down_pressure'.tr), + keyboardType: TextInputType.number, + ), + TextField( + decoration: InputDecoration(labelText: 'allergies_presence'.tr), + maxLines: null, + ), + TextField( + decoration: InputDecoration(labelText: 'do_you_take_pills'.tr), + maxLines: null, + ), + TextField( + decoration: + InputDecoration(labelText: 'your_favorite_sports'.tr), + maxLines: null, + ), + Row( + children: [ + HypoHyperSwitch('do_you_have_hypotension_tendency'.tr), + ], + ), + Row( + children: [ + HypoHyperSwitch('do_you_have_hypertension_tendency'.tr), + ], + ), + NextStepButton( + buttonStyle: CustomButtonStyles.outlinePrimaryTL15, + text: "save".tr.toUpperCase(), + margin: EdgeInsets.only(top: 20.h, bottom: 20.h)), + ]), ), Divider(), ],