From c9676d7820c7f0c33a63adbaf193632e6c59f9a8 Mon Sep 17 00:00:00 2001 From: Nico Date: Sat, 23 Mar 2024 16:15:17 +0100 Subject: [PATCH] added option to cancel save of data --- lib/addCam/add_cam_main.dart | 39 ++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/lib/addCam/add_cam_main.dart b/lib/addCam/add_cam_main.dart index 2478f00..7c9cfee 100644 --- a/lib/addCam/add_cam_main.dart +++ b/lib/addCam/add_cam_main.dart @@ -245,20 +245,38 @@ class _AddCamMainState extends State { } Future showSaveOptionsDialog() async { - return showDialog( + return + showDialog( context: context, builder: (BuildContext context) { + var dialogContext = context; return AlertDialog( title: Text(AppLocalizations.of(context)!.savemethod), actions: [ + + TextButton(onPressed: () async { + saveTemplate(); + Navigator.pushNamedAndRemoveUntil( + // ignore: use_build_context_synchronously + context, + '/home', + (route) => false); + }, child: Text(AppLocalizations.of(context)!.template)), + TextButton( onPressed: () async { + saveFile(); _httpRequest(); - // Navigator.pushNamedAndRemoveUntil(context, '/home', (route) => false); + Navigator.pushNamedAndRemoveUntil( + // ignore: use_build_context_synchronously + context, + '/home', + (route) => false); }, child: Text(AppLocalizations.of(context)!.sendtoserver)), TextButton( onPressed: () async { + saveData(); await saveFile(); // ignore: use_build_context_synchronously Navigator.pushNamedAndRemoveUntil( @@ -267,7 +285,10 @@ class _AddCamMainState extends State { '/home', (route) => false); }, - child: Text(AppLocalizations.of(context)!.saveasfile)) + child: Text(AppLocalizations.of(context)!.saveasfile)), + TextButton(onPressed: () { + Navigator.pop(dialogContext); + }, child: Text(AppLocalizations.of(context)!.cancel)), ], ); }); @@ -715,27 +736,19 @@ class _AddCamMainState extends State { if (!isLastStep) { saveTemplate(); - setState(() { currentStep += 1; }); } else { List emptyFields = validateData(); - // ! always fileed out - empty = true; + // ! always filled out + empty = false; if (empty == true) { showTemplateDialog(emptyFields); (); return; } else if (empty == false) { - // throw const FormatException(("Speichert")); - saveData(); await showSaveOptionsDialog(); - Navigator.pushNamedAndRemoveUntil( - // ignore: use_build_context_synchronously - context, - '/home', - (route) => false); } } },