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,37 +354,35 @@ 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
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Datei gespeichert in $selectedDirectory')));
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
// ignore: use_build_context_synchronously
|
||||
context,
|
||||
'/home',
|
||||
(route) => false);
|
||||
}
|
||||
}
|
||||
|
||||
// checks if required fields are not empty. If one is the name will be returned
|
||||
List<String> validateData() {
|
||||
@@ -569,12 +561,12 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
Column(
|
||||
children: [
|
||||
Text(currentPosition.latitude.toString()),
|
||||
|
||||
Text(currentPosition.longitude.toString()),
|
||||
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 15,),
|
||||
const SizedBox(
|
||||
width: 15,
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
final result = await Navigator.of(context)
|
||||
@@ -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(
|
||||
|
||||
@@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:geocoding/geocoding.dart';
|
||||
@@ -155,14 +154,15 @@ class Karte extends StatefulWidget {
|
||||
{super.key,
|
||||
required this.currentPosition,
|
||||
required this.onPositionChange,
|
||||
required this.beiOrtC, required this.ortInfoC});
|
||||
required this.beiOrtC,
|
||||
required this.ortInfoC});
|
||||
|
||||
@override
|
||||
KarteState createState() => KarteState();
|
||||
}
|
||||
|
||||
class KarteState extends State<Karte> {
|
||||
List<Marker> markers = [ ];
|
||||
List<Marker> markers = [];
|
||||
LatLng? selectedPosition;
|
||||
Position? updatedPosition;
|
||||
bool saveVisible = false;
|
||||
@@ -197,7 +197,7 @@ class KarteState extends State<Karte> {
|
||||
List<Placemark> placemarks = await placemarkFromCoordinates(
|
||||
selectedPosition!.latitude,
|
||||
selectedPosition!.longitude);
|
||||
print(placemarks);
|
||||
// print(placemarks);
|
||||
|
||||
if (selectedPosition != null) {
|
||||
setState(() {
|
||||
@@ -293,16 +293,23 @@ class KarteState extends State<Karte> {
|
||||
// datum is the variable where the chosen date is stored
|
||||
|
||||
class Datum extends StatefulWidget {
|
||||
final DateTime? datum;
|
||||
final DateTime? initDatum;
|
||||
final Function(DateTime) onDateChanged;
|
||||
|
||||
const Datum({super.key, required this.datum});
|
||||
const Datum({super.key, required this.initDatum, required this.onDateChanged});
|
||||
|
||||
@override
|
||||
State<Datum> createState() => _DatumState();
|
||||
}
|
||||
|
||||
class _DatumState extends State<Datum> {
|
||||
DateTime? datum = DateTime.now();
|
||||
DateTime? datum;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
datum = widget.initDatum;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -316,6 +323,7 @@ class _DatumState extends State<Datum> {
|
||||
final date = await pickDate();
|
||||
if (date == null) return;
|
||||
setState(() => datum = date);
|
||||
widget.onDateChanged(date);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.pickDate)),
|
||||
),
|
||||
@@ -336,14 +344,8 @@ class _DatumState extends State<Datum> {
|
||||
initialDate: datum!,
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(5000));
|
||||
if (date == null) return null;
|
||||
setState(() => datum = date);
|
||||
|
||||
var place = {'Datum': DateFormat('yyyy-MM-dd').format(datum!)};
|
||||
|
||||
await DBHelper().addPlace(place);
|
||||
|
||||
return datum;
|
||||
return date;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -473,10 +475,10 @@ class Platzung extends StatefulWidget {
|
||||
final Function(String) onPlatzungChanged;
|
||||
final String? initialPlatzung;
|
||||
|
||||
|
||||
const Platzung(
|
||||
{super.key,
|
||||
required this.onPlatzungChanged, this.initialPlatzung,
|
||||
const Platzung({
|
||||
super.key,
|
||||
required this.onPlatzungChanged,
|
||||
this.initialPlatzung,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -494,7 +496,6 @@ class _PlatzungState extends State<Platzung> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
@@ -725,16 +726,24 @@ class _MEZState extends State<MEZ> {
|
||||
// KontDat
|
||||
|
||||
class KontDat extends StatefulWidget {
|
||||
final DateTime? kontDat;
|
||||
final DateTime? initKontDat;
|
||||
final Function(DateTime) onDateChanged;
|
||||
|
||||
const KontDat({super.key, required this.kontDat});
|
||||
const KontDat(
|
||||
{super.key, required this.initKontDat, required this.onDateChanged});
|
||||
|
||||
@override
|
||||
State<KontDat> createState() => _KontDatState();
|
||||
}
|
||||
|
||||
class _KontDatState extends State<KontDat> {
|
||||
DateTime? kontDat = DateTime.now();
|
||||
DateTime? kontDat;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
kontDat = widget.initKontDat;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -747,7 +756,10 @@ class _KontDatState extends State<KontDat> {
|
||||
onPressed: () async {
|
||||
final date = await pickDate();
|
||||
if (date == null) return;
|
||||
setState(() => kontDat = date);
|
||||
setState(() {
|
||||
kontDat = date;
|
||||
});
|
||||
widget.onDateChanged(date);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.pickkontdat)),
|
||||
),
|
||||
@@ -765,26 +777,21 @@ class _KontDatState extends State<KontDat> {
|
||||
Future<DateTime?> pickDate() async {
|
||||
final date = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: kontDat!,
|
||||
initialDate: kontDat ?? DateTime.now(),
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(5000));
|
||||
if (date == null) return null;
|
||||
setState(() => kontDat = date);
|
||||
|
||||
var place = {'KontDat': DateFormat('yyyy-MM-dd').format(kontDat!)};
|
||||
|
||||
await DBHelper().addPlace(place);
|
||||
|
||||
return kontDat;
|
||||
return date;
|
||||
}
|
||||
}
|
||||
|
||||
// AbbauDat
|
||||
|
||||
class AbbauDat extends StatefulWidget {
|
||||
final DateTime? abbauDat;
|
||||
final DateTime? initAbbauDat;
|
||||
final Function(DateTime) onDateChanged;
|
||||
|
||||
const AbbauDat({super.key, required this.abbauDat});
|
||||
const AbbauDat({super.key, required this.initAbbauDat, required this.onDateChanged});
|
||||
|
||||
@override
|
||||
State<AbbauDat> createState() => _AbbauDatState();
|
||||
@@ -793,6 +800,12 @@ class AbbauDat extends StatefulWidget {
|
||||
class _AbbauDatState extends State<AbbauDat> {
|
||||
DateTime? abbauDat;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
abbauDat = widget.initAbbauDat;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
@@ -805,6 +818,7 @@ class _AbbauDatState extends State<AbbauDat> {
|
||||
final date = await pickDate();
|
||||
if (date == null) return;
|
||||
setState(() => abbauDat = date);
|
||||
widget.onDateChanged(date);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.pickabbaudat)),
|
||||
),
|
||||
@@ -841,7 +855,6 @@ class _AbbauDatState extends State<AbbauDat> {
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(5000));
|
||||
if (date == null) return null;
|
||||
setState(() => abbauDat = date);
|
||||
|
||||
return abbauDat;
|
||||
}
|
||||
|
||||
@@ -32,11 +32,11 @@ class Methods {
|
||||
// ignore: unused_catch_clause
|
||||
} on DioException catch (e) {
|
||||
_errorCode = response.statusCode;
|
||||
print('is hier. var: ${_errorCode}');
|
||||
print('is hier. var: $_errorCode');
|
||||
return;
|
||||
}
|
||||
_errorCode = response.statusCode;
|
||||
print('is hier 2. var: ${_errorCode}');
|
||||
print('is hier 2. var: $_errorCode');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user