new test cases

This commit is contained in:
Username1548
2025-01-29 14:47:27 +07:00
parent 370e8883a0
commit 4242265830
39 changed files with 898 additions and 461 deletions

View File

@@ -5,8 +5,8 @@ import 'package:intl/intl.dart';
import 'package:table_calendar/table_calendar.dart';
class CalendarWidget extends StatefulWidget {
const CalendarWidget({super.key});
const CalendarWidget({super.key, required this.startDate});
final List<DateTime> startDate;
@override
State<CalendarWidget> createState() => _CalendarWidgetState();
}
@@ -56,6 +56,9 @@ class _CalendarWidgetState extends State<CalendarWidget> {
_selectedDay = selectedDay;
_focusedDay = focusedDay;
});
if (widget.startDate.isNotEmpty) {
widget.startDate[0] = selectedDay;
}
}
},
onFormatChanged: (format) {
@@ -69,6 +72,7 @@ class _CalendarWidgetState extends State<CalendarWidget> {
_focusedDay = focusedDay;
},
calendarStyle: CalendarStyle(
outsideDaysVisible: true,
weekendTextStyle: TextStyle(
color: appTheme.gray,
),
@@ -90,6 +94,17 @@ class _CalendarWidgetState extends State<CalendarWidget> {
color: appTheme.blueA400,
shape: BoxShape.circle,
),
outsideTextStyle: TextStyle(
color: appTheme.gray,
),
outsideDecoration: BoxDecoration(
color: appTheme.dividerColor,
shape: BoxShape.circle,
),
withinRangeDecoration: BoxDecoration(
color: appTheme.blueA400,
shape: BoxShape.circle,
),
todayTextStyle: TextStyle(
color: appTheme.gray,
),

View File

@@ -0,0 +1,79 @@
import 'package:eatvio_app/core/utils/toasts.dart';
import 'package:eatvio_app/core/widgets/bottom_sheet_handler_bar.dart';
import 'package:eatvio_app/features/diets/presentation/cubit/about_diet_cubit.dart';
import 'package:eatvio_app/features/diets/presentation/widgets/start_diet_bottom_sheet.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_outlined_button.dart';
import 'package:flutter/material.dart';
class CancelDietBottomSheet extends StatelessWidget {
const CancelDietBottomSheet({super.key, required this.aboutDietCubit, this.title, this.dietName});
final AboutDietCubit aboutDietCubit;
final String? title;
final String? dietName;
@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(height: 4),
BottomSheetHandlerBar(),
SizedBox(height: 12),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 25.0),
child: Text(
title ?? 'Вы действительно хотите отменить прохождение диеты ${dietName ?? ''}?',
textAlign: TextAlign.center,
style: TextStyles.headingXLSemibold.copyWith(
color: appTheme.black,
),
),
),
Padding(
padding: EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 28),
child: CustomOutlinedButton(
onPressed: () async {
if (title != null) {
final result = await aboutDietCubit.cancelDiet();
if (result) {
Navigator.pop(context);
showSuccessToast('предыдущая диета отменена');
showModalBottomSheet(
context: context,
builder: (context) => StartDietBottomSheet(
aboutDietCubit: aboutDietCubit,
),
);
} else {
showErrorToast('Не удалось отменить диету');
Navigator.pop(context);
}
} else {
final result = await aboutDietCubit.cancelDiet();
if (result) {
showSuccessToast('Диета отменена');
Navigator.pop(context);
aboutDietCubit.clearStartedDietsState();
} else {
showErrorToast('Не удалось отменить диету');
Navigator.pop(context);
}
}
},
height: 60,
text: 'Подтвердить',
buttonTextStyle: TextStyles.textLSemibold.copyWith(
color: appTheme.whiteA700,
),
buttonStyle: ButtonStyle(
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
side: WidgetStatePropertyAll(BorderSide.none),
),
),
),
],
);
}
}

View File

@@ -1,3 +1,4 @@
import 'package:eatvio_app/core/utils/toasts.dart';
import 'package:eatvio_app/core/widgets/bottom_sheet_handler_bar.dart';
import 'package:eatvio_app/core/widgets/custom_divider.dart';
import 'package:eatvio_app/features/diets/presentation/cubit/about_diet_cubit.dart';
@@ -8,9 +9,16 @@ import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
import 'package:flutter/material.dart';
class StartDietBottomSheet extends StatelessWidget {
class StartDietBottomSheet extends StatefulWidget {
const StartDietBottomSheet({super.key, required this.aboutDietCubit});
final AboutDietCubit aboutDietCubit;
@override
State<StartDietBottomSheet> createState() => _StartDietBottomSheetState();
}
class _StartDietBottomSheetState extends State<StartDietBottomSheet> {
final startDate = [DateTime.now()];
@override
Widget build(BuildContext context) {
final s = S.of(context);
@@ -42,11 +50,23 @@ class StartDietBottomSheet extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: CustomDivider(),
),
CalendarWidget(),
CalendarWidget(
startDate: startDate,
),
Padding(
padding: EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 28),
child: CustomOutlinedButton(
onPressed: () {},
onPressed: () async {
final result = await widget.aboutDietCubit.startDiet(startDate[0]);
if (result) {
showSuccessToast('Диета успешно начата');
Navigator.pop(context);
widget.aboutDietCubit.emitCurrentStartedDietsState();
} else {
showErrorToast('Не удалось начать диету');
Navigator.pop(context);
}
},
height: 60,
text: s.startDiet,
buttonTextStyle: TextStyles.textLSemibold.copyWith(