forked from eatvio/eatvio_app
sync upsteam #3
@@ -31,10 +31,7 @@ class InfoByOrderScreen extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => sl<OrderInfoCubit>()..getChosenPlan(planId),
|
||||
child: InfoByOrderScreenContent(
|
||||
successfulPayment: successfulPayment,
|
||||
planId: planId,
|
||||
),
|
||||
child: InfoByOrderScreenContent(successfulPayment: successfulPayment, planId: planId),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -42,11 +39,7 @@ class InfoByOrderScreen extends StatelessWidget {
|
||||
class InfoByOrderScreenContent extends StatefulWidget {
|
||||
static const name = 'infoByOrderScreen';
|
||||
static const path = '/info-by-order-screen';
|
||||
const InfoByOrderScreenContent({
|
||||
super.key,
|
||||
required this.planId,
|
||||
required this.successfulPayment,
|
||||
});
|
||||
const InfoByOrderScreenContent({super.key, required this.planId, required this.successfulPayment});
|
||||
final int planId;
|
||||
final bool? successfulPayment;
|
||||
@override
|
||||
@@ -64,39 +57,30 @@ class _InfoByOrderScreenContentState extends State<InfoByOrderScreenContent> {
|
||||
if (state.isLoading) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
s.infoAboutOrder,
|
||||
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
|
||||
),
|
||||
title: Text(s.infoAboutOrder, style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black)),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () {
|
||||
GoRouter.of(context).pop();
|
||||
}),
|
||||
),
|
||||
body: const Center(
|
||||
child: Loader(),
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () {
|
||||
GoRouter.of(context).pop();
|
||||
},
|
||||
),
|
||||
),
|
||||
body: const Center(child: Loader()),
|
||||
);
|
||||
}
|
||||
if (plan == null) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
s.infoAboutOrder,
|
||||
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
|
||||
),
|
||||
title: Text(s.infoAboutOrder, style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black)),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () {
|
||||
GoRouter.of(context).pop();
|
||||
}),
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () {
|
||||
GoRouter.of(context).pop();
|
||||
},
|
||||
),
|
||||
),
|
||||
body: Center(
|
||||
child: Text(
|
||||
s.sorry_we_did_not_find_the_plan,
|
||||
style: TextStyles.textSSemibold.copyWith(color: appTheme.black),
|
||||
),
|
||||
child: Text(s.sorry_we_did_not_find_the_plan, style: TextStyles.textSSemibold.copyWith(color: appTheme.black)),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -122,31 +106,19 @@ class _InfoByOrderScreenContentState extends State<InfoByOrderScreenContent> {
|
||||
return Scaffold(
|
||||
backgroundColor: appTheme.gray100,
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
s.infoAboutOrder,
|
||||
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
|
||||
),
|
||||
title: Text(s.infoAboutOrder, style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black)),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () {
|
||||
GoRouter.of(context).pop();
|
||||
}),
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () {
|
||||
GoRouter.of(context).pop();
|
||||
},
|
||||
),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
if (plan.chosenPlanState == ChosenPlanStateEnum.stateDone) ...[
|
||||
CollectChargeBanner(
|
||||
chosenPlan: plan,
|
||||
price: chosenOption?.price ?? 0,
|
||||
)
|
||||
],
|
||||
if (widget.successfulPayment != null) ...[
|
||||
const SizedBox(height: 8),
|
||||
PaymentBanner(
|
||||
successfulPayment: widget.successfulPayment ?? false,
|
||||
),
|
||||
],
|
||||
if (plan.chosenPlanState == ChosenPlanStateEnum.stateDone) ...[CollectChargeBanner(chosenPlan: plan, price: chosenOption?.price ?? 0)],
|
||||
if (widget.successfulPayment != null) ...[const SizedBox(height: 8), PaymentBanner(successfulPayment: widget.successfulPayment ?? false)],
|
||||
const SizedBox(height: 8),
|
||||
AuthorCard(
|
||||
author: plan.plan.author,
|
||||
@@ -155,26 +127,13 @@ class _InfoByOrderScreenContentState extends State<InfoByOrderScreenContent> {
|
||||
backgroundColor: appTheme.whiteA700,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
PlanProps(
|
||||
planDuration: plan.plan.duration,
|
||||
planPrice: chosenOption?.price.toDouble() ?? 0,
|
||||
planStatus: planStatus),
|
||||
PlanProps(planDuration: plan.plan.duration, planPrice: chosenOption?.price.toDouble() ?? 0, planStatus: planStatus),
|
||||
const SizedBox(height: 8),
|
||||
PlanInfo(
|
||||
title: plan.plan.name,
|
||||
description: plan.plan.details,
|
||||
imagePath: plan.plan.image,
|
||||
),
|
||||
PlanInfo(title: plan.plan.name, description: plan.plan.details, imagePath: plan.plan.image),
|
||||
const SizedBox(height: 8),
|
||||
OptionWidget(
|
||||
option: chosenOption,
|
||||
disableDuration: true,
|
||||
duration: plan.plan.duration,
|
||||
),
|
||||
OptionWidget(option: chosenOption, disableDuration: true, duration: plan.plan.duration),
|
||||
const SizedBox(height: 8),
|
||||
PlanState(
|
||||
state: plan.chosenPlanState,
|
||||
),
|
||||
PlanState(state: plan.chosenPlanState, hasPersonalDiet: chosenOption?.hasPersonalDiet ?? false,),
|
||||
const SizedBox(height: 20),
|
||||
if (widget.successfulPayment == null)
|
||||
CustomOutlinedButton(
|
||||
@@ -185,13 +144,10 @@ class _InfoByOrderScreenContentState extends State<InfoByOrderScreenContent> {
|
||||
onPressed: () async {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (context) => CancelPlanBottomSheet(
|
||||
enableForm: plan.chosenPlanState.isStateAfterPaidState(),
|
||||
planId: plan.id,
|
||||
),
|
||||
builder: (context) => CancelPlanBottomSheet(enableForm: plan.chosenPlanState.isStateAfterPaidState(), planId: plan.id),
|
||||
);
|
||||
},
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -5,42 +5,65 @@ import 'package:eatvio_app/features/plans/enums/chosen_plan_state_enum.dart';
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PlanState extends StatelessWidget {
|
||||
PlanState({super.key, required this.state});
|
||||
class PlanState extends StatefulWidget {
|
||||
const PlanState({super.key, required this.state, required this.hasPersonalDiet});
|
||||
final ChosenPlanStateEnum state;
|
||||
final List<List<ChosenPlanStateEnum>> states = [
|
||||
[
|
||||
ChosenPlanStateEnum.stateInited,
|
||||
ChosenPlanStateEnum.stateInCoordination,
|
||||
],
|
||||
[
|
||||
ChosenPlanStateEnum.stateStartDateHasBeenSet,
|
||||
ChosenPlanStateEnum.statePendingPayment,
|
||||
],
|
||||
[
|
||||
ChosenPlanStateEnum.statePaid,
|
||||
],
|
||||
[
|
||||
ChosenPlanStateEnum.stateStarted,
|
||||
ChosenPlanStateEnum.stateInProgress,
|
||||
ChosenPlanStateEnum.stateLastDayStarted,
|
||||
ChosenPlanStateEnum.stateLastDayFinished,
|
||||
],
|
||||
[
|
||||
ChosenPlanStateEnum.stateComplained,
|
||||
ChosenPlanStateEnum.stateDone,
|
||||
ChosenPlanStateEnum.stateChargeWasCollected,
|
||||
]
|
||||
];
|
||||
final bool hasPersonalDiet;
|
||||
|
||||
@override
|
||||
State<PlanState> createState() => _PlanStateState();
|
||||
}
|
||||
|
||||
class _PlanStateState extends State<PlanState> {
|
||||
late final List<List<ChosenPlanStateEnum>> states;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.hasPersonalDiet) {
|
||||
states = [
|
||||
[ChosenPlanStateEnum.stateInited, ChosenPlanStateEnum.stateInCoordination],
|
||||
[ChosenPlanStateEnum.stateStartDateHasBeenSet, ChosenPlanStateEnum.statePendingPayment],
|
||||
[ChosenPlanStateEnum.statePaid],
|
||||
[ChosenPlanStateEnum.personalDietSet],
|
||||
[
|
||||
ChosenPlanStateEnum.stateStarted,
|
||||
ChosenPlanStateEnum.stateInProgress,
|
||||
ChosenPlanStateEnum.stateLastDayStarted,
|
||||
ChosenPlanStateEnum.stateLastDayFinished,
|
||||
],
|
||||
[ChosenPlanStateEnum.stateComplained, ChosenPlanStateEnum.stateDone, ChosenPlanStateEnum.stateChargeWasCollected],
|
||||
];
|
||||
} else {
|
||||
states = [
|
||||
[ChosenPlanStateEnum.stateInited, ChosenPlanStateEnum.stateInCoordination],
|
||||
[ChosenPlanStateEnum.stateStartDateHasBeenSet, ChosenPlanStateEnum.statePendingPayment],
|
||||
[ChosenPlanStateEnum.statePaid],
|
||||
[
|
||||
ChosenPlanStateEnum.stateStarted,
|
||||
ChosenPlanStateEnum.stateInProgress,
|
||||
ChosenPlanStateEnum.stateLastDayStarted,
|
||||
ChosenPlanStateEnum.stateLastDayFinished,
|
||||
],
|
||||
[ChosenPlanStateEnum.stateComplained, ChosenPlanStateEnum.stateDone, ChosenPlanStateEnum.stateChargeWasCollected],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = S.of(context);
|
||||
final titles = [s.order_created, s.startDateHasBeenSet, s.order_paid, s.in_progress, s.done];
|
||||
final List<String> titles;
|
||||
if (widget.hasPersonalDiet) {
|
||||
titles = [s.order_created, s.startDateHasBeenSet, s.order_paid, s.personal_diet_set, s.in_progress, s.done];
|
||||
} else {
|
||||
titles = [s.order_created, s.startDateHasBeenSet, s.order_paid, s.in_progress, s.done];
|
||||
}
|
||||
return MainBackgroundBouble(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
children: List.generate(states.length, (index) {
|
||||
final color = index <= states.indexWhere((element) => element.contains(state)) ? appTheme.greenA700 : appTheme.lightGray00;
|
||||
final color = index <= states.indexWhere((element) => element.contains(widget.state)) ? appTheme.greenA700 : appTheme.lightGray00;
|
||||
final text = titles[index];
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -51,29 +74,16 @@ class PlanState extends StatelessWidget {
|
||||
width: 24,
|
||||
height: 24,
|
||||
decoration: BoxDecoration(shape: BoxShape.circle, color: color),
|
||||
child: Center(
|
||||
child: Icon(
|
||||
Icons.check,
|
||||
color: appTheme.whiteA700,
|
||||
size: 14,
|
||||
),
|
||||
),
|
||||
child: Center(child: Icon(Icons.check, color: appTheme.whiteA700, size: 14)),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
text,
|
||||
style: TextStyles.textMMedium.copyWith(color: appTheme.black),
|
||||
),
|
||||
Text(text, style: TextStyles.textMMedium.copyWith(color: appTheme.black)),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 12),
|
||||
child: Container(
|
||||
height: 12,
|
||||
width: 1,
|
||||
color: color,
|
||||
),
|
||||
)
|
||||
child: Container(height: 12, width: 1, color: color),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
|
||||
@@ -575,6 +575,9 @@ class MessageLookup extends MessageLookupByLibrary {
|
||||
"personalDietCreating": MessageLookupByLibrary.simpleMessage(
|
||||
"Составление индивидуальной диеты",
|
||||
),
|
||||
"personal_diet_set": MessageLookupByLibrary.simpleMessage(
|
||||
"Персональная диета установлена",
|
||||
),
|
||||
"personal_diet_state": MessageLookupByLibrary.simpleMessage("Персональная"),
|
||||
"photo": MessageLookupByLibrary.simpleMessage("Фото"),
|
||||
"physical_fitness": MessageLookupByLibrary.simpleMessage(
|
||||
|
||||
@@ -28,9 +28,10 @@ class S {
|
||||
static const AppLocalizationDelegate delegate = AppLocalizationDelegate();
|
||||
|
||||
static Future<S> load(Locale locale) {
|
||||
final name = (locale.countryCode?.isEmpty ?? false)
|
||||
? locale.languageCode
|
||||
: locale.toString();
|
||||
final name =
|
||||
(locale.countryCode?.isEmpty ?? false)
|
||||
? locale.languageCode
|
||||
: locale.toString();
|
||||
final localeName = Intl.canonicalizedLocale(name);
|
||||
return initializeMessages(localeName).then((_) {
|
||||
Intl.defaultLocale = localeName;
|
||||
@@ -3568,6 +3569,16 @@ class S {
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Персональная диета установлена`
|
||||
String get personal_diet_set {
|
||||
return Intl.message(
|
||||
'Персональная диета установлена',
|
||||
name: 'personal_diet_set',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AppLocalizationDelegate extends LocalizationsDelegate<S> {
|
||||
|
||||
@@ -422,6 +422,7 @@
|
||||
"delete": "Удалить",
|
||||
"cannotDeleteAccount": "Не получилось удалить ваш аккаунт",
|
||||
"resend": "Отправить повторно",
|
||||
"notifications": "Уведомления"
|
||||
"notifications": "Уведомления",
|
||||
"personal_diet_set": "Персональная диета установлена"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user