From 4af39985ee1123601495d5b1fab12c992d239978 Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Fri, 9 Aug 2024 15:10:27 +0300 Subject: [PATCH] feat(feed): about diets screen --- lib/app_router.dart | 9 ++ .../presentation/pages/about_diet_screen.dart | 94 +++++++++++++++++++ .../feed/presentation/pages/feed_screen.dart | 4 +- .../presentation/widgets/diets_widget.dart | 4 +- .../pages/about_recipes_screen.dart | 15 ++- 5 files changed, 122 insertions(+), 4 deletions(-) create mode 100644 lib/features/diets/presentation/pages/about_diet_screen.dart diff --git a/lib/app_router.dart b/lib/app_router.dart index 96851119..752d0ab5 100644 --- a/lib/app_router.dart +++ b/lib/app_router.dart @@ -8,6 +8,8 @@ import 'package:eatvio_app/features/chat/presentation/pages/chat_screen.dart'; import 'package:eatvio_app/features/chat/presentation/pages/chat_select_screen/chat_select_screen.dart'; import 'package:eatvio_app/features/chat/presentation/pages/photo_view_screen.dart'; import 'package:eatvio_app/features/diary/presentation/pages/diary_screen.dart'; +import 'package:eatvio_app/features/diets/presentation/pages/about_diet_screen.dart'; +import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; import 'package:eatvio_app/features/feed/models/recipes_model.dart'; import 'package:eatvio_app/features/feed/presentation/pages/feed_screen.dart'; import 'package:eatvio_app/features/recipes/presentation/pages/about_recipes_screen.dart'; @@ -92,6 +94,13 @@ class AppRouter { recipes: state.extra as Recipes, ), ), + GoRoute( + path: '/about-diet-screen', + name: 'aboutDietScreen', + builder: (context, state) => AboutDietScreen( + datum: state.extra as Datum, + ), + ), GoRoute( path: '/blog-post-create-screen', name: 'blogPostCreateScreen', diff --git a/lib/features/diets/presentation/pages/about_diet_screen.dart b/lib/features/diets/presentation/pages/about_diet_screen.dart new file mode 100644 index 00000000..916085ce --- /dev/null +++ b/lib/features/diets/presentation/pages/about_diet_screen.dart @@ -0,0 +1,94 @@ +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:eatvio_app/core/constants/constants.dart'; +import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; +import 'package:flutter/material.dart'; + +class AboutDietScreen extends StatelessWidget { + final Datum datum; + + const AboutDietScreen({super.key, required this.datum}); + + @override + Widget build(BuildContext context) { + return Scaffold( + floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, + floatingActionButton: SizedBox( + width: MediaQuery.of(context).size.width - 32, + child: FloatingActionButton.extended( + heroTag: 'nextButtonRegistration', + highlightElevation: 0, + elevation: 0, + focusElevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + backgroundColor: appTheme.greenA700, + onPressed: () {}, + label: Text( + 'Начать диету', + style: theme.textTheme.titleSmall, + ), + ), + ), + appBar: AppBar(), + body: SingleChildScrollView( + padding: EdgeInsets.only(bottom: 80), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Text( + datum.name, + style: TextStyle( + color: Colors.black, + fontSize: 24, + fontWeight: FontWeight.w500, + height: 1, + ), + ), + ), + SizedBox(height: 12), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Row( + children: [ + Icon(Icons.timer_outlined), + SizedBox(width: 4), + Text( + datum.duration.toString() + ' дней', + style: TextStyle( + color: Colors.black, + fontSize: 12, + fontWeight: FontWeight.w400, + height: 1, + ), + ), + ], + ), + ), + SizedBox(height: 12), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Text( + datum.details, + style: TextStyle( + color: Colors.black, + fontSize: 14, + fontWeight: FontWeight.w400, + height: 1.2, + ), + ), + ), + SizedBox(height: 12), + CachedNetworkImage( + imageUrl: baseUrl + '/storage/' + datum.image, + ), + SizedBox(height: 12), + ], + ), + ), + ); + } +} diff --git a/lib/features/feed/presentation/pages/feed_screen.dart b/lib/features/feed/presentation/pages/feed_screen.dart index f3c32cd6..ec949667 100644 --- a/lib/features/feed/presentation/pages/feed_screen.dart +++ b/lib/features/feed/presentation/pages/feed_screen.dart @@ -64,8 +64,10 @@ class _FeedScreenState extends State { return _buildAllBlogPosts(); else if (_selectedChipIndex == 1) return _buildAllRecipes(); - else + else if (_selectedChipIndex == 2) return _buildDiets(); + else + return Center(child: Text(chipsLabelList[_selectedChipIndex])); }, ), ), diff --git a/lib/features/feed/presentation/widgets/diets_widget.dart b/lib/features/feed/presentation/widgets/diets_widget.dart index 58dc0db0..323c9e24 100644 --- a/lib/features/feed/presentation/widgets/diets_widget.dart +++ b/lib/features/feed/presentation/widgets/diets_widget.dart @@ -84,7 +84,7 @@ class _DietsWidgetState extends State { ), SizedBox(width: 4), Text( - '0', + widget.datum.totalLikes.toString(), style: TextStyle( fontSize: 12, color: Colors.black, @@ -113,7 +113,7 @@ class _DietsWidgetState extends State { ), SizedBox(width: 4), Text( - '0', + widget.datum.totalViews.toString(), style: TextStyle( fontSize: 12, color: Colors.black, diff --git a/lib/features/recipes/presentation/pages/about_recipes_screen.dart b/lib/features/recipes/presentation/pages/about_recipes_screen.dart index fb4ae6b7..d4e03b26 100644 --- a/lib/features/recipes/presentation/pages/about_recipes_screen.dart +++ b/lib/features/recipes/presentation/pages/about_recipes_screen.dart @@ -61,6 +61,19 @@ class AboutRecipesScreen extends StatelessWidget { ), ), SizedBox(height: 12), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Text( + recipes.description, + style: TextStyle( + color: Colors.black, + fontSize: 14, + fontWeight: FontWeight.w400, + height: 1.2, + ), + ), + ), + SizedBox(height: 12), CachedNetworkImage( imageUrl: baseUrl + '/storage/' + recipes.image, ), @@ -124,7 +137,7 @@ class AboutRecipesScreen extends StatelessWidget { _ingredient(Ingredient ingredient) { return Text( - '• '+ ingredient.name + ' ' + ingredient.portion + ' ' + (ingredient.unit ?? ''), + '• ' + ingredient.name + ' ' + ingredient.portion + ' ' + (ingredient.unit ?? ''), style: TextStyle( color: Colors.black, fontSize: 14,