added last save location in settings

This commit is contained in:
Nico
2024-03-24 15:24:37 +01:00
parent edfe6c31bb
commit a902541591
6 changed files with 116 additions and 28 deletions

View File

@@ -1,9 +1,6 @@
todo: todo:
add primary key
maybe auch vorschläge aus templates in dropdown menüs anzeigen maybe auch vorschläge aus templates in dropdown menüs anzeigen
beim nächsten schritt als template
im englischen abändern im englischen abändern
Überall absätze machen und textfeld größer wenn langer text
gespeicherten ordner anzeigen gespeicherten ordner anzeigen
zurückfeld in datenansicht zurückfeld in datenansicht
überschriften für view cams überschriften für view cams
@@ -22,6 +19,9 @@ eintrg in db wenn http response (in sent column)
not to do: not to do:
Überall absätze machen und textfeld größer wenn langer text
beim nächsten schritt als template
add primary ke
wenn alles ausgefüllt trotzdem als template speichern wenn alles ausgefüllt trotzdem als template speichern
nach screenshots sortieren nach screenshots sortieren
speichern funktion zum Abbrechen speichern funktion zum Abbrechen

View File

@@ -237,24 +237,23 @@ class _AddCamMainState extends State<AddCamMain> {
} }
Future<void> showSaveOptionsDialog() async { Future<void> showSaveOptionsDialog() async {
return return showDialog(
showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
var dialogContext = context; var dialogContext = context;
return AlertDialog( return AlertDialog(
title: Text(AppLocalizations.of(context)!.savemethod), title: Text(AppLocalizations.of(context)!.savemethod),
actions: [ actions: [
TextButton(
TextButton(onPressed: () async { onPressed: () async {
saveTemplate(); saveTemplate();
Navigator.pushNamedAndRemoveUntil( Navigator.pushNamedAndRemoveUntil(
// ignore: use_build_context_synchronously // ignore: use_build_context_synchronously
context, context,
'/home', '/home',
(route) => false); (route) => false);
}, child: Text(AppLocalizations.of(context)!.template)), },
child: Text(AppLocalizations.of(context)!.template)),
TextButton( TextButton(
onPressed: () async { onPressed: () async {
saveFile(); saveFile();
@@ -278,9 +277,11 @@ class _AddCamMainState extends State<AddCamMain> {
(route) => false); (route) => false);
}, },
child: Text(AppLocalizations.of(context)!.saveasfile)), child: Text(AppLocalizations.of(context)!.saveasfile)),
TextButton(onPressed: () { TextButton(
onPressed: () {
Navigator.pop(dialogContext); Navigator.pop(dialogContext);
}, child: Text(AppLocalizations.of(context)!.cancel)), },
child: Text(AppLocalizations.of(context)!.cancel)),
], ],
); );
}); });
@@ -321,6 +322,8 @@ class _AddCamMainState extends State<AddCamMain> {
Future<void> saveFile() async { Future<void> saveFile() async {
String? selectedDirectory = await FilePicker.platform.getDirectoryPath(); String? selectedDirectory = await FilePicker.platform.getDirectoryPath();
SharedPreferences prefs = await SharedPreferences.getInstance();
Map place = getPlace(); Map place = getPlace();
String jsonPlace = jsonEncode(place); String jsonPlace = jsonEncode(place);
@@ -328,6 +331,7 @@ class _AddCamMainState extends State<AddCamMain> {
if (selectedDirectory == null) { if (selectedDirectory == null) {
return; return;
} }
await prefs.setString('saveDir', selectedDirectory);
File file = File('$selectedDirectory/cam-${id.text}.txt'); 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 // checks if required fields are not empty. If one is the name will be returned
List<String> validateData() { List<String> validateData() {
List<String> emptyFields = <String>[]; List<String> emptyFields = <String>[];
Map<String, TextEditingController> fields = { Map<String, TextEditingController> fields = {
@@ -649,8 +652,7 @@ class _AddCamMainState extends State<AddCamMain> {
), ),
Align( Align(
alignment: Alignment.bottomLeft, alignment: Alignment.bottomLeft,
child: child: SonstBem(sonstBemC: sonstBemC),
SonstBem(sonstBemC: sonstBemC),
), ),
], ],
)), )),

View File

@@ -46,6 +46,8 @@ class _CamIdState extends State<CamId> {
Expanded( Expanded(
flex: 2, flex: 2,
child: TextField( child: TextField(
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.camLink, hintText: AppLocalizations.of(context)!.camLink,
enabledBorder: widget.id.text.isEmpty enabledBorder: widget.id.text.isEmpty
@@ -138,6 +140,8 @@ class _RudelState extends State<Rudel> {
Expanded( Expanded(
flex: 2, flex: 2,
child: TextField( child: TextField(
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.rudel, hintText: AppLocalizations.of(context)!.rudel,
enabledBorder: widget.rudelC.text.isEmpty enabledBorder: widget.rudelC.text.isEmpty
@@ -436,6 +440,8 @@ class _Adresse1State extends State<Adresse1> {
Expanded( Expanded(
flex: 2, flex: 2,
child: TextField( child: TextField(
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.adresse1, hintText: AppLocalizations.of(context)!.adresse1,
enabledBorder: widget.adresse1C.text.isEmpty enabledBorder: widget.adresse1C.text.isEmpty
@@ -526,6 +532,8 @@ class _Adresse2State extends State<Adresse2> {
Expanded( Expanded(
flex: 2, flex: 2,
child: TextField( child: TextField(
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.adresse2), hintText: AppLocalizations.of(context)!.adresse2),
controller: widget.adresse2C, controller: widget.adresse2C,
@@ -604,6 +612,8 @@ class _Adresse3State extends State<Adresse3> {
Expanded( Expanded(
flex: 2, flex: 2,
child: TextField( child: TextField(
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.adresse3), hintText: AppLocalizations.of(context)!.adresse3),
controller: widget.adresse3C, controller: widget.adresse3C,
@@ -693,6 +703,8 @@ class _BLandState extends State<BLand> {
Expanded( Expanded(
flex: 2, flex: 2,
child: TextField( child: TextField(
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.bland, hintText: AppLocalizations.of(context)!.bland,
enabledBorder: widget.bLandC.text.isEmpty enabledBorder: widget.bLandC.text.isEmpty
@@ -782,6 +794,8 @@ class _LkrState extends State<Lkr> {
Expanded( Expanded(
flex: 2, flex: 2,
child: TextField( child: TextField(
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.lkr, hintText: AppLocalizations.of(context)!.lkr,
enabledBorder: widget.lkrC.text.isEmpty enabledBorder: widget.lkrC.text.isEmpty
@@ -871,6 +885,8 @@ class _BeiOrtState extends State<BeiOrt> {
Expanded( Expanded(
flex: 2, flex: 2,
child: TextField( child: TextField(
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.beiort, hintText: AppLocalizations.of(context)!.beiort,
enabledBorder: widget.beiOrtC.text.isEmpty enabledBorder: widget.beiOrtC.text.isEmpty
@@ -960,6 +976,8 @@ class _OrtInfoState extends State<OrtInfo> {
Expanded( Expanded(
flex: 2, flex: 2,
child: TextField( child: TextField(
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.ortinfo, hintText: AppLocalizations.of(context)!.ortinfo,
), ),
@@ -1160,6 +1178,8 @@ class _FFTypState extends State<FFTyp> {
Expanded( Expanded(
flex: 2, flex: 2,
child: TextField( child: TextField(
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.fftyp, hintText: AppLocalizations.of(context)!.fftyp,
enabledBorder: widget.ffTypC.text.isEmpty enabledBorder: widget.ffTypC.text.isEmpty
@@ -1500,6 +1520,8 @@ class _KSchloNrState extends State<KSchloNr> {
Expanded( Expanded(
flex: 2, flex: 2,
child: TextField( child: TextField(
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.kschlonr), hintText: AppLocalizations.of(context)!.kschlonr),
controller: widget.kSchloNrC, controller: widget.kSchloNrC,
@@ -1755,6 +1777,8 @@ class _AuftragState extends State<Auftrag> {
Expanded( Expanded(
flex: 2, flex: 2,
child: TextField( child: TextField(
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.auftrag), hintText: AppLocalizations.of(context)!.auftrag),
controller: widget.auftragC, controller: widget.auftragC,
@@ -1831,6 +1855,8 @@ class _KontAbspState extends State<KontAbsp> {
Expanded( Expanded(
flex: 2, flex: 2,
child: TextField( child: TextField(
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.kontabsp), hintText: AppLocalizations.of(context)!.kontabsp),
controller: widget.kontAbspC, controller: widget.kontAbspC,
@@ -1907,6 +1933,8 @@ class _SonstBemState extends State<SonstBem> {
Expanded( Expanded(
flex: 2, flex: 2,
child: TextField( child: TextField(
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.sonstbemerkungen), hintText: AppLocalizations.of(context)!.sonstbemerkungen),
controller: widget.sonstBemC, controller: widget.sonstBemC,
@@ -1983,6 +2011,8 @@ class _FKontakt1State extends State<FKontakt1> {
Expanded( Expanded(
flex: 2, flex: 2,
child: TextField( child: TextField(
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.fkontakt1), hintText: AppLocalizations.of(context)!.fkontakt1),
controller: widget.fKontakt1C, controller: widget.fKontakt1C,
@@ -2059,6 +2089,8 @@ class _FKontakt2State extends State<FKontakt2> {
Expanded( Expanded(
flex: 2, flex: 2,
child: TextField( child: TextField(
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.fkontakt2), hintText: AppLocalizations.of(context)!.fkontakt2),
controller: widget.fKontakt2C, controller: widget.fKontakt2C,
@@ -2135,6 +2167,8 @@ class _FKontakt3State extends State<FKontakt3> {
Expanded( Expanded(
flex: 3, flex: 3,
child: TextField( child: TextField(
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.fkontakt3), hintText: AppLocalizations.of(context)!.fkontakt3),
controller: widget.fKontakt3C, controller: widget.fKontakt3C,
@@ -2211,6 +2245,8 @@ class _StandortState extends State<Standort> {
Expanded( Expanded(
flex: 3, flex: 3,
child: TextField( child: TextField(
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.altstort, hintText: AppLocalizations.of(context)!.altstort,
enabledBorder: widget.standortC.text.isEmpty enabledBorder: widget.standortC.text.isEmpty
@@ -2385,6 +2421,8 @@ class _IntKommState extends State<IntKomm> {
Expanded( Expanded(
flex: 2, flex: 2,
child: TextField( child: TextField(
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.intkomm), hintText: AppLocalizations.of(context)!.intkomm),
controller: widget.intKommC, controller: widget.intKommC,
@@ -2461,6 +2499,8 @@ class _BetreuungState extends State<Betreuung> {
Expanded( Expanded(
flex: 3, flex: 3,
child: TextField( child: TextField(
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.betreuung), hintText: AppLocalizations.of(context)!.betreuung),
controller: widget.betreuungC, controller: widget.betreuungC,

View File

@@ -80,5 +80,7 @@
"viewplaces": "Standorte anzeigen", "viewplaces": "Standorte anzeigen",
"showloginscreen": "Login-Bildschirm Anzeigen", "showloginscreen": "Login-Bildschirm Anzeigen",
"apiaddress": "Api-Adresse", "apiaddress": "Api-Adresse",
"benutzername": "Benutzername" "benutzername": "Benutzername",
"filelocation": "Ort der zuletzt gespeicherten Datei:",
"open": "öffnen"
} }

View File

@@ -388,6 +388,16 @@
"benutzername": "Username", "benutzername": "Username",
"@benutzername": { "@benutzername": {
"description": "intro screen benutzername hint" "description": "intro screen benutzername hint"
},
"filelocation": "Location of the last saved file:",
"@filelocation": {
"description": "settings file location header"
},
"open": "Open",
"@open": {
"description": "open button"
} }
} }

View File

@@ -1,4 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:shared_preferences/shared_preferences.dart';
class Settings extends StatefulWidget { class Settings extends StatefulWidget {
const Settings({super.key}); const Settings({super.key});
@@ -8,8 +10,40 @@ class Settings extends StatefulWidget {
} }
class _SettingsState extends State<Settings> { class _SettingsState extends State<Settings> {
Future<String> _getSaveDir() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
final String saveDir = prefs.getString('saveDir') ?? "";
return saveDir;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return const Placeholder(); return Scaffold(
appBar: AppBar(title: Text(AppLocalizations.of(context)!.settings),),
body: Center(
child: Column(
children: [
Text(AppLocalizations.of(context)!.filelocation, style: const TextStyle(fontSize: 20),),
FutureBuilder(future: _getSaveDir(), builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
return Text(snapshot.data ?? "");
} else {
return const CircularProgressIndicator();
}
}),
ElevatedButton(onPressed: () {
}, child: Text(AppLocalizations.of(context)!.open))
],
),
),
);
} }
} }