From ffcf1a98f47b88104dfc0f5a35712eecc87e5826 Mon Sep 17 00:00:00 2001 From: DmitriyLabutin Date: Mon, 3 Jun 2024 12:12:54 +0300 Subject: [PATCH 1/7] debugShowCheckedModeBanner --- lib/main.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.dart b/lib/main.dart index 3a5a94bd..3ec0c335 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -37,7 +37,7 @@ class MyApp extends StatelessWidget { theme: theme, title: 'Eatvio', navigatorKey: NavigatorService.navigatorKey, - debugShowCheckedModeBanner: false, + debugShowCheckedModeBanner: true, localizationsDelegates: [ AppLocalizationDelegate(), GlobalMaterialLocalizations.delegate, From 425c6600aed32f6b5664a81330f1dee57f484cac Mon Sep 17 00:00:00 2001 From: DmitriyLabutin Date: Tue, 4 Jun 2024 12:35:12 +0300 Subject: [PATCH 2/7] go router + bottom nav bar --- ios/Runner.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- lib/app_router.dart | 41 ++ lib/main.dart | 55 +- .../auth/auth_screen/auth_screen.dart | 104 ++-- .../chat_select_screen.dart | 123 +++-- .../diary_edit_screen/diary_edit_screen.dart | 139 ++---- .../feed/feed_screen/feed_screen.dart | 18 +- .../my_profile_screen/my_profile_screen.dart | 469 +++++++----------- lib/widgets/app_bar/custom_app_bar.dart | 6 +- lib/widgets/custom_bottom_bar.dart | 175 +++++-- pubspec.yaml | 6 +- test/diary_test.dart | 10 +- 13 files changed, 576 insertions(+), 574 deletions(-) create mode 100644 lib/app_router.dart diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 29940b0f..68ec53f4 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -156,7 +156,7 @@ isa = PBXProject; attributes = { BuildIndependentTargetsInParallel = YES; - LastUpgradeCheck = 1430; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a6b826db..5e31d3d3 100644 --- a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ MyProfileScreen(), + ), + GoRoute( + path: '/feed-screen', + name: 'feedScreen', + builder: (context, state) => FeedScreen(), + ), + GoRoute( + path: '/diary-screen', + name: 'diaryScreen', + builder: (context, state) => DiaryEditScreen(), + ), + GoRoute( + path: '/chat-select-screen', + name: 'chatSelectScreen', + builder: (context, state) => ChatSelectScreen(), + ), + ], + ), + ], + ); +} diff --git a/lib/main.dart b/lib/main.dart index 3ec0c335..e3ddb1fe 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,12 @@ +import 'package:eatvio_app/app_router.dart'; +import 'package:eatvio_app/presentation/chat/chat_select_screen/bloc/chat_select_bloc.dart'; +import 'package:eatvio_app/presentation/chat/chat_select_screen/models/chat_select_model.dart'; +import 'package:eatvio_app/presentation/diary/diary_edit_screen/bloc/diary_edit_bloc.dart'; +import 'package:eatvio_app/presentation/diary/diary_edit_screen/models/diary_edit_model.dart'; +import 'package:eatvio_app/presentation/feed/feed_screen/bloc/feed_bloc.dart'; +import 'package:eatvio_app/presentation/feed/feed_screen/models/feed_model.dart'; +import 'package:eatvio_app/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart'; +import 'package:eatvio_app/presentation/profile/my_profile_screen/models/my_profile_model.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; @@ -7,6 +16,7 @@ import 'package:path_provider/path_provider.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; var globalMessengerKey = GlobalKey(); + void main() async { WidgetsFlutterBinding.ensureInitialized(); final appDocumentDir = await getApplicationDocumentsDirectory(); @@ -25,19 +35,46 @@ void main() async { class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return BlocProvider( - create: (context) => ThemeBloc( - ThemeState( - themeType: PrefUtils().getThemeData(), + return MultiBlocProvider( + providers: [ + BlocProvider( + create: (context) => ThemeBloc( + ThemeState(themeType: PrefUtils().getThemeData()), + ), ), - ), + BlocProvider( + create: (context) => MyProfileBloc( + MyProfileState( + myProfileModelObj: MyProfileModel(), + ), + )..add(MyProfileInitialEvent()), + ), + BlocProvider( + create: (context) => FeedBloc(FeedState(myProfileModelObj: FeedModel())) + ..add( + FeedInitialEvent(), + ), + ), + BlocProvider( + create: (context) => DiaryEditBloc(DiaryEditState(diaryEditModelObj: DiaryEditModel())) + ..add( + DiaryEditInitialEvent(), + ), + ), + BlocProvider( + create: (context) => ChatSelectBloc(ChatSelectState(chatSelectModelObj: ChatSelectModel())) + ..add( + ChatSelectInitialEvent(), + ), + ), + ], child: BlocBuilder( builder: (context, state) { - return MaterialApp( + return MaterialApp.router( theme: theme, title: 'Eatvio', - navigatorKey: NavigatorService.navigatorKey, - debugShowCheckedModeBanner: true, + routerConfig: AppRouter.appRouter, + debugShowCheckedModeBanner: false, localizationsDelegates: [ AppLocalizationDelegate(), GlobalMaterialLocalizations.delegate, @@ -50,8 +87,6 @@ class MyApp extends StatelessWidget { '', ), ], - initialRoute: AppRoutes.initialRoute, - routes: AppRoutes.routes, ); }, ), diff --git a/lib/presentation/auth/auth_screen/auth_screen.dart b/lib/presentation/auth/auth_screen/auth_screen.dart index e934925b..558d5657 100644 --- a/lib/presentation/auth/auth_screen/auth_screen.dart +++ b/lib/presentation/auth/auth_screen/auth_screen.dart @@ -30,44 +30,40 @@ class AuthScreen extends StatelessWidget { 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( + 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), @@ -79,31 +75,26 @@ class AuthScreen extends StatelessWidget { 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: 50.v), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: onTapAuth(state, context)); - }), - ])))); + BlocBuilder(builder: (context, state) { + return NextStepButton( + text: "authentificate".tr.toUpperCase(), + margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), + buttonStyle: CustomButtonStyles.outlinePrimaryTL15, + onPressed: onTapAuth(state, context)); + }), + ])))); } onTapAuth(AuthState state, BuildContext context) { return () async { - List errors = validateFields( - state.emailController!.text, state.passwordController!.text); + List errors = validateFields(state.emailController!.text, state.passwordController!.text); if (errors.isEmpty) { final Map credentials = { 'email': state.emailController!.text, 'password': state.passwordController!.text, }; - final response = await http.post( - Uri.parse(dotenv.env['SERVER_ROOT']! + '/login'), - headers: {'Content-Type': 'application/json'}, - body: json.encode(credentials), - encoding: utf8); + final response = await http.post(Uri.parse(dotenv.env['SERVER_ROOT']! + '/login'), + headers: {'Content-Type': 'application/json'}, body: json.encode(credentials), encoding: utf8); print(response.statusCode); if (response.statusCode == 200) { var res = await jsonDecode(response.body); @@ -179,10 +170,7 @@ class AuthScreen extends StatelessWidget { /// Section Widget _buildAppBar(BuildContext context) { - return CustomAppBar( - leadingWidth: 29.h, - centerTitle: true, - title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio)); + return CustomAppBar(leadingWidth: 29.h, centerTitle: true, title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio)); } List validateFields(String email, String password) { diff --git a/lib/presentation/chat/chat_select_screen/chat_select_screen.dart b/lib/presentation/chat/chat_select_screen/chat_select_screen.dart index dea9d3bc..92bbfe81 100644 --- a/lib/presentation/chat/chat_select_screen/chat_select_screen.dart +++ b/lib/presentation/chat/chat_select_screen/chat_select_screen.dart @@ -9,82 +9,81 @@ import 'package:eatvio_app/presentation/chat/chat_select_screen/widgets/chat_ent class ChatSelectScreen extends StatelessWidget { const ChatSelectScreen({Key? key}) : super(key: key); + static Widget builder(BuildContext context) { return BlocProvider( - create: (context) => ChatSelectBloc( - ChatSelectState(chatSelectModelObj: ChatSelectModel())) - ..add(ChatSelectInitialEvent()), - child: ChatSelectScreen()); + create: (context) => ChatSelectBloc(ChatSelectState(chatSelectModelObj: ChatSelectModel()))..add(ChatSelectInitialEvent()), child: ChatSelectScreen()); } Widget build(BuildContext context) { return BlocBuilder( - builder: (context, state) { - if (state is ChatSelectInitialState) { - // Это начальное состояние, данные ещё не загружены. - return Container( - color: Colors.white, - ); - } else if (state is ChatSelectLoadedState) { - // Данные загружены, можно строить экран. - return _buildScreen(context, state); - } else if (state is ChatSelectErrorState) { - // Произошла ошибка при загрузке данных. - return Center(child: Text(state.errorMessage)); - } else { - // Другие состояния, если они есть. - return Container(); // Пустой контейнер для необработанных состояний. - } - }, + builder: (context, state) { + if (state is ChatSelectInitialState) { + // Это начальное состояние, данные ещё не загружены. + return Container( + color: Colors.white, + ); + } else if (state is ChatSelectLoadedState) { + // Данные загружены, можно строить экран. + return _buildScreen(context, state); + } else if (state is ChatSelectErrorState) { + // Произошла ошибка при загрузке данных. + return Center(child: Text(state.errorMessage)); + } else { + // Другие состояния, если они есть. + return Container(); // Пустой контейнер для необработанных состояний. + } + }, ); } _buildScreen(BuildContext context, ChatSelectLoadedState state) { mediaQueryData = MediaQuery.of(context); return SafeArea( - child: Scaffold( - resizeToAvoidBottomInset: false, - body: Container( - width: double.maxFinite, - decoration: AppDecoration.fillGray, - child: ListView( - children: [ - SizedBox(height: 30.v), - Container( - margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, + child: Scaffold( + resizeToAvoidBottomInset: false, + body: Container( + width: double.maxFinite, + decoration: AppDecoration.fillGray, + child: ListView( + children: [ + SizedBox(height: 30.v), + Container( + margin: EdgeInsets.only( + left: 16.h, + right: 20.h, + bottom: 10.h, + ), + padding: EdgeInsets.all(12.h), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), ), - padding: EdgeInsets.all(12.h), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], + ], + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + CustomSearchView( + controller: state.searchController, + hintText: "Поиск", ), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - CustomSearchView( - controller: state.searchController, - hintText: "Поиск", - ), - SizedBox(height: 20.v), - _buildChatList(context, state), - ], - ), - ) - ], - ), - ), - bottomNavigationBar: _buildBottomBar(context))); + SizedBox(height: 20.v), + _buildChatList(context, state), + ], + ), + ) + ], + ), + ), + ), + ); } } diff --git a/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart b/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart index 1e81c626..2aa53ddf 100644 --- a/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart +++ b/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart @@ -18,17 +18,11 @@ import 'package:carousel_slider/carousel_slider.dart'; // ignore: must_be_immutable class DiaryEditScreen extends StatelessWidget { - final void Function() onInitialize; - DiaryEditScreen({Key? key, required this.onInitialize}) : super(key: key); + DiaryEditScreen({Key? key}) : super(key: key); static Widget builder(BuildContext context) { return BlocProvider( - create: (context) => - DiaryEditBloc(DiaryEditState(diaryEditModelObj: DiaryEditModel())) - ..add(DiaryEditInitialEvent()), - child: DiaryEditScreen( - onInitialize: () {}, - )); + create: (context) => DiaryEditBloc(DiaryEditState(diaryEditModelObj: DiaryEditModel()))..add(DiaryEditInitialEvent()), child: DiaryEditScreen()); } Widget build(BuildContext context) { @@ -53,8 +47,7 @@ class DiaryEditScreen extends StatelessWidget { ); } - Widget _buildDiaryEditScreen( - BuildContext context, DiaryEditLoadedState state) { + Widget _buildDiaryEditScreen(BuildContext context, DiaryEditLoadedState state) { mediaQueryData = MediaQuery.of(context); return RefreshIndicator( onRefresh: refreshPage(context), @@ -94,7 +87,6 @@ class DiaryEditScreen extends StatelessWidget { ], ), ), - bottomNavigationBar: _buildBottomBar(context), ), ), ), @@ -156,8 +148,7 @@ class DiaryEditScreen extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - CustomImageView( - imagePath: ImageConstant.imgArrowLeft, onTap: onTapBack()), + CustomImageView(imagePath: ImageConstant.imgArrowLeft, onTap: onTapBack()), Padding( padding: EdgeInsets.only(top: 1.v), child: Column( @@ -260,9 +251,7 @@ class DiaryEditScreen extends StatelessWidget { borderRadius: BorderRadiusStyle.roundedBorder5, ), child: Center( - child: CircularProgressIndicator( - color: appTheme - .blueGray300), // Замените на свой прелоадер при необходимости + child: CircularProgressIndicator(color: appTheme.blueGray300), // Замените на свой прелоадер при необходимости ), ), ], @@ -286,8 +275,7 @@ class DiaryEditScreen extends StatelessWidget { _buildMeal(BuildContext context, DiaryEditLoadedState state) { final digitsOnly = FilteringTextInputFormatter.digitsOnly; - List _options = - state.autocompleteList!.map((dynamic item) => item as String).toList(); + List _options = state.autocompleteList!.map((dynamic item) => item as String).toList(); //print(_options); FocusNode focusNodeName = FocusNode(); return Container( @@ -332,9 +320,7 @@ class DiaryEditScreen extends StatelessWidget { onTap: () => _selectMealTime(context, state), child: AbsorbPointer( child: CustomTextFormField( - hintText: state.mealTimeController - ?.format(context) - .toString(), + hintText: state.mealTimeController?.format(context).toString(), autofocus: false, ), ), @@ -348,8 +334,7 @@ class DiaryEditScreen extends StatelessWidget { SizedBox(height: 20.v), Padding( padding: EdgeInsets.symmetric(horizontal: 10.h), - child: BlocSelector( + child: BlocSelector( selector: (state) => state.diaryEditModelObj, builder: (context, diaryEditModelObj) { return CustomDropDown( @@ -441,8 +426,7 @@ class DiaryEditScreen extends StatelessWidget { ), Padding( padding: EdgeInsets.only(left: 30.h), - child: BlocSelector( + child: BlocSelector( selector: (state) => state.diaryEditModelObj, builder: (context, diaryEditModelObj) { return CustomDropDown( @@ -460,9 +444,7 @@ class DiaryEditScreen extends StatelessWidget { SizedBox(height: 30.v), _buildAddProduct(context, state), SizedBox(height: 30.v), - ...state.portions! - .map((portion) => _buildProduct(context, portion)) - .toList(), + ...state.portions!.map((portion) => _buildProduct(context, portion)).toList(), SizedBox(height: 30.v), /*...state.photos != null ? state.photos!.isEmpty @@ -575,14 +557,8 @@ class DiaryEditScreen extends StatelessWidget { child: Text('Отмена'), ), TextButton( - onPressed: triggerModeration( - context, - state.productNameController!.text, - state.caloriesController!.text, - state.proteinsController!.text, - state.fatsController!.text, - state.carbsController!.text, - dialogContext), + onPressed: triggerModeration(context, state.productNameController!.text, state.caloriesController!.text, state.proteinsController!.text, + state.fatsController!.text, state.carbsController!.text, dialogContext), child: Text('Отправить'), ), ], @@ -591,30 +567,19 @@ class DiaryEditScreen extends StatelessWidget { ); } - triggerModeration( - BuildContext context, - String name, - String energyOn100gr, - String proteinsOn100gr, - String fatsOn100gr, - String carbohydratesOn100gr, + triggerModeration(BuildContext context, String name, String energyOn100gr, String proteinsOn100gr, String fatsOn100gr, String carbohydratesOn100gr, BuildContext dialogContext) { return () { // Call function to send moderation with the entered values context.read().add(SendModeration( - name: name, - energyOn100gr: energyOn100gr, - proteinsOn100gr: proteinsOn100gr, - fatsOn100gr: fatsOn100gr, - carbohydratesOn100gr: carbohydratesOn100gr)); + name: name, energyOn100gr: energyOn100gr, proteinsOn100gr: proteinsOn100gr, fatsOn100gr: fatsOn100gr, carbohydratesOn100gr: carbohydratesOn100gr)); Navigator.of(dialogContext).pop(); // Dismiss the dialog }; } popDialog(BuildContext dialogContext) { return () { - Navigator.of(dialogContext) - .pop(); // Dismiss the dialog on Cancel button press + Navigator.of(dialogContext).pop(); // Dismiss the dialog on Cancel button press }; } @@ -624,8 +589,7 @@ class DiaryEditScreen extends StatelessWidget { }; } - selectProduct(AutocompleteOnSelected onSelected, String option, - DiaryEditLoadedState state) { + selectProduct(AutocompleteOnSelected onSelected, String option, DiaryEditLoadedState state) { state.productNameController?.text = option; return () { onSelected(option); @@ -653,9 +617,7 @@ class DiaryEditScreen extends StatelessWidget { changeMeal(BuildContext context, DiaryEditLoadedState state) { return (value) { - context - .read() - .add(ChangeMeal(meals: state.meals, value: value)); + context.read().add(ChangeMeal(meals: state.meals, value: value)); }; } @@ -672,8 +634,7 @@ class DiaryEditScreen extends StatelessWidget { return CarouselSlider( options: CarouselOptions(height: 340.0), items: state.photos!.map((photo) { - return _buildPhoto( - context, photo); // Assuming photos are stored as strings + return _buildPhoto(context, photo); // Assuming photos are stored as strings }).toList(), ); } @@ -699,9 +660,7 @@ class DiaryEditScreen extends StatelessWidget { top: 5.v, ), child: Text( - portion['product_name'].length > 8 - ? portion['product_name'].substring(0, 8) - : portion['product_name'], + portion['product_name'].length > 8 ? portion['product_name'].substring(0, 8) : portion['product_name'], style: CustomTextStyles.titleMedium16, )), Padding( @@ -711,9 +670,7 @@ class DiaryEditScreen extends StatelessWidget { bottom: 3.v, ), child: Text( - portion['quantity'].toString() + - ' ' + - portion['portion'].toString().tr, + portion['quantity'].toString() + ' ' + portion['portion'].toString().tr, ), ), Spacer(), @@ -773,15 +730,12 @@ class DiaryEditScreen extends StatelessWidget { removePhoto(BuildContext context, Map photo) { return () { - context - .read() - .add(RemoveImageEvent(photo['id'].toString(), photo['path'])); + context.read().add(RemoveImageEvent(photo['id'].toString(), photo['path'])); }; } _buildNutritionChart(BuildContext context, DiaryEditLoadedState state) { - final List recommendedValues = state - .recommendedChartValues; // Рекомендуемые значения: калории, жиры, белки, углеводы + final List recommendedValues = state.recommendedChartValues; // Рекомендуемые значения: калории, жиры, белки, углеводы final List consumedValues = state.consumedChartValues; // return Container( margin: EdgeInsets.symmetric(horizontal: 16.h), @@ -843,37 +797,25 @@ class DiaryEditScreen extends StatelessWidget { BarChartGroupData(x: 0, barRods: [ BarChartRodData( toY: consumedValues[0] / recommendedValues[0] * 100, - color: checkConsumedValues( - [recommendedValues[0]], [consumedValues[1]]) - ? Colors.red - : Colors.blue, + color: checkConsumedValues([recommendedValues[0]], [consumedValues[1]]) ? Colors.red : Colors.blue, ) ]), BarChartGroupData(x: 1, barRods: [ BarChartRodData( toY: consumedValues[1] / recommendedValues[1] * 100, - color: checkConsumedValues( - [recommendedValues[1]], [consumedValues[1]]) - ? Colors.red - : Colors.blue, + color: checkConsumedValues([recommendedValues[1]], [consumedValues[1]]) ? Colors.red : Colors.blue, ) ]), BarChartGroupData(x: 2, barRods: [ BarChartRodData( toY: consumedValues[2] / recommendedValues[2] * 100, - color: checkConsumedValues( - [recommendedValues[2]], [consumedValues[2]]) - ? Colors.red - : Colors.blue, + color: checkConsumedValues([recommendedValues[2]], [consumedValues[2]]) ? Colors.red : Colors.blue, ) ]), BarChartGroupData(x: 3, barRods: [ BarChartRodData( toY: consumedValues[3] / recommendedValues[3] * 100, - color: checkConsumedValues( - [recommendedValues[3]], [consumedValues[3]]) - ? Colors.red - : Colors.blue, + color: checkConsumedValues([recommendedValues[3]], [consumedValues[3]]) ? Colors.red : Colors.blue, ) ]), ], @@ -1063,9 +1005,7 @@ class DiaryEditScreen extends StatelessWidget { r"Подъем \ отход ко сну", style: CustomTextStyles.bodyMediumBlack900, ), - Icon(state.wakeupExpanded - ? Icons.arrow_drop_up - : Icons.arrow_drop_down), + Icon(state.wakeupExpanded ? Icons.arrow_drop_up : Icons.arrow_drop_down), ], ), ), @@ -1079,8 +1019,7 @@ class DiaryEditScreen extends StatelessWidget { onTap: () => _selectWakeupTime(context, state), child: AbsorbPointer( child: CustomTextFormField( - hintText: - state.wakeupController?.format(context).toString(), + hintText: state.wakeupController?.format(context).toString(), prefix: Icon(Icons.sunny), autofocus: false, ), @@ -1091,8 +1030,7 @@ class DiaryEditScreen extends StatelessWidget { onTap: () => _selectRetireTime(context, state), child: AbsorbPointer( child: CustomTextFormField( - hintText: - state.retireController?.format(context).toString(), + hintText: state.retireController?.format(context).toString(), prefix: Icon(Icons.bed), autofocus: false, ), @@ -1139,8 +1077,7 @@ class DiaryEditScreen extends StatelessWidget { }; } - Function() sendFinishDayData( - BuildContext dialogContext, BuildContext context) { + Function() sendFinishDayData(BuildContext dialogContext, BuildContext context) { return () { closeDialog(dialogContext); context.read().add(FinishDay()); @@ -1182,9 +1119,7 @@ class DiaryEditScreen extends StatelessWidget { "Ваше настроение после приема пищи", style: CustomTextStyles.bodyMediumBlack900, ), - Icon(state.moodExpanded - ? Icons.arrow_drop_up - : Icons.arrow_drop_down), + Icon(state.moodExpanded ? Icons.arrow_drop_up : Icons.arrow_drop_down), ], ), ), @@ -1242,8 +1177,7 @@ class DiaryEditScreen extends StatelessWidget { }; } - Future _selectWakeupTime( - BuildContext context, DiaryEditLoadedState state) async { + Future _selectWakeupTime(BuildContext context, DiaryEditLoadedState state) async { final TimeOfDay? pickedTime = await showTimePicker( context: context, initialTime: state.wakeupController ?? TimeOfDay.now(), @@ -1254,8 +1188,7 @@ class DiaryEditScreen extends StatelessWidget { } } - Future _selectRetireTime( - BuildContext context, DiaryEditLoadedState state) async { + Future _selectRetireTime(BuildContext context, DiaryEditLoadedState state) async { final TimeOfDay? pickedTime = await showTimePicker( context: context, initialTime: state.retireController ?? TimeOfDay.now(), @@ -1266,8 +1199,7 @@ class DiaryEditScreen extends StatelessWidget { } } - Future _selectMealTime( - BuildContext context, DiaryEditLoadedState state) async { + Future _selectMealTime(BuildContext context, DiaryEditLoadedState state) async { final TimeOfDay? pickedTime = await showTimePicker( context: context, initialTime: state.mealTimeController ?? TimeOfDay.now(), @@ -1279,8 +1211,7 @@ class DiaryEditScreen extends StatelessWidget { } } -bool checkConsumedValues( - List recommendedValues, List consumedValues) { +bool checkConsumedValues(List recommendedValues, List consumedValues) { for (int i = 0; i < recommendedValues.length; i++) { if (consumedValues[i] > recommendedValues[i]) { // Если хотя бы одно потребленное значение превышает рекомендованное diff --git a/lib/presentation/feed/feed_screen/feed_screen.dart b/lib/presentation/feed/feed_screen/feed_screen.dart index d5d25004..12c00655 100644 --- a/lib/presentation/feed/feed_screen/feed_screen.dart +++ b/lib/presentation/feed/feed_screen/feed_screen.dart @@ -12,10 +12,7 @@ import 'package:intl/intl.dart'; class FeedScreen extends StatelessWidget { static Widget builder(BuildContext context) { - return BlocProvider( - create: (context) => FeedBloc(FeedState(myProfileModelObj: FeedModel())) - ..add(FeedInitialEvent()), - child: FeedScreen()); + return BlocProvider(create: (context) => FeedBloc(FeedState(myProfileModelObj: FeedModel()))..add(FeedInitialEvent()), child: FeedScreen()); } Widget build(BuildContext context) { @@ -64,7 +61,6 @@ class FeedScreen extends StatelessWidget { ), ), ), - bottomNavigationBar: _buildBottomBar(context), ), ); } @@ -154,8 +150,7 @@ class FeedScreen extends StatelessWidget { child: Column(children: [ ListTile( leading: CachedNetworkImage( - imageUrl: dotenv.env['STORAGE_URL']! + - (post["author"]['profile_photo_path'] ?? ''), + imageUrl: dotenv.env['STORAGE_URL']! + (post["author"]['profile_photo_path'] ?? ''), imageBuilder: (context, imageProvider) => CircleAvatar( backgroundImage: imageProvider, radius: 25, @@ -172,8 +167,7 @@ class FeedScreen extends StatelessWidget { style: CustomTextStyles.titleMediumSemiBold, ), subtitle: Text( - DateFormat('dd.MM.yyyy') - .format(DateTime.parse(post?['post']['updated_at'])), + DateFormat('dd.MM.yyyy').format(DateTime.parse(post?['post']['updated_at'])), style: theme.textTheme.bodyMedium, ), onTap: () => Navigator.pushNamed( @@ -220,13 +214,11 @@ class FeedScreen extends StatelessWidget { ), SizedBox(height: 16.0), CachedNetworkImage( - imageUrl: dotenv.env['STORAGE_URL']! + - (post?['post']['image'] ?? ''), + imageUrl: dotenv.env['STORAGE_URL']! + (post?['post']['image'] ?? ''), imageBuilder: (context, imageProvider) => Stack( children: [ ClipRRect( - borderRadius: - const BorderRadius.all(Radius.circular(8.0)), + borderRadius: const BorderRadius.all(Radius.circular(8.0)), child: Image( image: imageProvider, ), 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 5d1f9bf3..d6fe53b1 100644 --- a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart @@ -1,3 +1,5 @@ +import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart'; + import 'bloc/my_profile_bloc.dart'; import 'models/my_profile_model.dart'; import 'package:eatvio_app/core/app_export.dart'; @@ -19,10 +21,13 @@ import 'dart:convert'; class MyProfileScreen extends StatelessWidget { static Widget builder(BuildContext context) { return BlocProvider( - create: (context) => - MyProfileBloc(MyProfileState(myProfileModelObj: MyProfileModel())) - ..add(MyProfileInitialEvent()), - child: MyProfileScreen()); + create: (context) => MyProfileBloc( + MyProfileState( + myProfileModelObj: MyProfileModel(), + ), + )..add(MyProfileInitialEvent()), + child: MyProfileScreen(), + ); } Widget build(BuildContext context) { @@ -50,103 +55,100 @@ class MyProfileScreen extends StatelessWidget { _buildMyProfileScreen(BuildContext context, MyProfileLoadedState state) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( - backgroundColor: Colors.grey[200], - resizeToAvoidBottomInset: true, - body: SingleChildScrollView( - child: Container( - width: double.maxFinite, - decoration: BoxDecoration(color: Colors.grey[200]), - child: Padding( - padding: EdgeInsets.all(16), - child: Column(children: [ - SizedBox(height: 30.v), - Container( - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: - const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: _buildInfo(context, state)), - SizedBox(height: 15.v), - Container( - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: - const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: _buildCarousel(context, state)), - SizedBox(height: 15.v), - if (!state.plans!.isEmpty) - Container( - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all( - Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: _buildPlans( - context, - state.plans - ?.map((plan) => plan['name']) - .toList(), - state.plans - ?.map((plan) => plan['image']) - .toList(), - state.plans - ?.map((plan) => plan['state']) - .toList(), - )), - SizedBox(height: 5.v), - ])))), - bottomNavigationBar: _buildBottomBar(context))); + return Scaffold( + appBar: CustomAppBar( + height: 0, + ), + backgroundColor: Colors.grey[200], + resizeToAvoidBottomInset: true, + body: SingleChildScrollView( + child: Container( + width: double.maxFinite, + decoration: BoxDecoration(color: Colors.grey[200]), + child: Padding( + padding: EdgeInsets.all(16), + child: Column( + children: [ + SizedBox(height: 30.v), + Container( + padding: EdgeInsets.symmetric( + horizontal: 24.h, + vertical: 12.v, + ), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), + ), + ], + ), + child: _buildInfo(context, state)), + SizedBox(height: 15.v), + Container( + padding: EdgeInsets.symmetric( + horizontal: 24.h, + vertical: 12.v, + ), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), + ), + ], + ), + child: _buildCarousel(context, state)), + SizedBox(height: 15.v), + if (!state.plans!.isEmpty) + Container( + padding: EdgeInsets.symmetric( + horizontal: 24.h, + vertical: 12.v, + ), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), + ), + ], + ), + child: _buildPlans( + context, + state.plans?.map((plan) => plan['name']).toList(), + state.plans?.map((plan) => plan['image']).toList(), + state.plans?.map((plan) => plan['state']).toList(), + )), + SizedBox(height: 5.v), + ], + ), + ), + ), + ), + ); } /// Section Widget - _buildInfo(BuildContext context, MyProfileLoadedState state) { + Widget _buildInfo(BuildContext context, MyProfileLoadedState state) { return Column( children: [ GestureDetector( onTap: () => addImage(context), child: CachedNetworkImage( - imageUrl: dotenv.env['STORAGE_URL']! + - (state.user?['profile_photo_path'] ?? ''), + imageUrl: dotenv.env['STORAGE_URL']! + (state.user?['profile_photo_path'] ?? ''), imageBuilder: (context, imageProvider) => CircleAvatar( backgroundImage: imageProvider, radius: 60, @@ -208,12 +210,7 @@ class MyProfileScreen extends StatelessWidget { 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['weight']).toList().map((i) => i.toDouble()).toList() ?? [0.0, 0.0, 0.0, 0.0], state.chartDates, ) ])); @@ -228,13 +225,7 @@ class MyProfileScreen extends StatelessWidget { SizedBox(height: 50.v), _buildChart( context, - _bodyMassIndex( - state.chartPoints?.values - .map((e) => e['weight']) - .toList() - .map((i) => i.toDouble()) - .toList() ?? - [0.0, 0.0, 0.0, 0.0], + _bodyMassIndex(state.chartPoints?.values.map((e) => e['weight']).toList().map((i) => i.toDouble()).toList() ?? [0.0, 0.0, 0.0, 0.0], state.userDetails?['height'].toInt() ?? 160), state.chartDates), ]); @@ -249,8 +240,7 @@ class MyProfileScreen extends StatelessWidget { ), ), SizedBox(height: 30.v), - _buildCircumferenceChart( - context, state.circumferences, state.chartDates), + _buildCircumferenceChart(context, state.circumferences, state.chartDates), _buildChartLegend() ])); default: @@ -294,8 +284,7 @@ class MyProfileScreen extends StatelessWidget { ); } - _buildChart( - BuildContext context, List chartPoints, List? dates) { + _buildChart(BuildContext context, List chartPoints, List? dates) { List spots = []; for (int i = 0; i < 4; i++) { spots.add( @@ -303,8 +292,7 @@ class MyProfileScreen extends StatelessWidget { ); } - Widget bottomTitleWidgets( - double value, TitleMeta meta, double chartWidth, List? dates) { + Widget bottomTitleWidgets(double value, TitleMeta meta, double chartWidth, List? dates) { if (value % 1 != 0) { return Container(); } @@ -316,8 +304,7 @@ class MyProfileScreen extends StatelessWidget { int index = value.toInt(); if (index >= 0 && index < dates!.length) { // Проверка на допустимый индекс в массиве dates - String formattedDate = - DateFormat('dd.MM').format(DateTime.parse(dates[index])); + String formattedDate = DateFormat('dd.MM').format(DateTime.parse(dates[index])); return SideTitleWidget( axisSide: meta.axisSide, space: 16, @@ -374,18 +361,15 @@ class MyProfileScreen extends StatelessWidget { dotData: const FlDotData(show: false), ), ], - minY: chartPoints.reduce( - (value, element) => value < element ? value : element), - maxY: chartPoints.reduce( - (value, element) => value > element ? value : element), + minY: chartPoints.reduce((value, element) => value < element ? value : element), + maxY: chartPoints.reduce((value, element) => value > element ? value : element), minX: 1, maxX: 4, titlesData: FlTitlesData( leftTitles: AxisTitles( sideTitles: SideTitles( showTitles: true, - getTitlesWidget: (value, meta) => - leftTitleWidgets(value, meta, constraints.maxWidth), + getTitlesWidget: (value, meta) => leftTitleWidgets(value, meta, constraints.maxWidth), reservedSize: 56, ), drawBelowEverything: true, @@ -396,8 +380,7 @@ class MyProfileScreen extends StatelessWidget { bottomTitles: AxisTitles( sideTitles: SideTitles( showTitles: true, - getTitlesWidget: (value, meta) => bottomTitleWidgets( - value, meta, constraints.maxWidth, dates), + getTitlesWidget: (value, meta) => bottomTitleWidgets(value, meta, constraints.maxWidth, dates), reservedSize: 36, interval: 1, ), @@ -457,11 +440,9 @@ class MyProfileScreen extends StatelessWidget { }; } - _buildCircumferenceChart( - BuildContext context, chartPoints, List? dates) { + _buildCircumferenceChart(BuildContext context, chartPoints, List? dates) { // Определение осей графика - final chestCircumferences = - chartPoints.values.map((e) => e['chest_circumference']).toList(); + final chestCircumferences = chartPoints.values.map((e) => e['chest_circumference']).toList(); List spotsChest = []; for (int i = 0; i < 4; i++) { chestCircumferences[i] = chestCircumferences[i] * 10 / 10; @@ -469,8 +450,7 @@ class MyProfileScreen extends StatelessWidget { FlSpot((i * 10 / 10) + 1, chestCircumferences[i] * 10 / 10), ); } - final waistCircumferences = - chartPoints.values.map((e) => e['waist_circumference']).toList(); + final waistCircumferences = chartPoints.values.map((e) => e['waist_circumference']).toList(); List spotsWaist = []; for (int i = 0; i < 4; i++) { waistCircumferences[i] = waistCircumferences[i] * 10 / 10; @@ -478,8 +458,7 @@ class MyProfileScreen extends StatelessWidget { FlSpot((i * 10 / 10) + 1, waistCircumferences[i] * 10 / 10), ); } - final hipCircumferences = - chartPoints.values.map((e) => e['hip_circumference']).toList(); + final hipCircumferences = chartPoints.values.map((e) => e['hip_circumference']).toList(); List spotsHip = []; for (int i = 0; i < 4; i++) { hipCircumferences[i] = hipCircumferences[i] * 10 / 10; @@ -488,14 +467,9 @@ class MyProfileScreen extends StatelessWidget { ); } - final allCircumferences = [ - ...chestCircumferences, - ...hipCircumferences, - ...waistCircumferences - ]; + final allCircumferences = [...chestCircumferences, ...hipCircumferences, ...waistCircumferences]; - Widget bottomTitleWidgets( - double value, TitleMeta meta, double chartWidth, List? dates) { + Widget bottomTitleWidgets(double value, TitleMeta meta, double chartWidth, List? dates) { if (value % 1 != 0) { return Container(); } @@ -507,8 +481,7 @@ class MyProfileScreen extends StatelessWidget { int index = value.toInt(); if (index >= 0 && index < dates!.length) { // Проверка на допустимый индекс в массиве dates - String formattedDate = - DateFormat('dd.MM').format(DateTime.parse(dates[index])); + String formattedDate = DateFormat('dd.MM').format(DateTime.parse(dates[index])); return SideTitleWidget( axisSide: meta.axisSide, space: 16, @@ -587,18 +560,15 @@ class MyProfileScreen extends StatelessWidget { dotData: const FlDotData(show: false), ), ], - minY: allCircumferences.reduce( - (value, element) => value < element ? value : element), - maxY: allCircumferences.reduce( - (value, element) => value > element ? value : element), + minY: allCircumferences.reduce((value, element) => value < element ? value : element), + maxY: allCircumferences.reduce((value, element) => value > element ? value : element), minX: 1, maxX: 4, titlesData: FlTitlesData( leftTitles: AxisTitles( sideTitles: SideTitles( showTitles: true, - getTitlesWidget: (value, meta) => - leftTitleWidgets(value, meta, constraints.maxWidth), + getTitlesWidget: (value, meta) => leftTitleWidgets(value, meta, constraints.maxWidth), reservedSize: 56, ), drawBelowEverything: true, @@ -609,8 +579,7 @@ class MyProfileScreen extends StatelessWidget { bottomTitles: AxisTitles( sideTitles: SideTitles( showTitles: true, - getTitlesWidget: (value, meta) => bottomTitleWidgets( - value, meta, constraints.maxWidth, dates), + getTitlesWidget: (value, meta) => bottomTitleWidgets(value, meta, constraints.maxWidth, dates), reservedSize: 36, interval: 1, ), @@ -665,125 +634,80 @@ class MyProfileScreen extends StatelessWidget { } /// Section Widget - _buildPlans(BuildContext context, List? plans, - List? imagePaths, List? states) { + _buildPlans(BuildContext context, List? plans, List? imagePaths, List? states) { return Padding( padding: EdgeInsets.only(left: 7.h), child: Column(children: [ Padding( padding: EdgeInsets.only(left: 15.h), - child: Text("plans_complete".tr, - style: CustomTextStyles.titleMediumBlack - .copyWith(color: appTheme.black900))), + child: Text("plans_complete".tr, style: CustomTextStyles.titleMediumBlack.copyWith(color: appTheme.black900))), SizedBox(height: 5.v), Container( - decoration: AppDecoration.outlineBlueGray - .copyWith(borderRadius: BorderRadiusStyle.roundedBorder5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 105.v, - width: 343.h, - child: - Stack(alignment: Alignment.bottomCenter, children: [ - Align( - alignment: Alignment.topCenter, - child: ListView.builder( - itemCount: plans?.length ?? 0, - itemBuilder: (context, i) { - String state = states?[i]; - var boxColor = appTheme.greenA700; - switch (states?[i]) { - case 'active': - boxColor = appTheme.greenA700; - break; - case 'archived': // График ИМТ - boxColor = appTheme.gray400; - break; - case 'draft': - boxColor = appTheme.deepOrange900; - break; - case 'in_progress': //График обхватов - boxColor = appTheme.lightGreen300; - break; - } - return SizedBox( - height: 40.v, - width: 343.h, - child: Stack( - alignment: Alignment.bottomRight, - children: [ - Align( - alignment: - Alignment.topCenter, - child: Container( - margin: EdgeInsets.only( - bottom: 11.v), - padding: - EdgeInsets.symmetric( - horizontal: 6.h, - vertical: 4.v), - decoration: AppDecoration - .fillGray - .copyWith( - borderRadius: - BorderRadiusStyle - .roundedBorder5), - child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - Padding( - padding: EdgeInsets - .only( - bottom: 1 - .v), - child: Text( - plans![i], - style: CustomTextStyles - .titleSmallBluegray800Bold)), - Container( - height: 19.v, - width: 100.h, - decoration: BoxDecoration( - color: - boxColor, - borderRadius: - BorderRadius.circular( - 5.h))) - ]))), - Align( - alignment: Alignment.center, - child: Container( - margin: EdgeInsets.only( - bottom: 12.h), - child: Image.network( - dotenv.env[ - 'STORAGE_URL']! + - imagePaths?[i], - height: 25.adaptSize, - width: 25.adaptSize, - ))), - Align( - alignment: - Alignment.bottomRight, - child: Container( - width: 70.h, - margin: EdgeInsets.only( - bottom: 14.h, - right: 22.h), - child: Text("$state".tr, - maxLines: 3, - overflow: TextOverflow - .ellipsis, - style: theme.textTheme - .titleSmall))) - ])); - })), - ])) - ])) + decoration: AppDecoration.outlineBlueGray.copyWith(borderRadius: BorderRadiusStyle.roundedBorder5), + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + SizedBox( + height: 105.v, + width: 343.h, + child: Stack(alignment: Alignment.bottomCenter, children: [ + Align( + alignment: Alignment.topCenter, + child: ListView.builder( + itemCount: plans?.length ?? 0, + itemBuilder: (context, i) { + String state = states?[i]; + var boxColor = appTheme.greenA700; + switch (states?[i]) { + case 'active': + boxColor = appTheme.greenA700; + break; + case 'archived': // График ИМТ + boxColor = appTheme.gray400; + break; + case 'draft': + boxColor = appTheme.deepOrange900; + break; + case 'in_progress': //График обхватов + boxColor = appTheme.lightGreen300; + break; + } + return SizedBox( + height: 40.v, + width: 343.h, + child: Stack(alignment: Alignment.bottomRight, children: [ + Align( + alignment: Alignment.topCenter, + child: Container( + margin: EdgeInsets.only(bottom: 11.v), + padding: EdgeInsets.symmetric(horizontal: 6.h, vertical: 4.v), + decoration: AppDecoration.fillGray.copyWith(borderRadius: BorderRadiusStyle.roundedBorder5), + child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Padding( + padding: EdgeInsets.only(bottom: 1.v), + child: Text(plans![i], style: CustomTextStyles.titleSmallBluegray800Bold)), + Container( + height: 19.v, + width: 100.h, + decoration: BoxDecoration(color: boxColor, borderRadius: BorderRadius.circular(5.h))) + ]))), + Align( + alignment: Alignment.center, + child: Container( + margin: EdgeInsets.only(bottom: 12.h), + child: Image.network( + dotenv.env['STORAGE_URL']! + imagePaths?[i], + height: 25.adaptSize, + width: 25.adaptSize, + ))), + Align( + alignment: Alignment.bottomRight, + child: Container( + width: 70.h, + margin: EdgeInsets.only(bottom: 14.h, right: 22.h), + child: Text("$state".tr, maxLines: 3, overflow: TextOverflow.ellipsis, style: theme.textTheme.titleSmall))) + ])); + })), + ])) + ])) ])); } @@ -811,44 +735,38 @@ class MyProfileScreen extends StatelessWidget { children: [ Padding( padding: EdgeInsets.symmetric(vertical: 5.v), - child: Text("chest_circumference".tr, - style: theme.textTheme.bodyLarge), + child: Text("chest_circumference".tr, style: theme.textTheme.bodyLarge), ), SizedBox(height: 5.v), CustomTextFormField( controller: state.chestCircumferenceController, keyboardType: TextInputType.number, inputFormatters: [ - FilteringTextInputFormatter - .digitsOnly, // Ограничение ввода только цифрами + FilteringTextInputFormatter.digitsOnly, // Ограничение ввода только цифрами ], ), Padding( padding: EdgeInsets.symmetric(vertical: 15.v), - child: Text("waist_circumference".tr, - style: theme.textTheme.bodyLarge), + child: Text("waist_circumference".tr, style: theme.textTheme.bodyLarge), ), SizedBox(height: 5.v), CustomTextFormField( controller: state.waistCircumferenceController, keyboardType: TextInputType.number, inputFormatters: [ - FilteringTextInputFormatter - .digitsOnly, // Ограничение ввода только цифрами + FilteringTextInputFormatter.digitsOnly, // Ограничение ввода только цифрами ], ), Padding( padding: EdgeInsets.symmetric(vertical: 15.v), - child: Text("hip_circumference".tr, - style: theme.textTheme.bodyLarge), + child: Text("hip_circumference".tr, style: theme.textTheme.bodyLarge), ), SizedBox(height: 5.v), CustomTextFormField( controller: state.hipCircumferenceController, keyboardType: TextInputType.number, inputFormatters: [ - FilteringTextInputFormatter - .digitsOnly, // Ограничение ввода только цифрами + FilteringTextInputFormatter.digitsOnly, // Ограничение ввода только цифрами ], ), ], @@ -867,8 +785,7 @@ class MyProfileScreen extends StatelessWidget { ), ], backgroundColor: Colors.white, - titlePadding: EdgeInsets.all( - 20.0), // Можете настроить отступы по вашему желанию + titlePadding: EdgeInsets.all(20.0), // Можете настроить отступы по вашему желанию ); }, ); @@ -904,8 +821,7 @@ class MyProfileScreen extends StatelessWidget { ); } else { // Ошибка от сервера - print( - "Ошибка при отправке данных. Код ответа: ${response.statusCode}"); + print("Ошибка при отправке данных. Код ответа: ${response.statusCode}"); } } catch (e) { // Обработка ошибок при отправке запроса @@ -997,8 +913,7 @@ class MyProfileScreen extends StatelessWidget { ); } else { // Ошибка от сервера - print( - "Ошибка при отправке данных. Код ответа: ${response.statusCode}"); + print("Ошибка при отправке данных. Код ответа: ${response.statusCode}"); } } catch (e) { // Обработка ошибок при отправке запроса diff --git a/lib/widgets/app_bar/custom_app_bar.dart b/lib/widgets/app_bar/custom_app_bar.dart index 7ffe17b3..05811706 100644 --- a/lib/widgets/app_bar/custom_app_bar.dart +++ b/lib/widgets/app_bar/custom_app_bar.dart @@ -1,5 +1,6 @@ import 'package:eatvio_app/core/app_export.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; // ignore: must_be_immutable class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { @@ -30,7 +31,10 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { @override Widget build(BuildContext context) { return AppBar( - elevation: 0, + systemOverlayStyle: SystemUiOverlayStyle( + statusBarIconBrightness: Brightness.dark, + statusBarBrightness: Brightness.light, + ), toolbarHeight: height ?? 56.v, automaticallyImplyLeading: false, backgroundColor: Colors.transparent, diff --git a/lib/widgets/custom_bottom_bar.dart b/lib/widgets/custom_bottom_bar.dart index d6e47d6d..b8e54605 100644 --- a/lib/widgets/custom_bottom_bar.dart +++ b/lib/widgets/custom_bottom_bar.dart @@ -2,6 +2,106 @@ import 'package:eatvio_app/core/app_export.dart'; import 'package:flutter/material.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_title_circleimage.dart'; import 'package:eatvio_app/widgets/custom_navigation_menu.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:go_router/go_router.dart'; + +int currentBottomNavBarIndex = 0; + +class BottomNavigationBarWidget extends StatefulWidget { + final Widget child; + + const BottomNavigationBarWidget({ + super.key, + required this.child, + }); + + @override + State createState() => _BottomNavigationBarWidgetState(); +} + +class _BottomNavigationBarWidgetState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + body: widget.child, + bottomNavigationBar: BottomNavigationBar( + type: BottomNavigationBarType.fixed, + onTap: (index) { + if (currentBottomNavBarIndex != index) { + setState(() { + currentBottomNavBarIndex = index; + }); + } + switch (currentBottomNavBarIndex) { + case 0: + GoRouter.of(context).replace('/my-profile-screen'); + break; + case 1: + GoRouter.of(context).replace('/feed-screen'); + break; + case 2: + GoRouter.of(context).replace('/diary-screen'); + break; + case 3: + GoRouter.of(context).replace('/chat-select-screen'); + break; + case 4: + break; + case 5: + final RenderBox overlay = Overlay.of(context).context.findRenderObject() as RenderBox; + final size = overlay.size; + showMenu( + context: context, + color: Colors.white, + shadowColor: Colors.white, + surfaceTintColor: Colors.white, + items: [ + PopupMenuItem( + child: CustomNavigationMenu(), + ) + ], + position: RelativeRect.fromLTRB(size.width, size.height, 0, 0), + ); + break; + } + }, + selectedFontSize: 12, + unselectedFontSize: 12, + currentIndex: currentBottomNavBarIndex, + items: [ + BottomNavigationBarItem( + label: '', + icon: SvgPicture.asset(ImageConstant.imgLogo), + ), + BottomNavigationBarItem( + label: 'Лента', + icon: SvgPicture.asset(ImageConstant.imgFeed), + ), + BottomNavigationBarItem( + label: "diary".tr, + icon: SvgPicture.asset(ImageConstant.imgDiary), + ), + BottomNavigationBarItem( + label: "chat".tr, + icon: SvgPicture.asset(ImageConstant.imgChat), + ), + BottomNavigationBarItem( + label: '', + icon: SvgPicture.asset(ImageConstant.imgBell), + ), + BottomNavigationBarItem( + label: '', + icon: Image.asset( + ImageConstant.imgEllipse1, + width: 32, + height: 32, + ), + ), + ], + ), + ); + } +} // ignore: must_be_immutable class CustomBottomBar extends StatefulWidget { @@ -18,33 +118,38 @@ class CustomBottomBarState extends State { List bottomMenuList = [ BottomMenuModel( - icon: ImageConstant.imgLogo, - activeIcon: ImageConstant.imgLogo, - type: BottomBarEnum.tf, - image: false), + icon: ImageConstant.imgLogo, + activeIcon: ImageConstant.imgLogo, + type: BottomBarEnum.tf, + image: false, + ), BottomMenuModel( - icon: ImageConstant.imgFeed, - activeIcon: ImageConstant.imgFeed, - title: "Лента", - type: BottomBarEnum.tf, - image: false), + icon: ImageConstant.imgFeed, + activeIcon: ImageConstant.imgFeed, + title: "Лента", + type: BottomBarEnum.tf, + image: false, + ), BottomMenuModel( - icon: ImageConstant.imgDiary, - activeIcon: ImageConstant.imgDiary, - title: "diary".tr, - type: BottomBarEnum.tf, - image: false), + icon: ImageConstant.imgDiary, + activeIcon: ImageConstant.imgDiary, + title: "diary".tr, + type: BottomBarEnum.tf, + image: false, + ), BottomMenuModel( - icon: ImageConstant.imgChat, - activeIcon: ImageConstant.imgChat, - title: "chat".tr, - type: BottomBarEnum.tf, - image: false), + icon: ImageConstant.imgChat, + activeIcon: ImageConstant.imgChat, + title: "chat".tr, + type: BottomBarEnum.tf, + image: false, + ), BottomMenuModel( - icon: ImageConstant.imgBell, - activeIcon: ImageConstant.imgBell, - type: BottomBarEnum.tf, - image: false), + icon: ImageConstant.imgBell, + activeIcon: ImageConstant.imgBell, + type: BottomBarEnum.tf, + image: false, + ), BottomMenuModel( icon: ImageConstant.imgEllipse1, activeIcon: ImageConstant.imgEllipse1, @@ -84,16 +189,16 @@ class CustomBottomBarState extends State { switch (index) { case 0: - Navigator.pushNamed(context, AppRoutes.myProfile); + Navigator.pushReplacementNamed(context, AppRoutes.myProfile); break; case 1: - Navigator.pushNamed(context, AppRoutes.feedScreen); + Navigator.pushReplacementNamed(context, AppRoutes.feedScreen); break; case 2: - Navigator.pushNamed(context, AppRoutes.diaryEdit); + Navigator.pushReplacementNamed(context, AppRoutes.diaryEdit); break; case 3: - Navigator.pushNamed(context, AppRoutes.chatSelectScreen); + Navigator.pushReplacementNamed(context, AppRoutes.chatSelectScreen); break; } } @@ -131,8 +236,7 @@ class CustomBottomBarState extends State { imagePath: bottomMenuList[index].icon, height: iconHeight, width: iconWidth, - color: - isSelected ? theme.colorScheme.primary : appTheme.blueGray400, + color: isSelected ? theme.colorScheme.primary : appTheme.blueGray400, ), if (bottomMenuList[index].image) GestureDetector( @@ -143,16 +247,14 @@ class CustomBottomBarState extends State { surfaceTintColor: Colors.white, position: RelativeRect.fromLTRB( // Указываем позицию справа по центру - MediaQuery.of(context).size.width - - 50, // Расположение от правого края + MediaQuery.of(context).size.width - 50, // Расположение от правого края kToolbarHeight + 340, // Расположение от верхнего края 0, // Не смещаем по горизонтали 0, // Не смещаем по вертикали ), items: [ PopupMenuItem( - child: - CustomNavigationMenu(), // Используйте ваше меню здесь + child: CustomNavigationMenu(), // Используйте ваше меню здесь ) ], ), @@ -160,16 +262,13 @@ class CustomBottomBarState extends State { imagePath: ImageConstant.imgEllipse1, ), ), - if (bottomMenuList[index].title != - null) // Проверяем, существует ли title + if (bottomMenuList[index].title != null) // Проверяем, существует ли title Padding( padding: EdgeInsets.only(top: 8.v), child: Text( bottomMenuList[index].title!, style: CustomTextStyles.bodySmallMulishBluegray80012.copyWith( - color: isSelected - ? theme.colorScheme.primary - : appTheme.blueGray800, + color: isSelected ? theme.colorScheme.primary : appTheme.blueGray800, ), ), ), diff --git a/pubspec.yaml b/pubspec.yaml index 8f1a6f45..26be6077 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,8 +1,8 @@ name: eatvio_app description: A new Flutter project. version: 0.0.0+1 -environment: - sdk: '>=2.12.0 <3.0.0' +environment: + sdk: '>=3.3.4 <4.0.0' dependencies: flutter: sdk: flutter @@ -27,6 +27,8 @@ dependencies: image_picker: ^1.0.7 flutter_typeahead: ^5.2.0 bloc_test: ^9.1.6 + # navigation + go_router: ^14.1.4 dev_dependencies: dart_code_metrics: ^5.7.6 diff --git a/test/diary_test.dart b/test/diary_test.dart index 224b05a3..c7570d39 100644 --- a/test/diary_test.dart +++ b/test/diary_test.dart @@ -16,10 +16,8 @@ void main() { ); });*/ - testWidgets('renders _buildDiaryEditScreen when in loaded state', - (WidgetTester tester) async { - final diaryEditBloc = - DiaryEditBloc(DiaryEditState(diaryEditModelObj: DiaryEditModel())); + testWidgets('renders _buildDiaryEditScreen when in loaded state', (WidgetTester tester) async { + final diaryEditBloc = DiaryEditBloc(DiaryEditState(diaryEditModelObj: DiaryEditModel())); final loadedState = DiaryEditLoadedState( diaryId: 1, selectedSatiety: 4, @@ -36,9 +34,7 @@ void main() { MaterialApp( home: BlocProvider.value( value: diaryEditBloc, - child: DiaryEditScreen( - onInitialize: () {}, - ), + child: DiaryEditScreen(), ), ), ); From ed0c3fcef1ffe3c343f2d610ba0f7d14020d4389 Mon Sep 17 00:00:00 2001 From: DmitriyLabutin Date: Tue, 4 Jun 2024 18:02:00 +0300 Subject: [PATCH 3/7] fix warnings --- .../chat/chat_select_screen/chat_select_screen.dart | 5 ----- .../diary/diary_edit_screen/diary_edit_screen.dart | 5 ----- lib/presentation/feed/feed_screen/feed_screen.dart | 5 ----- .../profile/my_profile_screen/my_profile_screen.dart | 5 ----- lib/theme/custom_button_style.dart | 4 ++-- 5 files changed, 2 insertions(+), 22 deletions(-) diff --git a/lib/presentation/chat/chat_select_screen/chat_select_screen.dart b/lib/presentation/chat/chat_select_screen/chat_select_screen.dart index 92bbfe81..e59e2155 100644 --- a/lib/presentation/chat/chat_select_screen/chat_select_screen.dart +++ b/lib/presentation/chat/chat_select_screen/chat_select_screen.dart @@ -2,7 +2,6 @@ import 'bloc/chat_select_bloc.dart'; import 'models/chat_select_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import '../chat_select_screen/chat_search_view.dart'; -import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; import 'package:flutter/material.dart'; import 'package:eatvio_app/presentation/chat/chat_select_screen/models/chat_entry.dart'; // ignore: must_be_immutable import 'package:eatvio_app/presentation/chat/chat_select_screen/widgets/chat_entry_widget.dart'; // ignore: must_be_immutable @@ -104,7 +103,3 @@ _buildChatList(BuildContext context, ChatSelectLoadedState state) { }, ); } - -_buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); -} diff --git a/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart b/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart index 2aa53ddf..3de4ff40 100644 --- a/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart +++ b/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart @@ -13,7 +13,6 @@ import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart'; import 'package:eatvio_app/widgets/custom_edit_drop_down.dart'; import 'package:eatvio_app/widgets/custom_outlined_button.dart'; import 'package:eatvio_app/widgets/custom_scale_element.dart'; -import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; import 'package:carousel_slider/carousel_slider.dart'; // ignore: must_be_immutable @@ -179,10 +178,6 @@ class DiaryEditScreen extends StatelessWidget { }; } - _buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); - } - /// Section Widget _buildAddProduct(BuildContext context, DiaryEditLoadedState state) { return CustomOutlinedButton( diff --git a/lib/presentation/feed/feed_screen/feed_screen.dart b/lib/presentation/feed/feed_screen/feed_screen.dart index 12c00655..4e8be2c2 100644 --- a/lib/presentation/feed/feed_screen/feed_screen.dart +++ b/lib/presentation/feed/feed_screen/feed_screen.dart @@ -3,7 +3,6 @@ import 'models/feed_model.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:eatvio_app/presentation/feed/feed_screen/widgets/feed_search_view.dart'; import 'package:eatvio_app/presentation/feed/feed_screen/widgets/feed_scroll_item.dart'; -import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; import 'package:eatvio_app/widgets/custom_outlined_button.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; @@ -269,10 +268,6 @@ class FeedScreen extends StatelessWidget { }; } - _buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); - } - onTapArrowLeft(BuildContext context) { NavigatorService.goBack(); } 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 d6fe53b1..3bfb6cc8 100644 --- a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart @@ -4,7 +4,6 @@ import 'bloc/my_profile_bloc.dart'; import 'models/my_profile_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart'; -import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:carousel_slider/carousel_slider.dart'; import 'package:image_picker/image_picker.dart'; @@ -186,10 +185,6 @@ class MyProfileScreen extends StatelessWidget { }; } - _buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); - } - _buildCarousel(BuildContext contex, MyProfileLoadedState state) { return CarouselSlider( options: CarouselOptions(height: 320.0), diff --git a/lib/theme/custom_button_style.dart b/lib/theme/custom_button_style.dart index bdd84d93..60204f5e 100644 --- a/lib/theme/custom_button_style.dart +++ b/lib/theme/custom_button_style.dart @@ -16,7 +16,7 @@ class CustomButtonStyles { ); // text button style static ButtonStyle get none => ButtonStyle( - backgroundColor: MaterialStateProperty.all(Colors.transparent), - elevation: MaterialStateProperty.all(0), + backgroundColor: WidgetStateProperty.all(Colors.transparent), + elevation: WidgetStateProperty.all(0), ); } From 1951edd8f832a2a2a8332fc109b0c2940df4f049 Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Wed, 5 Jun 2024 12:52:03 +0300 Subject: [PATCH 4/7] go router --- .gitea/workflows/build.yml | 2 +- .gitea/workflows/test.yml | 2 +- lib/app_router.dart | 72 ++++- .../auth/auth_screen/auth_screen.dart | 9 +- .../chat/chat_screen/chat_screen.dart | 13 - .../diary_edit_screen/diary_edit_screen.dart | 24 +- .../diet_create_screen.dart | 101 ++++--- .../diet_edit_screen/diet_edit_screen.dart | 88 +++---- .../diet_select_screen.dart | 126 +++++---- .../diet_show_screen/diet_show_screen.dart | 156 +++++------ .../blog_post_create_screen.dart | 154 +++++------ .../blog_post_edit_screen.dart | 90 ++++--- .../blog_post_screen/blog_post_screen.dart | 101 +++---- .../feed/feed_screen/feed_screen.dart | 14 +- .../glossary_screen/glossary_screen.dart | 73 ++--- .../plan_create_screen.dart | 107 ++++---- .../plan_edit_screen/plan_edit_screen.dart | 88 +++---- .../plan_select_screen.dart | 126 +++++---- .../plan_show_screen/plan_show_screen.dart | 155 +++++------ .../my_profile_screen/my_settings_screen.dart | 246 ++++++++--------- .../recipe_create_screen.dart | 55 ++-- .../recipe_edit_screen.dart | 88 +++---- .../recipe_select_screen.dart | 126 +++++---- .../recipe_show_screen.dart | 151 +++++------ .../language_select_screen.dart | 169 ++++++------ lib/routes/app_routes.dart | 4 +- lib/widgets/custom_bottom_bar.dart | 249 ++---------------- lib/widgets/custom_navigation_menu.dart | 19 +- 28 files changed, 1160 insertions(+), 1448 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index e8f9d11f..4a2d90f8 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -3,7 +3,7 @@ name: Android Release on: [push, pull_request] env: - flutter_version: "3.19.0" + flutter_version: "3.22.0" java_version: "12.x" flutter_channel: "stable" diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index b5f75243..27c7c439 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -3,7 +3,7 @@ name: Eatvio App Android Test on: [pull_request] env: - flutter_version: "3.19.0" + flutter_version: "3.22.0" java_version: "12.x" flutter_channel: "stable" diff --git a/lib/app_router.dart b/lib/app_router.dart index b5869654..255df7aa 100644 --- a/lib/app_router.dart +++ b/lib/app_router.dart @@ -1,14 +1,44 @@ +import 'package:eatvio_app/presentation/auth/auth_screen/auth_screen.dart'; import 'package:eatvio_app/presentation/chat/chat_select_screen/chat_select_screen.dart'; import 'package:eatvio_app/presentation/diary/diary_edit_screen/diary_edit_screen.dart'; +import 'package:eatvio_app/presentation/diets/diet_select_screen/diet_select_screen.dart'; +import 'package:eatvio_app/presentation/feed/blog_post_create_screen/blog_post_create_screen.dart'; +import 'package:eatvio_app/presentation/feed/blog_post_screen/blog_post_screen.dart'; import 'package:eatvio_app/presentation/feed/feed_screen/feed_screen.dart'; +import 'package:eatvio_app/presentation/glossary/glossary_screen/glossary_screen.dart'; +import 'package:eatvio_app/presentation/plans/plan_select_screen/plan_select_screen.dart'; import 'package:eatvio_app/presentation/profile/my_profile_screen/my_profile_screen.dart'; +import 'package:eatvio_app/presentation/profile/my_profile_screen/my_settings_screen.dart'; +import 'package:eatvio_app/presentation/recipe/recipe_select_screen/recipe_select_screen.dart'; +import 'package:eatvio_app/presentation/registration/language_select_screen/language_select_screen.dart'; import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; import 'package:go_router/go_router.dart'; +import 'package:hive_flutter/hive_flutter.dart'; class AppRouter { static GoRouter appRouter = GoRouter( - initialLocation: '/my-profile-screen', + initialLocation: '/auth-screen', routes: [ + GoRoute( + path: '/auth-screen', + name: 'authScreen', + redirect: (context, state) async { + final box = await Hive.openBox('token'); + final token = box.get('token'); + if (token != null) { + return '/my-profile-screen'; + } + return null; + }, + builder: (context, state) => AuthScreen.builder(context), + routes: [ + GoRoute( + path: 'language-select-screen', + name: 'languageSelectScreen', + builder: (context, state) => LanguageSelectScreen.builder(context), + ), + ], + ), ShellRoute( builder: (context, state, child) { return BottomNavigationBarWidget(child: child); @@ -23,6 +53,21 @@ class AppRouter { path: '/feed-screen', name: 'feedScreen', builder: (context, state) => FeedScreen(), + routes: [ + GoRoute( + path: 'blog-post-create-screen', + name: 'blogPostCreateScreen', + builder: (context, state) => BlogPostCreateScreen.builder(context), + ), + GoRoute( + path: 'blog-post-screen', + name: 'blogPostScreen', + builder: (context, state) => BlogPostScreen.builder( + context, + state.extra.toString(), + ), + ), + ], ), GoRoute( path: '/diary-screen', @@ -36,6 +81,31 @@ class AppRouter { ), ], ), + GoRoute( + path: '/my-settings-screen', + name: 'mySettingsScreen', + builder: (context, state) => MySettingsScreen.builder(context), + ), + GoRoute( + path: '/recipe-select-screen', + name: 'recipeSelectScreen', + builder: (context, state) => RecipeSelectScreen.builder(context), + ), + GoRoute( + path: '/diet-select-screen', + name: 'dietSelectScreen', + builder: (context, state) => DietSelectScreen.builder(context), + ), + GoRoute( + path: '/plan-select-screen', + name: 'planSelectScreen', + builder: (context, state) => PlanSelectScreen.builder(context), + ), + GoRoute( + path: '/glossary-screen', + name: 'glossaryScreen', + builder: (context, state) => GlossaryScreen.builder(context), + ), ], ); } diff --git a/lib/presentation/auth/auth_screen/auth_screen.dart b/lib/presentation/auth/auth_screen/auth_screen.dart index 558d5657..ff4408de 100644 --- a/lib/presentation/auth/auth_screen/auth_screen.dart +++ b/lib/presentation/auth/auth_screen/auth_screen.dart @@ -1,3 +1,5 @@ +import 'package:go_router/go_router.dart'; + import 'bloc/auth_bloc.dart'; import 'models/auth_model.dart'; import 'package:eatvio_app/core/app_export.dart'; @@ -101,10 +103,7 @@ class AuthScreen extends StatelessWidget { final box = await Hive.openBox('token'); final token = res['token']; box.put('token', token); - Navigator.pushNamed( - context, - AppRoutes.myProfile, - ); + GoRouter.of(context).go('/my-profile-screen'); } else { showDialog( context: context, @@ -164,7 +163,7 @@ class AuthScreen extends StatelessWidget { onTapNoAccount(BuildContext context) { return () { - Navigator.pushNamed(context, AppRoutes.languageSelectScreen); + GoRouter.of(context).goNamed('languageSelectScreen'); }; } diff --git a/lib/presentation/chat/chat_screen/chat_screen.dart b/lib/presentation/chat/chat_screen/chat_screen.dart index 37c3df52..a132f880 100644 --- a/lib/presentation/chat/chat_screen/chat_screen.dart +++ b/lib/presentation/chat/chat_screen/chat_screen.dart @@ -59,7 +59,6 @@ class ChatScreen extends StatelessWidget { ), ), ), - bottomNavigationBar: _buildTextField(context), ); } @@ -160,18 +159,6 @@ class ChatScreen extends StatelessWidget { ); } - /// Common widget - - ///Handling route based on bottom click actions - String getCurrentRoute(BottomBarEnum type) { - switch (type) { - case BottomBarEnum.tf: - return AppRoutes.chatScreen; - default: - return "/"; - } - } - ///Handling page based on route Widget getCurrentPage( BuildContext context, diff --git a/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart b/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart index 3de4ff40..698d6e0c 100644 --- a/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart +++ b/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart @@ -1,5 +1,7 @@ // ignore_for_file: unused_local_variable +import 'package:go_router/go_router.dart'; + import 'bloc/diary_edit_bloc.dart'; import 'models/diary_edit_model.dart'; import 'package:flutter/material.dart'; @@ -47,10 +49,10 @@ class DiaryEditScreen extends StatelessWidget { } Widget _buildDiaryEditScreen(BuildContext context, DiaryEditLoadedState state) { - mediaQueryData = MediaQuery.of(context); return RefreshIndicator( onRefresh: refreshPage(context), child: Stack( + alignment: Alignment.bottomCenter, children: [ FormBuilder( child: SafeArea( @@ -89,12 +91,7 @@ class DiaryEditScreen extends StatelessWidget { ), ), ), - Positioned( - left: 16.h, - right: 16.h, - bottom: 50.v, // Adjusted position to lift the button higher - child: _buildEndDay(context), - ), + _buildEndDay(context), ], ), ); @@ -106,7 +103,7 @@ class DiaryEditScreen extends StatelessWidget { margin: EdgeInsets.only( left: 16.h, right: 16.h, - bottom: 41.v, + bottom: 16.v, ), buttonStyle: CustomButtonStyles.outlinePrimaryTL15, decoration: BoxDecoration( @@ -147,7 +144,10 @@ class DiaryEditScreen extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - CustomImageView(imagePath: ImageConstant.imgArrowLeft, onTap: onTapBack()), + CustomImageView( + imagePath: ImageConstant.imgArrowLeft, + onTap: () => GoRouter.of(context).pop(), + ), Padding( padding: EdgeInsets.only(top: 1.v), child: Column( @@ -172,12 +172,6 @@ class DiaryEditScreen extends StatelessWidget { ); } - onTapBack() { - return () { - NavigatorService.goBack(); - }; - } - /// Section Widget _buildAddProduct(BuildContext context, DiaryEditLoadedState state) { return CustomOutlinedButton( diff --git a/lib/presentation/diets/diet_create_screen/diet_create_screen.dart b/lib/presentation/diets/diet_create_screen/diet_create_screen.dart index 6896701c..eae238b7 100644 --- a/lib/presentation/diets/diet_create_screen/diet_create_screen.dart +++ b/lib/presentation/diets/diet_create_screen/diet_create_screen.dart @@ -6,12 +6,11 @@ import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; class DietCreateScreen extends StatelessWidget { const DietCreateScreen({Key? key}) : super(key: key); + static Widget builder(BuildContext context) { final dietID = ModalRoute.of(context)!.settings.arguments; return BlocProvider( - create: (context) => DietCreateBloc(DietCreateState( - dietModelObj: DietCreateModel(dietID: dietID.toString()))) - ..add(DietCreateInitialEvent()), + create: (context) => DietCreateBloc(DietCreateState(dietModelObj: DietCreateModel(dietID: dietID.toString())))..add(DietCreateInitialEvent()), child: DietCreateScreen()); } @@ -40,58 +39,54 @@ class DietCreateScreen extends StatelessWidget { _buildDietCreate(BuildContext context, DietCreateLoadedState state) { mediaQueryData = MediaQuery.of(context); return SafeArea( - child: Scaffold( - resizeToAvoidBottomInset: false, - body: Container( - width: double.maxFinite, - decoration: AppDecoration.fillGray, - child: ListView(children: [ - SizedBox(height: 30.v), - Container( - margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, + child: Scaffold( + resizeToAvoidBottomInset: false, + body: Container( + width: double.maxFinite, + decoration: AppDecoration.fillGray, + child: ListView(children: [ + SizedBox(height: 30.v), + Container( + margin: EdgeInsets.only( + left: 16.h, + right: 20.h, + bottom: 10.h, + ), + padding: EdgeInsets.all(12.h), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), ), - padding: EdgeInsets.all(12.h), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column(mainAxisSize: MainAxisSize.min, children: [ - SizedBox(height: 16.0), - TextFormField( - controller: state.name, - decoration: InputDecoration(labelText: 'Заголовок'), - ), - SizedBox(height: 16.0), - TextFormField( - controller: state.details, - decoration: InputDecoration(labelText: 'Описание'), - ), - SizedBox(height: 16.0), - // Здесь нужно добавить виджет для загрузки картинки - ElevatedButton( - onPressed: () => - context.read().add(CreateDiet()), - child: Text('Создать'), - ) - ]), + ], + ), + child: Column(mainAxisSize: MainAxisSize.min, children: [ + SizedBox(height: 16.0), + TextFormField( + controller: state.name, + decoration: InputDecoration(labelText: 'Заголовок'), + ), + SizedBox(height: 16.0), + TextFormField( + controller: state.details, + decoration: InputDecoration(labelText: 'Описание'), + ), + SizedBox(height: 16.0), + // Здесь нужно добавить виджет для загрузки картинки + ElevatedButton( + onPressed: () => context.read().add(CreateDiet()), + child: Text('Создать'), ) ]), - ), - bottomNavigationBar: _buildBottomBar(context))); + ) + ]), + ), + ), + ); } } - -_buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); -} diff --git a/lib/presentation/diets/diet_edit_screen/diet_edit_screen.dart b/lib/presentation/diets/diet_edit_screen/diet_edit_screen.dart index 75f02810..665927b1 100644 --- a/lib/presentation/diets/diet_edit_screen/diet_edit_screen.dart +++ b/lib/presentation/diets/diet_edit_screen/diet_edit_screen.dart @@ -8,12 +8,11 @@ import 'package:flutter_dotenv/flutter_dotenv.dart'; class DietEditScreen extends StatelessWidget { const DietEditScreen({Key? key}) : super(key: key); + static Widget builder(BuildContext context) { final dietID = ModalRoute.of(context)!.settings.arguments; return BlocProvider( - create: (context) => DietEditBloc(DietEditState( - dietModelObj: DietEditModel(dietID: dietID.toString()))) - ..add(DietEditInitialEvent()), + create: (context) => DietEditBloc(DietEditState(dietModelObj: DietEditModel(dietID: dietID.toString())))..add(DietEditInitialEvent()), child: DietEditScreen()); } @@ -42,42 +41,43 @@ class DietEditScreen extends StatelessWidget { _buildDietEdit(BuildContext context, DietEditLoadedState state) { mediaQueryData = MediaQuery.of(context); return SafeArea( - child: Scaffold( - resizeToAvoidBottomInset: false, - body: Container( - width: double.maxFinite, - decoration: AppDecoration.fillGray, - child: ListView(children: [ - SizedBox(height: 30.v), - Container( - margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, - ), - padding: EdgeInsets.all(12.h), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column(mainAxisSize: MainAxisSize.min, children: [ + child: Scaffold( + resizeToAvoidBottomInset: false, + body: Container( + width: double.maxFinite, + decoration: AppDecoration.fillGray, + child: ListView( + children: [ + SizedBox(height: 30.v), + Container( + margin: EdgeInsets.only( + left: 16.h, + right: 20.h, + bottom: 10.h, + ), + padding: EdgeInsets.all(12.h), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), + ), + ], + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ CachedNetworkImage( - imageUrl: dotenv.env['STORAGE_URL']! + - (state.diet?['image'] ?? ''), + imageUrl: dotenv.env['STORAGE_URL']! + (state.diet?['image'] ?? ''), imageBuilder: (context, imageProvider) => CircleAvatar( backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => - CircularProgressIndicator(), + placeholder: (context, url) => CircularProgressIndicator(), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, @@ -97,18 +97,16 @@ class DietEditScreen extends StatelessWidget { SizedBox(height: 16.0), // Здесь нужно добавить виджет для загрузки картинки ElevatedButton( - onPressed: () => - context.read().add(EditDiet()), + onPressed: () => context.read().add(EditDiet()), child: Text('Сохранить'), ) - ]), - ) - ]), - ), - bottomNavigationBar: _buildBottomBar(context))); + ], + ), + ) + ], + ), + ), + ), + ); } } - -_buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); -} diff --git a/lib/presentation/diets/diet_select_screen/diet_select_screen.dart b/lib/presentation/diets/diet_select_screen/diet_select_screen.dart index c44308d8..207cbb6d 100644 --- a/lib/presentation/diets/diet_select_screen/diet_select_screen.dart +++ b/lib/presentation/diets/diet_select_screen/diet_select_screen.dart @@ -1,3 +1,5 @@ +import 'package:go_router/go_router.dart'; + import 'bloc/diet_select_bloc.dart'; import 'models/diet_select_model.dart'; import 'package:eatvio_app/core/app_export.dart'; @@ -39,75 +41,71 @@ class DietSelectScreen extends StatelessWidget { } _buildSetingsScreen(BuildContext context, DietSelectLoadedState state) { - mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( - backgroundColor: Colors.grey[200], - resizeToAvoidBottomInset: true, - body: SingleChildScrollView( - child: Container( - width: double.maxFinite, - decoration: BoxDecoration(color: Colors.grey[200]), - child: Padding( - padding: EdgeInsets.all(16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - SizedBox(height: 10), - Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: CustomAppBar( - height: 54.v, - leadingWidth: 28.h, - leading: AppbarLeadingImage( - imagePath: ImageConstant.imgArrowLeft, - margin: EdgeInsets.only( - left: 16.h, top: 15.v, bottom: 15.v), - onTap: onTapBack(context), + return Scaffold( + backgroundColor: Colors.grey[200], + resizeToAvoidBottomInset: true, + body: SingleChildScrollView( + child: Container( + width: double.maxFinite, + decoration: BoxDecoration(color: Colors.grey[200]), + child: Padding( + padding: EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + SizedBox(height: 10), + Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), ), - title: Padding( - padding: EdgeInsets.only(left: 20.h), - child: Row( - children: [ - AppbarSubtitle( - text: "Диеты", - margin: EdgeInsets.only( - left: 80.h, top: 12.v, bottom: 9.v), - ), - Spacer(), - Padding( - padding: const EdgeInsets.only(right: 20.0), - child: GestureDetector( - onTap: () => Navigator.pushNamed( - context, - AppRoutes.dietCreateScreen, - ), - child: Icon(Icons.create_outlined)), - ) - ], - ), + ], + ), + child: CustomAppBar( + height: 54.v, + leadingWidth: 28.h, + leading: AppbarLeadingImage( + imagePath: ImageConstant.imgArrowLeft, + margin: EdgeInsets.only( + left: 16.h, top: 15.v, bottom: 15.v), + onTap: () => GoRouter.of(context).pop(), + ), + title: Padding( + padding: EdgeInsets.only(left: 20.h), + child: Row( + children: [ + AppbarSubtitle( + text: "Диеты", + margin: EdgeInsets.only( + left: 80.h, top: 12.v, bottom: 9.v), + ), + Spacer(), + Padding( + padding: const EdgeInsets.only(right: 20.0), + child: GestureDetector( + onTap: () => Navigator.pushNamed( + context, + AppRoutes.dietCreateScreen, + ), + child: Icon(Icons.create_outlined)), + ) + ], ), ), ), - SizedBox(height: 20), - _buildDietList(context, state) - ], - ), + ), + SizedBox(height: 20), + _buildDietList(context, state) + ], ), ), ), - bottomNavigationBar: _buildBottomBar(context), ), ); } @@ -174,10 +172,6 @@ class DietSelectScreen extends StatelessWidget { }; } - _buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); - } - onTapArrowLeft(BuildContext context) { NavigatorService.goBack(); } diff --git a/lib/presentation/diets/diet_show_screen/diet_show_screen.dart b/lib/presentation/diets/diet_show_screen/diet_show_screen.dart index dcc20aea..d05a39a8 100644 --- a/lib/presentation/diets/diet_show_screen/diet_show_screen.dart +++ b/lib/presentation/diets/diet_show_screen/diet_show_screen.dart @@ -8,13 +8,11 @@ import 'package:flutter_dotenv/flutter_dotenv.dart'; class DietScreen extends StatelessWidget { const DietScreen({Key? key}) : super(key: key); + static Widget builder(BuildContext context) { final dietID = ModalRoute.of(context)!.settings.arguments; return BlocProvider( - create: (context) => DietBloc( - DietState(dietModelObj: DietModel(dietID: dietID.toString()))) - ..add(DietInitialEvent()), - child: DietScreen()); + create: (context) => DietBloc(DietState(dietModelObj: DietModel(dietID: dietID.toString())))..add(DietInitialEvent()), child: DietScreen()); } Widget build(BuildContext context) { @@ -42,92 +40,78 @@ class DietScreen extends StatelessWidget { _buildDiet(BuildContext context, DietLoadedState state) { mediaQueryData = MediaQuery.of(context); return SafeArea( - child: Scaffold( - resizeToAvoidBottomInset: false, - body: Container( - width: double.maxFinite, - decoration: AppDecoration.fillGray, - child: ListView( - children: [ - SizedBox(height: 30.v), - Container( - margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, + child: Scaffold( + resizeToAvoidBottomInset: false, + body: Container( + width: double.maxFinite, + decoration: AppDecoration.fillGray, + child: ListView( + children: [ + SizedBox(height: 30.v), + Container( + margin: EdgeInsets.only( + left: 16.h, + right: 20.h, + bottom: 10.h, + ), + padding: EdgeInsets.all(12.h), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), ), - padding: EdgeInsets.all(12.h), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], + ], + ), + child: Column(mainAxisSize: MainAxisSize.min, children: [ + CachedNetworkImage( + imageUrl: dotenv.env['STORAGE_URL']! + (state.diet?['image'] ?? ''), + imageBuilder: (context, imageProvider) => CircleAvatar( + backgroundImage: imageProvider, + radius: 25, ), - child: Column(mainAxisSize: MainAxisSize.min, children: [ - CachedNetworkImage( - imageUrl: dotenv.env['STORAGE_URL']! + - (state.diet?['image'] ?? ''), - imageBuilder: (context, imageProvider) => CircleAvatar( - backgroundImage: imageProvider, - radius: 25, - ), - placeholder: (context, url) => - CircularProgressIndicator(), - errorWidget: (context, url, error) => CircleAvatar( - child: Icon(Icons.person), - backgroundColor: Colors.white, - radius: 25, + placeholder: (context, url) => CircularProgressIndicator(), + errorWidget: (context, url, error) => CircleAvatar( + child: Icon(Icons.person), + backgroundColor: Colors.white, + radius: 25, + ), + ), + SizedBox(height: 16.0), + Text(state.diet?['name'], style: CustomTextStyles.titleMediumBlack), + SizedBox(height: 8.0), + Text( + state.diet?['details'], + ), + SizedBox(height: 16.0), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + ElevatedButton( + onPressed: () => Navigator.pushNamed( + context, + AppRoutes.dietEditScreen, + arguments: state.diet?['id'].toString(), ), + child: Text('Редактировать'), ), - SizedBox(height: 16.0), - Text(state.diet?['name'], - style: CustomTextStyles.titleMediumBlack), - SizedBox(height: 8.0), - Text( - state.diet?['details'], + ElevatedButton( + onPressed: () => context.read().add(DeleteEntry(state.diet?['id'])), + child: Text('Удалить'), ), - SizedBox(height: 16.0), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - ElevatedButton( - onPressed: () => Navigator.pushNamed( - context, - AppRoutes.dietEditScreen, - arguments: state.diet?['id'].toString(), - ), - child: Text('Редактировать'), - ), - ElevatedButton( - onPressed: () => context - .read() - .add(DeleteEntry(state.diet?['id'])), - child: Text('Удалить'), - ), - ], - ) - ]), + ], ) - ], - ), - ), - bottomNavigationBar: _buildBottomBar(context))); - } - - ///Handling route based on bottom click actions - String getCurrentRoute(BottomBarEnum type) { - switch (type) { - case BottomBarEnum.tf: - return AppRoutes.dietScreen; - default: - return "/"; - } + ]), + ) + ], + ), + ), + ), + ); } ///Handling page based on route @@ -143,10 +127,6 @@ class DietScreen extends StatelessWidget { } } - _buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); - } - /// Navigates to the previous screen. onTapArrowleftone(BuildContext context) { NavigatorService.goBack(); diff --git a/lib/presentation/feed/blog_post_create_screen/blog_post_create_screen.dart b/lib/presentation/feed/blog_post_create_screen/blog_post_create_screen.dart index fc1d7c14..be78f7e3 100644 --- a/lib/presentation/feed/blog_post_create_screen/blog_post_create_screen.dart +++ b/lib/presentation/feed/blog_post_create_screen/blog_post_create_screen.dart @@ -2,18 +2,16 @@ import 'bloc/blog_post_create_bloc.dart'; import 'models/blog_post_create_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:flutter/material.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/custom_outlined_button.dart'; class BlogPostCreateScreen extends StatelessWidget { const BlogPostCreateScreen({Key? key}) : super(key: key); + static Widget builder(BuildContext context) { final blog_postID = ModalRoute.of(context)!.settings.arguments; return BlocProvider( - create: (context) => BlogPostCreateBloc(BlogPostCreateState( - blog_postModelObj: - BlogPostCreateModel(blog_postID: blog_postID.toString()))) + create: (context) => BlogPostCreateBloc(BlogPostCreateState(blog_postModelObj: BlogPostCreateModel(blog_postID: blog_postID.toString()))) ..add(BlogPostCreateInitialEvent()), child: BlogPostCreateScreen()); } @@ -41,92 +39,85 @@ class BlogPostCreateScreen extends StatelessWidget { } _buildBlogPostCreate(BuildContext context, BlogPostCreateLoadedState state) { - mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( - resizeToAvoidBottomInset: false, - body: Container( - width: double.maxFinite, - decoration: AppDecoration.fillGray, - child: ListView(children: [ - SizedBox(height: 30.v), - Container( - margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, + return Scaffold( + resizeToAvoidBottomInset: false, + body: Container( + width: double.maxFinite, + decoration: AppDecoration.fillGray, + child: ListView( + children: [ + SizedBox(height: 30.v), + Container( + margin: EdgeInsets.only( + left: 16.h, + right: 20.h, + bottom: 10.h, + ), + padding: EdgeInsets.all(12.h), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), + ), + ], + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Column( + children: [ + Text("Заголовок новости", style: theme.textTheme.bodyLarge), + CustomTextFormField( + controller: state.title, + validator: _validateTitle, ), - padding: EdgeInsets.all(12.h), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: - const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], + SizedBox(height: 8.0), + Text("Ссылка на YouTube", style: theme.textTheme.bodyLarge), + CustomTextFormField( + controller: state.youtube_url, + validator: _validateYouTubeLink, ), - child: Column(mainAxisSize: MainAxisSize.min, children: [ - Column( - children: [ - Text("Заголовок новости", - style: theme.textTheme.bodyLarge), - CustomTextFormField( - controller: state.title, - validator: _validateTitle, - ), - SizedBox(height: 8.0), - Text("Ссылка на YouTube", - style: theme.textTheme.bodyLarge), - CustomTextFormField( - controller: state.youtube_url, - validator: _validateYouTubeLink, - ), - SizedBox(height: 8.0), - Text("Описание", style: theme.textTheme.bodyLarge), - CustomTextFormField( - controller: state.description, - validator: _validateDescription, - maxLines: 6, - ), - SizedBox(height: 16.0), - // Add widget for image upload here - CustomOutlinedButton( - onPressed: () => _submitForm( - context, - state.title!.text, - state.description!.text, - state.youtube_url!.text), - buttonStyle: - CustomButtonStyles.outlinePrimaryTL15, - text: 'Создать', - ), - ], - ), - ])) - ])), - bottomNavigationBar: _buildBottomBar(context))); + SizedBox(height: 8.0), + Text("Описание", style: theme.textTheme.bodyLarge), + CustomTextFormField( + controller: state.description, + validator: _validateDescription, + maxLines: 6, + ), + SizedBox(height: 16.0), + // Add widget for image upload here + CustomOutlinedButton( + onPressed: () => _submitForm(context, state.title!.text, state.description!.text, state.youtube_url!.text), + buttonStyle: CustomButtonStyles.outlinePrimaryTL15, + text: 'Создать', + ), + ], + ), + ], + ), + ) + ], + ), + ), + ); } } -_submitForm( - BuildContext context, String title, String description, String youtubeURL) { +_submitForm(BuildContext context, String title, String description, String youtubeURL) { String? titleError = _validateTitle(title); String? descriptionError = _validateDescription(description); String? youtubeURLError = _validateYouTubeLink(youtubeURL); - if (titleError != null || - descriptionError != null || - youtubeURLError != null) { + if (titleError != null || descriptionError != null || youtubeURLError != null) { // Display error messages or handle invalid input as needed // For example, show a snackbar with the error message ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text(titleError ?? descriptionError ?? youtubeURLError!)), + SnackBar(content: Text(titleError ?? descriptionError ?? youtubeURLError!)), ); } else { // Proceed with form submission @@ -158,11 +149,6 @@ String? _validateYouTubeLink(value) { } bool _isValidUrl(String url) { - final RegExp urlRegExp = - new RegExp(r"^(http|https):\/\/([\w-]+\.)+[\w-]+(\/[\w-./?%&=]*)?$"); + final RegExp urlRegExp = new RegExp(r"^(http|https):\/\/([\w-]+\.)+[\w-]+(\/[\w-./?%&=]*)?$"); return urlRegExp.hasMatch(url); } - -_buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); -} diff --git a/lib/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart b/lib/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart index 1bba76d6..ac5a8338 100644 --- a/lib/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart +++ b/lib/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart @@ -8,13 +8,12 @@ import 'package:flutter_dotenv/flutter_dotenv.dart'; class BlogPostEditScreen extends StatelessWidget { const BlogPostEditScreen({Key? key}) : super(key: key); + static Widget builder(BuildContext context) { final blog_postID = ModalRoute.of(context)!.settings.arguments; return BlocProvider( - create: (context) => BlogPostEditBloc(BlogPostEditState( - blog_postModelObj: - BlogPostEditModel(blog_postID: blog_postID.toString()))) - ..add(BlogPostEditInitialEvent()), + create: (context) => + BlogPostEditBloc(BlogPostEditState(blog_postModelObj: BlogPostEditModel(blog_postID: blog_postID.toString())))..add(BlogPostEditInitialEvent()), child: BlogPostEditScreen()); } @@ -43,42 +42,43 @@ class BlogPostEditScreen extends StatelessWidget { _buildBlogPostEdit(BuildContext context, BlogPostEditLoadedState state) { mediaQueryData = MediaQuery.of(context); return SafeArea( - child: Scaffold( - resizeToAvoidBottomInset: false, - body: Container( - width: double.maxFinite, - decoration: AppDecoration.fillGray, - child: ListView(children: [ - SizedBox(height: 30.v), - Container( - margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, - ), - padding: EdgeInsets.all(12.h), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column(mainAxisSize: MainAxisSize.min, children: [ + child: Scaffold( + resizeToAvoidBottomInset: false, + body: Container( + width: double.maxFinite, + decoration: AppDecoration.fillGray, + child: ListView( + children: [ + SizedBox(height: 30.v), + Container( + margin: EdgeInsets.only( + left: 16.h, + right: 20.h, + bottom: 10.h, + ), + padding: EdgeInsets.all(12.h), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), + ), + ], + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ CachedNetworkImage( - imageUrl: dotenv.env['STORAGE_URL']! + - (state.blog_post?['image'] ?? ''), + imageUrl: dotenv.env['STORAGE_URL']! + (state.blog_post?['image'] ?? ''), imageBuilder: (context, imageProvider) => CircleAvatar( backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => - CircularProgressIndicator(), + placeholder: (context, url) => CircularProgressIndicator(), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, @@ -103,18 +103,16 @@ class BlogPostEditScreen extends StatelessWidget { SizedBox(height: 16.0), // Здесь нужно добавить виджет для загрузки картинки ElevatedButton( - onPressed: () => - context.read().add(EditBlogPost()), + onPressed: () => context.read().add(EditBlogPost()), child: Text('Сохранить'), ) - ]), - ) - ]), - ), - bottomNavigationBar: _buildBottomBar(context))); + ], + ), + ) + ], + ), + ), + ), + ); } } - -_buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); -} diff --git a/lib/presentation/feed/blog_post_screen/blog_post_screen.dart b/lib/presentation/feed/blog_post_screen/blog_post_screen.dart index 04637420..0b524122 100644 --- a/lib/presentation/feed/blog_post_screen/blog_post_screen.dart +++ b/lib/presentation/feed/blog_post_screen/blog_post_screen.dart @@ -1,10 +1,11 @@ +import 'package:go_router/go_router.dart'; + import 'bloc/blog_post_bloc.dart'; import 'models/blog_post_model.dart'; import 'widgets/comment_widget.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; -import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart'; import 'package:eatvio_app/widgets/custom_outlined_button.dart'; import 'package:cached_network_image/cached_network_image.dart'; @@ -12,60 +13,73 @@ import 'package:flutter_dotenv/flutter_dotenv.dart'; class BlogPostScreen extends StatelessWidget { const BlogPostScreen({Key? key}) : super(key: key); - static Widget builder(BuildContext context) { - final blog_postID = ModalRoute.of(context)!.settings.arguments; + + static Widget builder(BuildContext context, String blog_postID) { return BlocProvider( - create: (context) => BlogPostBloc(BlogPostState( - blog_postModelObj: - BlogPostModel(blog_postID: blog_postID.toString()))) - ..add(BlogPostInitialEvent()), - child: BlogPostScreen()); + create: (context) => BlogPostBloc( + BlogPostState( + blog_postModelObj: BlogPostModel( + blog_postID: blog_postID.toString(), + ), + ), + )..add( + BlogPostInitialEvent(), + ), + child: BlogPostScreen(), + ); } Widget build(BuildContext context) { return BlocBuilder( builder: (context, state) { if (state is BlogPostInitialState) { - // Это начальное состояние, данные ещё не загружены. - return Container( - color: Colors.white, + return Scaffold( + body: Center( + child: CircularProgressIndicator(), + ), ); } else if (state is BlogPostLoadedState) { // Данные загружены, можно строить экран. return _buildBlogPost(context, state); } else if (state is BlogPostErrorState) { // Произошла ошибка при загрузке данных. - return Center(child: Text(state.errorMessage)); + return Center( + child: Text(state.errorMessage), + ); } else { + return Scaffold( + body: Center( + child: CircularProgressIndicator(), + ), + ); // Другие состояния, если они есть. - return Container(); // Пустой контейнер для необработанных состояний. } }, ); } _buildBlogPost(BuildContext context, BlogPostLoadedState state) { - mediaQueryData = MediaQuery.of(context); return SafeArea( - child: Scaffold( - resizeToAvoidBottomInset: false, - body: Container( - width: double.maxFinite, - decoration: AppDecoration.fillGray, - child: ListView( - children: [ - SizedBox(height: 15.v), - _buildHeaderRow(context, state), - SizedBox(height: 15.v), - _buildBlogPostData(context, state), - SizedBox(height: 15.v), - _buildTextField(context, state), - SizedBox(height: 15.v), - _buildCommentSection(context, state), - ], - ), - ), - bottomNavigationBar: _buildBottomBar(context))); + child: Scaffold( + resizeToAvoidBottomInset: false, + body: Container( + width: double.maxFinite, + decoration: AppDecoration.fillGray, + child: ListView( + children: [ + SizedBox(height: 15.v), + _buildHeaderRow(context, state), + SizedBox(height: 15.v), + _buildBlogPostData(context, state), + SizedBox(height: 15.v), + _buildTextField(context, state), + SizedBox(height: 15.v), + _buildCommentSection(context, state), + ], + ), + ), + ), + ); } _buildHeaderRow(BuildContext context, BlogPostLoadedState state) { @@ -92,8 +106,9 @@ class BlogPostScreen extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ CustomImageView( - imagePath: ImageConstant.imgArrowLeft, - onTap: () => NavigatorService.goBack()), + imagePath: ImageConstant.imgArrowLeft, + onTap: () => GoRouter.of(context).pop(), + ), Padding( padding: EdgeInsets.only(top: 1.v), child: Row( @@ -106,8 +121,7 @@ class BlogPostScreen extends StatelessWidget { ), ), CachedNetworkImage( - imageUrl: dotenv.env['STORAGE_URL']! + - (state.author?['profile_photo_path'] ?? ''), + imageUrl: dotenv.env['STORAGE_URL']! + (state.author?['profile_photo_path'] ?? ''), imageBuilder: (context, imageProvider) => CircleAvatar( backgroundImage: imageProvider, radius: 25, @@ -181,8 +195,7 @@ class BlogPostScreen extends StatelessWidget { Align( alignment: Alignment.topLeft, child: Text( - DateFormat('dd.MM.yyyy') - .format(DateTime.parse(state.blog_post?['updated_at'])), + DateFormat('dd.MM.yyyy').format(DateTime.parse(state.blog_post?['updated_at'])), style: theme.textTheme.bodyMedium, )), SizedBox(height: 16.0), @@ -342,9 +355,7 @@ class BlogPostScreen extends StatelessWidget { decoration: BoxDecoration( color: Colors.transparent, ), - onPressed: () => context - .read() - .add(CreateComment(state.commentController!.text)), + onPressed: () => context.read().add(CreateComment(state.commentController!.text)), // Установите прозрачный фон ) ], @@ -377,12 +388,8 @@ class BlogPostScreen extends StatelessWidget { } } - _buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); - } - /// Navigates to the previous screen. onTapArrowleftone(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } } diff --git a/lib/presentation/feed/feed_screen/feed_screen.dart b/lib/presentation/feed/feed_screen/feed_screen.dart index 4e8be2c2..cddb9cca 100644 --- a/lib/presentation/feed/feed_screen/feed_screen.dart +++ b/lib/presentation/feed/feed_screen/feed_screen.dart @@ -1,3 +1,5 @@ +import 'package:go_router/go_router.dart'; + import 'bloc/feed_bloc.dart'; import 'models/feed_model.dart'; import 'package:cached_network_image/cached_network_image.dart'; @@ -101,10 +103,7 @@ class FeedScreen extends StatelessWidget { flex: 1, child: CustomOutlinedButton( text: "+", - onPressed: () => Navigator.pushNamed( - context, - AppRoutes.blogPostCreateScreen, - ), + onPressed: () => GoRouter.of(context).goNamed('blogPostCreateScreen'), buttonStyle: CustomButtonStyles.outlinePrimaryTL15, ), ), @@ -169,10 +168,9 @@ class FeedScreen extends StatelessWidget { DateFormat('dd.MM.yyyy').format(DateTime.parse(post?['post']['updated_at'])), style: theme.textTheme.bodyMedium, ), - onTap: () => Navigator.pushNamed( - context, - AppRoutes.blogPostScreen, - arguments: post?['post']['id'].toString(), + onTap: () => GoRouter.of(context).goNamed( + 'blogPostScreen', + extra: post?['post']['id'].toString(), ), trailing: PopupMenuButton( onSelected: (value) => print("tap"), diff --git a/lib/presentation/glossary/glossary_screen/glossary_screen.dart b/lib/presentation/glossary/glossary_screen/glossary_screen.dart index 65dc65cb..42b84775 100644 --- a/lib/presentation/glossary/glossary_screen/glossary_screen.dart +++ b/lib/presentation/glossary/glossary_screen/glossary_screen.dart @@ -12,12 +12,10 @@ import 'package:eatvio_app/presentation/glossary/glossary_screen/widgets/glossar class GlossaryScreen extends StatelessWidget { const GlossaryScreen({Key? key}) : super(key: key); + static Widget builder(BuildContext context) { return BlocProvider( - create: (context) => - GlossaryBloc(GlossaryState(glossaryModelObj: GlossaryModel())) - ..add(GlossaryInitialEvent()), - child: GlossaryScreen()); + create: (context) => GlossaryBloc(GlossaryState(glossaryModelObj: GlossaryModel()))..add(GlossaryInitialEvent()), child: GlossaryScreen()); } Widget build(BuildContext context) { @@ -43,32 +41,28 @@ class GlossaryScreen extends StatelessWidget { } _buildGlossary(BuildContext context, GlossaryLoadedState state) { - mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( - backgroundColor: Colors.grey[200], - resizeToAvoidBottomInset: true, - body: SingleChildScrollView( - child: Container( - width: double.maxFinite, - decoration: BoxDecoration(color: Colors.grey[200]), - child: Padding( - padding: EdgeInsets.all(16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - SizedBox(height: 20), - _buildSearch(context), - SizedBox(height: 20), - _buildMenu(context), - SizedBox(height: 20), - _buildProducts(context, state) - ], - ), + return Scaffold( + backgroundColor: Colors.grey[200], + resizeToAvoidBottomInset: true, + body: SingleChildScrollView( + child: Container( + width: double.maxFinite, + decoration: BoxDecoration(color: Colors.grey[200]), + child: Padding( + padding: EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + SizedBox(height: 20), + _buildSearch(context), + SizedBox(height: 20), + _buildMenu(context), + SizedBox(height: 20), + _buildProducts(context, state) + ], ), ), ), - bottomNavigationBar: _buildBottomBar(context), ), ); } @@ -184,16 +178,12 @@ class GlossaryScreen extends StatelessWidget { vertical: 9, ), onChanged: _changeProductGroup(context, state), - width: MediaQuery.of(context) - .size - .width, // Set a percentage value as per your layout + width: MediaQuery.of(context).size.width, // Set a percentage value as per your layout ), SizedBox( height: 8, ), - Align( - alignment: Alignment.centerLeft, - child: Text("*КБЖУ указано за 100гр")), + Align(alignment: Alignment.centerLeft, child: Text("*КБЖУ указано за 100гр")), SizedBox( height: 8, ), @@ -268,8 +258,7 @@ class GlossaryScreen extends StatelessWidget { child: Column(children: [ Text("Жиры - ${product['fats_on_100gr'].toString()}"), SizedBox(height: 8), - Text( - "Углеводы - ${product['carbohydrates_on_100gr'].toString()}") + Text("Углеводы - ${product['carbohydrates_on_100gr'].toString()}") ]), ) ]) @@ -298,16 +287,6 @@ class GlossaryScreen extends StatelessWidget { return result; } - ///Handling route based on bottom click actions - String getCurrentRoute(BottomBarEnum type) { - switch (type) { - case BottomBarEnum.tf: - return AppRoutes.glossaryScreen; - default: - return "/"; - } - } - ///Handling page based on route Widget getCurrentPage( BuildContext context, @@ -321,10 +300,6 @@ class GlossaryScreen extends StatelessWidget { } } - _buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); - } - _changeProductGroup(BuildContext context, GlossaryLoadedState state) { return (value) { context.read().add(ChangeProductGroup(value.id)); diff --git a/lib/presentation/plans/plan_create_screen/plan_create_screen.dart b/lib/presentation/plans/plan_create_screen/plan_create_screen.dart index af04abc7..9ab5cada 100644 --- a/lib/presentation/plans/plan_create_screen/plan_create_screen.dart +++ b/lib/presentation/plans/plan_create_screen/plan_create_screen.dart @@ -6,12 +6,11 @@ import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; class PlanCreateScreen extends StatelessWidget { const PlanCreateScreen({Key? key}) : super(key: key); + static Widget builder(BuildContext context) { final planID = ModalRoute.of(context)!.settings.arguments; return BlocProvider( - create: (context) => PlanCreateBloc(PlanCreateState( - planModelObj: PlanCreateModel(planID: planID.toString()))) - ..add(PlanCreateInitialEvent()), + create: (context) => PlanCreateBloc(PlanCreateState(planModelObj: PlanCreateModel(planID: planID.toString())))..add(PlanCreateInitialEvent()), child: PlanCreateScreen()); } @@ -40,58 +39,56 @@ class PlanCreateScreen extends StatelessWidget { _buildPlanCreate(BuildContext context, PlanCreateLoadedState state) { mediaQueryData = MediaQuery.of(context); return SafeArea( - child: Scaffold( - resizeToAvoidBottomInset: false, - body: Container( - width: double.maxFinite, - decoration: AppDecoration.fillGray, - child: ListView(children: [ - SizedBox(height: 30.v), - Container( - margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, - ), - padding: EdgeInsets.all(12.h), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column(mainAxisSize: MainAxisSize.min, children: [ - SizedBox(height: 16.0), - TextFormField( - controller: state.name, - decoration: InputDecoration(labelText: 'Заголовок'), + child: Scaffold( + resizeToAvoidBottomInset: false, + body: Container( + width: double.maxFinite, + decoration: AppDecoration.fillGray, + child: ListView( + children: [ + SizedBox(height: 30.v), + Container( + margin: EdgeInsets.only( + left: 16.h, + right: 20.h, + bottom: 10.h, + ), + padding: EdgeInsets.all(12.h), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), ), - SizedBox(height: 16.0), - TextFormField( - controller: state.details, - decoration: InputDecoration(labelText: 'Описание'), - ), - SizedBox(height: 16.0), - // Здесь нужно добавить виджет для загрузки картинки - ElevatedButton( - onPressed: () => - context.read().add(CreatePlan()), - child: Text('Создать'), - ) - ]), - ) - ]), - ), - bottomNavigationBar: _buildBottomBar(context))); + ], + ), + child: Column(mainAxisSize: MainAxisSize.min, children: [ + SizedBox(height: 16.0), + TextFormField( + controller: state.name, + decoration: InputDecoration(labelText: 'Заголовок'), + ), + SizedBox(height: 16.0), + TextFormField( + controller: state.details, + decoration: InputDecoration(labelText: 'Описание'), + ), + SizedBox(height: 16.0), + // Здесь нужно добавить виджет для загрузки картинки + ElevatedButton( + onPressed: () => context.read().add(CreatePlan()), + child: Text('Создать'), + ) + ]), + ) + ], + ), + ), + ), + ); } } - -_buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); -} diff --git a/lib/presentation/plans/plan_edit_screen/plan_edit_screen.dart b/lib/presentation/plans/plan_edit_screen/plan_edit_screen.dart index 71ac12b7..c163f2c7 100644 --- a/lib/presentation/plans/plan_edit_screen/plan_edit_screen.dart +++ b/lib/presentation/plans/plan_edit_screen/plan_edit_screen.dart @@ -8,12 +8,11 @@ import 'package:flutter_dotenv/flutter_dotenv.dart'; class PlanEditScreen extends StatelessWidget { const PlanEditScreen({Key? key}) : super(key: key); + static Widget builder(BuildContext context) { final planID = ModalRoute.of(context)!.settings.arguments; return BlocProvider( - create: (context) => PlanEditBloc(PlanEditState( - planModelObj: PlanEditModel(planID: planID.toString()))) - ..add(PlanEditInitialEvent()), + create: (context) => PlanEditBloc(PlanEditState(planModelObj: PlanEditModel(planID: planID.toString())))..add(PlanEditInitialEvent()), child: PlanEditScreen()); } @@ -42,42 +41,43 @@ class PlanEditScreen extends StatelessWidget { _buildPlanEdit(BuildContext context, PlanEditLoadedState state) { mediaQueryData = MediaQuery.of(context); return SafeArea( - child: Scaffold( - resizeToAvoidBottomInset: false, - body: Container( - width: double.maxFinite, - decoration: AppDecoration.fillGray, - child: ListView(children: [ - SizedBox(height: 30.v), - Container( - margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, - ), - padding: EdgeInsets.all(12.h), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column(mainAxisSize: MainAxisSize.min, children: [ + child: Scaffold( + resizeToAvoidBottomInset: false, + body: Container( + width: double.maxFinite, + decoration: AppDecoration.fillGray, + child: ListView( + children: [ + SizedBox(height: 30.v), + Container( + margin: EdgeInsets.only( + left: 16.h, + right: 20.h, + bottom: 10.h, + ), + padding: EdgeInsets.all(12.h), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), + ), + ], + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ CachedNetworkImage( - imageUrl: dotenv.env['STORAGE_URL']! + - (state.plan?['image'] ?? ''), + imageUrl: dotenv.env['STORAGE_URL']! + (state.plan?['image'] ?? ''), imageBuilder: (context, imageProvider) => CircleAvatar( backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => - CircularProgressIndicator(), + placeholder: (context, url) => CircularProgressIndicator(), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, @@ -97,18 +97,16 @@ class PlanEditScreen extends StatelessWidget { SizedBox(height: 16.0), // Здесь нужно добавить виджет для загрузки картинки ElevatedButton( - onPressed: () => - context.read().add(EditPlan()), + onPressed: () => context.read().add(EditPlan()), child: Text('Сохранить'), ) - ]), - ) - ]), - ), - bottomNavigationBar: _buildBottomBar(context))); + ], + ), + ) + ], + ), + ), + ), + ); } } - -_buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); -} diff --git a/lib/presentation/plans/plan_select_screen/plan_select_screen.dart b/lib/presentation/plans/plan_select_screen/plan_select_screen.dart index 7f3486a2..a82a6679 100644 --- a/lib/presentation/plans/plan_select_screen/plan_select_screen.dart +++ b/lib/presentation/plans/plan_select_screen/plan_select_screen.dart @@ -1,3 +1,5 @@ +import 'package:go_router/go_router.dart'; + import 'bloc/plan_select_bloc.dart'; import 'models/plan_select_model.dart'; import 'package:eatvio_app/core/app_export.dart'; @@ -39,75 +41,71 @@ class PlanSelectScreen extends StatelessWidget { } _buildSetingsScreen(BuildContext context, PlanSelectLoadedState state) { - mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( - backgroundColor: Colors.grey[200], - resizeToAvoidBottomInset: true, - body: SingleChildScrollView( - child: Container( - width: double.maxFinite, - decoration: BoxDecoration(color: Colors.grey[200]), - child: Padding( - padding: EdgeInsets.all(16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - SizedBox(height: 10), - Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: CustomAppBar( - height: 54.v, - leadingWidth: 28.h, - leading: AppbarLeadingImage( - imagePath: ImageConstant.imgArrowLeft, - margin: EdgeInsets.only( - left: 16.h, top: 15.v, bottom: 15.v), - onTap: onTapBack(context), + return Scaffold( + backgroundColor: Colors.grey[200], + resizeToAvoidBottomInset: true, + body: SingleChildScrollView( + child: Container( + width: double.maxFinite, + decoration: BoxDecoration(color: Colors.grey[200]), + child: Padding( + padding: EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + SizedBox(height: 10), + Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), ), - title: Padding( - padding: EdgeInsets.only(left: 20.h), - child: Row( - children: [ - AppbarSubtitle( - text: "Планы", - margin: EdgeInsets.only( - left: 80.h, top: 12.v, bottom: 9.v), - ), - Spacer(), - Padding( - padding: const EdgeInsets.only(right: 20.0), - child: GestureDetector( - onTap: () => Navigator.pushNamed( - context, - AppRoutes.planCreateScreen, - ), - child: Icon(Icons.create_outlined)), - ) - ], - ), + ], + ), + child: CustomAppBar( + height: 54.v, + leadingWidth: 28.h, + leading: AppbarLeadingImage( + imagePath: ImageConstant.imgArrowLeft, + margin: EdgeInsets.only( + left: 16.h, top: 15.v, bottom: 15.v), + onTap: () => GoRouter.of(context).pop(), + ), + title: Padding( + padding: EdgeInsets.only(left: 20.h), + child: Row( + children: [ + AppbarSubtitle( + text: "Планы", + margin: EdgeInsets.only( + left: 80.h, top: 12.v, bottom: 9.v), + ), + Spacer(), + Padding( + padding: const EdgeInsets.only(right: 20.0), + child: GestureDetector( + onTap: () => Navigator.pushNamed( + context, + AppRoutes.planCreateScreen, + ), + child: Icon(Icons.create_outlined)), + ) + ], ), ), ), - SizedBox(height: 20), - _buildPlanList(context, state) - ], - ), + ), + SizedBox(height: 20), + _buildPlanList(context, state) + ], ), ), ), - bottomNavigationBar: _buildBottomBar(context), ), ); } @@ -174,10 +172,6 @@ class PlanSelectScreen extends StatelessWidget { }; } - _buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); - } - onTapArrowLeft(BuildContext context) { NavigatorService.goBack(); } diff --git a/lib/presentation/plans/plan_show_screen/plan_show_screen.dart b/lib/presentation/plans/plan_show_screen/plan_show_screen.dart index d34e1a43..8e2f2431 100644 --- a/lib/presentation/plans/plan_show_screen/plan_show_screen.dart +++ b/lib/presentation/plans/plan_show_screen/plan_show_screen.dart @@ -8,13 +8,11 @@ import 'package:flutter_dotenv/flutter_dotenv.dart'; class PlanScreen extends StatelessWidget { const PlanScreen({Key? key}) : super(key: key); + static Widget builder(BuildContext context) { final planID = ModalRoute.of(context)!.settings.arguments; return BlocProvider( - create: (context) => PlanBloc( - PlanState(planModelObj: PlanModel(planID: planID.toString()))) - ..add(PlanInitialEvent()), - child: PlanScreen()); + create: (context) => PlanBloc(PlanState(planModelObj: PlanModel(planID: planID.toString())))..add(PlanInitialEvent()), child: PlanScreen()); } Widget build(BuildContext context) { @@ -42,91 +40,76 @@ class PlanScreen extends StatelessWidget { _buildPlan(BuildContext context, PlanLoadedState state) { mediaQueryData = MediaQuery.of(context); return SafeArea( - child: Scaffold( - resizeToAvoidBottomInset: false, - body: Container( - width: double.maxFinite, - decoration: AppDecoration.fillGray, - child: ListView( - children: [ - SizedBox(height: 30.v), - Container( - margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, + child: Scaffold( + resizeToAvoidBottomInset: false, + body: Container( + width: double.maxFinite, + decoration: AppDecoration.fillGray, + child: ListView( + children: [ + SizedBox(height: 30.v), + Container( + margin: EdgeInsets.only( + left: 16.h, + right: 20.h, + bottom: 10.h, + ), + padding: EdgeInsets.all(12.h), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), ), - padding: EdgeInsets.all(12.h), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], + ], + ), + child: Column(mainAxisSize: MainAxisSize.min, children: [ + CachedNetworkImage( + imageUrl: dotenv.env['STORAGE_URL']! + (state.plan?['image'] ?? ''), + imageBuilder: (context, imageProvider) => CircleAvatar( + backgroundImage: imageProvider, + radius: 25, ), - child: Column(mainAxisSize: MainAxisSize.min, children: [ - CachedNetworkImage( - imageUrl: dotenv.env['STORAGE_URL']! + - (state.plan?['image'] ?? ''), - imageBuilder: (context, imageProvider) => CircleAvatar( - backgroundImage: imageProvider, - radius: 25, - ), - placeholder: (context, url) => - CircularProgressIndicator(), - errorWidget: (context, url, error) => CircleAvatar( - child: Icon(Icons.person), - backgroundColor: Colors.white, - radius: 25, - ), + placeholder: (context, url) => CircularProgressIndicator(), + errorWidget: (context, url, error) => CircleAvatar( + child: Icon(Icons.person), + backgroundColor: Colors.white, + radius: 25, + ), + ), + SizedBox(height: 16.0), + Text(state.plan?['name'], style: CustomTextStyles.titleMediumBlack), + SizedBox(height: 8.0), + Text( + state.plan?['details'], + ), + SizedBox(height: 16.0), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + ElevatedButton( + onPressed: () { + // Действие для редактирования + }, + child: Text('Редактировать'), ), - SizedBox(height: 16.0), - Text(state.plan?['name'], - style: CustomTextStyles.titleMediumBlack), - SizedBox(height: 8.0), - Text( - state.plan?['details'], + ElevatedButton( + onPressed: () => context.read().add(DeleteEntry(state.plan?['id'])), + child: Text('Удалить'), ), - SizedBox(height: 16.0), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - ElevatedButton( - onPressed: () { - // Действие для редактирования - }, - child: Text('Редактировать'), - ), - ElevatedButton( - onPressed: () => context - .read() - .add(DeleteEntry(state.plan?['id'])), - child: Text('Удалить'), - ), - ], - ) - ]), + ], ) - ], - ), - ), - bottomNavigationBar: _buildBottomBar(context))); - } - - - ///Handling route based on bottom click actions - String getCurrentRoute(BottomBarEnum type) { - switch (type) { - case BottomBarEnum.tf: - return AppRoutes.planScreen; - default: - return "/"; - } + ]), + ) + ], + ), + ), + ), + ); } ///Handling page based on route @@ -142,10 +125,6 @@ class PlanScreen extends StatelessWidget { } } - _buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); - } - /// Navigates to the previous screen. onTapArrowleftone(BuildContext context) { NavigatorService.goBack(); 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 82ddc56b..0f2ac434 100644 --- a/lib/presentation/profile/my_profile_screen/my_settings_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_settings_screen.dart @@ -1,3 +1,5 @@ +import 'package:go_router/go_router.dart'; + import 'bloc/my_profile_bloc.dart'; import 'models/my_profile_model.dart'; import 'package:eatvio_app/core/app_export.dart'; @@ -15,10 +17,7 @@ import 'package:flutter/material.dart'; class MySettingsScreen extends StatelessWidget { static Widget builder(BuildContext context) { return BlocProvider( - create: (context) => - MyProfileBloc(MyProfileState(myProfileModelObj: MyProfileModel())) - ..add(MyProfileInitialEvent()), - child: MySettingsScreen()); + create: (context) => MyProfileBloc(MyProfileState(myProfileModelObj: MyProfileModel()))..add(MyProfileInitialEvent()), child: MySettingsScreen()); } Widget build(BuildContext context) { @@ -42,136 +41,125 @@ class MySettingsScreen extends StatelessWidget { } _buildSetingsScreen(BuildContext context, MyProfileLoadedState state) { - mediaQueryData = MediaQuery.of(context); - - return SafeArea( - child: Scaffold( - backgroundColor: Colors.grey[200], - resizeToAvoidBottomInset: true, - body: SingleChildScrollView( - child: Container( - width: double.maxFinite, - decoration: BoxDecoration(color: Colors.grey[200]), - child: Padding( - padding: EdgeInsets.all(16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - SizedBox(height: 30), - Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: - const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], + return Scaffold( + backgroundColor: Colors.grey[200], + resizeToAvoidBottomInset: true, + body: SingleChildScrollView( + child: Container( + width: double.maxFinite, + decoration: BoxDecoration(color: Colors.grey[200]), + child: Padding( + padding: EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + SizedBox(height: 30), + Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), + ), + ], + ), + child: CustomAppBar( + height: 54.v, + leadingWidth: 28.h, + leading: AppbarLeadingImage( + imagePath: ImageConstant.imgArrowLeft, + margin: EdgeInsets.only(left: 16.h, top: 15.v, bottom: 15.v), + onTap: () => GoRouter.of(context).pop(), ), - child: CustomAppBar( - height: 54.v, - leadingWidth: 28.h, - leading: AppbarLeadingImage( - imagePath: ImageConstant.imgArrowLeft, - margin: EdgeInsets.only( - left: 16.h, top: 15.v, bottom: 15.v), - onTap: onTapBack(context)), - title: Padding( - padding: EdgeInsets.only(left: 20.h), - child: Row(children: [ - AppbarSubtitle( - text: state.user?['name'], - margin: EdgeInsets.only( - left: 80.h, top: 12.v, bottom: 9.v)) - ])), - )), - SizedBox(height: 20), - Container( - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column( - children: [ - SectionTitle('Язык'), - LanguageDropdown(), - ], - ), + title: Padding( + padding: EdgeInsets.only(left: 20.h), + child: Row(children: [AppbarSubtitle(text: state.user?['name'], margin: EdgeInsets.only(left: 80.h, top: 12.v, bottom: 9.v))])), + )), + SizedBox(height: 20), + Container( + padding: EdgeInsets.symmetric( + horizontal: 24.h, + vertical: 12.v, ), - SizedBox(height: 20), - Container( - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column( - children: [ - SectionTitle('Уведомления'), - NotificationSwitch('Уведомление об обновлениях'), - NotificationSwitch('Напоминания о заполнении'), - ], - ), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), + ), + ], ), - SizedBox(height: 20), - Container( - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column( - children: [ - SectionTitle('Дополнительная информация'), - ExpandableList('Персональные данные'), - AboutList('О нас', ['ООО Итвио', '2023-н.в.']), - ], - ), + child: Column( + children: [ + SectionTitle('Язык'), + LanguageDropdown(), + ], ), - ], - ), + ), + SizedBox(height: 20), + Container( + padding: EdgeInsets.symmetric( + horizontal: 24.h, + vertical: 12.v, + ), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), + ), + ], + ), + child: Column( + children: [ + SectionTitle('Уведомления'), + NotificationSwitch('Уведомление об обновлениях'), + NotificationSwitch('Напоминания о заполнении'), + ], + ), + ), + SizedBox(height: 20), + Container( + padding: EdgeInsets.symmetric( + horizontal: 24.h, + vertical: 12.v, + ), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), + ), + ], + ), + child: Column( + children: [ + SectionTitle('Дополнительная информация'), + ExpandableList('Персональные данные'), + AboutList('О нас', ['ООО Итвио', '2023-н.в.']), + ], + ), + ), + ], ), ), ), - bottomNavigationBar: _buildBottomBar(context), ), ); } @@ -182,10 +170,6 @@ class MySettingsScreen extends StatelessWidget { }; } - _buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); - } - onTapArrowLeft(BuildContext context) { NavigatorService.goBack(); } diff --git a/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart b/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart index b663db22..84c484a0 100644 --- a/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart +++ b/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart @@ -11,12 +11,12 @@ import 'package:eatvio_app/widgets/custom_outlined_button.dart'; class RecipeCreateScreen extends StatelessWidget { const RecipeCreateScreen({Key? key}) : super(key: key); + static Widget builder(BuildContext context) { final recipeID = ModalRoute.of(context)!.settings.arguments; return BlocProvider( - create: (context) => RecipeCreateBloc(RecipeCreateState( - recipeModelObj: RecipeCreateModel(recipeID: recipeID.toString()))) - ..add(RecipeCreateInitialEvent()), + create: (context) => + RecipeCreateBloc(RecipeCreateState(recipeModelObj: RecipeCreateModel(recipeID: recipeID.toString())))..add(RecipeCreateInitialEvent()), child: RecipeCreateScreen()); } @@ -52,25 +52,28 @@ class RecipeCreateScreen extends StatelessWidget { } return SafeArea( - child: Scaffold( - resizeToAvoidBottomInset: false, - body: Container( - width: double.maxFinite, - decoration: BoxDecoration(color: Colors.grey[200]), - child: ListView(children: [ - _buldAppBar(context), - SizedBox(height: 20.v), - _buildRecipeInfo(state, context), - SizedBox(height: 20.v), - Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: steps, - ), - SizedBox(height: 20.v), - _buildAdditional(context, state) - ]), - ), - bottomNavigationBar: _buildBottomBar(context))); + child: Scaffold( + resizeToAvoidBottomInset: false, + body: Container( + width: double.maxFinite, + decoration: BoxDecoration(color: Colors.grey[200]), + child: ListView( + children: [ + _buldAppBar(context), + SizedBox(height: 20.v), + _buildRecipeInfo(state, context), + SizedBox(height: 20.v), + Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: steps, + ), + SizedBox(height: 20.v), + _buildAdditional(context, state) + ], + ), + ), + ), + ); } _buldAppBar(BuildContext context) { @@ -337,9 +340,7 @@ _buildAdditional(BuildContext context, RecipeCreateLoadedState state) { ), ), SizedBox(height: 8.0), - Align( - alignment: Alignment.centerLeft, - child: Text("Ссылка на видео (необязательно)")), + Align(alignment: Alignment.centerLeft, child: Text("Ссылка на видео (необязательно)")), CustomTextFormField( controller: state.description, hintText: "YouTube", @@ -361,10 +362,6 @@ _buildAdditional(BuildContext context, RecipeCreateLoadedState state) { ); } -_buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); -} - Function onTapBack(BuildContext context) { return () { onTapArrowLeft(context); diff --git a/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart b/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart index 31a723a9..7785466f 100644 --- a/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart +++ b/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart @@ -8,12 +8,11 @@ import 'package:flutter_dotenv/flutter_dotenv.dart'; class RecipeEditScreen extends StatelessWidget { const RecipeEditScreen({Key? key}) : super(key: key); + static Widget builder(BuildContext context) { final recipeID = ModalRoute.of(context)!.settings.arguments; return BlocProvider( - create: (context) => RecipeEditBloc(RecipeEditState( - recipeModelObj: RecipeEditModel(recipeID: recipeID.toString()))) - ..add(RecipeEditInitialEvent()), + create: (context) => RecipeEditBloc(RecipeEditState(recipeModelObj: RecipeEditModel(recipeID: recipeID.toString())))..add(RecipeEditInitialEvent()), child: RecipeEditScreen()); } @@ -42,42 +41,43 @@ class RecipeEditScreen extends StatelessWidget { _buildRecipeEdit(BuildContext context, RecipeEditLoadedState state) { mediaQueryData = MediaQuery.of(context); return SafeArea( - child: Scaffold( - resizeToAvoidBottomInset: false, - body: Container( - width: double.maxFinite, - decoration: AppDecoration.fillGray, - child: ListView(children: [ - SizedBox(height: 30.v), - Container( - margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, - ), - padding: EdgeInsets.all(12.h), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column(mainAxisSize: MainAxisSize.min, children: [ + child: Scaffold( + resizeToAvoidBottomInset: false, + body: Container( + width: double.maxFinite, + decoration: AppDecoration.fillGray, + child: ListView( + children: [ + SizedBox(height: 30.v), + Container( + margin: EdgeInsets.only( + left: 16.h, + right: 20.h, + bottom: 10.h, + ), + padding: EdgeInsets.all(12.h), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), + ), + ], + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ CachedNetworkImage( - imageUrl: dotenv.env['STORAGE_URL']! + - (state.recipe?['image'] ?? ''), + imageUrl: dotenv.env['STORAGE_URL']! + (state.recipe?['image'] ?? ''), imageBuilder: (context, imageProvider) => CircleAvatar( backgroundImage: imageProvider, radius: 25, ), - placeholder: (context, url) => - CircularProgressIndicator(), + placeholder: (context, url) => CircularProgressIndicator(), errorWidget: (context, url, error) => CircleAvatar( child: Icon(Icons.person), backgroundColor: Colors.white, @@ -102,18 +102,16 @@ class RecipeEditScreen extends StatelessWidget { SizedBox(height: 16.0), // Здесь нужно добавить виджет для загрузки картинки ElevatedButton( - onPressed: () => - context.read().add(EditRecipe()), + onPressed: () => context.read().add(EditRecipe()), child: Text('Сохранить'), ) - ]), - ) - ]), - ), - bottomNavigationBar: _buildBottomBar(context))); + ], + ), + ) + ], + ), + ), + ), + ); } } - -_buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); -} diff --git a/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart b/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart index 0623c053..0b45fda2 100644 --- a/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart +++ b/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart @@ -1,3 +1,5 @@ +import 'package:go_router/go_router.dart'; + import 'bloc/recipe_select_bloc.dart'; import 'models/recipe_select_model.dart'; import 'package:eatvio_app/core/app_export.dart'; @@ -39,75 +41,71 @@ class RecipeSelectScreen extends StatelessWidget { } _buildRecipeScreen(BuildContext context, RecipeSelectLoadedState state) { - mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( - backgroundColor: Colors.grey[200], - resizeToAvoidBottomInset: true, - body: SingleChildScrollView( - child: Container( - width: double.maxFinite, - decoration: BoxDecoration(color: Colors.grey[200]), - child: Padding( - padding: EdgeInsets.all(16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - SizedBox(height: 10), - Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: CustomAppBar( - height: 54.v, - leadingWidth: 28.h, - leading: AppbarLeadingImage( - imagePath: ImageConstant.imgArrowLeft, - margin: EdgeInsets.only( - left: 16.h, top: 15.v, bottom: 15.v), - onTap: onTapBack(context), + return Scaffold( + backgroundColor: Colors.grey[200], + resizeToAvoidBottomInset: true, + body: SingleChildScrollView( + child: Container( + width: double.maxFinite, + decoration: BoxDecoration(color: Colors.grey[200]), + child: Padding( + padding: EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + SizedBox(height: 10), + Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), ), - title: Padding( - padding: EdgeInsets.only(left: 20.h), - child: Row( - children: [ - AppbarSubtitle( - text: "Рецепты", - margin: EdgeInsets.only( - left: 80.h, top: 12.v, bottom: 9.v), - ), - Spacer(), - Padding( - padding: const EdgeInsets.only(right: 20.0), - child: GestureDetector( - onTap: () => Navigator.pushNamed( - context, - AppRoutes.recipeCreateScreen, - ), - child: Icon(Icons.create_outlined)), - ) - ], - ), + ], + ), + child: CustomAppBar( + height: 54.v, + leadingWidth: 28.h, + leading: AppbarLeadingImage( + imagePath: ImageConstant.imgArrowLeft, + margin: EdgeInsets.only( + left: 16.h, top: 15.v, bottom: 15.v), + onTap: () => GoRouter.of(context).pop(), + ), + title: Padding( + padding: EdgeInsets.only(left: 20.h), + child: Row( + children: [ + AppbarSubtitle( + text: "Рецепты", + margin: EdgeInsets.only( + left: 80.h, top: 12.v, bottom: 9.v), + ), + Spacer(), + Padding( + padding: const EdgeInsets.only(right: 20.0), + child: GestureDetector( + onTap: () => Navigator.pushNamed( + context, + AppRoutes.recipeCreateScreen, + ), + child: Icon(Icons.create_outlined)), + ) + ], ), ), ), - SizedBox(height: 20), - _buildRecipeList(context, state), - ], - ), + ), + SizedBox(height: 20), + _buildRecipeList(context, state), + ], ), ), ), - bottomNavigationBar: _buildBottomBar(context), ), ); } @@ -174,10 +172,6 @@ class RecipeSelectScreen extends StatelessWidget { }; } - _buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); - } - onTapArrowLeft(BuildContext context) { NavigatorService.goBack(); } diff --git a/lib/presentation/recipe/recipe_show_screen/recipe_show_screen.dart b/lib/presentation/recipe/recipe_show_screen/recipe_show_screen.dart index ee757764..d250e1f3 100644 --- a/lib/presentation/recipe/recipe_show_screen/recipe_show_screen.dart +++ b/lib/presentation/recipe/recipe_show_screen/recipe_show_screen.dart @@ -8,12 +8,11 @@ import 'package:flutter_dotenv/flutter_dotenv.dart'; class RecipeScreen extends StatelessWidget { const RecipeScreen({Key? key}) : super(key: key); + static Widget builder(BuildContext context) { final recipeID = ModalRoute.of(context)!.settings.arguments; return BlocProvider( - create: (context) => RecipeBloc(RecipeState( - recipeModelObj: RecipeModel(recipeID: recipeID.toString()))) - ..add(RecipeInitialEvent()), + create: (context) => RecipeBloc(RecipeState(recipeModelObj: RecipeModel(recipeID: recipeID.toString())))..add(RecipeInitialEvent()), child: RecipeScreen()); } @@ -42,90 +41,74 @@ class RecipeScreen extends StatelessWidget { _buildRecipe(BuildContext context, RecipeLoadedState state) { mediaQueryData = MediaQuery.of(context); return SafeArea( - child: Scaffold( - resizeToAvoidBottomInset: false, - body: Container( - width: double.maxFinite, - decoration: AppDecoration.fillGray, - child: ListView( - children: [ - SizedBox(height: 30.v), - Container( - margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, + child: Scaffold( + resizeToAvoidBottomInset: false, + body: Container( + width: double.maxFinite, + decoration: AppDecoration.fillGray, + child: ListView( + children: [ + SizedBox(height: 30.v), + Container( + margin: EdgeInsets.only( + left: 16.h, + right: 20.h, + bottom: 10.h, + ), + padding: EdgeInsets.all(12.h), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), ), - padding: EdgeInsets.all(12.h), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], + ], + ), + child: Column(mainAxisSize: MainAxisSize.min, children: [ + CachedNetworkImage( + imageUrl: dotenv.env['STORAGE_URL']! + (state.recipe?['image'] ?? ''), + imageBuilder: (context, imageProvider) => CircleAvatar( + backgroundImage: imageProvider, + radius: 25, ), - child: Column(mainAxisSize: MainAxisSize.min, children: [ - CachedNetworkImage( - imageUrl: dotenv.env['STORAGE_URL']! + - (state.recipe?['image'] ?? ''), - imageBuilder: (context, imageProvider) => CircleAvatar( - backgroundImage: imageProvider, - radius: 25, - ), - placeholder: (context, url) => - CircularProgressIndicator(), - errorWidget: (context, url, error) => CircleAvatar( - child: Icon(Icons.person), - backgroundColor: Colors.white, - radius: 25, - ), + placeholder: (context, url) => CircularProgressIndicator(), + errorWidget: (context, url, error) => CircleAvatar( + child: Icon(Icons.person), + backgroundColor: Colors.white, + radius: 25, + ), + ), + SizedBox(height: 16.0), + Text(state.recipe?['title'], style: CustomTextStyles.titleMediumBlack), + SizedBox(height: 8.0), + Text( + state.recipe?['description'], + ), + SizedBox(height: 16.0), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + ElevatedButton( + onPressed: () => Navigator.pushNamed(context, AppRoutes.recipeEditScreen, arguments: state.recipe?['id'].toString()), + child: Text('Редактировать'), ), - SizedBox(height: 16.0), - Text(state.recipe?['title'], - style: CustomTextStyles.titleMediumBlack), - SizedBox(height: 8.0), - Text( - state.recipe?['description'], + ElevatedButton( + onPressed: () => context.read().add(DeleteEntry(state.recipe?['id'])), + child: Text('Удалить'), ), - SizedBox(height: 16.0), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - ElevatedButton( - onPressed: () => Navigator.pushNamed( - context, AppRoutes.recipeEditScreen, - arguments: state.recipe?['id'].toString()), - child: Text('Редактировать'), - ), - ElevatedButton( - onPressed: () => context - .read() - .add(DeleteEntry(state.recipe?['id'])), - child: Text('Удалить'), - ), - ], - ) - ]), + ], ) - ], - ), - ), - bottomNavigationBar: _buildBottomBar(context))); - } - - ///Handling route based on bottom click actions - String getCurrentRoute(BottomBarEnum type) { - switch (type) { - case BottomBarEnum.tf: - return AppRoutes.recipeScreen; - default: - return "/"; - } + ]), + ) + ], + ), + ), + ), + ); } ///Handling page based on route @@ -141,10 +124,6 @@ class RecipeScreen extends StatelessWidget { } } - _buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); - } - /// Navigates to the previous screen. onTapArrowleftone(BuildContext context) { NavigatorService.goBack(); diff --git a/lib/presentation/registration/language_select_screen/language_select_screen.dart b/lib/presentation/registration/language_select_screen/language_select_screen.dart index 56e644a0..80b3a8bf 100644 --- a/lib/presentation/registration/language_select_screen/language_select_screen.dart +++ b/lib/presentation/registration/language_select_screen/language_select_screen.dart @@ -9,97 +9,104 @@ import 'package:flutter/material.dart'; class LanguageSelectScreen extends StatelessWidget { const LanguageSelectScreen({Key? key}) : super(key: key); + static Widget builder(BuildContext context) { return BlocProvider( - create: (context) => LanguageSelectBloc( - LanguageSelectState(languageSelectModelObj: LanguageSelectModel())) - ..add(LanguageSelectInitialEvent()), - child: LanguageSelectScreen()); + create: (context) => LanguageSelectBloc( + LanguageSelectState( + languageSelectModelObj: LanguageSelectModel(), + ), + )..add(LanguageSelectInitialEvent()), + child: LanguageSelectScreen(), + ); } @override Widget build(BuildContext context) { - mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( - body: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 5.v), - child: Column(children: [ - CustomImageView( - imagePath: ImageConstant.imgLogoEatvio, - height: 50.adaptSize, - width: 50.adaptSize), - SizedBox(height: 20.v), - Container( - height: 16.v, - width: 343.h, + return Scaffold( + body: Container( + width: double.maxFinite, + padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 5.v), + child: Column( + children: [ + CustomImageView(imagePath: ImageConstant.imgLogoEatvio, height: 50.adaptSize, width: 50.adaptSize), + SizedBox(height: 20.v), + Container( + height: 16.v, + width: 343.h, + decoration: BoxDecoration( + color: theme.colorScheme.onPrimary, + borderRadius: BorderRadius.circular(8.h), + border: Border.all( + color: theme.colorScheme.primary, + width: 1.h, + ), + ), + child: ClipRRect( + borderRadius: BorderRadius.circular(8.h), + child: LinearProgressIndicator( + value: 0, + backgroundColor: theme.colorScheme.onPrimary, + valueColor: AlwaysStoppedAnimation(appTheme.blueA400), + ), + ), + ), + SizedBox(height: 20.v), + 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, + ), + ), + Spacer(flex: 36), + BlocSelector( + selector: (state) => state.languageSelectModelObj, + builder: ( + context, + languageSelectModelObj, + ) { + return CustomDropDown( + icon: Container( + margin: EdgeInsets.fromLTRB(30.h, 11.v, 17.h, 11.v), decoration: BoxDecoration( - color: theme.colorScheme.onPrimary, - borderRadius: BorderRadius.circular(8.h), - border: Border.all( - color: theme.colorScheme.primary, width: 1.h)), - child: ClipRRect( - borderRadius: BorderRadius.circular(8.h), - child: LinearProgressIndicator( - value: 0, - backgroundColor: theme.colorScheme.onPrimary, - valueColor: AlwaysStoppedAnimation( - appTheme.blueA400)))), - SizedBox(height: 20.v), - 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)), - Spacer(flex: 36), - BlocSelector( - selector: (state) => state.languageSelectModelObj, - builder: ( - context, - languageSelectModelObj, - ) { - return 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: languageSelectModelObj?.dropdownItemList ?? [], - onChanged: (value) => - _onDropDownChanged(context, value), - ); - }), - Spacer(flex: 63), - ])), - bottomNavigationBar: - BlocBuilder( - builder: (context, state) { - return NextStepButton( - text: "continue".tr.toUpperCase(), - margin: - EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: _saveAndPush(state, context)); - }))); + borderRadius: BorderRadius.circular(1.h), + ), + child: CustomImageView( + imagePath: ImageConstant.imgFavorite, + height: 12.adaptSize, + width: 12.adaptSize, + ), + ), + hintText: "Не выбрано".tr, + items: languageSelectModelObj?.dropdownItemList ?? [], + onChanged: (value) => _onDropDownChanged(context, value), + ); + }), + Spacer(flex: 63), + ], + ), + ), + bottomNavigationBar: BlocBuilder( + builder: (context, state) { + return NextStepButton( + text: "continue".tr.toUpperCase(), + margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), + buttonStyle: CustomButtonStyles.outlinePrimaryTL15, + onPressed: _saveAndPush(state, context), + ); + }, + ), + ); } - void Function()? _saveAndPush( - LanguageSelectState state, BuildContext context) { + void Function()? _saveAndPush(LanguageSelectState state, BuildContext context) { return () { - UserRegistrationSheet sheet = - state.languageSelectModelObj!.userRegistrationSheet; + UserRegistrationSheet sheet = state.languageSelectModelObj!.userRegistrationSheet; Navigator.pushNamed( context, AppRoutes.credentialsScreen, diff --git a/lib/routes/app_routes.dart b/lib/routes/app_routes.dart index 16235b16..d8708717 100644 --- a/lib/routes/app_routes.dart +++ b/lib/routes/app_routes.dart @@ -198,8 +198,8 @@ class AppRoutes { planCreateScreen: (context) => _buildFadeRoute(context, PlanCreateScreen.builder), feedScreen: (context) => _buildFadeRoute(context, FeedScreen.builder), - blogPostScreen: (context) => - _buildFadeRoute(context, BlogPostScreen.builder), + // blogPostScreen: (context) => + // _buildFadeRoute(context, BlogPostScreen.builder), blogPostEditScreen: (context) => _buildFadeRoute(context, BlogPostEditScreen.builder), blogPostCreateScreen: (context) => diff --git a/lib/widgets/custom_bottom_bar.dart b/lib/widgets/custom_bottom_bar.dart index b8e54605..f7ecba52 100644 --- a/lib/widgets/custom_bottom_bar.dart +++ b/lib/widgets/custom_bottom_bar.dart @@ -67,6 +67,7 @@ class _BottomNavigationBarWidgetState extends State { }, selectedFontSize: 12, unselectedFontSize: 12, + selectedItemColor: appTheme.blueA400, currentIndex: currentBottomNavBarIndex, items: [ BottomNavigationBarItem( @@ -76,18 +77,46 @@ class _BottomNavigationBarWidgetState extends State { BottomNavigationBarItem( label: 'Лента', icon: SvgPicture.asset(ImageConstant.imgFeed), + activeIcon: SvgPicture.asset( + ImageConstant.imgFeed, + colorFilter: ColorFilter.mode( + appTheme.blueA400, + BlendMode.srcIn, + ), + ), ), BottomNavigationBarItem( label: "diary".tr, icon: SvgPicture.asset(ImageConstant.imgDiary), + activeIcon: SvgPicture.asset( + ImageConstant.imgDiary, + colorFilter: ColorFilter.mode( + appTheme.blueA400, + BlendMode.srcIn, + ), + ), ), BottomNavigationBarItem( label: "chat".tr, icon: SvgPicture.asset(ImageConstant.imgChat), + activeIcon: SvgPicture.asset( + ImageConstant.imgChat, + colorFilter: ColorFilter.mode( + appTheme.blueA400, + BlendMode.srcIn, + ), + ), ), BottomNavigationBarItem( label: '', icon: SvgPicture.asset(ImageConstant.imgBell), + activeIcon: SvgPicture.asset( + ImageConstant.imgBell, + colorFilter: ColorFilter.mode( + appTheme.blueA400, + BlendMode.srcIn, + ), + ), ), BottomNavigationBarItem( label: '', @@ -102,223 +131,3 @@ class _BottomNavigationBarWidgetState extends State { ); } } - -// ignore: must_be_immutable -class CustomBottomBar extends StatefulWidget { - CustomBottomBar({this.onChanged}); - - Function(BottomBarEnum)? onChanged; - - @override - CustomBottomBarState createState() => CustomBottomBarState(); -} - -class CustomBottomBarState extends State { - int selectedIndex = 2; - - List bottomMenuList = [ - BottomMenuModel( - icon: ImageConstant.imgLogo, - activeIcon: ImageConstant.imgLogo, - type: BottomBarEnum.tf, - image: false, - ), - BottomMenuModel( - icon: ImageConstant.imgFeed, - activeIcon: ImageConstant.imgFeed, - title: "Лента", - type: BottomBarEnum.tf, - image: false, - ), - BottomMenuModel( - icon: ImageConstant.imgDiary, - activeIcon: ImageConstant.imgDiary, - title: "diary".tr, - type: BottomBarEnum.tf, - image: false, - ), - BottomMenuModel( - icon: ImageConstant.imgChat, - activeIcon: ImageConstant.imgChat, - title: "chat".tr, - type: BottomBarEnum.tf, - image: false, - ), - BottomMenuModel( - icon: ImageConstant.imgBell, - activeIcon: ImageConstant.imgBell, - type: BottomBarEnum.tf, - image: false, - ), - BottomMenuModel( - icon: ImageConstant.imgEllipse1, - activeIcon: ImageConstant.imgEllipse1, - type: BottomBarEnum.tf, - image: true, - ), - ]; - - @override - Widget build(BuildContext context) { - return Container( - height: 83.v, - decoration: BoxDecoration( - border: Border.all( - color: appTheme.whiteA700, - width: 1.h, - ), - ), - child: BottomNavigationBar( - backgroundColor: Colors.transparent, - showSelectedLabels: false, - showUnselectedLabels: false, - selectedFontSize: 0, - elevation: 0, - currentIndex: selectedIndex, - type: BottomNavigationBarType.fixed, - items: List.generate(bottomMenuList.length, bottomMenu), - onTap: changeMeny, - ), - ); - } - - void changeMeny(index) { - setState(() { - selectedIndex = index; - }); - - switch (index) { - case 0: - Navigator.pushReplacementNamed(context, AppRoutes.myProfile); - break; - case 1: - Navigator.pushReplacementNamed(context, AppRoutes.feedScreen); - break; - case 2: - Navigator.pushReplacementNamed(context, AppRoutes.diaryEdit); - break; - case 3: - Navigator.pushReplacementNamed(context, AppRoutes.chatSelectScreen); - break; - } - } - - BottomNavigationBarItem bottomMenu(index) { - bool isSelected = selectedIndex == index; - - double iconHeight; - double iconWidth; - - if (index == 0) { - // Для логотипа- - iconHeight = 52.v; // Увеличиваем высоту - iconWidth = 48.h; // Меняем ширину, чтобы сохранить пропорции - } else if (index == bottomMenuList.length - 2) { - // Для колокольчика - iconHeight = 20.v; // Уменьшаем высоту - iconWidth = 20.h; // Меняем ширину, чтобы сохранить пропорции - } else if (index == bottomMenuList.length - 1) { - // Для колокольчика - iconHeight = 40.v; // Уменьшаем высоту - iconWidth = 40.h; // Меняем ширину, чтобы сохранить пропорции - } else { - // Для остальных иконок - iconHeight = 24.v; // Стандартная высота - iconWidth = 19.h; // Стандартная ширина - } - - return BottomNavigationBarItem( - icon: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - if (!bottomMenuList[index].image) - CustomImageView( - imagePath: bottomMenuList[index].icon, - height: iconHeight, - width: iconWidth, - color: isSelected ? theme.colorScheme.primary : appTheme.blueGray400, - ), - if (bottomMenuList[index].image) - GestureDetector( - onTap: () => showMenu( - context: context, - color: Colors.white, - shadowColor: Colors.white, - surfaceTintColor: Colors.white, - position: RelativeRect.fromLTRB( - // Указываем позицию справа по центру - MediaQuery.of(context).size.width - 50, // Расположение от правого края - kToolbarHeight + 340, // Расположение от верхнего края - 0, // Не смещаем по горизонтали - 0, // Не смещаем по вертикали - ), - items: [ - PopupMenuItem( - child: CustomNavigationMenu(), // Используйте ваше меню здесь - ) - ], - ), - child: AppbarTitleCircleimage( - imagePath: ImageConstant.imgEllipse1, - ), - ), - if (bottomMenuList[index].title != null) // Проверяем, существует ли title - Padding( - padding: EdgeInsets.only(top: 8.v), - child: Text( - bottomMenuList[index].title!, - style: CustomTextStyles.bodySmallMulishBluegray80012.copyWith( - color: isSelected ? theme.colorScheme.primary : appTheme.blueGray800, - ), - ), - ), - ], - ), - activeIcon: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - CustomImageView( - imagePath: bottomMenuList[index].activeIcon, - height: iconHeight, // Используем тот же размер для активной иконки - width: iconWidth, // Используем тот же размер для активной иконки - color: theme.colorScheme.primary, - ), - Padding( - padding: EdgeInsets.only(top: 9.v), - child: Text( - bottomMenuList[index].title ?? "", - style: CustomTextStyles.bodySmallMulishPrimary.copyWith( - color: theme.colorScheme.primary, - ), - ), - ), - ], - ), - label: '', - ); - } -} - -enum BottomBarEnum { - tf, -} - -class BottomMenuModel { - BottomMenuModel({ - required this.icon, - required this.activeIcon, - this.title, - required this.type, - required this.image, - }); - - String icon; - - String activeIcon; - - String? title; - - BottomBarEnum type; - - bool image; -} diff --git a/lib/widgets/custom_navigation_menu.dart b/lib/widgets/custom_navigation_menu.dart index 4bbdc758..03d11a98 100644 --- a/lib/widgets/custom_navigation_menu.dart +++ b/lib/widgets/custom_navigation_menu.dart @@ -1,6 +1,7 @@ import 'package:eatvio_app/core/app_export.dart'; import 'package:flutter/material.dart'; import 'package:eatvio_app/widgets/custom_navigation_menu_item.dart'; +import 'package:go_router/go_router.dart'; import 'package:hive/hive.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:http/http.dart' as http; @@ -16,33 +17,30 @@ class CustomNavigationMenu extends StatelessWidget { MenuItem( icon: ImageConstant.imgSettings, text: 'Настройки профиля', - onTap: () => Navigator.pushNamed(context, AppRoutes.mySettings), + onTap: () => GoRouter.of(context).push('/my-settings-screen'), ), MenuItem( icon: ImageConstant.imgRecipes, text: 'Мои рецепты', - onTap: () => - Navigator.pushNamed(context, AppRoutes.recipeSelectScreen), + onTap: () => GoRouter.of(context).push('/recipe-select-screen'), // Действие при нажатии на "Мои рецепты" ), MenuItem( icon: ImageConstant.imgDiets, text: 'Мои диеты', - onTap: () => - Navigator.pushNamed(context, AppRoutes.dietSelectScreen), + onTap: () => GoRouter.of(context).push('/diet-select-screen'), // Действие при нажатии на "Мои рецепты" ), MenuItem( icon: ImageConstant.imgPlans, text: 'Мои планы', - onTap: () => - Navigator.pushNamed(context, AppRoutes.planSelectScreen), + onTap: () => GoRouter.of(context).push('/plan-select-screen'), // Действие при нажатии на "Мои рецепты" ), MenuItem( icon: ImageConstant.imgFinance, text: 'Глоссарий', - onTap: () => Navigator.pushNamed(context, AppRoutes.glossaryScreen), + onTap: () => GoRouter.of(context).push('/glossary-screen'), ), MenuItem( icon: ImageConstant.imgSupport, @@ -77,10 +75,7 @@ _onTapLogout(BuildContext context) { if (response.statusCode == 204) { print(response.statusCode); box.delete('token'); // Удаляем токен из Hive - Navigator.pushNamed( - context, - AppRoutes.authScreen, - ); + GoRouter.of(context).go('/auth-screen'); } }; } From 60c372fb4cca0539dad772290e6fa056ddb39ca6 Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Wed, 5 Jun 2024 12:53:38 +0300 Subject: [PATCH 5/7] fix warnings --- lib/app_router.dart | 2 +- .../chat/chat_screen/chat_screen.dart | 57 ------------------- .../diet_create_screen.dart | 1 - .../diet_edit_screen/diet_edit_screen.dart | 1 - .../diet_select_screen.dart | 1 - .../diet_show_screen/diet_show_screen.dart | 1 - .../blog_post_edit_screen.dart | 1 - .../glossary_screen/glossary_screen.dart | 1 - .../plan_create_screen.dart | 1 - .../plan_edit_screen/plan_edit_screen.dart | 1 - .../plan_select_screen.dart | 1 - .../plan_show_screen/plan_show_screen.dart | 1 - .../my_profile_screen/my_settings_screen.dart | 1 - .../recipe_create_screen.dart | 1 - .../recipe_edit_screen.dart | 1 - .../recipe_select_screen.dart | 1 - .../recipe_show_screen.dart | 1 - lib/routes/app_routes.dart | 1 - ...dart => bottom_navigation_bar_widget.dart} | 1 - 19 files changed, 1 insertion(+), 75 deletions(-) rename lib/widgets/{custom_bottom_bar.dart => bottom_navigation_bar_widget.dart} (98%) diff --git a/lib/app_router.dart b/lib/app_router.dart index 255df7aa..a7de9889 100644 --- a/lib/app_router.dart +++ b/lib/app_router.dart @@ -11,7 +11,7 @@ import 'package:eatvio_app/presentation/profile/my_profile_screen/my_profile_scr import 'package:eatvio_app/presentation/profile/my_profile_screen/my_settings_screen.dart'; import 'package:eatvio_app/presentation/recipe/recipe_select_screen/recipe_select_screen.dart'; import 'package:eatvio_app/presentation/registration/language_select_screen/language_select_screen.dart'; -import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; +import 'package:eatvio_app/widgets/bottom_navigation_bar_widget.dart'; import 'package:go_router/go_router.dart'; import 'package:hive_flutter/hive_flutter.dart'; diff --git a/lib/presentation/chat/chat_screen/chat_screen.dart b/lib/presentation/chat/chat_screen/chat_screen.dart index a132f880..7ec3ea67 100644 --- a/lib/presentation/chat/chat_screen/chat_screen.dart +++ b/lib/presentation/chat/chat_screen/chat_screen.dart @@ -6,8 +6,6 @@ import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_title_image.dart'; -import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; -import 'package:eatvio_app/widgets/custom_text_form_field.dart'; class ChatScreen extends StatelessWidget { const ChatScreen({Key? key}) : super(key: key); @@ -104,61 +102,6 @@ class ChatScreen extends StatelessWidget { ); } - /// Section Widget - _buildTextField(BuildContext context) { - return Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric( - horizontal: 7.h, - vertical: 6.v, - ), - decoration: AppDecoration.outlineBlueGray, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CustomImageView( - imagePath: ImageConstant.imgAttach, - height: 29.adaptSize, - width: 29.adaptSize, - margin: EdgeInsets.only( - top: 1.v, - bottom: 6.v, - ), - ), - Expanded( - child: Padding( - padding: EdgeInsets.only( - left: 4.h, - bottom: 4.v, - ), - child: BlocSelector( - selector: (state) => TextEditingController(), - builder: (context, messageController) { - return CustomTextFormField( - controller: messageController, - hintText: "Напишите сообщение...", - textInputAction: TextInputAction.done, - ); - }, - ), - ), - ), - CustomImageView( - imagePath: ImageConstant.imgMic, - height: 24.v, - width: 18.h, - margin: EdgeInsets.only( - left: 11.h, - top: 4.v, - bottom: 8.v, - ), - ) - ], - ), - ); - } - ///Handling page based on route Widget getCurrentPage( BuildContext context, diff --git a/lib/presentation/diets/diet_create_screen/diet_create_screen.dart b/lib/presentation/diets/diet_create_screen/diet_create_screen.dart index eae238b7..516a9312 100644 --- a/lib/presentation/diets/diet_create_screen/diet_create_screen.dart +++ b/lib/presentation/diets/diet_create_screen/diet_create_screen.dart @@ -2,7 +2,6 @@ import 'bloc/diet_create_bloc.dart'; import 'models/diet_create_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:flutter/material.dart'; -import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; class DietCreateScreen extends StatelessWidget { const DietCreateScreen({Key? key}) : super(key: key); diff --git a/lib/presentation/diets/diet_edit_screen/diet_edit_screen.dart b/lib/presentation/diets/diet_edit_screen/diet_edit_screen.dart index 665927b1..a0f988d1 100644 --- a/lib/presentation/diets/diet_edit_screen/diet_edit_screen.dart +++ b/lib/presentation/diets/diet_edit_screen/diet_edit_screen.dart @@ -2,7 +2,6 @@ import 'bloc/diet_edit_bloc.dart'; import 'models/diet_edit_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:flutter/material.dart'; -import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; diff --git a/lib/presentation/diets/diet_select_screen/diet_select_screen.dart b/lib/presentation/diets/diet_select_screen/diet_select_screen.dart index 207cbb6d..e573be6b 100644 --- a/lib/presentation/diets/diet_select_screen/diet_select_screen.dart +++ b/lib/presentation/diets/diet_select_screen/diet_select_screen.dart @@ -6,7 +6,6 @@ import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart'; 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:cached_network_image/cached_network_image.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter/material.dart'; diff --git a/lib/presentation/diets/diet_show_screen/diet_show_screen.dart b/lib/presentation/diets/diet_show_screen/diet_show_screen.dart index d05a39a8..a15c8f64 100644 --- a/lib/presentation/diets/diet_show_screen/diet_show_screen.dart +++ b/lib/presentation/diets/diet_show_screen/diet_show_screen.dart @@ -2,7 +2,6 @@ import 'bloc/diet_show_bloc.dart'; import 'models/diet_show_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:flutter/material.dart'; -import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; diff --git a/lib/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart b/lib/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart index ac5a8338..cd3ad78f 100644 --- a/lib/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart +++ b/lib/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart @@ -2,7 +2,6 @@ import 'bloc/blog_post_edit_bloc.dart'; import 'models/blog_post_edit_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:flutter/material.dart'; -import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; diff --git a/lib/presentation/glossary/glossary_screen/glossary_screen.dart b/lib/presentation/glossary/glossary_screen/glossary_screen.dart index 42b84775..ebfa70d2 100644 --- a/lib/presentation/glossary/glossary_screen/glossary_screen.dart +++ b/lib/presentation/glossary/glossary_screen/glossary_screen.dart @@ -4,7 +4,6 @@ import 'package:eatvio_app/core/app_export.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; -import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; import 'package:eatvio_app/widgets/custom_outlined_button.dart'; import 'package:eatvio_app/widgets/custom_drop_down.dart'; import 'package:eatvio_app/presentation/glossary/glossary_screen/widgets/glossary_search_widget.dart'; diff --git a/lib/presentation/plans/plan_create_screen/plan_create_screen.dart b/lib/presentation/plans/plan_create_screen/plan_create_screen.dart index 9ab5cada..bd354af0 100644 --- a/lib/presentation/plans/plan_create_screen/plan_create_screen.dart +++ b/lib/presentation/plans/plan_create_screen/plan_create_screen.dart @@ -2,7 +2,6 @@ import 'bloc/plan_create_bloc.dart'; import 'models/plan_create_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:flutter/material.dart'; -import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; class PlanCreateScreen extends StatelessWidget { const PlanCreateScreen({Key? key}) : super(key: key); diff --git a/lib/presentation/plans/plan_edit_screen/plan_edit_screen.dart b/lib/presentation/plans/plan_edit_screen/plan_edit_screen.dart index c163f2c7..7baa33d2 100644 --- a/lib/presentation/plans/plan_edit_screen/plan_edit_screen.dart +++ b/lib/presentation/plans/plan_edit_screen/plan_edit_screen.dart @@ -2,7 +2,6 @@ import 'bloc/plan_edit_bloc.dart'; import 'models/plan_edit_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:flutter/material.dart'; -import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; diff --git a/lib/presentation/plans/plan_select_screen/plan_select_screen.dart b/lib/presentation/plans/plan_select_screen/plan_select_screen.dart index a82a6679..78ac405f 100644 --- a/lib/presentation/plans/plan_select_screen/plan_select_screen.dart +++ b/lib/presentation/plans/plan_select_screen/plan_select_screen.dart @@ -6,7 +6,6 @@ import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart'; 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:cached_network_image/cached_network_image.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter/material.dart'; diff --git a/lib/presentation/plans/plan_show_screen/plan_show_screen.dart b/lib/presentation/plans/plan_show_screen/plan_show_screen.dart index 8e2f2431..262f876b 100644 --- a/lib/presentation/plans/plan_show_screen/plan_show_screen.dart +++ b/lib/presentation/plans/plan_show_screen/plan_show_screen.dart @@ -2,7 +2,6 @@ import 'bloc/plan_show_bloc.dart'; import 'models/plan_show_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:flutter/material.dart'; -import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; 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 0f2ac434..501ffcac 100644 --- a/lib/presentation/profile/my_profile_screen/my_settings_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_settings_screen.dart @@ -6,7 +6,6 @@ import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart'; 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_about_list.dart'; import 'package:eatvio_app/widgets/custom_expandable_list.dart'; import 'package:eatvio_app/widgets/custom_notification_screen.dart'; diff --git a/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart b/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart index 84c484a0..88654074 100644 --- a/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart +++ b/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart @@ -5,7 +5,6 @@ import 'package:flutter/material.dart'; import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.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/custom_outlined_button.dart'; diff --git a/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart b/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart index 7785466f..9ee0075f 100644 --- a/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart +++ b/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart @@ -2,7 +2,6 @@ import 'bloc/recipe_edit_bloc.dart'; import 'models/recipe_edit_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:flutter/material.dart'; -import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; diff --git a/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart b/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart index 0b45fda2..f72ca514 100644 --- a/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart +++ b/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart @@ -6,7 +6,6 @@ import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart'; 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:cached_network_image/cached_network_image.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter/material.dart'; diff --git a/lib/presentation/recipe/recipe_show_screen/recipe_show_screen.dart b/lib/presentation/recipe/recipe_show_screen/recipe_show_screen.dart index d250e1f3..4bdea28d 100644 --- a/lib/presentation/recipe/recipe_show_screen/recipe_show_screen.dart +++ b/lib/presentation/recipe/recipe_show_screen/recipe_show_screen.dart @@ -2,7 +2,6 @@ import 'bloc/recipe_show_bloc.dart'; import 'models/recipe_show_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:flutter/material.dart'; -import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; diff --git a/lib/routes/app_routes.dart b/lib/routes/app_routes.dart index d8708717..fd656020 100644 --- a/lib/routes/app_routes.dart +++ b/lib/routes/app_routes.dart @@ -35,7 +35,6 @@ import 'package:eatvio_app/presentation/plans/plan_show_screen/plan_show_screen. import 'package:eatvio_app/presentation/recipe/recipe_show_screen/recipe_show_screen.dart'; import 'package:eatvio_app/presentation/recipe/recipe_create_screen/recipe_create_screen.dart'; import 'package:eatvio_app/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart'; -import 'package:eatvio_app/presentation/feed/blog_post_screen/blog_post_screen.dart'; import 'package:eatvio_app/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart'; import 'package:eatvio_app/presentation/feed/blog_post_create_screen/blog_post_create_screen.dart'; import 'package:eatvio_app/presentation/glossary/glossary_screen/glossary_screen.dart'; diff --git a/lib/widgets/custom_bottom_bar.dart b/lib/widgets/bottom_navigation_bar_widget.dart similarity index 98% rename from lib/widgets/custom_bottom_bar.dart rename to lib/widgets/bottom_navigation_bar_widget.dart index f7ecba52..dbf9ba2b 100644 --- a/lib/widgets/custom_bottom_bar.dart +++ b/lib/widgets/bottom_navigation_bar_widget.dart @@ -1,6 +1,5 @@ import 'package:eatvio_app/core/app_export.dart'; import 'package:flutter/material.dart'; -import 'package:eatvio_app/widgets/app_bar/appbar_title_circleimage.dart'; import 'package:eatvio_app/widgets/custom_navigation_menu.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:go_router/go_router.dart'; From bd88d8003481ee66f87df42423bc6c72b0e3722c Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Wed, 5 Jun 2024 13:13:35 +0300 Subject: [PATCH 6/7] fix style warning --- lib/widgets/bottom_navigation_bar_widget.dart | 80 ++++++++++--------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/lib/widgets/bottom_navigation_bar_widget.dart b/lib/widgets/bottom_navigation_bar_widget.dart index dbf9ba2b..6f29ef34 100644 --- a/lib/widgets/bottom_navigation_bar_widget.dart +++ b/lib/widgets/bottom_navigation_bar_widget.dart @@ -19,51 +19,53 @@ class BottomNavigationBarWidget extends StatefulWidget { } class _BottomNavigationBarWidgetState extends State { + void _onItemTapped(int index) { + if (currentBottomNavBarIndex != index) { + setState(() { + currentBottomNavBarIndex = index; + }); + } + switch (currentBottomNavBarIndex) { + case 0: + GoRouter.of(context).replace('/my-profile-screen'); + break; + case 1: + GoRouter.of(context).replace('/feed-screen'); + break; + case 2: + GoRouter.of(context).replace('/diary-screen'); + break; + case 3: + GoRouter.of(context).replace('/chat-select-screen'); + break; + case 4: + break; + case 5: + final RenderBox overlay = Overlay.of(context).context.findRenderObject() as RenderBox; + final size = overlay.size; + showMenu( + context: context, + color: Colors.white, + shadowColor: Colors.white, + surfaceTintColor: Colors.white, + items: [ + PopupMenuItem( + child: CustomNavigationMenu(), + ) + ], + position: RelativeRect.fromLTRB(size.width, size.height, 0, 0), + ); + break; + } + } + @override Widget build(BuildContext context) { return Scaffold( body: widget.child, bottomNavigationBar: BottomNavigationBar( type: BottomNavigationBarType.fixed, - onTap: (index) { - if (currentBottomNavBarIndex != index) { - setState(() { - currentBottomNavBarIndex = index; - }); - } - switch (currentBottomNavBarIndex) { - case 0: - GoRouter.of(context).replace('/my-profile-screen'); - break; - case 1: - GoRouter.of(context).replace('/feed-screen'); - break; - case 2: - GoRouter.of(context).replace('/diary-screen'); - break; - case 3: - GoRouter.of(context).replace('/chat-select-screen'); - break; - case 4: - break; - case 5: - final RenderBox overlay = Overlay.of(context).context.findRenderObject() as RenderBox; - final size = overlay.size; - showMenu( - context: context, - color: Colors.white, - shadowColor: Colors.white, - surfaceTintColor: Colors.white, - items: [ - PopupMenuItem( - child: CustomNavigationMenu(), - ) - ], - position: RelativeRect.fromLTRB(size.width, size.height, 0, 0), - ); - break; - } - }, + onTap: _onItemTapped, selectedFontSize: 12, unselectedFontSize: 12, selectedItemColor: appTheme.blueA400, From fc743727c2caac74baec4703dcfcfa0daae9b438 Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Wed, 5 Jun 2024 13:23:02 +0300 Subject: [PATCH 7/7] fix style! warning --- .../my_profile_screen/my_profile_screen.dart | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart index 3bfb6cc8..52969177 100644 --- a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart @@ -70,23 +70,24 @@ class MyProfileScreen extends StatelessWidget { children: [ SizedBox(height: 30.v), Container( - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: _buildInfo(context, state)), + padding: EdgeInsets.symmetric( + horizontal: 24.h, + vertical: 12.v, + ), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(12)), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), + ), + ], + ), + child: _buildInfo(context, state), + ), SizedBox(height: 15.v), Container( padding: EdgeInsets.symmetric( @@ -141,7 +142,7 @@ class MyProfileScreen extends StatelessWidget { } /// Section Widget - Widget _buildInfo(BuildContext context, MyProfileLoadedState state) { + _buildInfo(BuildContext context, MyProfileLoadedState state) { return Column( children: [ GestureDetector(