2023-03-03 18:26:44 +01:00
|
|
|
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 '../services/date_service.dart';
|
|
|
|
import '../services/pages_service.dart';
|
|
|
|
|
|
|
|
void showTaskDonePopup(BuildContext context, Pages page) async {
|
|
|
|
Duration duration = await getTimeTill(page);
|
2023-03-04 10:29:35 +01:00
|
|
|
if (context.mounted) {
|
|
|
|
await showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return ChangeNotifierProvider(
|
|
|
|
create: (context) => TimerProvider(),
|
|
|
|
child: TaskDonePopup(
|
|
|
|
duration: duration,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
2023-03-03 18:26:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
]));
|
|
|
|
}
|
|
|
|
}
|