forked from eatvio/eatvio_app
feat(Лента): фильтрация рецептов по тегам, поиск по строке
This commit is contained in:
@@ -5,9 +5,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class DietsWidget extends StatefulWidget {
|
||||
final Datum datum;
|
||||
final Diet diet;
|
||||
|
||||
const DietsWidget({super.key, required this.datum});
|
||||
const DietsWidget({super.key, required this.diet});
|
||||
|
||||
@override
|
||||
State<DietsWidget> createState() => _DietsWidgetState();
|
||||
@@ -18,7 +18,7 @@ class _DietsWidgetState extends State<DietsWidget> {
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
onTap: () => GoRouter.of(context).pushNamed('aboutDietScreen', extra: widget.datum),
|
||||
onTap: () => GoRouter.of(context).pushNamed('aboutDietScreen', extra: widget.diet),
|
||||
child: Ink(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
@@ -33,7 +33,7 @@ class _DietsWidgetState extends State<DietsWidget> {
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(12)),
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: baseUrl + '/storage/' + widget.datum.image,
|
||||
imageUrl: baseUrl + '/storage/' + widget.diet.image,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
@@ -44,9 +44,9 @@ class _DietsWidgetState extends State<DietsWidget> {
|
||||
children: [
|
||||
_iconButton(Icons.fastfood, '139.9 ккал'),
|
||||
SizedBox(width: 8),
|
||||
_iconButton(Icons.timer_rounded, widget.datum.state),
|
||||
_iconButton(Icons.timer_rounded, widget.diet.state),
|
||||
SizedBox(width: 8),
|
||||
_iconButton(Icons.fast_forward_rounded, widget.datum.duration.toString()),
|
||||
_iconButton(Icons.fast_forward_rounded, widget.diet.duration.toString()),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -68,7 +68,7 @@ class _DietsWidgetState extends State<DietsWidget> {
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
Text(
|
||||
widget.datum.totalLikes.toString(),
|
||||
widget.diet.totalLikes.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.black,
|
||||
@@ -97,7 +97,7 @@ class _DietsWidgetState extends State<DietsWidget> {
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
Text(
|
||||
widget.datum.totalViews.toString(),
|
||||
widget.diet.totalViews.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.black,
|
||||
@@ -114,7 +114,7 @@ class _DietsWidgetState extends State<DietsWidget> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Text(
|
||||
widget.datum.name,
|
||||
widget.diet.name,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.black87,
|
||||
@@ -125,7 +125,7 @@ class _DietsWidgetState extends State<DietsWidget> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Text(
|
||||
widget.datum.details,
|
||||
widget.diet.details,
|
||||
style: TextStyle(
|
||||
color: Colors.black87,
|
||||
),
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes_cubit.dart';
|
||||
import 'package:eatvio_app/features/recipes/models/recipe_tag_model.dart';
|
||||
import 'package:eatvio_app/theme/theme_helper.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class TagsModalWidget extends StatefulWidget {
|
||||
final List<RecipeTag> tagsList;
|
||||
final Set<int> selectedTags;
|
||||
|
||||
const TagsModalWidget({
|
||||
super.key,
|
||||
required this.tagsList,
|
||||
required this.selectedTags,
|
||||
});
|
||||
|
||||
@override
|
||||
State<TagsModalWidget> createState() => _TagsModalWidgetState();
|
||||
}
|
||||
|
||||
class _TagsModalWidgetState extends State<TagsModalWidget> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: -8,
|
||||
children: [
|
||||
for (int i = 0; i < widget.tagsList.length; i++)
|
||||
_tagChip(
|
||||
tag: widget.tagsList[i],
|
||||
isSelected: widget.selectedTags.contains(widget.tagsList[i].id),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_tagChip({
|
||||
required RecipeTag tag,
|
||||
required bool isSelected,
|
||||
}) {
|
||||
return ChoiceChip(
|
||||
selectedColor: appTheme.blueA400,
|
||||
pressElevation: 0,
|
||||
showCheckmark: false,
|
||||
side: BorderSide.none,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
label: Text(tag.name),
|
||||
labelStyle: TextStyle(
|
||||
color: isSelected ? Colors.white : appTheme.gray600,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 12,
|
||||
),
|
||||
selected: isSelected,
|
||||
backgroundColor: appTheme.gray100,
|
||||
onSelected: (bool selected) => context.read<RecipesCubit>().updateTags(tag),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user