forked from eatvio/eatvio_app
feat: diary add modal and error dialogs
This commit is contained in:
@@ -1,20 +1,89 @@
|
||||
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/bottom_sheet_handler_bar.dart';
|
||||
import 'package:eatvio_app/core/widgets/bottom_sheet_with_blur.dart';
|
||||
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
|
||||
import 'package:eatvio_app/core/widgets/show_error_dialog.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class FinishDayButtonWidget extends StatefulWidget {
|
||||
final Future<void> Function() onPressed;
|
||||
final bool hasProducts;
|
||||
|
||||
const FinishDayButtonWidget({super.key, required this.onPressed});
|
||||
const FinishDayButtonWidget({super.key, required this.onPressed, required this.hasProducts});
|
||||
|
||||
@override
|
||||
State<FinishDayButtonWidget> createState() => _FinishDayButtonWidgetState();
|
||||
}
|
||||
|
||||
class _FinishDayButtonWidgetState extends State<FinishDayButtonWidget> {
|
||||
void _onTap() {
|
||||
if (!widget.hasProducts) {
|
||||
showErrorDialog(
|
||||
context,
|
||||
title: 'Не добавлено продуктов',
|
||||
description: 'Добавьте хотя бы один продукт в любой из приёмов пищи, чтобы закончить день.',
|
||||
);
|
||||
return;
|
||||
}
|
||||
_showConfirmationBottomSheet();
|
||||
}
|
||||
|
||||
void _showConfirmationBottomSheet() {
|
||||
showBottomSheetWithBlur(
|
||||
context: context,
|
||||
height: null,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
const BottomSheetHandlerBar(),
|
||||
const SizedBox(height: 20),
|
||||
Text('Закончить день', style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black)),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'После завершения дня, его уже нельзя будет отредактировать',
|
||||
style: TextStyles.textSMedium.copyWith(color: appTheme.black),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
CustomOutlinedButton(
|
||||
text: 'Закончить',
|
||||
height: 52,
|
||||
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.whiteA700),
|
||||
buttonStyle: ButtonStyle(
|
||||
side: const WidgetStatePropertyAll(BorderSide.none),
|
||||
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
|
||||
),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
await widget.onPressed();
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
CustomOutlinedButton(
|
||||
text: 'Отмена',
|
||||
height: 52,
|
||||
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.black),
|
||||
buttonStyle: const ButtonStyle(
|
||||
side: WidgetStatePropertyAll(BorderSide.none),
|
||||
backgroundColor: WidgetStatePropertyAll(Color(0xFFEAEAEA)),
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: widget.onPressed,
|
||||
onTap: _onTap,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Ink(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
|
||||
Reference in New Issue
Block a user