added option to cancel save of data
This commit is contained in:
@@ -245,20 +245,38 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> showSaveOptionsDialog() async {
|
Future<void> showSaveOptionsDialog() async {
|
||||||
return showDialog(
|
return
|
||||||
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
|
var dialogContext = context;
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: Text(AppLocalizations.of(context)!.savemethod),
|
title: Text(AppLocalizations.of(context)!.savemethod),
|
||||||
actions: [
|
actions: [
|
||||||
|
|
||||||
|
TextButton(onPressed: () async {
|
||||||
|
saveTemplate();
|
||||||
|
Navigator.pushNamedAndRemoveUntil(
|
||||||
|
// ignore: use_build_context_synchronously
|
||||||
|
context,
|
||||||
|
'/home',
|
||||||
|
(route) => false);
|
||||||
|
}, child: Text(AppLocalizations.of(context)!.template)),
|
||||||
|
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
saveFile();
|
||||||
_httpRequest();
|
_httpRequest();
|
||||||
// Navigator.pushNamedAndRemoveUntil(context, '/home', (route) => false);
|
Navigator.pushNamedAndRemoveUntil(
|
||||||
|
// ignore: use_build_context_synchronously
|
||||||
|
context,
|
||||||
|
'/home',
|
||||||
|
(route) => false);
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context)!.sendtoserver)),
|
child: Text(AppLocalizations.of(context)!.sendtoserver)),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
saveData();
|
||||||
await saveFile();
|
await saveFile();
|
||||||
// ignore: use_build_context_synchronously
|
// ignore: use_build_context_synchronously
|
||||||
Navigator.pushNamedAndRemoveUntil(
|
Navigator.pushNamedAndRemoveUntil(
|
||||||
@@ -267,7 +285,10 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
'/home',
|
'/home',
|
||||||
(route) => false);
|
(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<AddCamMain> {
|
|||||||
|
|
||||||
if (!isLastStep) {
|
if (!isLastStep) {
|
||||||
saveTemplate();
|
saveTemplate();
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
currentStep += 1;
|
currentStep += 1;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
List<String> emptyFields = validateData();
|
List<String> emptyFields = validateData();
|
||||||
// ! always fileed out
|
// ! always filled out
|
||||||
empty = true;
|
empty = false;
|
||||||
if (empty == true) {
|
if (empty == true) {
|
||||||
showTemplateDialog(emptyFields);
|
showTemplateDialog(emptyFields);
|
||||||
();
|
();
|
||||||
return;
|
return;
|
||||||
} else if (empty == false) {
|
} else if (empty == false) {
|
||||||
// throw const FormatException(("Speichert"));
|
|
||||||
saveData();
|
|
||||||
await showSaveOptionsDialog();
|
await showSaveOptionsDialog();
|
||||||
Navigator.pushNamedAndRemoveUntil(
|
|
||||||
// ignore: use_build_context_synchronously
|
|
||||||
context,
|
|
||||||
'/home',
|
|
||||||
(route) => false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user