action display, and full display, started action editor

This commit is contained in:
Joshua Burman
2025-01-24 16:15:22 -05:00
parent 0cf62ec4b4
commit 60bc571987
39 changed files with 32576 additions and 251 deletions

View File

@ -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);
}
},
),
],
);
},
);
}
}