luc sitzung
This commit is contained in:
@@ -17,7 +17,11 @@ class AddCamMain extends StatefulWidget {
|
||||
final bool isFinished;
|
||||
final Map<String, dynamic>? existingData;
|
||||
|
||||
const AddCamMain({super.key, this.isTemplate = false, this.existingData, this.isFinished = false});
|
||||
const AddCamMain(
|
||||
{super.key,
|
||||
this.isTemplate = false,
|
||||
this.existingData,
|
||||
this.isFinished = false});
|
||||
|
||||
@override
|
||||
State<AddCamMain> createState() => _AddCamMainState();
|
||||
@@ -52,11 +56,9 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
TextEditingController betreuungC = TextEditingController();
|
||||
|
||||
String selectedStatus = 'aktiv';
|
||||
String selectedSTTyp = 'opportunistisch';
|
||||
String selectedFotoFilm = 'Foto';
|
||||
String selectedMEZ = 'Sommerzeit';
|
||||
String selectedPlatzung = 'Kirrung';
|
||||
String selectedBearsafe = 'Nein';
|
||||
String selectedPlatzung = '';
|
||||
|
||||
Position currentPosition = Position(
|
||||
longitude: 10.0,
|
||||
@@ -89,13 +91,11 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
'BeiOrt': beiOrtC.text,
|
||||
'OrtInfo': ortInfoC.text,
|
||||
'Status': selectedStatus,
|
||||
'STTyp': selectedSTTyp,
|
||||
'FFTyp': ffTypC.text,
|
||||
'FotoFilm': selectedFotoFilm,
|
||||
'MEZ': selectedMEZ,
|
||||
'Platzung': selectedPlatzung,
|
||||
'KSchloNr': kSchloNrC.text,
|
||||
'Bearsafe': selectedBearsafe,
|
||||
'KontDat': kontDat.toString().split(" ").first,
|
||||
'AbbauDat': abbauDat.toString().split(" ").first.replaceAll("null", ""),
|
||||
'Auftrag': auftragC.text,
|
||||
@@ -179,16 +179,16 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
beiOrtC.text = widget.existingData!['BeiOrt'];
|
||||
ortInfoC.text = widget.existingData!['OrtInfo'];
|
||||
selectedStatus = widget.existingData!['Status'];
|
||||
selectedSTTyp = widget.existingData!['STTyp'];
|
||||
ffTypC.text = widget.existingData!['FFTyp'];
|
||||
selectedFotoFilm = widget.existingData!['FotoFilm'];
|
||||
selectedMEZ = widget.existingData!['MEZ'];
|
||||
selectedPlatzung = widget.existingData!['Platzung'];
|
||||
kSchloNrC.text = widget.existingData!['KSchloNr'];
|
||||
selectedBearsafe = widget.existingData!['Bearsafe'];
|
||||
datum = DateTime.parse(widget.existingData!['Datum']);
|
||||
kontDat = DateTime.parse(widget.existingData!['KontDat']);
|
||||
abbauDat = widget.existingData!['AbbauDat'] == "" ? null : DateTime.parse(widget.existingData!['AbbauDat']);
|
||||
abbauDat = widget.existingData!['AbbauDat'] == ""
|
||||
? null
|
||||
: DateTime.parse(widget.existingData!['AbbauDat']);
|
||||
auftragC.text = widget.existingData!['Auftrag'];
|
||||
kontAbspC.text = widget.existingData!['KontAbsp'];
|
||||
sonstBemC.text = widget.existingData!['SonstBem'];
|
||||
@@ -233,6 +233,35 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
});
|
||||
}
|
||||
|
||||
Future<dynamic> _showServerErrorDialog() {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text(AppLocalizations.of(context)!.servererrortitle),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
|
||||
|
||||
int errorCode = _httpRequest();
|
||||
|
||||
if (errorCode != 201) {
|
||||
Navigator.pop(context);
|
||||
_showServerErrorDialog();
|
||||
}
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.sendagain)),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.cancel))
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> showSaveOptionsDialog() async {
|
||||
return showDialog(
|
||||
context: context,
|
||||
@@ -252,13 +281,38 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
child: Text(AppLocalizations.of(context)!.template)),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
_httpRequest();
|
||||
saveData();
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
// ignore: use_build_context_synchronously
|
||||
context,
|
||||
'/home',
|
||||
(route) => false);
|
||||
|
||||
int errorCode = _httpRequest();
|
||||
|
||||
if (errorCode != 201) {
|
||||
saveData();
|
||||
_showServerErrorDialog();
|
||||
} else {
|
||||
saveData();
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text(
|
||||
AppLocalizations.of(context)!.successful),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.back)),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
context, '/home', (route) => false);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!
|
||||
.continueB))
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.sendtoserver)),
|
||||
TextButton(
|
||||
@@ -269,14 +323,15 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.saveasfile)),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
saveData();
|
||||
onPressed: () {
|
||||
saveData();
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
// ignore: use_build_context_synchronously
|
||||
context,
|
||||
'/home',
|
||||
(route) => false);
|
||||
}, child: Text(AppLocalizations.of(context)!.justsave)),
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.justsave)),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
@@ -287,13 +342,15 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
});
|
||||
}
|
||||
|
||||
int _httpRequest() {
|
||||
|
||||
|
||||
void _httpRequest() async {
|
||||
Map<String, dynamic> place = getPlace();
|
||||
|
||||
Methods(jsonEncode(place)).httpRequest();
|
||||
Methods method = Methods();
|
||||
|
||||
method.httpRequest(jsonEncode(place));
|
||||
|
||||
return method.errorCode;
|
||||
}
|
||||
|
||||
Future<void> saveFile() async {
|
||||
@@ -310,7 +367,8 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
await prefs.setString('saveDir', selectedDirectory);
|
||||
|
||||
// ignore: use_build_context_synchronously
|
||||
File file = File('$selectedDirectory/${AppLocalizations.of(context)!.justplace}-${standortC.text}.txt');
|
||||
File file = File(
|
||||
'$selectedDirectory/${AppLocalizations.of(context)!.justplace}-${standortC.text}.txt');
|
||||
|
||||
try {
|
||||
await file.writeAsString(jsonPlace);
|
||||
@@ -346,7 +404,6 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
'Lkr': lkrC,
|
||||
'BeiOrt': beiOrtC,
|
||||
'Status': TextEditingController(text: selectedStatus),
|
||||
'STTyp': TextEditingController(text: selectedSTTyp),
|
||||
'FFTyp': ffTypC,
|
||||
'FotoFilm': TextEditingController(text: selectedFotoFilm),
|
||||
'MEZ': TextEditingController(text: selectedMEZ),
|
||||
@@ -418,14 +475,6 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
const SizedBox(
|
||||
height: 1,
|
||||
),
|
||||
STTyp(
|
||||
initialSTTyp: selectedSTTyp,
|
||||
onSTTypChanged: (sttyp) {
|
||||
setState(() {
|
||||
selectedSTTyp = sttyp;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
@@ -488,21 +537,6 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
});
|
||||
},
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Row(
|
||||
children: [
|
||||
Text(AppLocalizations.of(context)!.bearsafe),
|
||||
],
|
||||
)),
|
||||
Bearsafe(
|
||||
initialBearsafe: selectedBearsafe,
|
||||
onBearsafeChanged: (bearsafe) {
|
||||
setState(() {
|
||||
selectedBearsafe = bearsafe;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
@@ -530,20 +564,24 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
title: Text(AppLocalizations.of(context)!.secondstep),
|
||||
content: Column(
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Text(currentPosition.latitude.toString())),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Text(currentPosition.longitude.toString())),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: ElevatedButton(
|
||||
Row(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
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) {
|
||||
@@ -571,6 +609,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
}
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.openMap)),
|
||||
],
|
||||
),
|
||||
VarTextField(
|
||||
textController: bLandC,
|
||||
@@ -609,6 +648,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
],
|
||||
)),
|
||||
Platzung(
|
||||
initialPlatzung: selectedPlatzung,
|
||||
onPlatzungChanged: (platzung) {
|
||||
setState(() {
|
||||
selectedPlatzung = platzung;
|
||||
|
||||
Reference in New Issue
Block a user