forked from eatvio/eatvio_app
139 lines
4.5 KiB
Dart
139 lines
4.5 KiB
Dart
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
|
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
|
import 'package:eatvio_app/core/utils/localization_utils.dart';
|
|
import 'package:eatvio_app/core/widgets/custom_divider.dart';
|
|
import 'package:eatvio_app/core/widgets/main_background_bouble.dart';
|
|
import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart';
|
|
import 'package:eatvio_app/core/widgets/item_widget.dart';
|
|
import 'package:eatvio_app/generated/l10n.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class OptionWidget extends StatelessWidget {
|
|
const OptionWidget({super.key, required this.option, this.disableDuration = false, required this.duration});
|
|
final PacketOptions? option;
|
|
final bool disableDuration;
|
|
final int duration;
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (option == null) {
|
|
return const SizedBox.shrink();
|
|
}
|
|
return MainBackgroundBouble(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
const SizedBox(height: 16),
|
|
Text(
|
|
option?.short ?? '',
|
|
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
|
|
),
|
|
const SizedBox(height: 12),
|
|
Text(
|
|
option?.description ?? '',
|
|
style: TextStyles.textSMedium.copyWith(color: appTheme.black),
|
|
),
|
|
const SizedBox(height: 12),
|
|
if (!disableDuration) ...[
|
|
_OptionDurationWidget(duration: duration),
|
|
SizedBox(height: option?.hasPersonalDiet ?? false ? 8 : 12),
|
|
],
|
|
if ((option?.hasPersonalDiet ?? false) && !disableDuration) ...[
|
|
const _OptionHasPersonalDietWidget(),
|
|
const SizedBox(height: 12),
|
|
],
|
|
const CustomDivider(),
|
|
const SizedBox(height: 16),
|
|
ListView.separated(
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
separatorBuilder: (context, index) => const SizedBox(height: 12),
|
|
itemBuilder: (context, index) => ItemWidget(text: option?.items[index] ?? ''),
|
|
itemCount: option?.items.length ?? 0,
|
|
shrinkWrap: true,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _OptionDurationWidget extends StatelessWidget {
|
|
const _OptionDurationWidget({required this.duration});
|
|
final int duration;
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final s = S.of(context);
|
|
return Container(
|
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(4), color: appTheme.cardBackground),
|
|
child: Row(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
|
child: Container(
|
|
width: 4,
|
|
height: 20,
|
|
decoration: BoxDecoration(
|
|
color: appTheme.blueA400,
|
|
borderRadius: const BorderRadius.only(
|
|
topRight: Radius.circular(100),
|
|
bottomRight: Radius.circular(100),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(
|
|
width: 12,
|
|
),
|
|
Text(
|
|
'${s.option_duration} $duration ${getDayForm(duration, s)}',
|
|
style: TextStyles.textSMedium.copyWith(color: appTheme.black),
|
|
),
|
|
const SizedBox(
|
|
width: 12,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _OptionHasPersonalDietWidget extends StatelessWidget {
|
|
const _OptionHasPersonalDietWidget();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final s = S.of(context);
|
|
return Container(
|
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(4), color: appTheme.transparentGreen),
|
|
child: Row(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
|
child: Container(
|
|
width: 4,
|
|
height: 20,
|
|
decoration: BoxDecoration(
|
|
color: appTheme.green,
|
|
borderRadius: const BorderRadius.only(
|
|
topRight: Radius.circular(100),
|
|
bottomRight: Radius.circular(100),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(
|
|
width: 12,
|
|
),
|
|
Text(
|
|
s.personalDietCreating,
|
|
style: TextStyles.textSMedium.copyWith(color: appTheme.black),
|
|
),
|
|
const SizedBox(
|
|
width: 12,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|