added last save location in settings
This commit is contained in:
@@ -237,33 +237,32 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
}
|
||||
|
||||
Future<void> 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 {
|
||||
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(
|
||||
// ignore: use_build_context_synchronously
|
||||
context,
|
||||
'/home',
|
||||
(route) => false);
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
// ignore: use_build_context_synchronously
|
||||
context,
|
||||
'/home',
|
||||
(route) => false);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.sendtoserver)),
|
||||
TextButton(
|
||||
@@ -278,9 +277,11 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
(route) => false);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.saveasfile)),
|
||||
TextButton(onPressed: () {
|
||||
Navigator.pop(dialogContext);
|
||||
}, child: Text(AppLocalizations.of(context)!.cancel)),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(dialogContext);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.cancel)),
|
||||
],
|
||||
);
|
||||
});
|
||||
@@ -321,6 +322,8 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
Future<void> saveFile() async {
|
||||
String? selectedDirectory = await FilePicker.platform.getDirectoryPath();
|
||||
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
|
||||
Map place = getPlace();
|
||||
|
||||
String jsonPlace = jsonEncode(place);
|
||||
@@ -328,6 +331,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
if (selectedDirectory == null) {
|
||||
return;
|
||||
}
|
||||
await prefs.setString('saveDir', selectedDirectory);
|
||||
|
||||
File file = File('$selectedDirectory/cam-${id.text}.txt');
|
||||
|
||||
@@ -340,7 +344,6 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
|
||||
// checks if required fields are not empty. If one is the name will be returned
|
||||
List<String> validateData() {
|
||||
|
||||
List<String> emptyFields = <String>[];
|
||||
|
||||
Map<String, TextEditingController> fields = {
|
||||
@@ -649,8 +652,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child:
|
||||
SonstBem(sonstBemC: sonstBemC),
|
||||
child: SonstBem(sonstBemC: sonstBemC),
|
||||
),
|
||||
],
|
||||
)),
|
||||
|
||||
Reference in New Issue
Block a user