action display, and full display, started action editor
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:sendtrain/providers/action_timer.dart';
|
||||
|
||||
Future showGenericDialog(dynamic object, BuildContext parentContext) {
|
||||
return showGeneralDialog(
|
||||
@ -55,3 +57,51 @@ Future showUpdateDialog(String title, String content, BuildContext context,
|
||||
[Function? callback]) {
|
||||
return showCrudDialog(title, content, context, callback);
|
||||
}
|
||||
|
||||
// TODO - factor out, this should be more generic
|
||||
Future<bool?> showBackDialog(BuildContext context) async {
|
||||
ActionTimer at = Provider.of<ActionTimer>(context, listen: false);
|
||||
|
||||
if (at.pending || at.complete) {
|
||||
await at.clear();
|
||||
return true;
|
||||
} else {
|
||||
return await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Are you sure?'),
|
||||
content: const Text(
|
||||
'Leaving will stop the current activity. Are you sure you want to leave?',
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
textStyle: Theme.of(context).textTheme.labelLarge,
|
||||
),
|
||||
child: const Text('Nevermind'),
|
||||
onPressed: () async {
|
||||
Navigator.pop(context, false);
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
textStyle: Theme.of(context).textTheme.labelLarge,
|
||||
),
|
||||
child: const Text('Leave'),
|
||||
onPressed: () async {
|
||||
ActionTimer at =
|
||||
Provider.of<ActionTimer>(context, listen: false);
|
||||
await at.clear();
|
||||
|
||||
if (context.mounted) {
|
||||
Navigator.pop(context, true);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user