forked from eatvio/eatvio_app
126 lines
4.4 KiB
Dart
126 lines
4.4 KiB
Dart
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
|
import 'package:eatvio_app/core/enums/product_type.dart';
|
|
import 'package:eatvio_app/core/utils/localization_utils.dart';
|
|
import 'package:eatvio_app/features/diets/presentation/widgets/info_bouble.dart';
|
|
import 'package:eatvio_app/features/diets/presentation/widgets/type_badges.dart';
|
|
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
|
|
import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart';
|
|
import 'package:eatvio_app/features/feed/models/recipes_model.dart';
|
|
import 'package:eatvio_app/generated/l10n.dart';
|
|
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/svg.dart';
|
|
|
|
class InfoRow extends StatelessWidget {
|
|
const InfoRow({
|
|
required this.type,
|
|
super.key,
|
|
this.diet,
|
|
this.itemsBackgroundColor,
|
|
this.disableDescriptionOfTypes = false,
|
|
this.plan,
|
|
this.recipe,
|
|
});
|
|
final ProductType type;
|
|
final Color? itemsBackgroundColor;
|
|
final Diet? diet;
|
|
final PlanModel? plan;
|
|
final Recipe? recipe;
|
|
|
|
final bool disableDescriptionOfTypes;
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final s = S.of(context);
|
|
|
|
String? timeTitle;
|
|
if (recipe != null) {
|
|
final hours = recipe!.cookingTime ~/ 60;
|
|
final minutes = recipe!.cookingTime % 60;
|
|
if (hours > 0) {
|
|
timeTitle = '$hours ${getHourForm(hours)} $minutes ${getMinuteForm(minutes)}';
|
|
} else {
|
|
timeTitle = '$minutes ${getMinuteForm(minutes)}';
|
|
}
|
|
}
|
|
return SingleChildScrollView(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
scrollDirection: Axis.horizontal,
|
|
child: Row(
|
|
children: [
|
|
InfoBouble(
|
|
backgroundColor: itemsBackgroundColor,
|
|
children: [
|
|
SvgPicture.asset(
|
|
'assets/icons/time2.svg',
|
|
width: 13.3,
|
|
height: 13.3,
|
|
),
|
|
const SizedBox(width: 4),
|
|
Text(
|
|
switch (type) {
|
|
ProductType.diet => '${diet?.duration} ${getDayForm(diet?.duration ?? 7, s)}',
|
|
ProductType.plan => '${plan?.duration} ${getDayForm(plan?.duration ?? 7, s)}',
|
|
ProductType.recipe => timeTitle ?? '',
|
|
},
|
|
style: TextStyles.textXSSemibold.copyWith(color: appTheme.black),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(width: 12),
|
|
InfoBouble(
|
|
backgroundColor: itemsBackgroundColor,
|
|
children: [
|
|
SvgPicture.asset(
|
|
switch (type) {
|
|
ProductType.diet => 'assets/icons/people.svg',
|
|
ProductType.plan => 'assets/icons/people.svg',
|
|
ProductType.recipe => 'assets/icons/calories.svg',
|
|
},
|
|
width: 13.3,
|
|
height: 13.3,
|
|
),
|
|
const SizedBox(width: 4),
|
|
Text(
|
|
switch (type) {
|
|
ProductType.diet => '80 человек прошли',
|
|
ProductType.plan => '80 человек прошли',
|
|
ProductType.recipe => '${recipe?.calories.toStringAsFixed(0) ?? '0'} ккал',
|
|
},
|
|
style: TextStyles.textXSSemibold.copyWith(color: appTheme.black),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(width: 12),
|
|
if (type == ProductType.recipe)
|
|
InfoBouble(
|
|
backgroundColor: itemsBackgroundColor,
|
|
children: [
|
|
SvgPicture.asset(
|
|
'assets/icons/steps.svg',
|
|
width: 13.3,
|
|
height: 13.3,
|
|
),
|
|
const SizedBox(width: 4),
|
|
Text(
|
|
'${recipe?.steps?.length ?? 0} ${getStepForm(recipe?.steps?.length ?? 0)}',
|
|
style: TextStyles.textXSSemibold.copyWith(color: appTheme.black),
|
|
),
|
|
],
|
|
),
|
|
if (plan?.type.hasAtLeastOneType() == true || diet?.type.hasAtLeastOneType() == true)
|
|
InfoBouble(
|
|
backgroundColor: itemsBackgroundColor,
|
|
children: [
|
|
TypeBadges(
|
|
type: diet?.type,
|
|
planType: plan?.type,
|
|
disableDescriptionOfTypes: disableDescriptionOfTypes,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|