From 795dc48629733b1d081058e468bc12936b335066 Mon Sep 17 00:00:00 2001 From: maxxkim Date: Mon, 3 Jun 2024 16:00:48 +0300 Subject: [PATCH 1/5] feat(app): SafeArea insets refactoring --- .DS_Store | Bin 8196 -> 8196 bytes lib/core/app_export.dart | 1 - .../chat_select_screen.dart | 9 ++--- .../diary_edit_screen/diary_edit_screen.dart | 9 ++--- .../diet_create_screen.dart | 11 +++--- .../diet_edit_screen/diet_edit_screen.dart | 11 +++--- .../diet_select_screen.dart | 8 ++-- .../diet_show_screen/diet_show_screen.dart | 8 ++-- .../blog_post_create_screen.dart | 9 ++--- .../blog_post_edit_screen.dart | 9 ++--- .../blog_post_screen/blog_post_screen.dart | 37 +++++++++--------- .../feed/feed_screen/feed_screen.dart | 10 ++--- .../plan_create_screen.dart | 9 ++--- .../plan_edit_screen/plan_edit_screen.dart | 11 +++--- .../plan_select_screen.dart | 10 ++--- .../plan_show_screen/plan_show_screen.dart | 8 ++-- .../bloc/my_profile_bloc.dart | 4 ++ .../my_profile_screen/my_profile_screen.dart | 14 +++---- .../my_profile_screen/my_settings_screen.dart | 10 ++--- .../recipe_create_screen.dart | 11 +++--- .../recipe_edit_screen.dart | 11 +++--- .../recipe_select_screen.dart | 10 ++--- .../recipe_show_screen.dart | 8 ++-- lib/routes/app_routes.dart | 2 + lib/widgets/app_bar/appbar_subtitle.dart | 5 --- lib/widgets/custom_bottom_bar.dart | 28 ++++++------- 26 files changed, 121 insertions(+), 142 deletions(-) diff --git a/.DS_Store b/.DS_Store index bad9d0d2c3d8feb19a94decc095769ce626a0d6a..506ab56a1bbab76b0cc160948fb2d34d83b3f3f7 100644 GIT binary patch delta 20 bcmZp1XmQx!D9CPVsiR*llyWU@ad2FmDA; diff --git a/lib/core/app_export.dart b/lib/core/app_export.dart index 6d115305..6c17ee13 100644 --- a/lib/core/app_export.dart +++ b/lib/core/app_export.dart @@ -1,4 +1,3 @@ -export 'package:connectivity_plus/connectivity_plus.dart'; export 'package:flutter_bloc/flutter_bloc.dart'; export 'package:eatvio_app/core/constants/constants.dart'; export 'package:eatvio_app/core/errors/exceptions.dart'; 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..6304ca29 100644 --- a/lib/presentation/chat/chat_select_screen/chat_select_screen.dart +++ b/lib/presentation/chat/chat_select_screen/chat_select_screen.dart @@ -41,15 +41,14 @@ class ChatSelectScreen extends StatelessWidget { _buildScreen(BuildContext context, ChatSelectLoadedState state) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( + return Scaffold( resizeToAvoidBottomInset: false, - body: Container( + body: SafeArea( + child: Container( width: double.maxFinite, decoration: AppDecoration.fillGray, child: ListView( children: [ - SizedBox(height: 30.v), Container( margin: EdgeInsets.only( left: 16.h, @@ -84,7 +83,7 @@ class ChatSelectScreen extends StatelessWidget { ], ), ), - bottomNavigationBar: _buildBottomBar(context))); + ), bottomNavigationBar: _buildBottomBar(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 1e81c626..0bef582e 100644 --- a/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart +++ b/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart @@ -61,11 +61,11 @@ class DiaryEditScreen extends StatelessWidget { child: Stack( children: [ FormBuilder( - child: SafeArea( - child: Scaffold( + child: Scaffold( backgroundColor: Color.fromARGB(255, 240, 242, 245), resizeToAvoidBottomInset: true, - body: SizedBox( + body: SafeArea( + child: SizedBox( width: double.maxFinite, child: Column( children: [ @@ -94,9 +94,8 @@ class DiaryEditScreen extends StatelessWidget { ], ), ), - bottomNavigationBar: _buildBottomBar(context), ), - ), + bottomNavigationBar: _buildBottomBar(context) ), ), Positioned( left: 16.h, 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..0ba49889 100644 --- a/lib/presentation/diets/diet_create_screen/diet_create_screen.dart +++ b/lib/presentation/diets/diet_create_screen/diet_create_screen.dart @@ -39,14 +39,13 @@ class DietCreateScreen extends StatelessWidget { _buildDietCreate(BuildContext context, DietCreateLoadedState state) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( + return Scaffold( resizeToAvoidBottomInset: false, - body: Container( + body: SafeArea( + child: Container( width: double.maxFinite, decoration: AppDecoration.fillGray, - child: ListView(children: [ - SizedBox(height: 30.v), + child: ListView(children: [ Container( margin: EdgeInsets.only( left: 16.h, @@ -88,7 +87,7 @@ class DietCreateScreen extends StatelessWidget { ) ]), ), - bottomNavigationBar: _buildBottomBar(context))); + ), bottomNavigationBar: _buildBottomBar(context)); } } 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..0a9ef1c9 100644 --- a/lib/presentation/diets/diet_edit_screen/diet_edit_screen.dart +++ b/lib/presentation/diets/diet_edit_screen/diet_edit_screen.dart @@ -41,14 +41,13 @@ class DietEditScreen extends StatelessWidget { _buildDietEdit(BuildContext context, DietEditLoadedState state) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( + return Scaffold( resizeToAvoidBottomInset: false, - body: Container( + body: SafeArea( + child: Container( width: double.maxFinite, decoration: AppDecoration.fillGray, - child: ListView(children: [ - SizedBox(height: 30.v), + child: ListView(children: [ Container( margin: EdgeInsets.only( left: 16.h, @@ -105,7 +104,7 @@ class DietEditScreen extends StatelessWidget { ) ]), ), - bottomNavigationBar: _buildBottomBar(context))); + ), bottomNavigationBar: _buildBottomBar(context)); } } 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..38670d37 100644 --- a/lib/presentation/diets/diet_select_screen/diet_select_screen.dart +++ b/lib/presentation/diets/diet_select_screen/diet_select_screen.dart @@ -40,11 +40,11 @@ class DietSelectScreen extends StatelessWidget { _buildSetingsScreen(BuildContext context, DietSelectLoadedState state) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( + return Scaffold( backgroundColor: Colors.grey[200], resizeToAvoidBottomInset: true, - body: SingleChildScrollView( + body: SafeArea( + child: SingleChildScrollView( child: Container( width: double.maxFinite, decoration: BoxDecoration(color: Colors.grey[200]), @@ -107,8 +107,8 @@ class DietSelectScreen extends StatelessWidget { ), ), ), - bottomNavigationBar: _buildBottomBar(context), ), + bottomNavigationBar: _buildBottomBar(context), ); } 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..5922a358 100644 --- a/lib/presentation/diets/diet_show_screen/diet_show_screen.dart +++ b/lib/presentation/diets/diet_show_screen/diet_show_screen.dart @@ -41,10 +41,10 @@ class DietScreen extends StatelessWidget { _buildDiet(BuildContext context, DietLoadedState state) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( + return Scaffold( resizeToAvoidBottomInset: false, - body: Container( + body: SafeArea( + child: Container( width: double.maxFinite, decoration: AppDecoration.fillGray, child: ListView( @@ -117,7 +117,7 @@ class DietScreen extends StatelessWidget { ], ), ), - bottomNavigationBar: _buildBottomBar(context))); + ), bottomNavigationBar: _buildBottomBar(context)); } ///Handling route based on bottom click actions 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 6950af55..c1c5514a 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 @@ -40,14 +40,13 @@ class BlogPostCreateScreen extends StatelessWidget { _buildBlogPostCreate(BuildContext context, BlogPostCreateLoadedState state) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( + return Scaffold( resizeToAvoidBottomInset: false, - body: Container( + body: SafeArea( + child: Container( width: double.maxFinite, decoration: AppDecoration.fillGray, child: ListView(children: [ - SizedBox(height: 30.v), Container( margin: EdgeInsets.only( left: 16.h, @@ -95,7 +94,7 @@ class BlogPostCreateScreen extends StatelessWidget { ) ]), ), - bottomNavigationBar: _buildBottomBar(context))); + ), bottomNavigationBar: _buildBottomBar(context)); } } 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..20988195 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 @@ -42,14 +42,13 @@ class BlogPostEditScreen extends StatelessWidget { _buildBlogPostEdit(BuildContext context, BlogPostEditLoadedState state) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( + return Scaffold( resizeToAvoidBottomInset: false, - body: Container( + body: SafeArea( + child: Container( width: double.maxFinite, decoration: AppDecoration.fillGray, child: ListView(children: [ - SizedBox(height: 30.v), Container( margin: EdgeInsets.only( left: 16.h, @@ -111,7 +110,7 @@ class BlogPostEditScreen extends StatelessWidget { ) ]), ), - bottomNavigationBar: _buildBottomBar(context))); + ), bottomNavigationBar: _buildBottomBar(context)); } } 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..c974e81f 100644 --- a/lib/presentation/feed/blog_post_screen/blog_post_screen.dart +++ b/lib/presentation/feed/blog_post_screen/blog_post_screen.dart @@ -46,26 +46,25 @@ class BlogPostScreen extends StatelessWidget { _buildBlogPost(BuildContext context, BlogPostLoadedState state) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( + return 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))); + body: SafeArea( + child: Container( + width: double.maxFinite, + decoration: AppDecoration.fillGray, + child: ListView( + children: [ + _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)); } _buildHeaderRow(BuildContext context, BlogPostLoadedState state) { diff --git a/lib/presentation/feed/feed_screen/feed_screen.dart b/lib/presentation/feed/feed_screen/feed_screen.dart index a7cd48fe..fdeff779 100644 --- a/lib/presentation/feed/feed_screen/feed_screen.dart +++ b/lib/presentation/feed/feed_screen/feed_screen.dart @@ -40,11 +40,11 @@ class FeedScreen extends StatelessWidget { _buildFeedScreen(BuildContext context, FeedLoadedState state) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( + return Scaffold( backgroundColor: Colors.grey[200], resizeToAvoidBottomInset: true, - body: SingleChildScrollView( + body: SafeArea( + child: SingleChildScrollView( child: Container( width: double.maxFinite, decoration: BoxDecoration(color: Colors.grey[200]), @@ -53,7 +53,6 @@ class FeedScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - SizedBox(height: 20), _buildSearch(), SizedBox(height: 20), _buildMenu(context, state), @@ -64,9 +63,8 @@ class FeedScreen extends StatelessWidget { ), ), ), - bottomNavigationBar: _buildBottomBar(context), ), - ); + bottomNavigationBar: _buildBottomBar(context),); } _buildSearch() { 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..bc871c62 100644 --- a/lib/presentation/plans/plan_create_screen/plan_create_screen.dart +++ b/lib/presentation/plans/plan_create_screen/plan_create_screen.dart @@ -39,14 +39,13 @@ class PlanCreateScreen extends StatelessWidget { _buildPlanCreate(BuildContext context, PlanCreateLoadedState state) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( + return Scaffold( resizeToAvoidBottomInset: false, - body: Container( + body: SafeArea( + child: Container( width: double.maxFinite, decoration: AppDecoration.fillGray, child: ListView(children: [ - SizedBox(height: 30.v), Container( margin: EdgeInsets.only( left: 16.h, @@ -88,7 +87,7 @@ class PlanCreateScreen extends StatelessWidget { ) ]), ), - bottomNavigationBar: _buildBottomBar(context))); + ), bottomNavigationBar: _buildBottomBar(context)); } } 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..b4cef923 100644 --- a/lib/presentation/plans/plan_edit_screen/plan_edit_screen.dart +++ b/lib/presentation/plans/plan_edit_screen/plan_edit_screen.dart @@ -41,14 +41,13 @@ class PlanEditScreen extends StatelessWidget { _buildPlanEdit(BuildContext context, PlanEditLoadedState state) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( + return Scaffold( resizeToAvoidBottomInset: false, - body: Container( + body: SafeArea( + child: Container( width: double.maxFinite, decoration: AppDecoration.fillGray, - child: ListView(children: [ - SizedBox(height: 30.v), + child: ListView(children: [ Container( margin: EdgeInsets.only( left: 16.h, @@ -105,7 +104,7 @@ class PlanEditScreen extends StatelessWidget { ) ]), ), - bottomNavigationBar: _buildBottomBar(context))); + ), bottomNavigationBar: _buildBottomBar(context)); } } 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..586f6a5e 100644 --- a/lib/presentation/plans/plan_select_screen/plan_select_screen.dart +++ b/lib/presentation/plans/plan_select_screen/plan_select_screen.dart @@ -40,11 +40,11 @@ class PlanSelectScreen extends StatelessWidget { _buildSetingsScreen(BuildContext context, PlanSelectLoadedState state) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( + return Scaffold( backgroundColor: Colors.grey[200], resizeToAvoidBottomInset: true, - body: SingleChildScrollView( + body: SafeArea( + child: SingleChildScrollView( child: Container( width: double.maxFinite, decoration: BoxDecoration(color: Colors.grey[200]), @@ -106,9 +106,9 @@ class PlanSelectScreen extends StatelessWidget { ), ), ), - ), - bottomNavigationBar: _buildBottomBar(context), + ), ), + bottomNavigationBar: _buildBottomBar(context), ); } 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..eb91c2b8 100644 --- a/lib/presentation/plans/plan_show_screen/plan_show_screen.dart +++ b/lib/presentation/plans/plan_show_screen/plan_show_screen.dart @@ -41,10 +41,10 @@ class PlanScreen extends StatelessWidget { _buildPlan(BuildContext context, PlanLoadedState state) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( + return Scaffold( resizeToAvoidBottomInset: false, - body: Container( + body: SafeArea( + child: Container( width: double.maxFinite, decoration: AppDecoration.fillGray, child: ListView( @@ -115,7 +115,7 @@ class PlanScreen extends StatelessWidget { ], ), ), - bottomNavigationBar: _buildBottomBar(context))); + ), bottomNavigationBar: _buildBottomBar(context)); } diff --git a/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart b/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart index b0359fd1..baf7cdcd 100644 --- a/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart +++ b/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart @@ -48,6 +48,10 @@ class MyProfileBloc extends Bloc { data.containsKey('userDetails') && data.containsKey('chartPoints') && data.containsKey('circumferences')) { + final avatarBox = await Hive.openBox('avatar'); + final avatar = data['user']['profile_photo_path']; + print(avatar); + avatarBox.put('avatar', avatar); if (state is MyProfileLoadedState) { var currentState = state as MyProfileLoadedState; var plans = [] 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..08c3a9c5 100644 --- a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart @@ -50,18 +50,17 @@ class MyProfileScreen extends StatelessWidget { _buildMyProfileScreen(BuildContext context, MyProfileLoadedState state) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( + return Scaffold( backgroundColor: Colors.grey[200], resizeToAvoidBottomInset: true, - body: SingleChildScrollView( + body: SafeArea( + child: 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, @@ -134,8 +133,7 @@ class MyProfileScreen extends StatelessWidget { .toList(), )), SizedBox(height: 5.v), - ])))), - bottomNavigationBar: _buildBottomBar(context))); + ]))))), bottomNavigationBar: _buildBottomBar(context)); } /// Section Widget @@ -166,8 +164,7 @@ class MyProfileScreen extends StatelessWidget { ); } - addImage(BuildContext context) { - return () async { + addImage(BuildContext context) async { final picker = ImagePicker(); List? images = await picker.pickMultiImage(); if (images.isNotEmpty) { @@ -175,7 +172,6 @@ class MyProfileScreen extends StatelessWidget { context.read().add(UploadAvatar(image)); } } - }; } onTapSettings(BuildContext context) { 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..df45cdb9 100644 --- a/lib/presentation/profile/my_profile_screen/my_settings_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_settings_screen.dart @@ -44,11 +44,11 @@ class MySettingsScreen extends StatelessWidget { _buildSetingsScreen(BuildContext context, MyProfileLoadedState state) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( + return Scaffold( backgroundColor: Colors.grey[200], resizeToAvoidBottomInset: true, - body: SingleChildScrollView( + body: SafeArea( + child: SingleChildScrollView( child: Container( width: double.maxFinite, decoration: BoxDecoration(color: Colors.grey[200]), @@ -170,9 +170,9 @@ class MySettingsScreen extends StatelessWidget { ), ), ), - ), - bottomNavigationBar: _buildBottomBar(context), + ), ), + bottomNavigationBar: _buildBottomBar(context), ); } 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 82d2bd9a..fc37aa30 100644 --- a/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart +++ b/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart @@ -39,14 +39,13 @@ class RecipeCreateScreen extends StatelessWidget { _buildRecipeCreate(BuildContext context, RecipeCreateLoadedState state) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( + return Scaffold( resizeToAvoidBottomInset: false, - body: Container( + body: SafeArea( + child: Container( width: double.maxFinite, decoration: AppDecoration.fillGray, - child: ListView(children: [ - SizedBox(height: 30.v), + child: ListView(children: [ Container( margin: EdgeInsets.only( left: 16.h, @@ -93,7 +92,7 @@ class RecipeCreateScreen extends StatelessWidget { ) ]), ), - bottomNavigationBar: _buildBottomBar(context))); + ), bottomNavigationBar: _buildBottomBar(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..63a43e6a 100644 --- a/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart +++ b/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart @@ -41,14 +41,13 @@ class RecipeEditScreen extends StatelessWidget { _buildRecipeEdit(BuildContext context, RecipeEditLoadedState state) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( + return Scaffold( resizeToAvoidBottomInset: false, - body: Container( + body: SafeArea( + child: Container( width: double.maxFinite, decoration: AppDecoration.fillGray, - child: ListView(children: [ - SizedBox(height: 30.v), + child: ListView(children: [ Container( margin: EdgeInsets.only( left: 16.h, @@ -110,7 +109,7 @@ class RecipeEditScreen extends StatelessWidget { ) ]), ), - bottomNavigationBar: _buildBottomBar(context))); + ), bottomNavigationBar: _buildBottomBar(context)); } } 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..0c143c6b 100644 --- a/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart +++ b/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart @@ -40,11 +40,11 @@ class RecipeSelectScreen extends StatelessWidget { _buildRecipeScreen(BuildContext context, RecipeSelectLoadedState state) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( + return Scaffold( backgroundColor: Colors.grey[200], resizeToAvoidBottomInset: true, - body: SingleChildScrollView( + body: SafeArea( + child: SingleChildScrollView( child: Container( width: double.maxFinite, decoration: BoxDecoration(color: Colors.grey[200]), @@ -106,9 +106,9 @@ class RecipeSelectScreen extends StatelessWidget { ), ), ), - ), - bottomNavigationBar: _buildBottomBar(context), + ), ), + bottomNavigationBar: _buildBottomBar(context), ); } 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..bad35e54 100644 --- a/lib/presentation/recipe/recipe_show_screen/recipe_show_screen.dart +++ b/lib/presentation/recipe/recipe_show_screen/recipe_show_screen.dart @@ -41,10 +41,10 @@ class RecipeScreen extends StatelessWidget { _buildRecipe(BuildContext context, RecipeLoadedState state) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( + return Scaffold( resizeToAvoidBottomInset: false, - body: Container( + body: SafeArea( + child: Container( width: double.maxFinite, decoration: AppDecoration.fillGray, child: ListView( @@ -115,7 +115,7 @@ class RecipeScreen extends StatelessWidget { ], ), ), - bottomNavigationBar: _buildBottomBar(context))); + ), bottomNavigationBar: _buildBottomBar(context)); } ///Handling route based on bottom click actions diff --git a/lib/routes/app_routes.dart b/lib/routes/app_routes.dart index 7163f5e5..fe8ee0fb 100644 --- a/lib/routes/app_routes.dart +++ b/lib/routes/app_routes.dart @@ -126,6 +126,8 @@ class AppRoutes { static const String planCreateScreen = '/planCreate'; + static const String glossaryScreen = '/glossary'; + static Map get routes => { dateOfBirthScreen: DateOfBirthScreen.builder, cityOfLivingScreen: CityOfLivingScreen.builder, diff --git a/lib/widgets/app_bar/appbar_subtitle.dart b/lib/widgets/app_bar/appbar_subtitle.dart index 58779324..75784abc 100644 --- a/lib/widgets/app_bar/appbar_subtitle.dart +++ b/lib/widgets/app_bar/appbar_subtitle.dart @@ -21,7 +21,6 @@ class AppbarSubtitle extends StatelessWidget { @override Widget build(BuildContext context) { return GestureDetector( - onTap: onTapCall, child: Padding( padding: margin ?? EdgeInsets.zero, child: Text( @@ -33,8 +32,4 @@ class AppbarSubtitle extends StatelessWidget { ), ); } - - void onTapCall() { - onTap!.call(); - } } diff --git a/lib/widgets/custom_bottom_bar.dart b/lib/widgets/custom_bottom_bar.dart index d6e47d6d..f484a194 100644 --- a/lib/widgets/custom_bottom_bar.dart +++ b/lib/widgets/custom_bottom_bar.dart @@ -56,7 +56,7 @@ class CustomBottomBarState extends State { @override Widget build(BuildContext context) { return Container( - height: 83.v, + height: 100.v, decoration: BoxDecoration( border: Border.all( color: appTheme.whiteA700, @@ -105,21 +105,18 @@ class CustomBottomBarState extends State { double iconWidth; if (index == 0) { - // Для логотипа- - iconHeight = 52.v; // Увеличиваем высоту - iconWidth = 48.h; // Меняем ширину, чтобы сохранить пропорции + + iconHeight = 50.v; + iconWidth = 50.h; } else if (index == bottomMenuList.length - 2) { - // Для колокольчика - iconHeight = 20.v; // Уменьшаем высоту - iconWidth = 20.h; // Меняем ширину, чтобы сохранить пропорции + iconHeight = 20.v; + iconWidth = 20.h; } else if (index == bottomMenuList.length - 1) { - // Для колокольчика - iconHeight = 40.v; // Уменьшаем высоту - iconWidth = 40.h; // Меняем ширину, чтобы сохранить пропорции + iconHeight = 40.v; + iconWidth = 40.h; } else { - // Для остальных иконок - iconHeight = 24.v; // Стандартная высота - iconWidth = 19.h; // Стандартная ширина + iconHeight = 24.v; + iconWidth = 19.h; } return BottomNavigationBarItem( @@ -142,10 +139,9 @@ class CustomBottomBarState extends State { shadowColor: Colors.white, surfaceTintColor: Colors.white, position: RelativeRect.fromLTRB( - // Указываем позицию справа по центру MediaQuery.of(context).size.width - - 50, // Расположение от правого края - kToolbarHeight + 340, // Расположение от верхнего края + 50, + kToolbarHeight + 340, 0, // Не смещаем по горизонтали 0, // Не смещаем по вертикали ), From 6b997a69fe7f69d53c776736f1a45c088571087e Mon Sep 17 00:00:00 2001 From: maxxkim Date: Tue, 4 Jun 2024 10:13:21 +0300 Subject: [PATCH 2/5] refactor(app): Some issues fixed --- .../auth/auth_screen/auth_screen.dart | 55 ++++++------------- lib/widgets/custom_bottom_bar.dart | 19 +++---- lib/widgets/custom_text_form_field.dart | 4 +- 3 files changed, 27 insertions(+), 51 deletions(-) diff --git a/lib/presentation/auth/auth_screen/auth_screen.dart b/lib/presentation/auth/auth_screen/auth_screen.dart index e934925b..bdd2d785 100644 --- a/lib/presentation/auth/auth_screen/auth_screen.dart +++ b/lib/presentation/auth/auth_screen/auth_screen.dart @@ -27,12 +27,11 @@ class AuthScreen extends StatelessWidget { @override Widget build(BuildContext context) { mediaQueryData = MediaQuery.of(context); - return Scaffold( - resizeToAvoidBottomInset: false, - appBar: _buildAppBar(context), - body:GestureDetector( - onTap: () => FocusScope.of(context).unfocus(), - child: Container( + return BlocBuilder(builder: (context, state) { + return Scaffold( + resizeToAvoidBottomInset: false, + appBar: _buildAppBar(context), + body: Container( width: double.maxFinite, padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), child: Column(children: [ @@ -42,24 +41,16 @@ class AuthScreen extends StatelessWidget { 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); - }), + CustomTextFormField( + controller: state.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, - ); - }), + CustomTextFormField( + obscureText: true, + controller: state.passwordController, + ), SizedBox(height: 50.v), NextStepButton( text: "no_account".tr.toUpperCase(), @@ -67,27 +58,15 @@ class AuthScreen extends StatelessWidget { EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), buttonStyle: CustomButtonStyles.outlinePrimaryTL15, onPressed: onTapNoAccount(context)), - /*NextStepButton( - text: "Тест дневника".toUpperCase(), - margin: - EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: onTapDiaryTest(context)), NextStepButton( - text: "Тест чата".toUpperCase(), + text: "authentificate".tr.toUpperCase(), margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: onTapProfileTest(context)),*/ - BlocBuilder(builder: (context, state) { - return NextStepButton( - text: "authentificate".tr.toUpperCase(), - margin: - EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: onTapAuth(state, context)); - }), - ])))); + onPressed: onTapAuth(state, context)), + ]), + )); + }); } onTapAuth(AuthState state, BuildContext context) { diff --git a/lib/widgets/custom_bottom_bar.dart b/lib/widgets/custom_bottom_bar.dart index f484a194..3dd396dd 100644 --- a/lib/widgets/custom_bottom_bar.dart +++ b/lib/widgets/custom_bottom_bar.dart @@ -56,7 +56,6 @@ class CustomBottomBarState extends State { @override Widget build(BuildContext context) { return Container( - height: 100.v, decoration: BoxDecoration( border: Border.all( color: appTheme.whiteA700, @@ -105,17 +104,16 @@ class CustomBottomBarState extends State { double iconWidth; if (index == 0) { - - iconHeight = 50.v; - iconWidth = 50.h; + iconHeight = 50.v; + iconWidth = 50.h; } else if (index == bottomMenuList.length - 2) { - iconHeight = 20.v; - iconWidth = 20.h; + iconHeight = 20.v; + iconWidth = 20.h; } else if (index == bottomMenuList.length - 1) { - iconHeight = 40.v; - iconWidth = 40.h; + iconHeight = 40.v; + iconWidth = 40.h; } else { - iconHeight = 24.v; + iconHeight = 24.v; iconWidth = 19.h; } @@ -139,8 +137,7 @@ class CustomBottomBarState extends State { shadowColor: Colors.white, surfaceTintColor: Colors.white, position: RelativeRect.fromLTRB( - MediaQuery.of(context).size.width - - 50, + MediaQuery.of(context).size.width - 50, kToolbarHeight + 340, 0, // Не смещаем по горизонтали 0, // Не смещаем по вертикали diff --git a/lib/widgets/custom_text_form_field.dart b/lib/widgets/custom_text_form_field.dart index 86a2a237..7b76f706 100644 --- a/lib/widgets/custom_text_form_field.dart +++ b/lib/widgets/custom_text_form_field.dart @@ -123,8 +123,8 @@ class CustomTextFormField extends StatelessWidget { width: width ?? double.maxFinite, child: TextFormField( controller: controller, - focusNode: focusNode ?? FocusNode(), - autofocus: autofocus!, + focusNode: focusNode ?? null, + autofocus: autofocus ?? false, style: textStyle ?? theme.textTheme.titleMedium, obscureText: obscureText!, textInputAction: textInputAction, From f2921a5136bc4653b4198315a32b437fa8bccf19 Mon Sep 17 00:00:00 2001 From: maxxkim Date: Tue, 4 Jun 2024 12:42:32 +0300 Subject: [PATCH 3/5] refactor(app): Fix --- .../blog_post_create_screen.dart | 105 +++++++++--------- .../feed/feed_screen/feed_screen.dart | 11 +- .../recipe_create_screen.dart | 103 ++++++++--------- 3 files changed, 111 insertions(+), 108 deletions(-) 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 c1c5514a..7221be5e 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 @@ -41,60 +41,61 @@ class BlogPostCreateScreen extends StatelessWidget { _buildBlogPostCreate(BuildContext context, BlogPostCreateLoadedState state) { mediaQueryData = MediaQuery.of(context); return Scaffold( - resizeToAvoidBottomInset: false, - body: SafeArea( - child: Container( - width: double.maxFinite, - decoration: AppDecoration.fillGray, - child: ListView(children: [ - Container( - margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, + resizeToAvoidBottomInset: false, + body: SafeArea( + child: Container( + width: double.maxFinite, + decoration: AppDecoration.fillGray, + child: ListView(children: [ + 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.title, + decoration: InputDecoration(labelText: 'Заголовок'), ), - 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.description, + decoration: InputDecoration(labelText: 'Описание'), ), - child: Column(mainAxisSize: MainAxisSize.min, children: [ - SizedBox(height: 16.0), - TextFormField( - controller: state.title, - decoration: InputDecoration(labelText: 'Заголовок'), - ), - SizedBox(height: 16.0), - TextFormField( - controller: state.description, - decoration: InputDecoration(labelText: 'Описание'), - ), - SizedBox(height: 16.0), - TextFormField( - controller: state.youtube_url, - decoration: InputDecoration(labelText: 'Ссылка'), - ), - SizedBox(height: 16.0), - // Здесь нужно добавить виджет для загрузки картинки - ElevatedButton( - onPressed: () => context - .read() - .add(CreateBlogPost()), - child: Text('Создать'), - ) - ]), - ) - ]), - ), - ), bottomNavigationBar: _buildBottomBar(context)); + SizedBox(height: 16.0), + TextFormField( + controller: state.youtube_url, + decoration: InputDecoration(labelText: 'Ссылка'), + ), + SizedBox(height: 16.0), + // Здесь нужно добавить виджет для загрузки картинки + ElevatedButton( + onPressed: () => context + .read() + .add(CreateBlogPost()), + child: Text('Создать'), + ) + ]), + ) + ]), + ), + ), + bottomNavigationBar: _buildBottomBar(context)); } } diff --git a/lib/presentation/feed/feed_screen/feed_screen.dart b/lib/presentation/feed/feed_screen/feed_screen.dart index fdeff779..07c67735 100644 --- a/lib/presentation/feed/feed_screen/feed_screen.dart +++ b/lib/presentation/feed/feed_screen/feed_screen.dart @@ -41,10 +41,10 @@ class FeedScreen extends StatelessWidget { _buildFeedScreen(BuildContext context, FeedLoadedState state) { mediaQueryData = MediaQuery.of(context); return Scaffold( - backgroundColor: Colors.grey[200], - resizeToAvoidBottomInset: true, - body: SafeArea( - child: SingleChildScrollView( + backgroundColor: Colors.grey[200], + resizeToAvoidBottomInset: true, + body: SafeArea( + child: SingleChildScrollView( child: Container( width: double.maxFinite, decoration: BoxDecoration(color: Colors.grey[200]), @@ -64,7 +64,8 @@ class FeedScreen extends StatelessWidget { ), ), ), - bottomNavigationBar: _buildBottomBar(context),); + bottomNavigationBar: _buildBottomBar(context), + ); } _buildSearch() { 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 fc37aa30..49ddfaa0 100644 --- a/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart +++ b/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart @@ -40,59 +40,60 @@ class RecipeCreateScreen extends StatelessWidget { _buildRecipeCreate(BuildContext context, RecipeCreateLoadedState state) { mediaQueryData = MediaQuery.of(context); return Scaffold( - resizeToAvoidBottomInset: false, - body: SafeArea( - child: Container( - width: double.maxFinite, - decoration: AppDecoration.fillGray, - child: ListView(children: [ - Container( - margin: EdgeInsets.only( - left: 16.h, - right: 20.h, - bottom: 10.h, + resizeToAvoidBottomInset: false, + body: SafeArea( + child: Container( + width: double.maxFinite, + decoration: AppDecoration.fillGray, + child: ListView(children: [ + 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.title, + decoration: InputDecoration(labelText: 'Заголовок'), ), - 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.description, + decoration: InputDecoration(labelText: 'Описание'), ), - child: Column(mainAxisSize: MainAxisSize.min, children: [ - SizedBox(height: 16.0), - TextFormField( - controller: state.title, - decoration: InputDecoration(labelText: 'Заголовок'), - ), - SizedBox(height: 16.0), - TextFormField( - controller: state.description, - decoration: InputDecoration(labelText: 'Описание'), - ), - SizedBox(height: 16.0), - TextFormField( - controller: state.video_url, - decoration: InputDecoration(labelText: 'Ссылка'), - ), - SizedBox(height: 16.0), - // Здесь нужно добавить виджет для загрузки картинки - ElevatedButton( - onPressed: () => - context.read().add(CreateRecipe()), - child: Text('Создать'), - ) - ]), - ) - ]), - ), - ), bottomNavigationBar: _buildBottomBar(context)); + SizedBox(height: 16.0), + TextFormField( + controller: state.video_url, + decoration: InputDecoration(labelText: 'Ссылка'), + ), + SizedBox(height: 16.0), + // Здесь нужно добавить виджет для загрузки картинки + ElevatedButton( + onPressed: () => + context.read().add(CreateRecipe()), + child: Text('Создать'), + ) + ]), + ) + ]), + ), + ), + bottomNavigationBar: _buildBottomBar(context)); } } From 3d08c3e76cb93b1a6739f4e4fcdd905132a62712 Mon Sep 17 00:00:00 2001 From: maxxkim Date: Tue, 4 Jun 2024 12:57:57 +0300 Subject: [PATCH 4/5] fix(app): merge conflict fix --- bpc | 104 ++++++ fc | 313 ++++++++++++++++++ .../blog_post_create_screen.dart | 110 +++--- .../feed/feed_screen/feed_screen.dart | 13 +- .../recipe_create_screen.dart | 108 +++--- rc | 102 ++++++ 6 files changed, 635 insertions(+), 115 deletions(-) create mode 100644 bpc create mode 100644 fc create mode 100644 rc diff --git a/bpc b/bpc new file mode 100644 index 00000000..7221be5e --- /dev/null +++ b/bpc @@ -0,0 +1,104 @@ +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'; + +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()))) + ..add(BlogPostCreateInitialEvent()), + child: BlogPostCreateScreen()); + } + + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, state) { + if (state is BlogPostCreateInitialState) { + // Это начальное состояние, данные ещё не загружены. + return Container( + color: Colors.white, + ); + } else if (state is BlogPostCreateLoadedState) { + // Данные загружены, можно строить экран. + return _buildBlogPostCreate(context, state); + } else if (state is BlogPostCreateErrorState) { + // Произошла ошибка при загрузке данных. + return Center(child: Text(state.errorMessage)); + } else { + // Другие состояния, если они есть. + return Container(); // Пустой контейнер для необработанных состояний. + } + }, + ); + } + + _buildBlogPostCreate(BuildContext context, BlogPostCreateLoadedState state) { + mediaQueryData = MediaQuery.of(context); + return Scaffold( + resizeToAvoidBottomInset: false, + body: SafeArea( + child: Container( + width: double.maxFinite, + decoration: AppDecoration.fillGray, + child: ListView(children: [ + 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.title, + decoration: InputDecoration(labelText: 'Заголовок'), + ), + SizedBox(height: 16.0), + TextFormField( + controller: state.description, + decoration: InputDecoration(labelText: 'Описание'), + ), + SizedBox(height: 16.0), + TextFormField( + controller: state.youtube_url, + decoration: InputDecoration(labelText: 'Ссылка'), + ), + SizedBox(height: 16.0), + // Здесь нужно добавить виджет для загрузки картинки + ElevatedButton( + onPressed: () => context + .read() + .add(CreateBlogPost()), + child: Text('Создать'), + ) + ]), + ) + ]), + ), + ), + bottomNavigationBar: _buildBottomBar(context)); + } +} + +_buildBottomBar(BuildContext context) { + return CustomBottomBar(onChanged: (BottomBarEnum type) {}); +} diff --git a/fc b/fc new file mode 100644 index 00000000..07c67735 --- /dev/null +++ b/fc @@ -0,0 +1,313 @@ +import 'bloc/feed_bloc.dart'; +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'; +import 'package:flutter/material.dart'; +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()); + } + + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, state) { + if (state is FeedInitialState) { + // Это начальное состояние, данные ещё не загружены. + return CircularProgressIndicator( + color: Colors.white, + backgroundColor: Colors.white, + ); + } else if (state is FeedLoadedState) { + // Данные загружены, можно строить экран. + return _buildFeedScreen(context, state); + } else { + // Другие состояния, если они есть. + return Container(); // Пустой контейнер для необработанных состояний. + } + }, + ); + } + + _buildFeedScreen(BuildContext context, FeedLoadedState state) { + mediaQueryData = MediaQuery.of(context); + return Scaffold( + backgroundColor: Colors.grey[200], + resizeToAvoidBottomInset: true, + body: SafeArea( + child: SingleChildScrollView( + child: Container( + width: double.maxFinite, + decoration: BoxDecoration(color: Colors.grey[200]), + child: Padding( + padding: EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + _buildSearch(), + SizedBox(height: 20), + _buildMenu(context, state), + SizedBox(height: 20), + _buildBlogPostList(context, state) + ], + ), + ), + ), + ), + ), + bottomNavigationBar: _buildBottomBar(context), + ); + } + + _buildSearch() { + return Container( + margin: EdgeInsets.only(bottom: 10), + 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: Padding( + padding: const EdgeInsets.all(12.0), + child: Column( + children: [ + CustomSearchView( + hintText: "Поиск записей", + ), + SizedBox(height: 10), + Row( + children: [ + Flexible( + flex: 5, + child: CustomOutlinedButton( + text: "Найти запись", + buttonStyle: CustomButtonStyles.outlinePrimaryTL15, + ), + ), + SizedBox(width: 8), // Add some spacing between the buttons + Flexible( + flex: 1, + child: CustomOutlinedButton( + text: "+", + buttonStyle: CustomButtonStyles.outlinePrimaryTL15, + ), + ), + ], + ) + ], + ), + ), + ); + } + + _buildBlogPostList(BuildContext context, FeedLoadedState state) { + List postWidgets = []; + + if (state.posts != null) { + for (var post in state.posts!) { + postWidgets.add(_buildFeedEntry(post, context)); + } + } + + return Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: postWidgets, + ); + } + + _buildFeedEntry(post, BuildContext context) { + return Container( + margin: EdgeInsets.only(bottom: 10), + 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: [ + ListTile( + leading: CachedNetworkImage( + imageUrl: dotenv.env['STORAGE_URL']! + + (post["author"]['profile_photo_path'] ?? ''), + 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, + ), + ), + title: Text( + post?['author']['name'] ?? '', + style: CustomTextStyles.titleMediumSemiBold, + ), + subtitle: Text( + 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(), + ), + trailing: PopupMenuButton( + onSelected: (value) => print("tap"), + itemBuilder: (BuildContext context) => >[ + PopupMenuItem( + value: 'edit', + child: Text('Редактировать'), + ), + PopupMenuItem( + value: 'delete', + child: Text('Удалить'), + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Spacer(), + Align( + alignment: Alignment.center, + child: Text( + post?['post']['title'], + style: CustomTextStyles.titleMediumBlack, + ), + ), + Spacer(), + ], + ), + SizedBox(height: 8.0), + Text( + post?['post']['description'], + style: CustomTextStyles.bodyMediumBluegray800, + ), + SizedBox(height: 16.0), + CachedNetworkImage( + imageUrl: dotenv.env['STORAGE_URL']! + + (post?['post']['image'] ?? ''), + imageBuilder: (context, imageProvider) => Stack( + children: [ + ClipRRect( + borderRadius: + const BorderRadius.all(Radius.circular(8.0)), + child: Image( + image: imageProvider, + ), + ), + ], + ), + placeholder: (context, url) => CircularProgressIndicator(), + ), + SizedBox(height: 16.0), + Row(children: [ + Padding( + padding: EdgeInsets.only(left: 4), + child: Row(children: [ + Padding( + padding: EdgeInsets.only(right: 4), + child: Icon(Icons.comment_outlined), + ), + Text( + "Комментировать", + ) + ]), + ), + Spacer(), + Row(children: [ + Padding( + padding: const EdgeInsets.only(right: 4), + child: Icon(Icons.favorite_outline), + ), + Text( + "Нравится", + ) + ]), + Spacer(), + Padding( + padding: EdgeInsets.only(right: 4), + child: Icon(Icons.share_outlined), + ), + ]), + ], + ), + ), + ])); + } + + Function onTapBack(BuildContext context) { + return () { + onTapArrowLeft(context); + }; + } + + _buildBottomBar(BuildContext context) { + return CustomBottomBar(onChanged: (BottomBarEnum type) {}); + } + + onTapArrowLeft(BuildContext context) { + NavigatorService.goBack(); + } + + _buildMenu(BuildContext context, FeedLoadedState state) { + return Container( + padding: EdgeInsets.all(12), + margin: EdgeInsets.only(bottom: 10), + 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: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + children: [ + ScrollItem(title: 'Все'), + ScrollItem(title: 'Рецепты'), + ScrollItem(title: 'Диеты'), + ScrollItem(title: 'Планы'), + ScrollItem(title: 'Записи'), + ], + ), + ), + ); + } +} 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 7221be5e..6950af55 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 @@ -40,62 +40,62 @@ class BlogPostCreateScreen extends StatelessWidget { _buildBlogPostCreate(BuildContext context, BlogPostCreateLoadedState state) { mediaQueryData = MediaQuery.of(context); - return Scaffold( - resizeToAvoidBottomInset: false, - body: SafeArea( - child: Container( - width: double.maxFinite, - decoration: AppDecoration.fillGray, - child: ListView(children: [ - 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), + 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.title, + decoration: InputDecoration(labelText: 'Заголовок'), ), - ], - ), - child: Column(mainAxisSize: MainAxisSize.min, children: [ - SizedBox(height: 16.0), - TextFormField( - controller: state.title, - decoration: InputDecoration(labelText: 'Заголовок'), - ), - SizedBox(height: 16.0), - TextFormField( - controller: state.description, - decoration: InputDecoration(labelText: 'Описание'), - ), - SizedBox(height: 16.0), - TextFormField( - controller: state.youtube_url, - decoration: InputDecoration(labelText: 'Ссылка'), - ), - SizedBox(height: 16.0), - // Здесь нужно добавить виджет для загрузки картинки - ElevatedButton( - onPressed: () => context - .read() - .add(CreateBlogPost()), - child: Text('Создать'), - ) - ]), - ) - ]), - ), - ), - bottomNavigationBar: _buildBottomBar(context)); + SizedBox(height: 16.0), + TextFormField( + controller: state.description, + decoration: InputDecoration(labelText: 'Описание'), + ), + SizedBox(height: 16.0), + TextFormField( + controller: state.youtube_url, + decoration: InputDecoration(labelText: 'Ссылка'), + ), + SizedBox(height: 16.0), + // Здесь нужно добавить виджет для загрузки картинки + ElevatedButton( + onPressed: () => context + .read() + .add(CreateBlogPost()), + child: Text('Создать'), + ) + ]), + ) + ]), + ), + bottomNavigationBar: _buildBottomBar(context))); } } diff --git a/lib/presentation/feed/feed_screen/feed_screen.dart b/lib/presentation/feed/feed_screen/feed_screen.dart index 07c67735..a7cd48fe 100644 --- a/lib/presentation/feed/feed_screen/feed_screen.dart +++ b/lib/presentation/feed/feed_screen/feed_screen.dart @@ -40,11 +40,11 @@ class FeedScreen extends StatelessWidget { _buildFeedScreen(BuildContext context, FeedLoadedState state) { mediaQueryData = MediaQuery.of(context); - return Scaffold( - backgroundColor: Colors.grey[200], - resizeToAvoidBottomInset: true, - body: SafeArea( - child: SingleChildScrollView( + return SafeArea( + child: Scaffold( + backgroundColor: Colors.grey[200], + resizeToAvoidBottomInset: true, + body: SingleChildScrollView( child: Container( width: double.maxFinite, decoration: BoxDecoration(color: Colors.grey[200]), @@ -53,6 +53,7 @@ class FeedScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ + SizedBox(height: 20), _buildSearch(), SizedBox(height: 20), _buildMenu(context, state), @@ -63,8 +64,8 @@ class FeedScreen extends StatelessWidget { ), ), ), + bottomNavigationBar: _buildBottomBar(context), ), - bottomNavigationBar: _buildBottomBar(context), ); } 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 49ddfaa0..82d2bd9a 100644 --- a/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart +++ b/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart @@ -39,61 +39,61 @@ class RecipeCreateScreen extends StatelessWidget { _buildRecipeCreate(BuildContext context, RecipeCreateLoadedState state) { mediaQueryData = MediaQuery.of(context); - return Scaffold( - resizeToAvoidBottomInset: false, - body: SafeArea( - child: Container( - width: double.maxFinite, - decoration: AppDecoration.fillGray, - child: ListView(children: [ - 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), + 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.title, + decoration: InputDecoration(labelText: 'Заголовок'), ), - ], - ), - child: Column(mainAxisSize: MainAxisSize.min, children: [ - SizedBox(height: 16.0), - TextFormField( - controller: state.title, - decoration: InputDecoration(labelText: 'Заголовок'), - ), - SizedBox(height: 16.0), - TextFormField( - controller: state.description, - decoration: InputDecoration(labelText: 'Описание'), - ), - SizedBox(height: 16.0), - TextFormField( - controller: state.video_url, - decoration: InputDecoration(labelText: 'Ссылка'), - ), - SizedBox(height: 16.0), - // Здесь нужно добавить виджет для загрузки картинки - ElevatedButton( - onPressed: () => - context.read().add(CreateRecipe()), - child: Text('Создать'), - ) - ]), - ) - ]), - ), - ), - bottomNavigationBar: _buildBottomBar(context)); + SizedBox(height: 16.0), + TextFormField( + controller: state.description, + decoration: InputDecoration(labelText: 'Описание'), + ), + SizedBox(height: 16.0), + TextFormField( + controller: state.video_url, + decoration: InputDecoration(labelText: 'Ссылка'), + ), + SizedBox(height: 16.0), + // Здесь нужно добавить виджет для загрузки картинки + ElevatedButton( + onPressed: () => + context.read().add(CreateRecipe()), + child: Text('Создать'), + ) + ]), + ) + ]), + ), + bottomNavigationBar: _buildBottomBar(context))); } } diff --git a/rc b/rc new file mode 100644 index 00000000..49ddfaa0 --- /dev/null +++ b/rc @@ -0,0 +1,102 @@ +import 'bloc/recipe_create_bloc.dart'; +import 'models/recipe_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 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()), + child: RecipeCreateScreen()); + } + + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, state) { + if (state is RecipeCreateInitialState) { + // Это начальное состояние, данные ещё не загружены. + return Container( + color: Colors.white, + ); + } else if (state is RecipeCreateLoadedState) { + // Данные загружены, можно строить экран. + return _buildRecipeCreate(context, state); + } else if (state is RecipeCreateErrorState) { + // Произошла ошибка при загрузке данных. + return Center(child: Text(state.errorMessage)); + } else { + // Другие состояния, если они есть. + return Container(); // Пустой контейнер для необработанных состояний. + } + }, + ); + } + + _buildRecipeCreate(BuildContext context, RecipeCreateLoadedState state) { + mediaQueryData = MediaQuery.of(context); + return Scaffold( + resizeToAvoidBottomInset: false, + body: SafeArea( + child: Container( + width: double.maxFinite, + decoration: AppDecoration.fillGray, + child: ListView(children: [ + 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.title, + decoration: InputDecoration(labelText: 'Заголовок'), + ), + SizedBox(height: 16.0), + TextFormField( + controller: state.description, + decoration: InputDecoration(labelText: 'Описание'), + ), + SizedBox(height: 16.0), + TextFormField( + controller: state.video_url, + decoration: InputDecoration(labelText: 'Ссылка'), + ), + SizedBox(height: 16.0), + // Здесь нужно добавить виджет для загрузки картинки + ElevatedButton( + onPressed: () => + context.read().add(CreateRecipe()), + child: Text('Создать'), + ) + ]), + ) + ]), + ), + ), + bottomNavigationBar: _buildBottomBar(context)); + } +} + +_buildBottomBar(BuildContext context) { + return CustomBottomBar(onChanged: (BottomBarEnum type) {}); +} From 8c8bcb4aab967c5b036f5c6b09899e3362487e34 Mon Sep 17 00:00:00 2001 From: maxxkim Date: Tue, 4 Jun 2024 12:58:14 +0300 Subject: [PATCH 5/5] fix(app): merge conflict fix --- bpc | 104 -------------------- fc | 313 ------------------------------------------------------------ rc | 102 -------------------- 3 files changed, 519 deletions(-) delete mode 100644 bpc delete mode 100644 fc delete mode 100644 rc diff --git a/bpc b/bpc deleted file mode 100644 index 7221be5e..00000000 --- a/bpc +++ /dev/null @@ -1,104 +0,0 @@ -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'; - -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()))) - ..add(BlogPostCreateInitialEvent()), - child: BlogPostCreateScreen()); - } - - Widget build(BuildContext context) { - return BlocBuilder( - builder: (context, state) { - if (state is BlogPostCreateInitialState) { - // Это начальное состояние, данные ещё не загружены. - return Container( - color: Colors.white, - ); - } else if (state is BlogPostCreateLoadedState) { - // Данные загружены, можно строить экран. - return _buildBlogPostCreate(context, state); - } else if (state is BlogPostCreateErrorState) { - // Произошла ошибка при загрузке данных. - return Center(child: Text(state.errorMessage)); - } else { - // Другие состояния, если они есть. - return Container(); // Пустой контейнер для необработанных состояний. - } - }, - ); - } - - _buildBlogPostCreate(BuildContext context, BlogPostCreateLoadedState state) { - mediaQueryData = MediaQuery.of(context); - return Scaffold( - resizeToAvoidBottomInset: false, - body: SafeArea( - child: Container( - width: double.maxFinite, - decoration: AppDecoration.fillGray, - child: ListView(children: [ - 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.title, - decoration: InputDecoration(labelText: 'Заголовок'), - ), - SizedBox(height: 16.0), - TextFormField( - controller: state.description, - decoration: InputDecoration(labelText: 'Описание'), - ), - SizedBox(height: 16.0), - TextFormField( - controller: state.youtube_url, - decoration: InputDecoration(labelText: 'Ссылка'), - ), - SizedBox(height: 16.0), - // Здесь нужно добавить виджет для загрузки картинки - ElevatedButton( - onPressed: () => context - .read() - .add(CreateBlogPost()), - child: Text('Создать'), - ) - ]), - ) - ]), - ), - ), - bottomNavigationBar: _buildBottomBar(context)); - } -} - -_buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); -} diff --git a/fc b/fc deleted file mode 100644 index 07c67735..00000000 --- a/fc +++ /dev/null @@ -1,313 +0,0 @@ -import 'bloc/feed_bloc.dart'; -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'; -import 'package:flutter/material.dart'; -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()); - } - - Widget build(BuildContext context) { - return BlocBuilder( - builder: (context, state) { - if (state is FeedInitialState) { - // Это начальное состояние, данные ещё не загружены. - return CircularProgressIndicator( - color: Colors.white, - backgroundColor: Colors.white, - ); - } else if (state is FeedLoadedState) { - // Данные загружены, можно строить экран. - return _buildFeedScreen(context, state); - } else { - // Другие состояния, если они есть. - return Container(); // Пустой контейнер для необработанных состояний. - } - }, - ); - } - - _buildFeedScreen(BuildContext context, FeedLoadedState state) { - mediaQueryData = MediaQuery.of(context); - return Scaffold( - backgroundColor: Colors.grey[200], - resizeToAvoidBottomInset: true, - body: SafeArea( - child: SingleChildScrollView( - child: Container( - width: double.maxFinite, - decoration: BoxDecoration(color: Colors.grey[200]), - child: Padding( - padding: EdgeInsets.all(16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - _buildSearch(), - SizedBox(height: 20), - _buildMenu(context, state), - SizedBox(height: 20), - _buildBlogPostList(context, state) - ], - ), - ), - ), - ), - ), - bottomNavigationBar: _buildBottomBar(context), - ); - } - - _buildSearch() { - return Container( - margin: EdgeInsets.only(bottom: 10), - 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: Padding( - padding: const EdgeInsets.all(12.0), - child: Column( - children: [ - CustomSearchView( - hintText: "Поиск записей", - ), - SizedBox(height: 10), - Row( - children: [ - Flexible( - flex: 5, - child: CustomOutlinedButton( - text: "Найти запись", - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - ), - ), - SizedBox(width: 8), // Add some spacing between the buttons - Flexible( - flex: 1, - child: CustomOutlinedButton( - text: "+", - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - ), - ), - ], - ) - ], - ), - ), - ); - } - - _buildBlogPostList(BuildContext context, FeedLoadedState state) { - List postWidgets = []; - - if (state.posts != null) { - for (var post in state.posts!) { - postWidgets.add(_buildFeedEntry(post, context)); - } - } - - return Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: postWidgets, - ); - } - - _buildFeedEntry(post, BuildContext context) { - return Container( - margin: EdgeInsets.only(bottom: 10), - 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: [ - ListTile( - leading: CachedNetworkImage( - imageUrl: dotenv.env['STORAGE_URL']! + - (post["author"]['profile_photo_path'] ?? ''), - 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, - ), - ), - title: Text( - post?['author']['name'] ?? '', - style: CustomTextStyles.titleMediumSemiBold, - ), - subtitle: Text( - 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(), - ), - trailing: PopupMenuButton( - onSelected: (value) => print("tap"), - itemBuilder: (BuildContext context) => >[ - PopupMenuItem( - value: 'edit', - child: Text('Редактировать'), - ), - PopupMenuItem( - value: 'delete', - child: Text('Удалить'), - ), - ], - ), - ), - Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Spacer(), - Align( - alignment: Alignment.center, - child: Text( - post?['post']['title'], - style: CustomTextStyles.titleMediumBlack, - ), - ), - Spacer(), - ], - ), - SizedBox(height: 8.0), - Text( - post?['post']['description'], - style: CustomTextStyles.bodyMediumBluegray800, - ), - SizedBox(height: 16.0), - CachedNetworkImage( - imageUrl: dotenv.env['STORAGE_URL']! + - (post?['post']['image'] ?? ''), - imageBuilder: (context, imageProvider) => Stack( - children: [ - ClipRRect( - borderRadius: - const BorderRadius.all(Radius.circular(8.0)), - child: Image( - image: imageProvider, - ), - ), - ], - ), - placeholder: (context, url) => CircularProgressIndicator(), - ), - SizedBox(height: 16.0), - Row(children: [ - Padding( - padding: EdgeInsets.only(left: 4), - child: Row(children: [ - Padding( - padding: EdgeInsets.only(right: 4), - child: Icon(Icons.comment_outlined), - ), - Text( - "Комментировать", - ) - ]), - ), - Spacer(), - Row(children: [ - Padding( - padding: const EdgeInsets.only(right: 4), - child: Icon(Icons.favorite_outline), - ), - Text( - "Нравится", - ) - ]), - Spacer(), - Padding( - padding: EdgeInsets.only(right: 4), - child: Icon(Icons.share_outlined), - ), - ]), - ], - ), - ), - ])); - } - - Function onTapBack(BuildContext context) { - return () { - onTapArrowLeft(context); - }; - } - - _buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); - } - - onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); - } - - _buildMenu(BuildContext context, FeedLoadedState state) { - return Container( - padding: EdgeInsets.all(12), - margin: EdgeInsets.only(bottom: 10), - 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: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row( - children: [ - ScrollItem(title: 'Все'), - ScrollItem(title: 'Рецепты'), - ScrollItem(title: 'Диеты'), - ScrollItem(title: 'Планы'), - ScrollItem(title: 'Записи'), - ], - ), - ), - ); - } -} diff --git a/rc b/rc deleted file mode 100644 index 49ddfaa0..00000000 --- a/rc +++ /dev/null @@ -1,102 +0,0 @@ -import 'bloc/recipe_create_bloc.dart'; -import 'models/recipe_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 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()), - child: RecipeCreateScreen()); - } - - Widget build(BuildContext context) { - return BlocBuilder( - builder: (context, state) { - if (state is RecipeCreateInitialState) { - // Это начальное состояние, данные ещё не загружены. - return Container( - color: Colors.white, - ); - } else if (state is RecipeCreateLoadedState) { - // Данные загружены, можно строить экран. - return _buildRecipeCreate(context, state); - } else if (state is RecipeCreateErrorState) { - // Произошла ошибка при загрузке данных. - return Center(child: Text(state.errorMessage)); - } else { - // Другие состояния, если они есть. - return Container(); // Пустой контейнер для необработанных состояний. - } - }, - ); - } - - _buildRecipeCreate(BuildContext context, RecipeCreateLoadedState state) { - mediaQueryData = MediaQuery.of(context); - return Scaffold( - resizeToAvoidBottomInset: false, - body: SafeArea( - child: Container( - width: double.maxFinite, - decoration: AppDecoration.fillGray, - child: ListView(children: [ - 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.title, - decoration: InputDecoration(labelText: 'Заголовок'), - ), - SizedBox(height: 16.0), - TextFormField( - controller: state.description, - decoration: InputDecoration(labelText: 'Описание'), - ), - SizedBox(height: 16.0), - TextFormField( - controller: state.video_url, - decoration: InputDecoration(labelText: 'Ссылка'), - ), - SizedBox(height: 16.0), - // Здесь нужно добавить виджет для загрузки картинки - ElevatedButton( - onPressed: () => - context.read().add(CreateRecipe()), - child: Text('Создать'), - ) - ]), - ) - ]), - ), - ), - bottomNavigationBar: _buildBottomBar(context)); - } -} - -_buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); -}