Merge branch 'main' of https://git.getmemy.coffee/nico/fforte
This commit is contained in:
@@ -74,8 +74,8 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
|
||||
DateTime? abbauDat;
|
||||
DateTime datum = DateTime.now();
|
||||
DateTime kontDat = DateTime.now();
|
||||
DateTime protoAm = DateTime.now();
|
||||
DateTime? kontDat = DateTime.now();
|
||||
DateTime? protoAm = DateTime.now();
|
||||
|
||||
Map<String, dynamic> getPlace() {
|
||||
Map<String, dynamic> place = {
|
||||
@@ -121,14 +121,15 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
|
||||
// determine live position with checks for denied permission and turned off location service
|
||||
Future<Position> _deteterminePosition() async {
|
||||
|
||||
|
||||
|
||||
bool locationEnabled;
|
||||
LocationPermission permissionGiven;
|
||||
|
||||
locationEnabled = await Geolocator.isLocationServiceEnabled();
|
||||
if (!locationEnabled) {
|
||||
// ignore: use_build_context_synchronously
|
||||
if (!locationEnabled && mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
// ignore: use_build_context_synchronously
|
||||
content: Text(AppLocalizations.of(context)!.locationDisabled)));
|
||||
return currentPosition;
|
||||
}
|
||||
@@ -136,20 +137,16 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
permissionGiven = await Geolocator.checkPermission();
|
||||
if (permissionGiven == LocationPermission.denied) {
|
||||
permissionGiven = await Geolocator.requestPermission();
|
||||
if (permissionGiven == LocationPermission.denied) {
|
||||
// ignore: use_build_context_synchronously
|
||||
if (permissionGiven == LocationPermission.denied && mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
// ignore: use_build_context_synchronously
|
||||
content: Text(AppLocalizations.of(context)!.locationForbidden)));
|
||||
|
||||
return currentPosition;
|
||||
}
|
||||
}
|
||||
|
||||
if (permissionGiven == LocationPermission.deniedForever) {
|
||||
// ignore: use_build_context_synchronously
|
||||
if (permissionGiven == LocationPermission.deniedForever && mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
// ignore: use_build_context_synchronously
|
||||
content: Text(AppLocalizations.of(context)!.locationForbidden)));
|
||||
return currentPosition;
|
||||
}
|
||||
@@ -169,38 +166,42 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
|
||||
// If a template is edited this fills in the existing values
|
||||
if (widget.isTemplate || widget.isFinished && widget.existingData != null) {
|
||||
cid.text = widget.existingData!['CID'];
|
||||
rudelC.text = widget.existingData!['Rudel'];
|
||||
adresse1C.text = widget.existingData!['Adresse1'];
|
||||
adresse2C.text = widget.existingData!['Adresse2'];
|
||||
adresse3C.text = widget.existingData!['Adresse3'];
|
||||
bLandC.text = widget.existingData!['BLand'];
|
||||
lkrC.text = widget.existingData!['Lkr'];
|
||||
beiOrtC.text = widget.existingData!['BeiOrt'];
|
||||
ortInfoC.text = widget.existingData!['OrtInfo'];
|
||||
selectedStatus = widget.existingData!['Status'];
|
||||
ffTypC.text = widget.existingData!['FFTyp'];
|
||||
selectedFotoFilm = widget.existingData!['FotoFilm'];
|
||||
selectedMEZ = widget.existingData!['MEZ'];
|
||||
selectedPlatzung = widget.existingData!['Platzung'];
|
||||
kSchloNrC.text = widget.existingData!['KSchloNr'];
|
||||
cid.text = widget.existingData!['CID'] ?? "";
|
||||
rudelC.text = widget.existingData!['Rudel'] ?? "";
|
||||
adresse1C.text = widget.existingData!['Adresse1'] ?? "";
|
||||
adresse2C.text = widget.existingData!['Adresse2'] ?? "";
|
||||
adresse3C.text = widget.existingData!['Adresse3'] ?? "";
|
||||
bLandC.text = widget.existingData!['BLand'] ?? "";
|
||||
lkrC.text = widget.existingData!['Lkr'] ?? "";
|
||||
beiOrtC.text = widget.existingData!['BeiOrt'] ?? "";
|
||||
ortInfoC.text = widget.existingData!['OrtInfo'] ?? "";
|
||||
selectedStatus = widget.existingData!['Status'] ?? "";
|
||||
ffTypC.text = widget.existingData!['FFTyp'] ?? "";
|
||||
selectedFotoFilm = widget.existingData!['FotoFilm'] ?? "";
|
||||
selectedMEZ = widget.existingData!['MEZ'] ?? "";
|
||||
selectedPlatzung = widget.existingData!['Platzung'] ?? "";
|
||||
kSchloNrC.text = widget.existingData!['KSchloNr'] ?? "";
|
||||
datum = DateTime.parse(widget.existingData!['Datum']);
|
||||
kontDat = DateTime.parse(widget.existingData!['KontDat']);
|
||||
abbauDat = widget.existingData!['AbbauDat'] == ""
|
||||
kontDat = widget.existingData!['KontDat'] == null
|
||||
? null
|
||||
: DateTime.parse(widget.existingData!['KontDat']);
|
||||
abbauDat = widget.existingData!['AbbauDat'] == null
|
||||
? null
|
||||
: DateTime.parse(widget.existingData!['AbbauDat']);
|
||||
auftragC.text = widget.existingData!['Auftrag'];
|
||||
kontAbspC.text = widget.existingData!['KontAbsp'];
|
||||
sonstBemC.text = widget.existingData!['SonstBem'];
|
||||
fKontakt1C.text = widget.existingData!['FKontakt1'];
|
||||
fKontakt2C.text = widget.existingData!['FKontakt2'];
|
||||
fKontakt3C.text = widget.existingData!['FKontakt3'];
|
||||
standortC.text = widget.existingData!['Standort'];
|
||||
auftragC.text = widget.existingData!['Auftrag'] ?? "";
|
||||
kontAbspC.text = widget.existingData!['KontAbsp'] ?? "";
|
||||
sonstBemC.text = widget.existingData!['SonstBem'] ?? "";
|
||||
fKontakt1C.text = widget.existingData!['FKontakt1'] ?? "";
|
||||
fKontakt2C.text = widget.existingData!['FKontakt2'] ?? "";
|
||||
fKontakt3C.text = widget.existingData!['FKontakt3'] ?? "";
|
||||
standortC.text = widget.existingData!['Standort'] ?? "";
|
||||
kTage1C.text = widget.existingData!['KTage1'].toString();
|
||||
kTage2C.text = widget.existingData!['KTage2'].toString();
|
||||
protoAm = DateTime.parse(widget.existingData!['ProtoAm']);
|
||||
intKommC.text = widget.existingData!['IntKomm'];
|
||||
betreuungC.text = widget.existingData!['Betreuung'];
|
||||
protoAm = widget.existingData!['ProtoAm'] == null
|
||||
? null
|
||||
: DateTime.parse(widget.existingData!['ProtoAm']);
|
||||
intKommC.text = widget.existingData!['IntKomm'] ?? "";
|
||||
betreuungC.text = widget.existingData!['Betreuung'] ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,8 +243,6 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
|
||||
|
||||
int errorCode = _httpRequest();
|
||||
|
||||
if (errorCode != 201) {
|
||||
@@ -273,7 +272,6 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
onPressed: () async {
|
||||
saveTemplate();
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
// ignore: use_build_context_synchronously
|
||||
context,
|
||||
'/home',
|
||||
(route) => false);
|
||||
@@ -281,7 +279,6 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
child: Text(AppLocalizations.of(context)!.template)),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
|
||||
int errorCode = _httpRequest();
|
||||
|
||||
if (errorCode != 201) {
|
||||
@@ -319,14 +316,12 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
onPressed: () async {
|
||||
saveData();
|
||||
saveFile();
|
||||
// ignore: use_build_context_synchronously
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.saveasfile)),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
saveData();
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
// ignore: use_build_context_synchronously
|
||||
context,
|
||||
'/home',
|
||||
(route) => false);
|
||||
@@ -343,7 +338,6 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
}
|
||||
|
||||
int _httpRequest() {
|
||||
|
||||
Map<String, dynamic> place = getPlace();
|
||||
|
||||
Methods method = Methods();
|
||||
@@ -360,36 +354,34 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
String jsonPlace = jsonEncode(place);
|
||||
|
||||
if (selectedDirectory == null) {
|
||||
// ignore: use_build_context_synchronously
|
||||
Navigator.pop(context);
|
||||
if (mounted) Navigator.pop(context);
|
||||
return;
|
||||
}
|
||||
await prefs.setString('saveDir', selectedDirectory);
|
||||
|
||||
// ignore: use_build_context_synchronously
|
||||
File file = File(
|
||||
'$selectedDirectory/${AppLocalizations.of(context)!.justplace}-${standortC.text}.txt');
|
||||
'$selectedDirectory/${mounted ? AppLocalizations.of(context)!.justplace : const Text('')}-${standortC.text}.txt');
|
||||
|
||||
try {
|
||||
await file.writeAsString(jsonPlace);
|
||||
} catch (e) {
|
||||
// ignore: use_build_context_synchronously
|
||||
if (mounted) {
|
||||
Navigator.pop(context);
|
||||
// ignore: use_build_context_synchronously
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
// ignore: use_build_context_synchronously
|
||||
content: Text(AppLocalizations.of(context)!.savefilefailed)));
|
||||
content: Text(AppLocalizations.of(context)!.savefilefailed))); }
|
||||
return;
|
||||
}
|
||||
// ignore: use_build_context_synchronously
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Datei gespeichert in $selectedDirectory')));
|
||||
}
|
||||
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
// ignore: use_build_context_synchronously
|
||||
if (mounted) {
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
context,
|
||||
'/home',
|
||||
(route) => false);
|
||||
}
|
||||
}
|
||||
|
||||
// checks if required fields are not empty. If one is the name will be returned
|
||||
@@ -568,47 +560,47 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Text(currentPosition.latitude.toString()),
|
||||
|
||||
Text(currentPosition.longitude.toString()),
|
||||
|
||||
Text(currentPosition.latitude.toString()),
|
||||
Text(currentPosition.longitude.toString()),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 15,),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
final result = await Navigator.of(context)
|
||||
.push<LatLng>(
|
||||
MaterialPageRoute(builder: (context) {
|
||||
return Karte(
|
||||
ortInfoC: ortInfoC,
|
||||
beiOrtC: beiOrtC,
|
||||
currentPosition: currentPosition,
|
||||
onPositionChange: (updatedPosition) {
|
||||
setState(() {
|
||||
currentPosition = updatedPosition;
|
||||
});
|
||||
},
|
||||
);
|
||||
}));
|
||||
if (result != null) {
|
||||
setState(() {
|
||||
currentPosition = Position(
|
||||
latitude: result.latitude,
|
||||
longitude: result.longitude,
|
||||
timestamp: DateTime.now(),
|
||||
accuracy: 0.0,
|
||||
altitude: 0.0,
|
||||
altitudeAccuracy: 0.0,
|
||||
heading: 0.0,
|
||||
headingAccuracy: 0.0,
|
||||
speed: 0.0,
|
||||
speedAccuracy: 0.0,
|
||||
const SizedBox(
|
||||
width: 15,
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
final result = await Navigator.of(context)
|
||||
.push<LatLng>(
|
||||
MaterialPageRoute(builder: (context) {
|
||||
return Karte(
|
||||
ortInfoC: ortInfoC,
|
||||
beiOrtC: beiOrtC,
|
||||
currentPosition: currentPosition,
|
||||
onPositionChange: (updatedPosition) {
|
||||
setState(() {
|
||||
currentPosition = updatedPosition;
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.openMap)),
|
||||
}));
|
||||
if (result != null) {
|
||||
setState(() {
|
||||
currentPosition = Position(
|
||||
latitude: result.latitude,
|
||||
longitude: result.longitude,
|
||||
timestamp: DateTime.now(),
|
||||
accuracy: 0.0,
|
||||
altitude: 0.0,
|
||||
altitudeAccuracy: 0.0,
|
||||
heading: 0.0,
|
||||
headingAccuracy: 0.0,
|
||||
speed: 0.0,
|
||||
speedAccuracy: 0.0,
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.openMap)),
|
||||
],
|
||||
),
|
||||
VarTextField(
|
||||
@@ -663,9 +655,19 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
content: Column(
|
||||
children: [
|
||||
Datum(
|
||||
datum: datum,
|
||||
initDatum: datum,
|
||||
onDateChanged: (value) {
|
||||
datum = value;
|
||||
},
|
||||
),
|
||||
KontDat(
|
||||
initKontDat: kontDat,
|
||||
onDateChanged: (value) {
|
||||
setState(() {
|
||||
kontDat = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
KontDat(kontDat: kontDat),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
@@ -714,7 +716,12 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
AbbauDat(abbauDat: abbauDat),
|
||||
AbbauDat(
|
||||
initAbbauDat: abbauDat,
|
||||
onDateChanged: (value) {
|
||||
abbauDat = value;
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
|
||||
Reference in New Issue
Block a user