forked from eatvio/eatvio_app
174 lines
5.7 KiB
Dart
174 lines
5.7 KiB
Dart
import 'package:cached_network_image/cached_network_image.dart';
|
|
import 'package:eatvio_app/core/app_export.dart';
|
|
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
class DietsWidget extends StatefulWidget {
|
|
final Diet diet;
|
|
|
|
const DietsWidget({super.key, required this.diet});
|
|
|
|
@override
|
|
State<DietsWidget> createState() => _DietsWidgetState();
|
|
}
|
|
|
|
class _DietsWidgetState extends State<DietsWidget> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return InkWell(
|
|
borderRadius: BorderRadius.circular(12),
|
|
onTap: () => GoRouter.of(context).pushNamed('aboutDietScreen', extra: widget.diet),
|
|
child: Ink(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(12),
|
|
color: Colors.white,
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Stack(
|
|
children: [
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(12)),
|
|
child: CachedNetworkImage(
|
|
imageUrl: baseUrl + '/storage/' + widget.diet.image,
|
|
fit: BoxFit.fitWidth,
|
|
width: MediaQuery.of(context).size.width,
|
|
),
|
|
),
|
|
Positioned(
|
|
left: 8,
|
|
bottom: 8,
|
|
child: Wrap(
|
|
runSpacing: 8,
|
|
children: [
|
|
_iconButton(Icons.fastfood, '139.9 ккал'),
|
|
SizedBox(width: 8),
|
|
_iconButton(Icons.timer_rounded, widget.diet.state),
|
|
SizedBox(width: 8),
|
|
_iconButton(Icons.fast_forward_rounded, widget.diet.duration.toString()),
|
|
],
|
|
),
|
|
),
|
|
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(
|
|
widget.diet.totalLikes.toString(),
|
|
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(
|
|
widget.diet.totalViews.toString(),
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: Colors.black,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 12),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
|
child: Text(
|
|
widget.diet.name,
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.w600,
|
|
color: Colors.black87,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 8),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
|
child: Text(
|
|
widget.diet.details,
|
|
style: TextStyle(
|
|
color: Colors.black87,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 12),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
_iconButton(IconData icon, [String? text]) {
|
|
return Container(
|
|
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white.withOpacity(0.8),
|
|
borderRadius: BorderRadius.circular(16),
|
|
),
|
|
height: 32,
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(
|
|
icon,
|
|
size: 16,
|
|
color: Colors.black,
|
|
),
|
|
if (text != null) SizedBox(width: 8),
|
|
if (text != null)
|
|
Text(
|
|
text,
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: Colors.black,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|