forked from eatvio/eatvio_app
223 lines
7.2 KiB
Dart
223 lines
7.2 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/recipes_model.dart' as step;
|
|
import 'package:eatvio_app/features/feed/models/recipes_model.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
class AboutRecipesScreen extends StatelessWidget {
|
|
final Recipes recipes;
|
|
|
|
const AboutRecipesScreen({super.key, required this.recipes});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
actions: [
|
|
InkWell(
|
|
borderRadius: BorderRadius.circular(16),
|
|
onTap: () => GoRouter.of(context).pushNamed('profileScreen', extra: recipes.author),
|
|
child: Ink(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
CircleAvatar(
|
|
maxRadius: 16,
|
|
minRadius: 16,
|
|
backgroundImage: NetworkImage(recipes.author.authorProfileIcon),
|
|
),
|
|
SizedBox(height: 4),
|
|
Text(
|
|
recipes.author.authorName,
|
|
style: TextStyle(
|
|
color: Colors.black,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w400,
|
|
height: 1,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
body: SingleChildScrollView(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
child: Text(
|
|
recipes.title,
|
|
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(
|
|
recipes.cookingTime.toString() + ' минут',
|
|
style: TextStyle(
|
|
color: Colors.black,
|
|
fontSize: 12,
|
|
fontWeight: FontWeight.w400,
|
|
height: 1,
|
|
),
|
|
),
|
|
SizedBox(width: 16),
|
|
Icon(Icons.fast_forward_outlined),
|
|
SizedBox(width: 4),
|
|
Text(
|
|
recipes.steps.length.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(
|
|
recipes.description,
|
|
style: TextStyle(
|
|
color: Colors.black,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w400,
|
|
height: 1.2,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 12),
|
|
CachedNetworkImage(
|
|
imageUrl: baseUrl + '/storage/' + recipes.image,
|
|
),
|
|
SizedBox(height: 12),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
child: Text(
|
|
'Ингредиенты',
|
|
style: TextStyle(
|
|
color: Colors.black,
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w500,
|
|
height: 1,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 12),
|
|
ListView.separated(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
shrinkWrap: true,
|
|
physics: NeverScrollableScrollPhysics(),
|
|
itemBuilder: (context, index) => _ingredient(recipes.ingredients[index]),
|
|
separatorBuilder: (context, index) => SizedBox(height: 4),
|
|
itemCount: recipes.ingredients.length,
|
|
),
|
|
SizedBox(height: 12),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
child: Text(
|
|
'Пошаговый рецепт',
|
|
style: TextStyle(
|
|
color: Colors.black,
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w500,
|
|
height: 1,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 12),
|
|
ListView.separated(
|
|
shrinkWrap: true,
|
|
physics: NeverScrollableScrollPhysics(),
|
|
itemBuilder: (context, index) => _step(recipes.steps[index], index + 1),
|
|
separatorBuilder: (context, index) => Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Container(
|
|
height: 0.4,
|
|
decoration: BoxDecoration(
|
|
color: Colors.grey,
|
|
borderRadius: BorderRadius.circular(16),
|
|
),
|
|
),
|
|
),
|
|
itemCount: recipes.steps.length,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
_ingredient(Ingredient ingredient) {
|
|
return Text(
|
|
'• ' + ingredient.name + ' ' + ingredient.portion + ' ' + (ingredient.unit ?? ''),
|
|
style: TextStyle(
|
|
color: Colors.black,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w400,
|
|
height: 1.2,
|
|
),
|
|
);
|
|
}
|
|
|
|
_step(step.Step step, int stepNumber) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
child: Text(
|
|
'Шаг ' + stepNumber.toString(),
|
|
style: TextStyle(
|
|
color: Colors.black54,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w400,
|
|
height: 1,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 12),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
child: Text(
|
|
step.description,
|
|
style: TextStyle(
|
|
color: Colors.black,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w400,
|
|
height: 1.2,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 8),
|
|
if (step.image.length > 1)
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.circular(16),
|
|
child: CachedNetworkImage(imageUrl: baseUrl + '/storage/' + step.image),
|
|
),
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|