use awesome dialog for taskdone popup

main
Julian Gegner 2023-03-06 13:48:15 +01:00
parent b8d3bc7048
commit 721d76dac0
2 changed files with 38 additions and 34 deletions

View File

@ -8,7 +8,9 @@ String formatTime(int seconds) {
String hours = twoDigits(duration.inHours.remainder(24)); String hours = twoDigits(duration.inHours.remainder(24));
String minutes = twoDigits(duration.inMinutes.remainder(60)); String minutes = twoDigits(duration.inMinutes.remainder(60));
String formattedSeconds = twoDigits(duration.inSeconds.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:'; if (duration.inHours != 0) formattedTime += '$hours:';
formattedTime += '$minutes:'; formattedTime += '$minutes:';
formattedTime += formattedSeconds; formattedTime += formattedSeconds;

View File

@ -1,43 +1,45 @@
import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.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/date_service.dart';
import 'package:smoke_cess_app/services/pages_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 { void showTaskDonePopup(BuildContext context, Pages page) async {
Duration duration = await getTimeTill(page); Duration duration = await getTimeTill(page);
if (context.mounted) { if (context.mounted) {
await showDialog( AwesomeDialog(
context: context, context: context,
builder: (BuildContext context) { dialogType: DialogType.info,
return ChangeNotifierProvider( body: Column(
create: (context) => TimerProvider(), children: [
child: TaskDonePopup( Text(
duration: duration, '${pages[page]?['title']} schon eingegeben',
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
), ),
); const SizedBox(
}, height: 10,
); ),
} const Text(
} 'Nächste Abfrage in',
),
class TaskDonePopup extends StatelessWidget { const SizedBox(
final Duration duration; height: 8,
const TaskDonePopup({super.key, required this.duration}); ),
ChangeNotifierProvider(
@override create: (context) => TimerProvider(),
Widget build(BuildContext context) { builder: (context, child) {
TimerProvider timerProvider = context.read<TimerProvider>(); TimerProvider timerProvider = context.read<TimerProvider>();
timerProvider.startTimer(duration); timerProvider.startTimer(duration);
return AlertDialog( return TimerWidget(duration: duration);
title: const Text('Schon gemacht'), },
content: Column( ),
mainAxisSize: MainAxisSize.min, const SizedBox(
crossAxisAlignment: CrossAxisAlignment.start, height: 15,
children: [ ),
const Text('Nächstes mal wieder:'), ],
TimerWidget(duration: duration) )).show();
]));
} }
} }