forked from eatvio/eatvio_app
feat(order info): added order info screen
This commit is contained in:
@@ -39,7 +39,7 @@ class CreateDietScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
class CreateDietScreenContent extends StatefulWidget {
|
||||
CreateDietScreenContent({super.key, this.diet});
|
||||
const CreateDietScreenContent({super.key, this.diet});
|
||||
final Diet? diet;
|
||||
|
||||
@override
|
||||
@@ -66,18 +66,20 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
|
||||
return BlocBuilder<CreateDietCubit, CreateDietState>(
|
||||
builder: (context, state) {
|
||||
if (state.published) {
|
||||
Future.delayed(Duration(milliseconds: 500), () {
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
if (!context.mounted) return;
|
||||
context.pop();
|
||||
showBottomSheetWithBlur(
|
||||
userRootNavigator: true,
|
||||
context: context,
|
||||
child: SuccessPublishedDietBottomSheet(
|
||||
title: '${state.dietData.name ?? 'Диета'}',
|
||||
title: state.dietData.name ?? 'Диета',
|
||||
),
|
||||
);
|
||||
});
|
||||
} else if (state.drafted) {
|
||||
Future.delayed(Duration(milliseconds: 500), () {
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
if (!context.mounted) return;
|
||||
context.pop();
|
||||
showBottomSheetWithBlur(
|
||||
context: context,
|
||||
@@ -103,13 +105,13 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: 8),
|
||||
const SizedBox(height: 8),
|
||||
MainBackgroundBouble(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(height: 16),
|
||||
const SizedBox(height: 16),
|
||||
CustomTextFormField(
|
||||
hintText: s.enter_diet_name,
|
||||
controller: nameController,
|
||||
@@ -119,12 +121,12 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
|
||||
},
|
||||
),
|
||||
if (state.dietNameError != null) ...[
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
CustomErrorWidget(error: state.dietNameError ?? ''),
|
||||
],
|
||||
SizedBox(height: 12),
|
||||
const SizedBox(height: 12),
|
||||
SizedBox(
|
||||
height: 132,
|
||||
child: CustomTextFormField(
|
||||
@@ -141,30 +143,30 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
|
||||
),
|
||||
),
|
||||
if (state.dietDescriptionError != null) ...[
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
CustomErrorWidget(error: state.dietDescriptionError ?? ''),
|
||||
],
|
||||
SizedBox(height: 12),
|
||||
DietDurationDropDownWidget(),
|
||||
SizedBox(height: 12),
|
||||
StatusDropDownWidget(),
|
||||
SizedBox(height: 16),
|
||||
DietTypeChoiceWidget(),
|
||||
SizedBox(height: 16),
|
||||
DietImagePickerWidget(),
|
||||
SizedBox(height: 16),
|
||||
const SizedBox(height: 12),
|
||||
const DietDurationDropDownWidget(),
|
||||
const SizedBox(height: 12),
|
||||
const StatusDropDownWidget(),
|
||||
const SizedBox(height: 16),
|
||||
const DietTypeChoiceWidget(),
|
||||
const SizedBox(height: 16),
|
||||
const DietImagePickerWidget(),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
const SizedBox(height: 16),
|
||||
MainBackgroundBouble(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
child: Center(
|
||||
child: Text(
|
||||
s.diet_plan + ' (${state.dietData.duration ?? 0} ' + getDayForm(state.dietData.duration ?? 0, s) + ')',
|
||||
'${s.diet_plan} (${state.dietData.duration ?? 0} ${getDayForm(state.dietData.duration ?? 0, s)})',
|
||||
style: TextStyles.headingXLSemibold.copyWith(
|
||||
color: appTheme.black,
|
||||
),
|
||||
@@ -172,16 +174,16 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
const SizedBox(height: 8),
|
||||
ListView.separated(
|
||||
padding: const EdgeInsets.all(0),
|
||||
itemBuilder: (context, index) => DayWidget(index: index),
|
||||
itemCount: state.dietData.dailySchedule?.length ?? 0,
|
||||
shrinkWrap: true,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
separatorBuilder: (context, index) => SizedBox(height: 8),
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
separatorBuilder: (context, index) => const SizedBox(height: 8),
|
||||
),
|
||||
SizedBox(height: 12),
|
||||
const SizedBox(height: 12),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Column(
|
||||
@@ -192,19 +194,20 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
|
||||
: () async {
|
||||
final diet = await context.read<CreateDietCubit>().getDietForPreview();
|
||||
if (diet == null) return;
|
||||
if (!context.mounted) return;
|
||||
GoRouter.of(context).pushNamed(DietPreviewScreen.name, extra: diet);
|
||||
},
|
||||
text: s.preview,
|
||||
height: 52,
|
||||
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.gray),
|
||||
buttonStyle: ButtonStyle(
|
||||
side: WidgetStatePropertyAll(BorderSide.none),
|
||||
side: const WidgetStatePropertyAll(BorderSide.none),
|
||||
backgroundColor: WidgetStatePropertyAll(appTheme.dottedBorder),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 12),
|
||||
const SizedBox(height: 12),
|
||||
if (state.isDietPublishing)
|
||||
Loader()
|
||||
const Loader()
|
||||
else
|
||||
CustomOutlinedButton(
|
||||
onPressed: () async {
|
||||
@@ -213,11 +216,13 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
|
||||
widget.diet!.id,
|
||||
);
|
||||
if (result == 'error') {
|
||||
if (!context.mounted) return;
|
||||
showErrorDialog(context, title: '${s.could_not_update_diet} ${state.dietData.name}');
|
||||
}
|
||||
} else {
|
||||
final result = await context.read<CreateDietCubit>().createDiet();
|
||||
if (result == 'error') {
|
||||
if (!context.mounted) return;
|
||||
showErrorDialog(context, title: '${s.could_not_publish_diet} ${state.dietData.name}');
|
||||
}
|
||||
}
|
||||
@@ -226,14 +231,14 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
|
||||
height: 52,
|
||||
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.whiteA700),
|
||||
buttonStyle: ButtonStyle(
|
||||
side: WidgetStatePropertyAll(BorderSide.none),
|
||||
side: const WidgetStatePropertyAll(BorderSide.none),
|
||||
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user