diff --git a/lib/localization/ru/ru_translations.dart b/lib/localization/ru/ru_translations.dart index 017f958a..338dbcb5 100644 --- a/lib/localization/ru/ru_translations.dart +++ b/lib/localization/ru/ru_translations.dart @@ -118,100 +118,9 @@ final Map ru = { "active": "Активен", "archived": "В архиве", "draft": "Черновик", - "my_blog": "Мой блог", "lbl_01_04_21": "01.04.21", "lbl_01_05_21": "01.05.21", - - // Настройки Screen + "my_blog": "Мой блог", "language": "Язык:", - "lbl23": "Уведомления", - "lbl24": "О нас ", - "msg2": "Уведомление о новых обновлениях", - "msg3": "Напоминания о заполнении дневника", - "msg4": "Дополнительная информация", - "msg5": "Персональные данные", - "msg6": "Стать консультантом", - - // Блог Screen - "lbl25": "Опубликовано", - "lbl26": "Черновик", - "msg_made_as_per_recipe": - "Made as per recipe, prepared about an hour early, covered and refrigerated. Very good, flavours melded with little astringency. Definitely will be having again.", - "msg_mediterranean_tuna": "Mediterranean tuna salad\r\n", - - // Блог - Tab Container Screen - "lbl27": "Мой Блог", "lbl28": "Статьи", "lbl29": "Рецепты", - - // Статья Screen - "lbl30": "Статья", - "lbl31": "Имя Фамилия", - "lbl32": "Цитировать", - "lbl33": "Комментарий", - "lbl_18_30": "18:30", - "lbl_23_04_2021": "23.04.2021,", - "lbl_32": "3", - "lbl_52": "5", - "msg7": "Комментарии пользователей: 3", - "msg_lorem_ipsum_dolor": - "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum", - "msg_lorem_ipsum_dolor2": - "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut", - "msg_lorem_ipsum_dolor3": - "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", - - // Личный кабинет One Screen - "lbl36": "Готов", "msg10": "Создать публикацию", - "msg8": "Редактировать профиль", "msg9": "Индекс массы тела:", - - // Личный кабинет Two Screen - "lbl40": "Написать", - - // Common String - "lbl10": "Талия:", - "lbl11": "Бедра:", - "lbl12": "Лёгкий", - "lbl14": "Умеренный", - "lbl15": "Полный", "in_progress": "В процессе", - "lbl17": "План", - "lbl18": "Лента", - "lbl19": "Главная", - "lbl20": "Профиль", - "lbl21": "Чат", - "lbl34": "Хедер", - "lbl35": "Анна Власова", - "lbl37": "Все публикации", - "lbl38": "Комментировать", - "lbl39": "Нравится", - "lbl4": "Настройки", - "lbl5": "Вес:", - "lbl6": "Было:", - "lbl7": "Стало:", - "lbl8": "Обхват:", - "lbl9": "Грудь:", - "lbl_0": "0", - "lbl_01_01_21": "01.01.21", - "lbl_01_02_21": "01.02.21", - "lbl_01_03_21": "01.03.21", - "lbl_100": "100", - "lbl_12_11": "Вчера в 12:11", - "lbl_200": "200", - "lbl_50": "50", - "lbl_55": "Стало: 55", - "lbl_552": " 55", - "lbl_60": "Талия: 60", - "lbl_602": "60", - "lbl_64": "64", - "lbl_80": "Было: 80", - "lbl_802": " 80", - "lbl_90": "Грудь: 90", - "lbl_902": "90", - "lbl_903": "Бедра: 90", - "msg": "Пройденные планы:", - "msg_10_trending_nutrition": - "10 Trending Nutrition Research Articles of 2021", - "msg_amet_minim_mollit": - "Amet minim mollit non deserunt ullamco est sit aliqua dolor do amet sint. Velit officia consequat duis enim velit mollit. Exercitation veniam consequat sunt nostrud amet. ", - "msg_as_2020_begins": - "As 2020 begins, we took a look back at nutrition in the news during 2019. The most popular diet search according to Google was intermittent fasting, which we can attest was a popular search term in American Society for Nutrition’s content as well. But there’s much more to nutrition than trending diets and many more areas in the field of nutrition were researched and discussed this past year. Below we share 10 articles from ASN’s four peer reviewed journals that received high levels of attention in the news and social media.", - "msg_as_2020_begins2": - "As 2020 begins, we took a look back at nutrition in the news during 2019. The most popular diet search according to Google was intermittent fasting...", + "add_measure": "Добавить замер", + "weight": "Вес", }; diff --git a/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart b/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart index 4a1c0f1f..dff96898 100644 --- a/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart +++ b/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart @@ -61,6 +61,7 @@ class MyProfileBloc extends Bloc { chestCircumferenceController: TextEditingController(), waistCircumferenceController: TextEditingController(), hipCircumferenceController: TextEditingController(), + weightController: TextEditingController(), circumferences: data['circumferences'], )); } diff --git a/lib/presentation/profile/my_profile_screen/bloc/my_profile_state.dart b/lib/presentation/profile/my_profile_screen/bloc/my_profile_state.dart index 2b1e3166..3ab92457 100644 --- a/lib/presentation/profile/my_profile_screen/bloc/my_profile_state.dart +++ b/lib/presentation/profile/my_profile_screen/bloc/my_profile_state.dart @@ -9,6 +9,7 @@ class MyProfileState extends Equatable { this.waistCircumferenceController, this.hipCircumferenceController, this.myProfileModelObj, + this.weightController, this.user, this.userDetails, this.chartPoints, @@ -22,6 +23,7 @@ class MyProfileState extends Equatable { Map? chartPoints; Map? circumferences; List? plans; + TextEditingController? weightController; TextEditingController? chestCircumferenceController; TextEditingController? waistCircumferenceController; TextEditingController? hipCircumferenceController; @@ -34,6 +36,7 @@ class MyProfileState extends Equatable { chartPoints, circumferences, plans, + weightController, chestCircumferenceController, waistCircumferenceController, hipCircumferenceController, @@ -46,6 +49,7 @@ class MyProfileState extends Equatable { List? plans, Map? chartPoints, Map? circumferences, + TextEditingController? weightController, TextEditingController? chestCircumferenceController, TextEditingController? waistCircumferenceController, TextEditingController? hipCircumferenceController, @@ -58,6 +62,7 @@ class MyProfileState extends Equatable { userDetails: userDetails ?? this.userDetails, circumferences: circumferences ?? this.circumferences, chartPoints: chartPoints ?? this.chartPoints, + weightController: weightController ?? this.weightController, chestCircumferenceController: chestCircumferenceController ?? this.chestCircumferenceController, waistCircumferenceController: 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 d7641b80..7af4f16a 100644 --- a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart @@ -53,32 +53,37 @@ class MyProfileScreen extends StatelessWidget { SizedBox(height: 30.v), CarouselSlider( options: CarouselOptions(height: 370.0), - items: [1, 2, 3, 4].map((chartType) { + items: [1, 2, 3].map((chartType) { return Builder( builder: (BuildContext context) { switch (chartType) { case 1: // График веса - return Column(children: [ - Text( - "weight_chart".tr, - style: CustomTextStyles.titleMediumBlack - .copyWith( - color: appTheme.black900, - ), - ), - SizedBox(height: 50.v), - _buildChart( - context, - state.chartPoints?.values - .map((e) => e['weight']) - .toList() - .map((i) => i.toDouble()) - .toList() ?? - [0.0, 0.0, 0.0, 0.0], - state.chartPoints?.values - .map((e) => e['created_at']) - .toList()), - ]); + return GestureDetector( + onTap: () { + _editWeight(context, state); + }, + child: Column(children: [ + Text( + "weight_chart".tr, + style: CustomTextStyles.titleMediumBlack + .copyWith( + color: appTheme.black900, + ), + ), + SizedBox(height: 50.v), + _buildChart( + context, + state.chartPoints?.values + .map((e) => e['weight']) + .toList() + .map((i) => i.toDouble()) + .toList() ?? + [0.0, 0.0, 0.0, 0.0], + state.chartPoints?.values + .map( + (e) => e['created_at']) + .toList()), + ])); case 2: // График ИМТ return Column(children: [ Text( @@ -128,7 +133,7 @@ class MyProfileScreen extends StatelessWidget { .toList()), _buildChartLegend() ])); - case 4: + /*case 4: return NextStepButton( buttonStyle: CustomButtonStyles.outlinePrimaryTL15, @@ -136,7 +141,7 @@ class MyProfileScreen extends StatelessWidget { margin: EdgeInsets.only(left: 10.h), onPressed: () { print(dotenv.env['STORAGE_URL']!); - }); + });*/ default: return Text('text', style: TextStyle(fontSize: 16.0)); @@ -808,8 +813,6 @@ class MyProfileScreen extends StatelessWidget { String jsonData = json.encode(data); // Отправка HTTP-запроса - print(jsonData); - print(state.token); try { final token = state.token; final response = await http.post( @@ -850,4 +853,83 @@ class MyProfileScreen extends StatelessWidget { }, ); } + + _editWeight(BuildContext context, MyProfileState state) { + showDialog( + context: context, + builder: (context) { + final digitsOnly = FilteringTextInputFormatter.digitsOnly; + return AlertDialog( + title: Center(child: Text("add_measure".tr)), + content: SingleChildScrollView( + child: Column( + children: [ + Text("weight".tr, style: theme.textTheme.bodyLarge), + SizedBox(height: 5.v), + CustomTextFormField( + controller: state.weightController, + keyboardType: TextInputType.number, + inputFormatters: [ + digitsOnly // Ограничение ввода только цифрами + ], + ), + ], + ), + ), + actions: [ + TextButton( + onPressed: () { + Navigator.pop(context); + }, + child: Text("Отмена", style: theme.textTheme.bodyLarge), + ), + TextButton( + onPressed: () async { + Map data = { + "weight": state.weightController!.text, + }; + // Преобразование Map в JSON + String jsonData = json.encode(data); + + // Отправка HTTP-запроса + try { + final token = state.token; + final response = await http.post( + Uri.parse( + dotenv.env['SERVER_ROOT']! + '/profile/addWeight'), + headers: { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer $token', + }, + body: jsonData, + ); + + if (response.statusCode == 200) { + Navigator.pushNamed( + context, + AppRoutes.myProfile, + ); + } else { + // Ошибка от сервера + print( + "Ошибка при отправке данных. Код ответа: ${response.statusCode}"); + } + } catch (e) { + // Обработка ошибок при отправке запроса + print("Ошибка при отправке запроса: $e"); + } + }, + child: Text("Изменить", + style: CustomTextStyles.titleMediumBlack.copyWith( + color: Colors.blue, + )), + ), + ], + backgroundColor: Colors.white, + titlePadding: EdgeInsets.all( + 20.0), // Можете настроить отступы по вашему желанию + ); + }, + ); + } }