forked from eatvio/eatvio_app
- show only the personal diet name in the diary and keep the plan day chip - hide consultation cancellation for terminal and non-cancellable states - enable the refund form only for paid, started and in-progress plans - cover diary rows and order info cancel visibility with tests
75 lines
2.4 KiB
Dart
75 lines
2.4 KiB
Dart
import 'package:eatvio_app/core/routing/route_constants.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/widgets/custom_divider.dart';
|
|
import 'package:eatvio_app/features/diary/presentation/bloc/diary_cubit.dart';
|
|
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
class ChosenDietWidget extends StatelessWidget {
|
|
const ChosenDietWidget({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocBuilder<DiaryCubit, DiaryState>(
|
|
builder: (context, state) {
|
|
if (state is DiaryStateLoaded) {
|
|
if (state.diary.typeOfDiary.hasChosenDiet) {
|
|
return ChosenDietWidgetContent(
|
|
dietName: state.diary.diet?.name ?? '',
|
|
dietId: state.diary.diet?.id ?? 0,
|
|
);
|
|
}
|
|
}
|
|
if (state is DiaryStateLoadedTomorrowWithDiet) {
|
|
if (state.diary.typeOfDiary.hasChosenDiet) {
|
|
return Column(
|
|
children: [
|
|
const CustomDivider(),
|
|
const SizedBox(height: 16),
|
|
ChosenDietWidgetContent(
|
|
dietName: state.diary.diet?.name ?? '',
|
|
dietId: state.diary.diet?.id ?? 0,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
return const SizedBox.shrink();
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|
|
class ChosenDietWidgetContent extends StatelessWidget {
|
|
const ChosenDietWidgetContent({super.key, required this.dietName, required this.dietId});
|
|
final String dietName;
|
|
final int dietId;
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
onTap: () {
|
|
GoRouter.of(context).push(RouteConstants.aboutDietScreen, extra: {'id': dietId, 'navigateToComments': false});
|
|
},
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
dietName,
|
|
style: TextStyles.textLMedium.copyWith(color: appTheme.black, decoration: TextDecoration.underline),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 16),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|