feat: recipe widget

This commit is contained in:
Alex
2024-12-13 17:11:15 +03:00
parent 1c4c73d98e
commit 799c63b427
5 changed files with 93 additions and 67 deletions

View File

@@ -1,10 +1,13 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/core/widgets/feed_icon_button.dart';
import 'package:eatvio_app/features/feed/models/recipes_model.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:go_router/go_router.dart';
import 'package:share_plus/share_plus.dart';
class RecipesWidget extends StatefulWidget {
final Recipes recipes;
@@ -46,72 +49,14 @@ class _RecipesWidgetState extends State<RecipesWidget> {
child: Wrap(
runSpacing: 8,
children: [
_iconButton(Icons.fastfood, '139.9 ккал'),
_iconButton('assets/icons/clock.svg', widget.recipes.cookingTime.toString() + ' минут'),
SizedBox(width: 8),
_iconButton(Icons.timer_rounded, widget.recipes.cookingTime.toString() + ' минут'),
_iconButton('assets/icons/steps.svg', widget.recipes.steps.length.toString() + ' этапов'),
SizedBox(width: 8),
_iconButton(Icons.fast_forward_rounded, widget.recipes.steps.length.toString() + ' этапов'),
_iconButton('assets/icons/calories.svg', '139.9 ккал'),
],
),
),
Positioned(
left: 8,
top: 8,
child: Container(
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.8),
borderRadius: BorderRadius.circular(16),
),
child: Row(
children: [
Icon(
Icons.favorite_rounded,
size: 16,
color: Colors.black,
),
SizedBox(width: 4),
Text(
'0',
style: TextStyle(
fontSize: 12,
color: Colors.black,
fontWeight: FontWeight.w400,
),
),
],
),
),
),
Positioned(
right: 8,
top: 8,
child: Container(
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.8),
borderRadius: BorderRadius.circular(16),
),
child: Row(
children: [
Icon(
Icons.visibility_rounded,
size: 16,
color: Colors.black,
),
SizedBox(width: 4),
Text(
'0',
style: TextStyle(
fontSize: 12,
color: Colors.black,
fontWeight: FontWeight.w400,
),
),
],
),
),
),
],
),
SizedBox(height: 12),
@@ -150,27 +95,96 @@ class _RecipesWidgetState extends State<RecipesWidget> {
),
),
SizedBox(height: 12),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Row(
children: [
FeedIconButton(
icon: true ? Icons.favorite_rounded : Icons.favorite_border_rounded,
text: widget.recipes.likesCount.toString(),
iconColor: true ? Colors.red.withOpacity(0.8) : null,
backgroundColor: true ? Colors.red.withOpacity(0.1) : null,
textColor: true ? Colors.red.withOpacity(0.8) : null,
onTap: () async {
// setState(() {
// isLiked = !isLiked;
// isLiked ? totalLikes++ : totalLikes--;
// });
// isLiked
// ? await context.read<FeedCubit>().likePost(state.feedBlogPostList[widget.index].id)
// : await context.read<FeedCubit>().unlikedPost(state.feedBlogPostList[widget.index].id);
// await context.read<FeedCubit>().loadFeedBlogPostList();
},
),
SizedBox(width: 8),
FeedIconButton(
svgIcon: SvgPicture.asset(
'assets/icons/comment.svg',
height: 20,
width: 20,
colorFilter: ColorFilter.mode(
appTheme.gray600,
BlendMode.srcIn,
),
),
text: widget.recipes.commentsCount.toString(),
onTap: () => GoRouter.of(context).pushNamed(
'aboutRecipesScreen',
extra: widget.recipes,
),
),
SizedBox(width: 8),
FeedIconButton(
svgIcon: SvgPicture.asset(
height: 20,
width: 20,
'assets/icons/share.svg',
colorFilter: ColorFilter.mode(appTheme.gray600, BlendMode.srcIn),
),
onTap: () => Share.shareUri(
Uri.parse(
baseUrl + '/ru/blog_post/' + widget.recipes.id.toString(),
),
),
),
Spacer(),
Icon(
Icons.visibility_rounded,
size: 16,
color: appTheme.gray500,
),
SizedBox(width: 4),
Text(
widget.recipes.viewsCount.toString(),
style: TextStyle(
fontSize: 12,
color: appTheme.gray500,
fontWeight: FontWeight.w400,
),
),
],
),
),
SizedBox(height: 12),
],
),
),
);
}
_iconButton(IconData icon, [String? text]) {
_iconButton(String iconPath, [String? text]) {
return Container(
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 4),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.8),
color: Colors.white.withValues(alpha: 0.8),
borderRadius: BorderRadius.circular(16),
),
height: 32,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
icon,
size: 16,
color: Colors.black,
SvgPicture.asset(
iconPath,
),
if (text != null) SizedBox(width: 8),
if (text != null)