From 5442a3f2e2fff150048f1118d1991b521c452aad Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Mon, 30 Sep 2024 17:44:25 +0300 Subject: [PATCH] feat: settings --- assets/rive_animations/loading.riv | Bin 965 -> 969 bytes lib/app_router.dart | 3 +- .../presentation/pages/blog_post_screen.dart | 9 +- .../presentation/pages/calendar_screen.dart | 9 +- .../chat/presentation/pages/chat_screen.dart | 19 ++- .../pages/chat_select_screen.dart | 17 ++- .../pages/diary_recommendations_scree.dart | 9 +- .../presentation/pages/diary_screen.dart | 17 ++- .../presentation/pages/about_diet_screen.dart | 9 +- .../feed/presentation/pages/feed_screen.dart | 41 +++++- .../bloc/profile_cubit/profile_cubit.dart | 1 - .../presentation/pages/profile_screen.dart | 19 +-- .../widgets/circumference_chart_widget.dart | 8 +- .../pages/about_recipes_screen.dart | 9 +- .../pages/recipe_create_screen.dart | 9 +- .../pages/recipe_edit_screen.dart | 9 +- .../pages/registration_screen.dart | 9 +- .../bloc/settings_cubit/settings_cubit.dart | 14 ++ .../pages/general_info_screen.dart | 22 ++- .../presentation/pages/other_info_screen.dart | 26 +++- .../pages/physical_activity_screen.dart | 69 +++++++-- .../pages/physical_form_screen.dart | 25 +++- .../presentation/pages/pressure_screen.dart | 31 +++- .../presentation/pages/settings_screen.dart | 135 ++++++++++-------- .../repositories/service_repository.dart | 4 +- .../settings/services/settings_service.dart | 2 +- .../settings/services/settings_service.g.dart | 5 +- .../diet_edit_screen/diet_edit_screen.dart | 9 +- .../diet_select_screen.dart | 25 +++- .../diet_show_screen/diet_show_screen.dart | 9 +- .../blog_post_edit_screen.dart | 25 +++- .../widgets/comment_widget.dart | 9 +- .../glossary_screen/glossary_screen.dart | 25 +++- .../plan_edit_screen/plan_edit_screen.dart | 9 +- .../plan_select_screen.dart | 25 +++- .../plan_show_screen/plan_show_screen.dart | 9 +- .../my_profile_screen/my_settings_screen.dart | 17 ++- .../recipe_edit_screen.dart | 17 ++- .../recipe_select_screen.dart | 25 +++- .../subscribers_screen.dart | 19 ++- lib/widgets/custom_expandable_list.dart | 11 +- lib/widgets/custom_text_form_field.dart | 2 +- 42 files changed, 600 insertions(+), 166 deletions(-) diff --git a/assets/rive_animations/loading.riv b/assets/rive_animations/loading.riv index d1b89c4383f51869510889d047cdfe7d9e2763ed..d328f26d4951ef0b71a5d1e83ba1f03527d176f6 100644 GIT binary patch delta 92 zcmX@gev*BIBD1YUg=K{`BZH)|5QCH{KZBeLBZHiCg$twGgN73hKp_F35R;@C`%W0vMa6KZF60su8b6H@>H diff --git a/lib/app_router.dart b/lib/app_router.dart index 66bd328e..7d97c634 100644 --- a/lib/app_router.dart +++ b/lib/app_router.dart @@ -172,10 +172,11 @@ class AppRouter { builder: (context, state) => SettingsScreen(), routes: [ GoRoute( - path: 'general-info-screen', + path: 'general-info-screen/:isPublicProfile', name: 'generalInfoScreen', builder: (context, state) => GeneralInfoScreen( profileDetailsModel: state.extra as ProfileDetailsModel, + isPublicProfile: bool.parse(state.pathParameters['isPublicProfile']!), ), ), GoRoute( diff --git a/lib/features/blog_post/presentation/pages/blog_post_screen.dart b/lib/features/blog_post/presentation/pages/blog_post_screen.dart index 3f6004fd..7c27ab09 100644 --- a/lib/features/blog_post/presentation/pages/blog_post_screen.dart +++ b/lib/features/blog_post/presentation/pages/blog_post_screen.dart @@ -13,6 +13,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_html/flutter_html.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; import 'package:share_plus/share_plus.dart'; class BlogPostScreen extends StatefulWidget { @@ -320,7 +321,13 @@ class _BlogPostScreenState extends State { if (state is CommentsStateLoading) Padding( padding: const EdgeInsets.all(32), - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), if (state is CommentsStateLoaded) CommentsWidget( diff --git a/lib/features/calendar/presentation/pages/calendar_screen.dart b/lib/features/calendar/presentation/pages/calendar_screen.dart index 7bc7c3fa..be3f22ed 100644 --- a/lib/features/calendar/presentation/pages/calendar_screen.dart +++ b/lib/features/calendar/presentation/pages/calendar_screen.dart @@ -9,6 +9,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:go_router/go_router.dart'; import 'package:intl/intl.dart'; +import 'package:rive/rive.dart'; class CalendarScreen extends StatelessWidget { CalendarScreen({Key? key}) : super(key: key); @@ -23,7 +24,13 @@ class CalendarScreen extends StatelessWidget { } else if (state is CalendarStateLoading) { return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } else if (state is CalendarStateError) { diff --git a/lib/features/chat/presentation/pages/chat_screen.dart b/lib/features/chat/presentation/pages/chat_screen.dart index 58c1b70c..2e96d007 100644 --- a/lib/features/chat/presentation/pages/chat_screen.dart +++ b/lib/features/chat/presentation/pages/chat_screen.dart @@ -10,6 +10,7 @@ import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:intl/intl.dart'; +import 'package:rive/rive.dart'; class ChatScreen extends StatefulWidget { final String chatId; @@ -62,7 +63,13 @@ class _ChatScreenState extends State { } else { return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } @@ -165,7 +172,15 @@ class _ChatScreenState extends State { } else { return Padding( padding: const EdgeInsets.all(8), - child: Center(child: CircularProgressIndicator()), + child: Center( + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), + ), ); } }, diff --git a/lib/features/chat/presentation/pages/chat_select_screen.dart b/lib/features/chat/presentation/pages/chat_select_screen.dart index b683eb39..b4660cf2 100644 --- a/lib/features/chat/presentation/pages/chat_select_screen.dart +++ b/lib/features/chat/presentation/pages/chat_select_screen.dart @@ -6,6 +6,7 @@ import 'package:eatvio_app/features/chat/presentation/widgets/chat_search_bar_wi import 'package:eatvio_app/locator_service.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:rive/rive.dart'; class ChatSelectScreen extends StatefulWidget { const ChatSelectScreen({Key? key}) : super(key: key); @@ -78,7 +79,13 @@ class _ChatSelectScreenState extends State { if (state is ChatSelectStateLoading) { return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } else if (state is ChatSelectStateLoaded) { @@ -91,7 +98,13 @@ class _ChatSelectScreenState extends State { } else { return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } diff --git a/lib/features/diary/presentation/pages/diary_recommendations_scree.dart b/lib/features/diary/presentation/pages/diary_recommendations_scree.dart index e76b33ab..53b20dee 100644 --- a/lib/features/diary/presentation/pages/diary_recommendations_scree.dart +++ b/lib/features/diary/presentation/pages/diary_recommendations_scree.dart @@ -6,6 +6,7 @@ import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:rive/rive.dart'; // ignore: must_be_immutable class DiaryRecommendationsScreen extends StatelessWidget { @@ -27,7 +28,13 @@ class DiaryRecommendationsScreen extends StatelessWidget { } else if (state is DiaryStateLoading) { return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } else if (state is DiaryStateError) { diff --git a/lib/features/diary/presentation/pages/diary_screen.dart b/lib/features/diary/presentation/pages/diary_screen.dart index 1a2e3bd3..aaa06ad8 100644 --- a/lib/features/diary/presentation/pages/diary_screen.dart +++ b/lib/features/diary/presentation/pages/diary_screen.dart @@ -20,6 +20,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:image_picker/image_picker.dart'; +import 'package:rive/rive.dart' as rive; import 'package:syncfusion_flutter_charts/charts.dart'; class DiaryScreen extends StatelessWidget { @@ -43,7 +44,13 @@ class DiaryScreen extends StatelessWidget { } else if (state is DiaryStateLoading) { return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: rive.RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } else if (state is DiaryStateError) { @@ -342,7 +349,13 @@ class DiaryScreen extends StatelessWidget { borderRadius: BorderRadiusStyle.roundedBorder5, ), child: Center( - child: CircularProgressIndicator(color: appTheme.blueGray300), // Замените на свой прелоадер при необходимости + child: SizedBox( + height: 32, + width: 32, + child: rive.RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ), ], diff --git a/lib/features/diets/presentation/pages/about_diet_screen.dart b/lib/features/diets/presentation/pages/about_diet_screen.dart index 1847689d..7dd66a37 100644 --- a/lib/features/diets/presentation/pages/about_diet_screen.dart +++ b/lib/features/diets/presentation/pages/about_diet_screen.dart @@ -12,6 +12,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_html/flutter_html.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; class AboutDietScreen extends StatefulWidget { final Diet diet; @@ -329,7 +330,13 @@ class _AboutDietScreenState extends State { if (state is CommentsStateLoading) Padding( padding: const EdgeInsets.all(32), - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), if (state is CommentsStateLoaded) CommentsWidget( diff --git a/lib/features/feed/presentation/pages/feed_screen.dart b/lib/features/feed/presentation/pages/feed_screen.dart index e74a9cf3..ab1c9768 100644 --- a/lib/features/feed/presentation/pages/feed_screen.dart +++ b/lib/features/feed/presentation/pages/feed_screen.dart @@ -17,6 +17,7 @@ import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; final bucket = PageStorageBucket(); @@ -164,7 +165,13 @@ class _FeedScreenState extends State { if (index == state.feedBlogPostList.length) { return Container( alignment: Alignment.center, - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ); } return BlogPostWidget(feedBlogPostModel: state.feedBlogPostList[index]); @@ -188,7 +195,13 @@ class _FeedScreenState extends State { return Scaffold( backgroundColor: Colors.grey.shade200, body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } @@ -232,7 +245,13 @@ class _FeedScreenState extends State { return Scaffold( backgroundColor: Colors.grey.shade200, body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } @@ -276,7 +295,13 @@ class _FeedScreenState extends State { return Scaffold( backgroundColor: Colors.grey.shade200, body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } @@ -320,7 +345,13 @@ class _FeedScreenState extends State { return Scaffold( backgroundColor: Colors.grey.shade200, body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } diff --git a/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart b/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart index 02cf5214..f6052a4b 100644 --- a/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart +++ b/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart @@ -29,7 +29,6 @@ class ProfileCubit extends Cubit { _currentPeriod = period; try { final profile = await profileRepository.getMyProfile(); - await Future.delayed(Duration(seconds: 2)); emit(ProfileState.loaded( profile: profile, profileDetails: await profileRepository.getMyProfileDetails(), diff --git a/lib/features/profile/presentation/pages/profile_screen.dart b/lib/features/profile/presentation/pages/profile_screen.dart index b0643e63..b62c2ec4 100644 --- a/lib/features/profile/presentation/pages/profile_screen.dart +++ b/lib/features/profile/presentation/pages/profile_screen.dart @@ -288,18 +288,13 @@ class _ProfileScreenState extends State { return Scaffold( appBar: AppBar(), body: Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - SizedBox( - height: 32, - width: 32, - child: RiveAnimation.asset( - 'assets/rive_animations/loading.riv', - ), - ), - ], - ) + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } diff --git a/lib/features/profile/presentation/widgets/circumference_chart_widget.dart b/lib/features/profile/presentation/widgets/circumference_chart_widget.dart index 21fef10c..eb37ec13 100644 --- a/lib/features/profile/presentation/widgets/circumference_chart_widget.dart +++ b/lib/features/profile/presentation/widgets/circumference_chart_widget.dart @@ -246,9 +246,9 @@ class _CircumferenceChartWidgetState extends State { InkWell( onTap: () { widget.profileCubit.addCircumference( - chestCircumference: chest, - waistCircumference: waist, - hipCircumference: hip, + chestCircumference: chest + 20, + waistCircumference: waist + 20, + hipCircumference: hip + 20, ); Navigator.of(context).pop(); }, @@ -275,7 +275,7 @@ class _CircumferenceChartWidgetState extends State { }, ); }, - backgroundColor: Colors.red, + backgroundColor: appTheme.blueA400, shape: CircleBorder(), child: Icon( Icons.add, diff --git a/lib/features/recipes/presentation/pages/about_recipes_screen.dart b/lib/features/recipes/presentation/pages/about_recipes_screen.dart index 130317e2..b54fed1f 100644 --- a/lib/features/recipes/presentation/pages/about_recipes_screen.dart +++ b/lib/features/recipes/presentation/pages/about_recipes_screen.dart @@ -13,6 +13,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_html/flutter_html.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; class AboutRecipesScreen extends StatefulWidget { final Recipes recipes; @@ -347,7 +348,13 @@ class _AboutRecipesScreenState extends State { if (state is CommentsStateLoading) Padding( padding: const EdgeInsets.all(32), - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), if (state is CommentsStateLoaded) CommentsWidget( diff --git a/lib/features/recipes/presentation/pages/recipe_create_screen.dart b/lib/features/recipes/presentation/pages/recipe_create_screen.dart index 947b2784..eb1339b4 100644 --- a/lib/features/recipes/presentation/pages/recipe_create_screen.dart +++ b/lib/features/recipes/presentation/pages/recipe_create_screen.dart @@ -17,6 +17,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:image_picker/image_picker.dart'; +import 'package:rive/rive.dart' as rive; class RecipeCreateScreen extends StatelessWidget { RecipeCreateScreen({Key? key}) : super(key: key); @@ -31,7 +32,13 @@ class RecipeCreateScreen extends StatelessWidget { } else if (state is RecipeCreateStateLoading) { return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: rive.RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } else if (state is RecipeCreateStateError) { diff --git a/lib/features/recipes/presentation/pages/recipe_edit_screen.dart b/lib/features/recipes/presentation/pages/recipe_edit_screen.dart index a5abe676..dc435059 100644 --- a/lib/features/recipes/presentation/pages/recipe_edit_screen.dart +++ b/lib/features/recipes/presentation/pages/recipe_edit_screen.dart @@ -14,6 +14,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:image_picker/image_picker.dart'; +import 'package:rive/rive.dart' as rive; // ignore: must_be_immutable class RecipeEditScreen extends StatelessWidget { @@ -35,7 +36,13 @@ class RecipeEditScreen extends StatelessWidget { } else if (state is RecipeCreateStateLoading) { return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: rive.RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } else if (state is RecipeCreateStateError) { diff --git a/lib/features/registration/presentation/pages/registration_screen.dart b/lib/features/registration/presentation/pages/registration_screen.dart index a2a4f5b3..7694582c 100644 --- a/lib/features/registration/presentation/pages/registration_screen.dart +++ b/lib/features/registration/presentation/pages/registration_screen.dart @@ -23,6 +23,7 @@ import 'package:eatvio_app/widgets/app_bar/appbar_title_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; import 'package:validators/validators.dart'; class RegistrationScreen extends StatefulWidget { @@ -318,7 +319,13 @@ class _RegistrationScreenState extends State { builder: (context) => PopScope( canPop: false, child: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ), ); diff --git a/lib/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart b/lib/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart index 0b734d25..c4c0287b 100644 --- a/lib/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart +++ b/lib/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart @@ -1,3 +1,4 @@ +import 'package:eatvio_app/features/profile/models/profile_model.dart'; import 'package:eatvio_app/features/profile/repositories/profile_repository.dart'; import 'package:eatvio_app/features/settings/models/profile_settings_model.dart'; import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_state.dart'; @@ -24,6 +25,19 @@ class SettingsCubit extends Cubit { } } + updateProfileDetails({ + required ProfileDetailsModel profileDetailsModel + }) async { + try { + await settingsRepository.updateProfileDetails( + profileDetailsModel: profileDetailsModel, + ); + } catch (e) { + print(e); + rethrow; + } + } + updateProfileSettings({ required ProfileSettingsModel profileSettingsModel }) async { diff --git a/lib/features/settings/presentation/pages/general_info_screen.dart b/lib/features/settings/presentation/pages/general_info_screen.dart index dbe7d57e..109e584c 100644 --- a/lib/features/settings/presentation/pages/general_info_screen.dart +++ b/lib/features/settings/presentation/pages/general_info_screen.dart @@ -9,10 +9,12 @@ import 'package:go_router/go_router.dart'; class GeneralInfoScreen extends StatefulWidget { final ProfileDetailsModel profileDetailsModel; + final bool isPublicProfile; const GeneralInfoScreen({ super.key, required this.profileDetailsModel, + required this.isPublicProfile, }); @override @@ -22,7 +24,12 @@ class GeneralInfoScreen extends StatefulWidget { class _GeneralInfoScreenState extends State { final firstNameController = TextEditingController(); final lastNameController = TextEditingController(); + final genderController = TextEditingController(); + final countryController = TextEditingController(); + final cityController = TextEditingController(); + final languageController = TextEditingController(); late DateTime selectedDate; + late bool isPublicProfile; @override void initState() { @@ -31,6 +38,11 @@ class _GeneralInfoScreenState extends State { firstNameController.text = widget.profileDetailsModel.firstName; lastNameController.text = widget.profileDetailsModel.lastName; selectedDate = DateTime.parse(widget.profileDetailsModel.birthdate); + genderController.text = widget.profileDetailsModel.gender; + countryController.text = widget.profileDetailsModel.country; + cityController.text = widget.profileDetailsModel.city; + languageController.text = widget.profileDetailsModel.lang; + isPublicProfile = widget.isPublicProfile; } @override @@ -73,35 +85,35 @@ class _GeneralInfoScreenState extends State { Text('Пол'), SizedBox(height: 4), CustomTextFormField( - initialValue: 'Мужской', + controller: genderController, onChanged: (newValue) {}, ), SizedBox(height: 16), Text('Страна'), SizedBox(height: 4), CustomTextFormField( - initialValue: 'Россия', + controller: countryController, onChanged: (newValue) {}, ), SizedBox(height: 16), Text('Город'), SizedBox(height: 4), CustomTextFormField( - initialValue: 'Москва', + controller: cityController, onChanged: (newValue) {}, ), SizedBox(height: 16), Text('Предпочтительный язык общения'), SizedBox(height: 4), CustomTextFormField( - initialValue: 'Русский', + controller: languageController, onChanged: (newValue) {}, ), SizedBox(height: 16), Text('Показывать анкету'), SizedBox(height: 4), CustomTextFormField( - initialValue: 'Всем', + initialValue: isPublicProfile ? 'Всем' : 'Только зарегистрированным', onChanged: (newValue) {}, ), ], diff --git a/lib/features/settings/presentation/pages/other_info_screen.dart b/lib/features/settings/presentation/pages/other_info_screen.dart index 1232db7e..4501a9f6 100644 --- a/lib/features/settings/presentation/pages/other_info_screen.dart +++ b/lib/features/settings/presentation/pages/other_info_screen.dart @@ -18,6 +18,24 @@ class OtherInfoScreen extends StatefulWidget { } class _OtherInfoScreenState extends State { + final aboutAllergyController = TextEditingController(); + final aboutTakingPillsController = TextEditingController(); + final aboutSportHobbiesController = TextEditingController(); + final favoriteFoodsController = TextEditingController(); + final unfavouriteFoodsController = TextEditingController(); + final additionalInfoController = TextEditingController(); + + @override + void initState() { + super.initState(); + aboutAllergyController.text = widget.profileDetailsModel.aboutAlergy; + aboutTakingPillsController.text = widget.profileDetailsModel.aboutTakingPils; + aboutSportHobbiesController.text = widget.profileDetailsModel.aboutSportHobbies; + favoriteFoodsController.text = widget.profileDetailsModel.favoriteFoods; + unfavouriteFoodsController.text = widget.profileDetailsModel.unfavoriteFoods; + additionalInfoController.text = widget.profileDetailsModel.additionalInfo; + } + @override Widget build(BuildContext context) { final s = S.of(context); @@ -35,6 +53,7 @@ class _OtherInfoScreenState extends State { Text(s.allergies_presence), SizedBox(height: 4), CustomTextFormField( + controller: aboutAllergyController, hintText: 'Например: орехи, мёд и т.д.', autofocus: true, minLines: 2, @@ -45,6 +64,7 @@ class _OtherInfoScreenState extends State { Text(s.do_you_take_pills), SizedBox(height: 4), CustomTextFormField( + controller: aboutTakingPillsController, hintText: s.enter_information, autofocus: true, minLines: 2, @@ -55,6 +75,7 @@ class _OtherInfoScreenState extends State { Text(s.your_favorite_sports), SizedBox(height: 4), CustomTextFormField( + controller: aboutSportHobbiesController, hintText: "Я занимаюсь плаванием , почти каждый вечер прогулки на свежем воздухе, пару раз в месяц играю в волейбол. Стараюсь не сидеть на месте!", autofocus: true, @@ -65,6 +86,7 @@ class _OtherInfoScreenState extends State { Text(s.favorite_foods), SizedBox(height: 4), CustomTextFormField( + controller: favoriteFoodsController, hintText: s.enter_information, maxLines: 7, minLines: 2, @@ -74,6 +96,7 @@ class _OtherInfoScreenState extends State { Text(s.unfavorite_foods), SizedBox(height: 4), CustomTextFormField( + controller: unfavouriteFoodsController, hintText: s.enter_information, maxLines: 7, minLines: 2, @@ -88,6 +111,7 @@ class _OtherInfoScreenState extends State { ), SizedBox(height: 4), CustomTextFormField( + controller: additionalInfoController, hintText: "У меня крепкое здоровье, но последнее время часто утомляюсь, однако, это мне не мешает радоваться жизни", maxLines: 8, onChanged: (newValue) {}, @@ -104,7 +128,7 @@ class _OtherInfoScreenState extends State { borderRadius: BorderRadius.circular(20), child: Ink( height: 52, - width: MediaQuery.of(context).size.width - 16, + width: MediaQuery.of(context).size.width - 32, decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: appTheme.blueA400, diff --git a/lib/features/settings/presentation/pages/physical_activity_screen.dart b/lib/features/settings/presentation/pages/physical_activity_screen.dart index 55878e4a..536009c2 100644 --- a/lib/features/settings/presentation/pages/physical_activity_screen.dart +++ b/lib/features/settings/presentation/pages/physical_activity_screen.dart @@ -1,4 +1,7 @@ import 'package:eatvio_app/features/profile/models/profile_model.dart'; +import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart'; +import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_state.dart'; +import 'package:eatvio_app/locator_service.dart'; import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; @@ -15,10 +18,32 @@ class PhysicalActivityScreen extends StatefulWidget { State createState() => _PhysicalActivityScreenState(); } -enum PhysicalActivity { minimum, low, medium, high, extreme, hardWork } +enum PhysicalActivity { minimum, low, medium, high, extreme } class _PhysicalActivityScreenState extends State { - PhysicalActivity? _physicalActivity = PhysicalActivity.minimum; + late PhysicalActivity? _physicalActivity; + + @override + void initState() { + super.initState(); + switch (widget.profileDetailsModel.activityCoefficient) { + case 1.2: + _physicalActivity = PhysicalActivity.minimum; + break; + case 1.375: + _physicalActivity = PhysicalActivity.low; + break; + case 1.55: + _physicalActivity = PhysicalActivity.medium; + break; + case 1.7: + _physicalActivity = PhysicalActivity.high; + break; + case 1.9: + _physicalActivity = PhysicalActivity.extreme; + break; + } + } @override Widget build(BuildContext context) { @@ -87,17 +112,6 @@ class _PhysicalActivityScreenState extends State { }); }, ), - RadioListTile( - contentPadding: EdgeInsets.zero, - title: const Text('1,9 6–7 раз в неделю; очень трудоёмкая работа).'), - value: PhysicalActivity.hardWork, - groupValue: _physicalActivity, - onChanged: (PhysicalActivity? value) { - setState(() { - _physicalActivity = value; - }); - }, - ), ], ), ), @@ -106,7 +120,34 @@ class _PhysicalActivityScreenState extends State { _saveButton() { return InkWell( - onTap: () => GoRouter.of(context).pop(), + onTap: () { + late final double activityCoefficient; + switch (_physicalActivity) { + case PhysicalActivity.minimum: + activityCoefficient = 1.2; + break; + case PhysicalActivity.low: + activityCoefficient = 1.375; + break; + case PhysicalActivity.medium: + activityCoefficient = 1.55; + break; + case PhysicalActivity.high: + activityCoefficient = 1.7; + break; + case PhysicalActivity.extreme: + activityCoefficient = 1.9; + break; + default: + break; + } + sl().updateProfileDetails( + profileDetailsModel: (sl().state as SettingsStateLoaded).profileDetails.copyWith( + activityCoefficient: activityCoefficient, + ), + ); + GoRouter.of(context).pop(); + }, borderRadius: BorderRadius.circular(20), child: Ink( height: 52, diff --git a/lib/features/settings/presentation/pages/physical_form_screen.dart b/lib/features/settings/presentation/pages/physical_form_screen.dart index 3b5f7097..d45a8367 100644 --- a/lib/features/settings/presentation/pages/physical_form_screen.dart +++ b/lib/features/settings/presentation/pages/physical_form_screen.dart @@ -23,6 +23,16 @@ class _PhysicalFormScreenState extends State { final chestCircumferenceController = TextEditingController(); final waistCircumferenceController = TextEditingController(); final hipCircumferenceController = TextEditingController(); + final heightController = TextEditingController(); + + @override + void initState() { + super.initState(); + chestCircumferenceController.text = widget.profileDetailsModel.chestCircumference.toString(); + waistCircumferenceController.text = widget.profileDetailsModel.waistCircumference.toString(); + hipCircumferenceController.text = widget.profileDetailsModel.hipCircumference.toString(); + heightController.text = widget.profileDetailsModel.height.toString(); + } @override Widget build(BuildContext context) { @@ -44,7 +54,7 @@ class _PhysicalFormScreenState extends State { CustomTextFormField( inputFormatters: [digitsOnly], controller: chestCircumferenceController, - hintText: '90', + hintText: 'см', ), SizedBox(height: 16), Text(s.waist_circumference), @@ -52,7 +62,7 @@ class _PhysicalFormScreenState extends State { CustomTextFormField( inputFormatters: [digitsOnly], controller: waistCircumferenceController, - hintText: "60", + hintText: 'см', ), SizedBox(height: 16), Text(s.hip_circumference), @@ -60,7 +70,16 @@ class _PhysicalFormScreenState extends State { CustomTextFormField( inputFormatters: [digitsOnly], controller: hipCircumferenceController, - hintText: '90', + hintText: 'см', + textInputAction: TextInputAction.done, + ), + SizedBox(height: 16), + Text('Рост'), + SizedBox(height: 4), + CustomTextFormField( + inputFormatters: [digitsOnly], + controller: heightController, + hintText: 'см', textInputAction: TextInputAction.done, ), ], diff --git a/lib/features/settings/presentation/pages/pressure_screen.dart b/lib/features/settings/presentation/pages/pressure_screen.dart index 5e8a9d51..62d4ce8a 100644 --- a/lib/features/settings/presentation/pages/pressure_screen.dart +++ b/lib/features/settings/presentation/pages/pressure_screen.dart @@ -22,9 +22,20 @@ class PressureScreen extends StatefulWidget { class _PressureScreenState extends State { final digitsOnly = FilteringTextInputFormatter.digitsOnly; - final chestCircumferenceController = TextEditingController(); - final waistCircumferenceController = TextEditingController(); - final hipCircumferenceController = TextEditingController(); + final bloodPressureUpController = TextEditingController(); + final bloodPressureDownController = TextEditingController(); + late SelectionPopupModel hypo; + late SelectionPopupModel hyper; + + @override + void initState() { + super.initState(); + bloodPressureUpController.text = widget.profileDetailsModel.bloodPressureUp.toString(); + bloodPressureDownController.text = widget.profileDetailsModel.bloodPressureDown.toString(); + hypo = widget.profileDetailsModel.hasHypo ? selectionPopupList[0] : selectionPopupList[1]; + hyper = widget.profileDetailsModel.hasHyper ? selectionPopupList[0] : selectionPopupList[1]; + } + final List selectionPopupList = [ SelectionPopupModel( id: 1, @@ -54,6 +65,7 @@ class _PressureScreenState extends State { Text(s.up_pressure), SizedBox(height: 4), CustomTextFormField( + controller: bloodPressureUpController, inputFormatters: [digitsOnly], hintText: "90", onChanged: (newValue) {}, @@ -62,6 +74,7 @@ class _PressureScreenState extends State { Text(s.down_pressure), SizedBox(height: 4), CustomTextFormField( + controller: bloodPressureDownController, inputFormatters: [digitsOnly], hintText: '90', onChanged: (newValue) {}, @@ -71,10 +84,12 @@ class _PressureScreenState extends State { SizedBox(height: 4), CustomDropDown( items: selectionPopupList, - value: selectionPopupList[0], + value: hypo, hintText: "Не выбрано", onChanged: (newPopup) { - setState(() {}); + setState(() { + hypo = newPopup; + }); }, ), SizedBox(height: 16), @@ -82,10 +97,12 @@ class _PressureScreenState extends State { SizedBox(height: 4), CustomDropDown( items: selectionPopupList, - value: selectionPopupList[0], + value: hyper, hintText: "Не выбрано", onChanged: (newPopup) { - setState(() {}); + setState(() { + hyper = newPopup; + }); }, ), ], diff --git a/lib/features/settings/presentation/pages/settings_screen.dart b/lib/features/settings/presentation/pages/settings_screen.dart index 76456714..1072c270 100644 --- a/lib/features/settings/presentation/pages/settings_screen.dart +++ b/lib/features/settings/presentation/pages/settings_screen.dart @@ -7,6 +7,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; import 'package:url_launcher/url_launcher.dart'; class SettingsScreen extends StatefulWidget { @@ -17,63 +18,70 @@ class SettingsScreen extends StatefulWidget { } class _SettingsScreenState extends State { - final SettingsCubit settingsCubit = sl()..init(); late bool updatesNotificationsSwitchState; late bool fillDiaryNotificationsSwitchState; @override Widget build(BuildContext context) { - return BlocConsumer( - bloc: settingsCubit, - listener: (BuildContext context, SettingsState state) { - if (state is SettingsStateLoaded) { - updatesNotificationsSwitchState = state.profileSettings.newUpdatesNotifications == 1 ? true : false; - fillDiaryNotificationsSwitchState = state.profileSettings.diaryReminderNotifications == 1 ? true : false; - } - }, - builder: (BuildContext context, SettingsState state) { - if (state is SettingsStateLoaded) { + return BlocProvider( + create: (BuildContext context) => sl()..init(), + child: BlocConsumer( + listener: (BuildContext context, SettingsState state) { + if (state is SettingsStateLoaded) { + updatesNotificationsSwitchState = state.profileSettings.newUpdatesNotifications == 1 ? true : false; + fillDiaryNotificationsSwitchState = state.profileSettings.diaryReminderNotifications == 1 ? true : false; + } + }, + builder: (BuildContext context, SettingsState state) { + if (state is SettingsStateLoaded) { + return Scaffold( + appBar: AppBar( + title: Text('Настройки'), + ), + body: SingleChildScrollView( + padding: EdgeInsets.symmetric(vertical: 16), + physics: const BouncingScrollPhysics(), + child: Column( + children: [ + _additionalInfo(state), + const SizedBox(height: 12), + _notifications(state), + const SizedBox(height: 12), + _aboutEatvio(state), + const SizedBox(height: 12), + _becomeConsultantButton(state), + const SizedBox(height: 8), + _deleteAccountButton(state), + ], + ), + ), + ); + } + if (state is SettingsStateError) { + return Scaffold( + body: Padding( + padding: const EdgeInsets.all(16), + child: Center(child: Text(state.errorMessage)), + ), + ); + } return Scaffold( - appBar: AppBar( - title: Text('Настройки'), - ), - body: SingleChildScrollView( - padding: EdgeInsets.symmetric(vertical: 16), - physics: const BouncingScrollPhysics(), - child: Column( - children: [ - _additionalInfo(), - const SizedBox(height: 12), - _notifications(), - const SizedBox(height: 12), - _aboutEatvio(), - const SizedBox(height: 12), - _becomeConsultantButton(), - const SizedBox(height: 8), - _deleteAccountButton(), - ], + body: Center( + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), ), ), ); - } - if (state is SettingsStateError) { - return Scaffold( - body: Padding( - padding: const EdgeInsets.all(16), - child: Center(child: Text(state.errorMessage)), - ), - ); - } - return Scaffold( - body: Center( - child: CircularProgressIndicator(), - ), - ); - }, + }, + ), ); } - _additionalInfo() { + _additionalInfo(SettingsStateLoaded state) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -92,7 +100,10 @@ class _SettingsScreenState extends State { _tile( onTap: () => GoRouter.of(context).pushNamed( 'generalInfoScreen', - extra: (settingsCubit.state as SettingsStateLoaded).profileDetails, + extra: state.profileDetails, + pathParameters: { + 'isPublicProfile': state.profileSettings.isPublicProfile.toString(), + }, ), title: 'Общая информация', ), @@ -100,7 +111,7 @@ class _SettingsScreenState extends State { _tile( onTap: () => GoRouter.of(context).pushNamed( 'physicalFormScreen', - extra: (settingsCubit.state as SettingsStateLoaded).profileDetails, + extra: state.profileDetails, ), title: 'Физическая форма', ), @@ -108,7 +119,7 @@ class _SettingsScreenState extends State { _tile( onTap: () => GoRouter.of(context).pushNamed( 'pressureScreen', - extra: (settingsCubit.state as SettingsStateLoaded).profileDetails, + extra: state.profileDetails, ), title: 'Давление', ), @@ -116,7 +127,7 @@ class _SettingsScreenState extends State { _tile( onTap: () => GoRouter.of(context).pushNamed( 'otherInfoScreen', - extra: (settingsCubit.state as SettingsStateLoaded).profileDetails, + extra: state.profileDetails, ), title: 'Прочая информация', ), @@ -124,7 +135,7 @@ class _SettingsScreenState extends State { _tile( onTap: () => GoRouter.of(context).pushNamed( 'physicalActivityScreen', - extra: (settingsCubit.state as SettingsStateLoaded).profileDetails, + extra: state.profileDetails, ), title: 'Физическая нагрузка', ), @@ -132,7 +143,7 @@ class _SettingsScreenState extends State { ); } - _notifications() { + _notifications(SettingsStateLoaded state) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -152,8 +163,8 @@ class _SettingsScreenState extends State { setState(() { updatesNotificationsSwitchState = !updatesNotificationsSwitchState; }); - settingsCubit.updateProfileSettings( - profileSettingsModel: (settingsCubit.state as SettingsStateLoaded).profileSettings.copyWith( + context.read().updateProfileSettings( + profileSettingsModel: state.profileSettings.copyWith( newUpdatesNotifications: updatesNotificationsSwitchState, ), ); @@ -166,8 +177,8 @@ class _SettingsScreenState extends State { setState(() { updatesNotificationsSwitchState = newValue; }); - settingsCubit.updateProfileSettings( - profileSettingsModel: (settingsCubit.state as SettingsStateLoaded).profileSettings.copyWith( + context.read().updateProfileSettings( + profileSettingsModel: state.profileSettings.copyWith( newUpdatesNotifications: updatesNotificationsSwitchState, ), ); @@ -180,8 +191,8 @@ class _SettingsScreenState extends State { setState(() { fillDiaryNotificationsSwitchState = !fillDiaryNotificationsSwitchState; }); - settingsCubit.updateProfileSettings( - profileSettingsModel: (settingsCubit.state as SettingsStateLoaded).profileSettings.copyWith( + context.read().updateProfileSettings( + profileSettingsModel: state.profileSettings.copyWith( diaryReminderNotifications: fillDiaryNotificationsSwitchState, ), ); @@ -194,8 +205,8 @@ class _SettingsScreenState extends State { setState(() { fillDiaryNotificationsSwitchState = newValue; }); - settingsCubit.updateProfileSettings( - profileSettingsModel: (settingsCubit.state as SettingsStateLoaded).profileSettings.copyWith( + context.read().updateProfileSettings( + profileSettingsModel: state.profileSettings.copyWith( diaryReminderNotifications: fillDiaryNotificationsSwitchState, ), ); @@ -206,7 +217,7 @@ class _SettingsScreenState extends State { ); } - _aboutEatvio() { + _aboutEatvio(SettingsStateLoaded state) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -234,7 +245,7 @@ class _SettingsScreenState extends State { ); } - _becomeConsultantButton() { + _becomeConsultantButton(SettingsStateLoaded state) { return Padding( padding: EdgeInsets.symmetric(horizontal: 16), child: InkWell( @@ -263,7 +274,7 @@ class _SettingsScreenState extends State { ); } - _deleteAccountButton() { + _deleteAccountButton(SettingsStateLoaded state) { return Padding( padding: EdgeInsets.symmetric(horizontal: 16), child: InkWell( diff --git a/lib/features/settings/repositories/service_repository.dart b/lib/features/settings/repositories/service_repository.dart index fe7d6492..eb462de3 100644 --- a/lib/features/settings/repositories/service_repository.dart +++ b/lib/features/settings/repositories/service_repository.dart @@ -31,7 +31,9 @@ class SettingsRepository { required ProfileDetailsModel profileDetailsModel, }) async { try { - return await settingsService.updateProfileDetails(profileDetailsModel: profileDetailsModel); + return await settingsService.updateProfileDetails( + data: profileDetailsModel.toJson(), + ); } catch (e) { rethrow; } diff --git a/lib/features/settings/services/settings_service.dart b/lib/features/settings/services/settings_service.dart index 8af3badc..71d5de73 100644 --- a/lib/features/settings/services/settings_service.dart +++ b/lib/features/settings/services/settings_service.dart @@ -19,6 +19,6 @@ abstract class SettingsService { @POST('/api/profile/update') Future updateProfileDetails({ - @MultiPart() required ProfileDetailsModel profileDetailsModel, + @Body() required Map data, }); } diff --git a/lib/features/settings/services/settings_service.g.dart b/lib/features/settings/services/settings_service.g.dart index 8fc04b6a..f1d38de5 100644 --- a/lib/features/settings/services/settings_service.g.dart +++ b/lib/features/settings/services/settings_service.g.dart @@ -91,11 +91,12 @@ class _SettingsService implements SettingsService { @override Future updateProfileDetails( - {required ProfileDetailsModel profileDetailsModel}) async { + {required Map data}) async { final _extra = {}; final queryParameters = {}; final _headers = {}; - const Map? _data = null; + final _data = {}; + _data.addAll(data); final _options = _setStreamType(Options( method: 'POST', headers: _headers, diff --git a/lib/old/diets/diet_edit_screen/diet_edit_screen.dart b/lib/old/diets/diet_edit_screen/diet_edit_screen.dart index 14888fcd..57b857b0 100644 --- a/lib/old/diets/diet_edit_screen/diet_edit_screen.dart +++ b/lib/old/diets/diet_edit_screen/diet_edit_screen.dart @@ -3,6 +3,7 @@ import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/theme/app_decoration.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:rive/rive.dart'; import 'bloc/diet_edit_bloc.dart'; import 'models/diet_edit_model.dart'; @@ -78,7 +79,13 @@ class DietEditScreen extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, diff --git a/lib/old/diets/diet_select_screen/diet_select_screen.dart b/lib/old/diets/diet_select_screen/diet_select_screen.dart index 9f49dd52..b4e517c2 100644 --- a/lib/old/diets/diet_select_screen/diet_select_screen.dart +++ b/lib/old/diets/diet_select_screen/diet_select_screen.dart @@ -8,6 +8,7 @@ import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; import 'bloc/diet_select_bloc.dart'; import 'models/diet_select_model.dart'; @@ -27,7 +28,13 @@ class DietSelectScreen extends StatelessWidget { // Это начальное состояние, данные ещё не загружены. return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } else if (state is DietSelectLoadedState) { @@ -37,7 +44,13 @@ class DietSelectScreen extends StatelessWidget { // Другие состояния, если они есть. return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } @@ -142,7 +155,13 @@ class DietSelectScreen extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, diff --git a/lib/old/diets/diet_show_screen/diet_show_screen.dart b/lib/old/diets/diet_show_screen/diet_show_screen.dart index d7132890..4339ccbc 100644 --- a/lib/old/diets/diet_show_screen/diet_show_screen.dart +++ b/lib/old/diets/diet_show_screen/diet_show_screen.dart @@ -5,6 +5,7 @@ import 'package:eatvio_app/theme/custom_text_style.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; import 'bloc/diet_show_bloc.dart'; import 'models/diet_show_model.dart'; @@ -80,7 +81,13 @@ class DietScreen extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, diff --git a/lib/old/feed/blog_post_edit_screen/blog_post_edit_screen.dart b/lib/old/feed/blog_post_edit_screen/blog_post_edit_screen.dart index 694df40c..7669284a 100644 --- a/lib/old/feed/blog_post_edit_screen/blog_post_edit_screen.dart +++ b/lib/old/feed/blog_post_edit_screen/blog_post_edit_screen.dart @@ -3,6 +3,7 @@ import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/theme/app_decoration.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:rive/rive.dart'; import 'bloc/blog_post_edit_bloc.dart'; import 'models/blog_post_edit_model.dart'; @@ -24,7 +25,13 @@ class BlogPostEditScreen extends StatelessWidget { if (state is BlogPostEditInitialState) { return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } else if (state is BlogPostEditLoadedState) { @@ -36,7 +43,13 @@ class BlogPostEditScreen extends StatelessWidget { } else { return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } @@ -81,7 +94,13 @@ class BlogPostEditScreen extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, diff --git a/lib/old/feed/blog_post_screen/widgets/comment_widget.dart b/lib/old/feed/blog_post_screen/widgets/comment_widget.dart index 78db0293..da9f5dfb 100644 --- a/lib/old/feed/blog_post_screen/widgets/comment_widget.dart +++ b/lib/old/feed/blog_post_screen/widgets/comment_widget.dart @@ -8,6 +8,7 @@ import 'package:eatvio_app/theme/custom_text_style.dart'; import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:eatvio_app/widgets/custom_image_view.dart'; import 'package:flutter/material.dart'; +import 'package:rive/rive.dart'; class CommentWidget extends StatelessWidget { CommentWidget(this.commentModelObj, {Key? key}) @@ -48,7 +49,13 @@ class CommentWidget extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, diff --git a/lib/old/glossary/glossary_screen/glossary_screen.dart b/lib/old/glossary/glossary_screen/glossary_screen.dart index 25122ff5..aa07d867 100644 --- a/lib/old/glossary/glossary_screen/glossary_screen.dart +++ b/lib/old/glossary/glossary_screen/glossary_screen.dart @@ -9,6 +9,7 @@ import 'package:eatvio_app/widgets/custom_drop_down.dart'; import 'package:eatvio_app/widgets/custom_outlined_button.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:rive/rive.dart'; import 'bloc/glossary_screen_bloc.dart'; import 'models/glossary_screen_model.dart'; @@ -30,7 +31,13 @@ class GlossaryScreen extends StatelessWidget { // Это начальное состояние, данные ещё не загружены. return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } else if (state is GlossaryLoadedState) { @@ -43,7 +50,13 @@ class GlossaryScreen extends StatelessWidget { // Другие состояния, если они есть. return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } @@ -250,7 +263,13 @@ class GlossaryScreen extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, diff --git a/lib/old/plans/plan_edit_screen/plan_edit_screen.dart b/lib/old/plans/plan_edit_screen/plan_edit_screen.dart index 40e2fd0c..31fbd435 100644 --- a/lib/old/plans/plan_edit_screen/plan_edit_screen.dart +++ b/lib/old/plans/plan_edit_screen/plan_edit_screen.dart @@ -3,6 +3,7 @@ import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/theme/app_decoration.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:rive/rive.dart'; import 'bloc/plan_edit_bloc.dart'; import 'models/plan_edit_model.dart'; @@ -78,7 +79,13 @@ class PlanEditScreen extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, diff --git a/lib/old/plans/plan_select_screen/plan_select_screen.dart b/lib/old/plans/plan_select_screen/plan_select_screen.dart index 1e7decc6..991ffe24 100644 --- a/lib/old/plans/plan_select_screen/plan_select_screen.dart +++ b/lib/old/plans/plan_select_screen/plan_select_screen.dart @@ -8,6 +8,7 @@ import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; import 'bloc/plan_select_bloc.dart'; import 'models/plan_select_model.dart'; @@ -27,7 +28,13 @@ class PlanSelectScreen extends StatelessWidget { // Это начальное состояние, данные ещё не загружены. return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } else if (state is PlanSelectLoadedState) { @@ -37,7 +44,13 @@ class PlanSelectScreen extends StatelessWidget { // Другие состояния, если они есть. return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } @@ -142,7 +155,13 @@ class PlanSelectScreen extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, diff --git a/lib/old/plans/plan_show_screen/plan_show_screen.dart b/lib/old/plans/plan_show_screen/plan_show_screen.dart index a2c9649a..f2467d2b 100644 --- a/lib/old/plans/plan_show_screen/plan_show_screen.dart +++ b/lib/old/plans/plan_show_screen/plan_show_screen.dart @@ -5,6 +5,7 @@ import 'package:eatvio_app/theme/custom_text_style.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; import 'bloc/plan_show_bloc.dart'; import 'models/plan_show_model.dart'; @@ -80,7 +81,13 @@ class PlanScreen extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, diff --git a/lib/old/profile/my_profile_screen/my_settings_screen.dart b/lib/old/profile/my_profile_screen/my_settings_screen.dart index 4b7a7740..9f3df67e 100644 --- a/lib/old/profile/my_profile_screen/my_settings_screen.dart +++ b/lib/old/profile/my_profile_screen/my_settings_screen.dart @@ -10,6 +10,7 @@ import 'package:eatvio_app/widgets/custom_section_title.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; import 'bloc/my_profile_bloc.dart'; import 'models/my_profile_model.dart'; @@ -29,7 +30,13 @@ class MySettingsScreen extends StatelessWidget { // Это начальное состояние, данные ещё не загружены. return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } else if (state is MyProfileLoadedState) { @@ -39,7 +46,13 @@ class MySettingsScreen extends StatelessWidget { // Другие состояния, если они есть. return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } diff --git a/lib/old/recipe/recipe_edit_screen/recipe_edit_screen.dart b/lib/old/recipe/recipe_edit_screen/recipe_edit_screen.dart index 2677c64f..1318211a 100644 --- a/lib/old/recipe/recipe_edit_screen/recipe_edit_screen.dart +++ b/lib/old/recipe/recipe_edit_screen/recipe_edit_screen.dart @@ -13,6 +13,7 @@ import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; import 'bloc/recipe_edit_bloc.dart'; import 'models/recipe_edit_model.dart'; @@ -155,7 +156,13 @@ class RecipeEditScreen extends StatelessWidget { // Установите ширину равной ширине родительского элемента height: 200.0, fit: BoxFit.cover, - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => Icon(Icons.error), ) else @@ -314,7 +321,13 @@ class RecipeEditScreen extends StatelessWidget { height: 200.0, // Задайте постоянную высоту элемента fit: BoxFit.cover, - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => Icon(Icons.error), ) else diff --git a/lib/old/recipe/recipe_select_screen/recipe_select_screen.dart b/lib/old/recipe/recipe_select_screen/recipe_select_screen.dart index 10c2f8ca..2d181146 100644 --- a/lib/old/recipe/recipe_select_screen/recipe_select_screen.dart +++ b/lib/old/recipe/recipe_select_screen/recipe_select_screen.dart @@ -8,6 +8,7 @@ import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart'; import 'bloc/recipe_select_bloc.dart'; import 'models/recipe_select_model.dart'; @@ -26,7 +27,13 @@ class RecipeSelectScreen extends StatelessWidget { if (state is RecipeSelectInitialState) { return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } else if (state is RecipeSelectLoadedState) { @@ -35,7 +42,13 @@ class RecipeSelectScreen extends StatelessWidget { } else { return Scaffold( body: Center( - child: CircularProgressIndicator(), + child: SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), ), ); } @@ -141,7 +154,13 @@ class RecipeSelectScreen extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, diff --git a/lib/old/users/subscribers_screen/subscribers_screen.dart b/lib/old/users/subscribers_screen/subscribers_screen.dart index 55cccb9b..adef5d67 100644 --- a/lib/old/users/subscribers_screen/subscribers_screen.dart +++ b/lib/old/users/subscribers_screen/subscribers_screen.dart @@ -10,6 +10,8 @@ import 'package:eatvio_app/widgets/custom_outlined_button.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:rive/rive.dart' as rive; +import 'package:rive/rive.dart'; import 'bloc/subscribers_bloc.dart'; import 'models/subscribers_model.dart'; @@ -26,9 +28,12 @@ class SubscribersScreen extends StatelessWidget { builder: (context, state) { if (state is SubscribersInitialState) { // Это начальное состояние, данные ещё не загружены. - return CircularProgressIndicator( - color: Colors.white, - backgroundColor: Colors.white, + return SizedBox( + height: 32, + width: 32, + child: rive.RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), ); } else if (state is SubscribersLoadedState) { // Данные загружены, можно строить экран. @@ -188,7 +193,13 @@ class SubscribersScreen extends StatelessWidget { backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => CircularProgressIndicator(), + placeholder: (context, url) => SizedBox( + height: 32, + width: 32, + child: RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), + ), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, diff --git a/lib/widgets/custom_expandable_list.dart b/lib/widgets/custom_expandable_list.dart index 872a8fd5..dfda23f9 100644 --- a/lib/widgets/custom_expandable_list.dart +++ b/lib/widgets/custom_expandable_list.dart @@ -1,5 +1,5 @@ import 'dart:convert'; - +import 'package:rive/rive.dart' as rive; import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/generated/l10n.dart'; @@ -56,9 +56,12 @@ class _ExpandableListState extends State { builder: (context, state) { if (state is MyProfileInitialState) { // Это начальное состояние, данные ещё не загружены. - return CircularProgressIndicator( - color: Colors.white, - backgroundColor: Colors.white, + return SizedBox( + height: 32, + width: 32, + child: rive.RiveAnimation.asset( + 'assets/rive_animations/loading.riv', + ), ); } else if (state is MyProfileLoadedState) { // Данные загружены, можно строить форму. diff --git a/lib/widgets/custom_text_form_field.dart b/lib/widgets/custom_text_form_field.dart index 81fb07b5..4c0b0005 100644 --- a/lib/widgets/custom_text_form_field.dart +++ b/lib/widgets/custom_text_form_field.dart @@ -90,7 +90,7 @@ class CustomTextFormField extends StatelessWidget { hintText: hintText ?? "", hintStyle: TextStyle( fontSize: 16, - color: Color(0xFF323F4B), + color: Colors.grey.shade400, fontWeight: FontWeight.w500, ), prefixIcon: prefix,