From 660d846b6620102caba7211e8ee80579d4b96b06 Mon Sep 17 00:00:00 2001 From: maxxkim Date: Tue, 14 May 2024 16:46:28 +0300 Subject: [PATCH] refactor(app): Native analysys and warning refactoring --- .../diet_create_screen.dart | 2 - .../diet_select_screen.dart | 115 +++++++++--------- .../diet_show_screen/diet_show_screen.dart | 46 ------- .../blog_post_create_screen.dart | 2 - .../blog_post_screen/blog_post_screen.dart | 47 ------- .../feed/feed_screen/feed_screen.dart | 115 +++++++++--------- .../plan_create_screen.dart | 2 - .../plan_select_screen.dart | 115 +++++++++--------- .../plan_show_screen/plan_show_screen.dart | 45 ------- .../recipe_create_screen.dart | 2 - .../recipe_select_screen.dart | 115 +++++++++--------- .../recipe_show_screen.dart | 46 ------- 12 files changed, 228 insertions(+), 424 deletions(-) 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 df525f60..6896701c 100644 --- a/lib/presentation/diets/diet_create_screen/diet_create_screen.dart +++ b/lib/presentation/diets/diet_create_screen/diet_create_screen.dart @@ -3,8 +3,6 @@ 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'; -import 'package:cached_network_image/cached_network_image.dart'; -import 'package:flutter_dotenv/flutter_dotenv.dart'; class DietCreateScreen extends StatelessWidget { const DietCreateScreen({Key? key}) : super(key: key); 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 b37dcb7f..c44308d8 100644 --- a/lib/presentation/diets/diet_select_screen/diet_select_screen.dart +++ b/lib/presentation/diets/diet_select_screen/diet_select_screen.dart @@ -101,64 +101,7 @@ class DietSelectScreen extends StatelessWidget { ), ), SizedBox(height: 20), - ListView.builder( - shrinkWrap: true, // Add this line - itemCount: state.posts?.length ?? 0, - itemBuilder: (context, index) { - final post = state.posts?[index]; - 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: ListTile( - leading: CachedNetworkImage( - imageUrl: - dotenv.env['STORAGE_URL']! + post['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, - ), - ), - title: Text( - post?['name'] ?? '', - style: CustomTextStyles.titleMediumSemiBold, - ), - subtitle: Text(post?['details'] ?? ''), - onTap: () => Navigator.pushNamed( - context, - AppRoutes.dietScreen, - arguments: post?['id'].toString(), - ), - trailing: GestureDetector( - onTap: () => Navigator.pushNamed( - context, - AppRoutes.dietEditScreen, - arguments: post?['id'].toString(), - ), - child: Icon(Icons.edit)), - )); - }, - ), + _buildDietList(context, state) ], ), ), @@ -169,6 +112,62 @@ class DietSelectScreen extends StatelessWidget { ); } + _buildDietList(BuildContext context, DietSelectLoadedState state) { + return ListView.builder( + shrinkWrap: true, // Add this line + itemCount: state.posts?.length ?? 0, + itemBuilder: (context, index) { + final post = state.posts?[index]; + 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: ListTile( + leading: CachedNetworkImage( + imageUrl: dotenv.env['STORAGE_URL']! + post['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, + ), + ), + title: Text( + post?['name'] ?? '', + style: CustomTextStyles.titleMediumSemiBold, + ), + subtitle: Text(post?['details'] ?? ''), + onTap: () => Navigator.pushNamed( + context, + AppRoutes.dietScreen, + arguments: post?['id'].toString(), + ), + trailing: GestureDetector( + onTap: () => Navigator.pushNamed( + context, + AppRoutes.dietEditScreen, + arguments: post?['id'].toString(), + ), + child: Icon(Icons.edit)), + )); + }, + ); + } + Function onTapBack(BuildContext context) { return () { onTapArrowLeft(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 af308838..dcc20aea 100644 --- a/lib/presentation/diets/diet_show_screen/diet_show_screen.dart +++ b/lib/presentation/diets/diet_show_screen/diet_show_screen.dart @@ -2,10 +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/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:cached_network_image/cached_network_image.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; @@ -124,48 +120,6 @@ class DietScreen extends StatelessWidget { bottomNavigationBar: _buildBottomBar(context))); } - /// Section Widget - _buildAppbar(BuildContext context) { - return CustomAppBar( - leadingWidth: 26.h, - leading: AppbarLeadingImage( - imagePath: ImageConstant.imgArrowLeft, - margin: EdgeInsets.only( - left: 16.h, - top: 18.v, - bottom: 25.v, - ), - onTap: () => onTapArrowleftone(context), - ), - title: Padding( - padding: EdgeInsets.only(left: 12.h), - child: Row( - children: [ - AppbarTitleImage( - imagePath: ImageConstant.imgIconMoreHorizontal, - margin: EdgeInsets.only(bottom: 3.v), - ), - Padding( - padding: EdgeInsets.only( - left: 12.h, - top: 2.v, - ), - child: Column( - children: [ - AppbarSubtitle( - text: "Валерий Леонтьев", - ), - SizedBox(height: 3.v), - Text("Был в сети вчера", style: theme.textTheme.bodySmall!) - ], - ), - ) - ], - ), - ), - ); - } - ///Handling route based on bottom click actions String getCurrentRoute(BottomBarEnum type) { switch (type) { 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 f19a29a4..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 @@ -3,8 +3,6 @@ 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:cached_network_image/cached_network_image.dart'; -import 'package:flutter_dotenv/flutter_dotenv.dart'; class BlogPostCreateScreen extends StatelessWidget { const BlogPostCreateScreen({Key? key}) : super(key: key); 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 4db80307..293dfb2b 100644 --- a/lib/presentation/feed/blog_post_screen/blog_post_screen.dart +++ b/lib/presentation/feed/blog_post_screen/blog_post_screen.dart @@ -2,11 +2,6 @@ import 'bloc/blog_post_bloc.dart'; import 'models/blog_post_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:flutter/material.dart'; -import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart'; -import 'package:eatvio_app/widgets/custom_outlined_button.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:cached_network_image/cached_network_image.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; @@ -126,48 +121,6 @@ class BlogPostScreen extends StatelessWidget { bottomNavigationBar: _buildBottomBar(context))); } - /// Section Widget - _buildAppbar(BuildContext context) { - return CustomAppBar( - leadingWidth: 26.h, - leading: AppbarLeadingImage( - imagePath: ImageConstant.imgArrowLeft, - margin: EdgeInsets.only( - left: 16.h, - top: 18.v, - bottom: 25.v, - ), - onTap: () => onTapArrowleftone(context), - ), - title: Padding( - padding: EdgeInsets.only(left: 12.h), - child: Row( - children: [ - AppbarTitleImage( - imagePath: ImageConstant.imgIconMoreHorizontal, - margin: EdgeInsets.only(bottom: 3.v), - ), - Padding( - padding: EdgeInsets.only( - left: 12.h, - top: 2.v, - ), - child: Column( - children: [ - AppbarSubtitle( - text: "Валерий Леонтьев", - ), - SizedBox(height: 3.v), - Text("Был в сети вчера", style: theme.textTheme.bodySmall!) - ], - ), - ) - ], - ), - ), - ); - } - ///Handling route based on bottom click actions String getCurrentRoute(BottomBarEnum type) { switch (type) { diff --git a/lib/presentation/feed/feed_screen/feed_screen.dart b/lib/presentation/feed/feed_screen/feed_screen.dart index e0c6b78f..e0712d31 100644 --- a/lib/presentation/feed/feed_screen/feed_screen.dart +++ b/lib/presentation/feed/feed_screen/feed_screen.dart @@ -100,64 +100,7 @@ class FeedScreen extends StatelessWidget { ), ), SizedBox(height: 20), - ListView.builder( - shrinkWrap: true, // Add this line - itemCount: state.posts?.length ?? 0, - itemBuilder: (context, index) { - final post = state.posts?[index]; - 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: ListTile( - leading: CachedNetworkImage( - imageUrl: - dotenv.env['STORAGE_URL']! + post['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, - ), - ), - title: Text( - post?['title'] ?? '', - style: CustomTextStyles.titleMediumSemiBold, - ), - subtitle: Text(post?['description'] ?? ''), - onTap: () => Navigator.pushNamed( - context, - AppRoutes.blogPostScreen, - arguments: post?['id'].toString(), - ), - trailing: GestureDetector( - onTap: () => Navigator.pushNamed( - context, - AppRoutes.blogPostEditScreen, - arguments: post?['id'].toString(), - ), - child: Icon(Icons.edit)), - )); - }, - ), + _buildBlogPostList(context, state) ], ), ), @@ -168,6 +111,62 @@ class FeedScreen extends StatelessWidget { ); } + _buildBlogPostList(BuildContext context, FeedLoadedState state) { + return ListView.builder( + shrinkWrap: true, // Add this line + itemCount: state.posts?.length ?? 0, + itemBuilder: (context, index) { + final post = state.posts?[index]; + 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: ListTile( + leading: CachedNetworkImage( + imageUrl: dotenv.env['STORAGE_URL']! + post['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, + ), + ), + title: Text( + post?['title'] ?? '', + style: CustomTextStyles.titleMediumSemiBold, + ), + subtitle: Text(post?['description'] ?? ''), + onTap: () => Navigator.pushNamed( + context, + AppRoutes.blogPostScreen, + arguments: post?['id'].toString(), + ), + trailing: GestureDetector( + onTap: () => Navigator.pushNamed( + context, + AppRoutes.blogPostEditScreen, + arguments: post?['id'].toString(), + ), + child: Icon(Icons.edit)), + )); + }, + ); + } + Function onTapBack(BuildContext context) { return () { onTapArrowLeft(context); 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 97e1fd7f..af04abc7 100644 --- a/lib/presentation/plans/plan_create_screen/plan_create_screen.dart +++ b/lib/presentation/plans/plan_create_screen/plan_create_screen.dart @@ -3,8 +3,6 @@ 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'; -import 'package:cached_network_image/cached_network_image.dart'; -import 'package:flutter_dotenv/flutter_dotenv.dart'; class PlanCreateScreen extends StatelessWidget { const PlanCreateScreen({Key? key}) : super(key: key); 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 a88ca9ab..7f3486a2 100644 --- a/lib/presentation/plans/plan_select_screen/plan_select_screen.dart +++ b/lib/presentation/plans/plan_select_screen/plan_select_screen.dart @@ -101,64 +101,7 @@ class PlanSelectScreen extends StatelessWidget { ), ), SizedBox(height: 20), - ListView.builder( - shrinkWrap: true, // Add this line - itemCount: state.posts?.length ?? 0, - itemBuilder: (context, index) { - final post = state.posts?[index]; - 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: ListTile( - leading: CachedNetworkImage( - imageUrl: - dotenv.env['STORAGE_URL']! + post['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, - ), - ), - title: Text( - post?['name'] ?? '', - style: CustomTextStyles.titleMediumSemiBold, - ), - subtitle: Text(post?['details'] ?? ''), - onTap: () => Navigator.pushNamed( - context, - AppRoutes.planScreen, - arguments: post?['id'].toString(), - ), - trailing: GestureDetector( - onTap: () => Navigator.pushNamed( - context, - AppRoutes.planEditScreen, - arguments: post?['id'].toString(), - ), - child: Icon(Icons.edit)), - )); - }, - ), + _buildPlanList(context, state) ], ), ), @@ -169,6 +112,62 @@ class PlanSelectScreen extends StatelessWidget { ); } + _buildPlanList(BuildContext context, PlanSelectLoadedState state) { + return ListView.builder( + shrinkWrap: true, // Add this line + itemCount: state.posts?.length ?? 0, + itemBuilder: (context, index) { + final post = state.posts?[index]; + 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: ListTile( + leading: CachedNetworkImage( + imageUrl: dotenv.env['STORAGE_URL']! + post['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, + ), + ), + title: Text( + post?['name'] ?? '', + style: CustomTextStyles.titleMediumSemiBold, + ), + subtitle: Text(post?['details'] ?? ''), + onTap: () => Navigator.pushNamed( + context, + AppRoutes.planScreen, + arguments: post?['id'].toString(), + ), + trailing: GestureDetector( + onTap: () => Navigator.pushNamed( + context, + AppRoutes.planEditScreen, + arguments: post?['id'].toString(), + ), + child: Icon(Icons.edit)), + )); + }, + ); + } + Function onTapBack(BuildContext context) { return () { onTapArrowLeft(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 0dab4173..d34e1a43 100644 --- a/lib/presentation/plans/plan_show_screen/plan_show_screen.dart +++ b/lib/presentation/plans/plan_show_screen/plan_show_screen.dart @@ -2,10 +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/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:cached_network_image/cached_network_image.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; @@ -122,47 +118,6 @@ class PlanScreen extends StatelessWidget { bottomNavigationBar: _buildBottomBar(context))); } - /// Section Widget - _buildAppbar(BuildContext context) { - return CustomAppBar( - leadingWidth: 26.h, - leading: AppbarLeadingImage( - imagePath: ImageConstant.imgArrowLeft, - margin: EdgeInsets.only( - left: 16.h, - top: 18.v, - bottom: 25.v, - ), - onTap: () => onTapArrowleftone(context), - ), - title: Padding( - padding: EdgeInsets.only(left: 12.h), - child: Row( - children: [ - AppbarTitleImage( - imagePath: ImageConstant.imgIconMoreHorizontal, - margin: EdgeInsets.only(bottom: 3.v), - ), - Padding( - padding: EdgeInsets.only( - left: 12.h, - top: 2.v, - ), - child: Column( - children: [ - AppbarSubtitle( - text: "Валерий Леонтьев", - ), - SizedBox(height: 3.v), - Text("Был в сети вчера", style: theme.textTheme.bodySmall!) - ], - ), - ) - ], - ), - ), - ); - } ///Handling route based on bottom click actions String getCurrentRoute(BottomBarEnum type) { 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 ad4c7edf..82d2bd9a 100644 --- a/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart +++ b/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart @@ -3,8 +3,6 @@ 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'; -import 'package:cached_network_image/cached_network_image.dart'; -import 'package:flutter_dotenv/flutter_dotenv.dart'; class RecipeCreateScreen extends StatelessWidget { const RecipeCreateScreen({Key? key}) : super(key: key); 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 f11d5c5e..0623c053 100644 --- a/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart +++ b/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart @@ -101,64 +101,7 @@ class RecipeSelectScreen extends StatelessWidget { ), ), SizedBox(height: 20), - ListView.builder( - shrinkWrap: true, // Add this line - itemCount: state.posts?.length ?? 0, - itemBuilder: (context, index) { - final post = state.posts?[index]; - 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: ListTile( - leading: CachedNetworkImage( - imageUrl: - dotenv.env['STORAGE_URL']! + post['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, - ), - ), - title: Text( - post?['title'] ?? '', - style: CustomTextStyles.titleMediumSemiBold, - ), - subtitle: Text(post?['description'] ?? ''), - onTap: () => Navigator.pushNamed( - context, - AppRoutes.recipeScreen, - arguments: post?['id'].toString(), - ), - trailing: GestureDetector( - onTap: () => Navigator.pushNamed( - context, - AppRoutes.recipeEditScreen, - arguments: post?['id'].toString(), - ), - child: Icon(Icons.edit)), - )); - }, - ), + _buildRecipeList(context, state), ], ), ), @@ -169,6 +112,62 @@ class RecipeSelectScreen extends StatelessWidget { ); } + _buildRecipeList(BuildContext context, RecipeSelectLoadedState state) { + return ListView.builder( + shrinkWrap: true, // Add this line + itemCount: state.posts?.length ?? 0, + itemBuilder: (context, index) { + final post = state.posts?[index]; + 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: ListTile( + leading: CachedNetworkImage( + imageUrl: dotenv.env['STORAGE_URL']! + post['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, + ), + ), + title: Text( + post?['title'] ?? '', + style: CustomTextStyles.titleMediumSemiBold, + ), + subtitle: Text(post?['description'] ?? ''), + onTap: () => Navigator.pushNamed( + context, + AppRoutes.recipeScreen, + arguments: post?['id'].toString(), + ), + trailing: GestureDetector( + onTap: () => Navigator.pushNamed( + context, + AppRoutes.recipeEditScreen, + arguments: post?['id'].toString(), + ), + child: Icon(Icons.edit)), + )); + }, + ); + } + Function onTapBack(BuildContext context) { return () { onTapArrowLeft(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 01e944e8..ee757764 100644 --- a/lib/presentation/recipe/recipe_show_screen/recipe_show_screen.dart +++ b/lib/presentation/recipe/recipe_show_screen/recipe_show_screen.dart @@ -2,10 +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/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:cached_network_image/cached_network_image.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; @@ -122,48 +118,6 @@ class RecipeScreen extends StatelessWidget { bottomNavigationBar: _buildBottomBar(context))); } - /// Section Widget - _buildAppbar(BuildContext context) { - return CustomAppBar( - leadingWidth: 26.h, - leading: AppbarLeadingImage( - imagePath: ImageConstant.imgArrowLeft, - margin: EdgeInsets.only( - left: 16.h, - top: 18.v, - bottom: 25.v, - ), - onTap: () => onTapArrowleftone(context), - ), - title: Padding( - padding: EdgeInsets.only(left: 12.h), - child: Row( - children: [ - AppbarTitleImage( - imagePath: ImageConstant.imgIconMoreHorizontal, - margin: EdgeInsets.only(bottom: 3.v), - ), - Padding( - padding: EdgeInsets.only( - left: 12.h, - top: 2.v, - ), - child: Column( - children: [ - AppbarSubtitle( - text: "Валерий Леонтьев", - ), - SizedBox(height: 3.v), - Text("Был в сети вчера", style: theme.textTheme.bodySmall!) - ], - ), - ) - ], - ), - ), - ); - } - ///Handling route based on bottom click actions String getCurrentRoute(BottomBarEnum type) { switch (type) {