diff --git a/lib/utils/timer_util.dart b/lib/utils/timer_util.dart index 42a9180..57b9f9c 100644 --- a/lib/utils/timer_util.dart +++ b/lib/utils/timer_util.dart @@ -8,7 +8,9 @@ String formatTime(int seconds) { String hours = twoDigits(duration.inHours.remainder(24)); String minutes = twoDigits(duration.inMinutes.remainder(60)); String formattedSeconds = twoDigits(duration.inSeconds.remainder(60)); - if (duration.inDays != 0) formattedTime += '$days:'; + if (duration.inDays != 0) { + formattedTime += '$days Tag ${duration.inDays > 1 ? "e" : ""}, '; + } if (duration.inHours != 0) formattedTime += '$hours:'; formattedTime += '$minutes:'; formattedTime += formattedSeconds; diff --git a/lib/widgets/popup/popup_for_task_done.dart b/lib/widgets/popup/popup_for_task_done.dart index cf7f7ed..4565aca 100644 --- a/lib/widgets/popup/popup_for_task_done.dart +++ b/lib/widgets/popup/popup_for_task_done.dart @@ -1,43 +1,45 @@ +import 'package:awesome_dialog/awesome_dialog.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:smoke_cess_app/providers/timer_provider.dart'; -import 'package:smoke_cess_app/widgets/timer_widget.dart'; import 'package:smoke_cess_app/services/date_service.dart'; import 'package:smoke_cess_app/services/pages_service.dart'; +import 'package:smoke_cess_app/widgets/timer_widget.dart'; + +import '../../providers/timer_provider.dart'; void showTaskDonePopup(BuildContext context, Pages page) async { Duration duration = await getTimeTill(page); if (context.mounted) { - await showDialog( - context: context, - builder: (BuildContext context) { - return ChangeNotifierProvider( - create: (context) => TimerProvider(), - child: TaskDonePopup( - duration: duration, - ), - ); - }, - ); - } -} - -class TaskDonePopup extends StatelessWidget { - final Duration duration; - const TaskDonePopup({super.key, required this.duration}); - - @override - Widget build(BuildContext context) { - TimerProvider timerProvider = context.read(); - timerProvider.startTimer(duration); - return AlertDialog( - title: const Text('Schon gemacht'), - content: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Text('Nächstes mal wieder:'), - TimerWidget(duration: duration) - ])); + AwesomeDialog( + context: context, + dialogType: DialogType.info, + body: Column( + children: [ + Text( + '${pages[page]?['title']} schon eingegeben', + style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16), + ), + const SizedBox( + height: 10, + ), + const Text( + 'Nächste Abfrage in', + ), + const SizedBox( + height: 8, + ), + ChangeNotifierProvider( + create: (context) => TimerProvider(), + builder: (context, child) { + TimerProvider timerProvider = context.read(); + timerProvider.startTimer(duration); + return TimerWidget(duration: duration); + }, + ), + const SizedBox( + height: 15, + ), + ], + )).show(); } }