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 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;

View File

@ -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>();
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>();
timerProvider.startTimer(duration);
return TimerWidget(duration: duration);
},
),
const SizedBox(
height: 15,
),
],
)).show();
}
}