Merge branch 'awesome-task-done-popup' into 'main'

use awesome dialog for taskdone popup

See merge request Crondung/hsma_cpd!32
main
Kai Mannweiler 2023-03-06 12:51:19 +00:00
commit 5ab6e598f9
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 { ),
final Duration duration; const SizedBox(
const TaskDonePopup({super.key, required this.duration}); height: 8,
),
@override ChangeNotifierProvider(
Widget build(BuildContext context) { create: (context) => TimerProvider(),
TimerProvider timerProvider = context.read<TimerProvider>(); builder: (context, child) {
timerProvider.startTimer(duration); TimerProvider timerProvider = context.read<TimerProvider>();
return AlertDialog( timerProvider.startTimer(duration);
title: const Text('Schon gemacht'), return TimerWidget(duration: duration);
content: Column( },
mainAxisSize: MainAxisSize.min, ),
crossAxisAlignment: CrossAxisAlignment.start, const SizedBox(
children: [ height: 15,
const Text('Nächstes mal wieder:'), ),
TimerWidget(duration: duration) ],
])); )).show();
} }
} }