42 lines
1.3 KiB
Dart
42 lines
1.3 KiB
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 '../services/date_service.dart';
|
||
|
import '../services/pages_service.dart';
|
||
|
|
||
|
void showTaskDonePopup(BuildContext context, Pages page) async {
|
||
|
Duration duration = await getTimeTill(page);
|
||
|
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)
|
||
|
]));
|
||
|
}
|
||
|
}
|