changed (hopefully) everything to new List with TextEditingControllers
time forgot to save sth ig
This commit is contained in:
@@ -7,15 +7,15 @@ abstract interface class IDb {
|
|||||||
|
|
||||||
onCreateDatabases(Database excursionDB, int version);
|
onCreateDatabases(Database excursionDB, int version);
|
||||||
|
|
||||||
Future<int> addMainEntry(Map<String, dynamic> excursion);
|
Future<int> addMainEntry(Map<String, String> excursion);
|
||||||
|
|
||||||
Future<void> updateMainEntry(Map<String, dynamic> excursion);
|
Future<void> updateMainEntry(Map<String, String> excursion);
|
||||||
|
|
||||||
Future<void> updateSent(int id);
|
Future<void> updateSent(int id);
|
||||||
|
|
||||||
Future<void> addTemplate(Map<String, dynamic> templates);
|
Future<void> addTemplate(Map<String, String> templates);
|
||||||
|
|
||||||
Future<void> updateTemplate(Map<String, dynamic> template);
|
Future<void> updateTemplate(Map<String, String> template);
|
||||||
|
|
||||||
Future<List<Map<String, dynamic>>> getAllMainEntries();
|
Future<List<Map<String, dynamic>>> getAllMainEntries();
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class ExcursionDBHelper implements IDb{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The function that helps
|
// The function that helps
|
||||||
|
// TODO Change to right cols
|
||||||
@override
|
@override
|
||||||
onCreateDatabases(Database excursionDB, int version) async {
|
onCreateDatabases(Database excursionDB, int version) async {
|
||||||
await excursionDB.execute(
|
await excursionDB.execute(
|
||||||
@@ -41,7 +42,7 @@ class ExcursionDBHelper implements IDb{
|
|||||||
|
|
||||||
// Function to add a finished entry and return its ID
|
// Function to add a finished entry and return its ID
|
||||||
@override
|
@override
|
||||||
Future<int> addMainEntry(Map<String, dynamic> excursion) async {
|
Future<int> addMainEntry(Map<String, String> excursion) async {
|
||||||
var excursionDBClient = await dB;
|
var excursionDBClient = await dB;
|
||||||
final existingID = await excursionDBClient.query(
|
final existingID = await excursionDBClient.query(
|
||||||
'excursion',
|
'excursion',
|
||||||
@@ -64,7 +65,7 @@ class ExcursionDBHelper implements IDb{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> updateMainEntry(Map<String, dynamic> excursion) async {
|
Future<void> updateMainEntry(Map<String, String> excursion) async {
|
||||||
var excursionDBClient = await dB;
|
var excursionDBClient = await dB;
|
||||||
|
|
||||||
await excursionDBClient
|
await excursionDBClient
|
||||||
@@ -82,7 +83,7 @@ class ExcursionDBHelper implements IDb{
|
|||||||
|
|
||||||
// same thing as before but with templatews
|
// same thing as before but with templatews
|
||||||
@override
|
@override
|
||||||
Future<void> addTemplate(Map<String, dynamic> templates) async {
|
Future<void> addTemplate(Map<String, String> templates) async {
|
||||||
var excursionDBClient = await dB;
|
var excursionDBClient = await dB;
|
||||||
|
|
||||||
final existingCID = await excursionDBClient.query(
|
final existingCID = await excursionDBClient.query(
|
||||||
@@ -103,7 +104,7 @@ class ExcursionDBHelper implements IDb{
|
|||||||
|
|
||||||
// Updates a existing template
|
// Updates a existing template
|
||||||
@override
|
@override
|
||||||
Future<void> updateTemplate(Map<String, dynamic> template) async {
|
Future<void> updateTemplate(Map<String, String> template) async {
|
||||||
var excursionDBClient = await dB;
|
var excursionDBClient = await dB;
|
||||||
|
|
||||||
await excursionDBClient.update(
|
await excursionDBClient.update(
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class PlaceDBHelper implements IDb{
|
|||||||
|
|
||||||
// Function to add a finished entry and return its ID
|
// Function to add a finished entry and return its ID
|
||||||
@override
|
@override
|
||||||
Future<int> addMainEntry(Map<String, dynamic> place) async {
|
Future<int> addMainEntry(Map<String, String> place) async {
|
||||||
var placeDBClient = await dB;
|
var placeDBClient = await dB;
|
||||||
final existingID = await placeDBClient.query(
|
final existingID = await placeDBClient.query(
|
||||||
'place',
|
'place',
|
||||||
@@ -64,7 +64,7 @@ class PlaceDBHelper implements IDb{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> updateMainEntry(Map<String, dynamic> place) async {
|
Future<void> updateMainEntry(Map<String, String> place) async {
|
||||||
var placeDBClient = await dB;
|
var placeDBClient = await dB;
|
||||||
|
|
||||||
await placeDBClient
|
await placeDBClient
|
||||||
@@ -82,7 +82,7 @@ class PlaceDBHelper implements IDb{
|
|||||||
|
|
||||||
// same thing as before but with templatews
|
// same thing as before but with templatews
|
||||||
@override
|
@override
|
||||||
Future<void> addTemplate(Map<String, dynamic> templates) async {
|
Future<void> addTemplate(Map<String, String> templates) async {
|
||||||
var placeDBClient = await dB;
|
var placeDBClient = await dB;
|
||||||
|
|
||||||
final existingCID = await placeDBClient.query(
|
final existingCID = await placeDBClient.query(
|
||||||
@@ -103,7 +103,7 @@ class PlaceDBHelper implements IDb{
|
|||||||
|
|
||||||
// Updates a existing template
|
// Updates a existing template
|
||||||
@override
|
@override
|
||||||
Future<void> updateTemplate(Map<String, dynamic> template) async {
|
Future<void> updateTemplate(Map<String, String> template) async {
|
||||||
var placeDBClient = await dB;
|
var placeDBClient = await dB;
|
||||||
|
|
||||||
await placeDBClient.update(
|
await placeDBClient.update(
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'package:fforte/enums/databases.dart';
|
import 'package:fforte/enums/databases.dart';
|
||||||
import 'package:fforte/screens/addCam/cam_widgets.dart';
|
import 'package:fforte/screens/addCam/cam_widgets.dart';
|
||||||
import 'package:fforte/screens/helper/dialog_helper.dart';
|
|
||||||
import 'package:fforte/screens/helper/snack_bar_helper.dart';
|
import 'package:fforte/screens/helper/snack_bar_helper.dart';
|
||||||
import 'package:fforte/screens/sharedMethods/http_request.dart';
|
|
||||||
import 'package:fforte/screens/addCam/exceptions/location_disabled_exception.dart';
|
import 'package:fforte/screens/addCam/exceptions/location_disabled_exception.dart';
|
||||||
import 'package:fforte/screens/addCam/exceptions/location_forbidden_exception.dart';
|
import 'package:fforte/screens/addCam/exceptions/location_forbidden_exception.dart';
|
||||||
import 'package:fforte/screens/addCam/services/geolocator_service.dart';
|
import 'package:fforte/screens/addCam/services/geolocator_service.dart';
|
||||||
import 'package:fforte/screens/sharedMethods/save_file.dart';
|
|
||||||
import 'package:fforte/screens/sharedMethods/save_main_entry.dart';
|
|
||||||
import 'package:fforte/screens/sharedMethods/save_template.dart';
|
import 'package:fforte/screens/sharedMethods/save_template.dart';
|
||||||
import 'package:fforte/screens/sharedWidgets/datum.dart';
|
import 'package:fforte/screens/sharedWidgets/datum.dart';
|
||||||
import 'package:fforte/screens/sharedWidgets/var_text_field.dart';
|
import 'package:fforte/screens/sharedWidgets/var_text_field.dart';
|
||||||
@@ -22,7 +17,7 @@ class AddCamMain extends StatefulWidget {
|
|||||||
final bool isTemplate;
|
final bool isTemplate;
|
||||||
final bool isFinished;
|
final bool isFinished;
|
||||||
final bool isSent;
|
final bool isSent;
|
||||||
final Map<String, dynamic>? existingData;
|
final Map<String, TextEditingController>? existingData;
|
||||||
|
|
||||||
const AddCamMain(
|
const AddCamMain(
|
||||||
{super.key,
|
{super.key,
|
||||||
@@ -40,28 +35,28 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
int currentStep = 0;
|
int currentStep = 0;
|
||||||
// bool isTemplate = false;
|
// bool isTemplate = false;
|
||||||
|
|
||||||
TextEditingController cid = TextEditingController();
|
// TextEditingController cid = TextEditingController();
|
||||||
TextEditingController rudelC = TextEditingController();
|
// TextEditingController rudelC = TextEditingController();
|
||||||
TextEditingController adresse1C = TextEditingController();
|
// TextEditingController adresse1C = TextEditingController();
|
||||||
TextEditingController adresse2C = TextEditingController();
|
// TextEditingController adresse2C = TextEditingController();
|
||||||
TextEditingController adresse3C = TextEditingController();
|
// TextEditingController adresse3C = TextEditingController();
|
||||||
TextEditingController bLandC = TextEditingController();
|
// TextEditingController bLandC = TextEditingController();
|
||||||
TextEditingController lkrC = TextEditingController();
|
// TextEditingController lkrC = TextEditingController();
|
||||||
TextEditingController beiOrtC = TextEditingController();
|
// TextEditingController beiOrtC = TextEditingController();
|
||||||
TextEditingController ortInfoC = TextEditingController();
|
// TextEditingController ortInfoC = TextEditingController();
|
||||||
TextEditingController ffTypC = TextEditingController();
|
// TextEditingController ffTypC = TextEditingController();
|
||||||
TextEditingController kSchloNrC = TextEditingController();
|
// TextEditingController kSchloNrC = TextEditingController();
|
||||||
TextEditingController auftragC = TextEditingController();
|
// TextEditingController auftragC = TextEditingController();
|
||||||
TextEditingController kontAbspC = TextEditingController();
|
// TextEditingController kontAbspC = TextEditingController();
|
||||||
TextEditingController sonstBemC = TextEditingController();
|
// TextEditingController sonstBemC = TextEditingController();
|
||||||
TextEditingController fKontakt1C = TextEditingController();
|
// TextEditingController fKontakt1C = TextEditingController();
|
||||||
TextEditingController fKontakt2C = TextEditingController();
|
// TextEditingController fKontakt2C = TextEditingController();
|
||||||
TextEditingController fKontakt3C = TextEditingController();
|
// TextEditingController fKontakt3C = TextEditingController();
|
||||||
TextEditingController standortC = TextEditingController();
|
// TextEditingController standortC = TextEditingController();
|
||||||
TextEditingController kTage1C = TextEditingController();
|
// TextEditingController kTage1C = TextEditingController();
|
||||||
TextEditingController kTage2C = TextEditingController();
|
// TextEditingController kTage2C = TextEditingController();
|
||||||
TextEditingController intKommC = TextEditingController();
|
// TextEditingController intKommC = TextEditingController();
|
||||||
TextEditingController betreuungC = TextEditingController();
|
// TextEditingController betreuungC = TextEditingController();
|
||||||
|
|
||||||
String selectedStatus = 'aktiv';
|
String selectedStatus = 'aktiv';
|
||||||
String selectedFotoFilm = 'Foto';
|
String selectedFotoFilm = 'Foto';
|
||||||
@@ -85,79 +80,105 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
DateTime? kontDat = DateTime.now();
|
DateTime? kontDat = DateTime.now();
|
||||||
DateTime? protoAm = DateTime.now();
|
DateTime? protoAm = DateTime.now();
|
||||||
|
|
||||||
Map<String, dynamic> getPlace() {
|
Map<String, TextEditingController> getFieldsController() {
|
||||||
Map<String, dynamic> place = {
|
Map<String, TextEditingController> rmap = {
|
||||||
'ID': widget.existingData?['ID'],
|
// Step 1
|
||||||
'CID': cid.text,
|
"Status": TextEditingController(),
|
||||||
'Rudel': rudelC.text,
|
"Betreuung": TextEditingController(),
|
||||||
'Datum': datum.toString().split(" ").first,
|
"Standort": TextEditingController(),
|
||||||
'Adresse1': adresse1C.text,
|
"CID": TextEditingController(),
|
||||||
'Adresse2': adresse2C.text,
|
"FFTyp": TextEditingController(),
|
||||||
'Adresse3': adresse3C.text,
|
"Mez": TextEditingController(),
|
||||||
'BLand': bLandC.text,
|
"KSchloNr": TextEditingController(),
|
||||||
'Lkr': lkrC.text,
|
"Rudel": TextEditingController(),
|
||||||
'BeiOrt': beiOrtC.text,
|
|
||||||
'OrtInfo': ortInfoC.text,
|
|
||||||
'Status': selectedStatus,
|
|
||||||
'FFTyp': ffTypC.text,
|
|
||||||
'FotoFilm': selectedFotoFilm,
|
|
||||||
'MEZ': selectedMEZ,
|
|
||||||
'Platzung': selectedPlatzung,
|
|
||||||
'KSchloNr': kSchloNrC.text,
|
|
||||||
'KontDat': kontDat.toString().split(" ").first,
|
|
||||||
'AbbauDat': abbauDat.toString().split(" ").first.replaceAll("null", ""),
|
|
||||||
'Auftrag': auftragC.text,
|
|
||||||
'KontAbsp': kontAbspC.text,
|
|
||||||
'SonstBem': sonstBemC.text,
|
|
||||||
'FKontakt1': fKontakt1C.text,
|
|
||||||
'FKontakt2': fKontakt2C.text,
|
|
||||||
'FKontakt3': fKontakt3C.text,
|
|
||||||
'Standort': standortC.text,
|
|
||||||
'KTage1': kTage1C.text,
|
|
||||||
'KTage2': kTage2C.text,
|
|
||||||
'ProtoAm': protoAm.toString().split(" ").first,
|
|
||||||
'IntKomm': intKommC.text,
|
|
||||||
'Betreuung': betreuungC.text,
|
|
||||||
'DECLNG': currentPosition.longitude,
|
|
||||||
'DECLAT': currentPosition.latitude,
|
|
||||||
};
|
|
||||||
|
|
||||||
return place;
|
// Step 2
|
||||||
|
"OrtInfo": TextEditingController(),
|
||||||
|
"BeiOrt": TextEditingController(),
|
||||||
|
"Bland": TextEditingController(),
|
||||||
|
"Lkr": TextEditingController(),
|
||||||
|
"Platzung": TextEditingController(),
|
||||||
|
|
||||||
|
// Step 3
|
||||||
|
"DECLNG": TextEditingController(),
|
||||||
|
"DECLAT": TextEditingController(),
|
||||||
|
"Datum": TextEditingController(),
|
||||||
|
"KontDat": TextEditingController(),
|
||||||
|
"KTage1": TextEditingController(),
|
||||||
|
"KTage2": TextEditingController(),
|
||||||
|
"AbbauDat": TextEditingController(),
|
||||||
|
"Auftrag": TextEditingController(),
|
||||||
|
"KontAbsp": TextEditingController(),
|
||||||
|
"SonstBem": TextEditingController(),
|
||||||
|
|
||||||
|
// Step 4
|
||||||
|
"Adresse1": TextEditingController(),
|
||||||
|
"Adresse2": TextEditingController(),
|
||||||
|
"Adresse3": TextEditingController(),
|
||||||
|
"FKontakt1": TextEditingController(),
|
||||||
|
"FKontakt2": TextEditingController(),
|
||||||
|
"FKontakt3": TextEditingController(),
|
||||||
|
"IntKomm": TextEditingController(),
|
||||||
|
|
||||||
|
// Gone?
|
||||||
|
"ProtoAm": TextEditingController(),
|
||||||
|
"FotoFilm": TextEditingController(),
|
||||||
|
};
|
||||||
|
return rmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool empty = false;
|
Map<String, String> getFieldsText() {
|
||||||
|
Map<String, String> rmap = {};
|
||||||
|
|
||||||
// determine live position with checks for denied permission and turned off location service
|
for (var itemKey in getFieldsController().keys) {
|
||||||
// Future<Position> _deteterminePosition() async {
|
rmap[itemKey] = getFieldsController()["key"]!.text;
|
||||||
// bool locationEnabled;
|
}
|
||||||
// LocationPermission permissionGiven;
|
|
||||||
|
return rmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Map<String, dynamic> getPlace() {
|
||||||
|
// Map<String, dynamic> place = {
|
||||||
|
// 'ID': widget.existingData?['ID'],
|
||||||
|
// 'CID': cid.text,
|
||||||
|
// 'Rudel': rudelC.text,
|
||||||
|
// 'Datum': datum.toString().split(" ").first,
|
||||||
|
// 'Adresse1': adresse1C.text,
|
||||||
|
// 'Adresse2': adresse2C.text,
|
||||||
|
// 'Adresse3': adresse3C.text,
|
||||||
|
// 'BLand': bLandC.text,
|
||||||
|
// 'Lkr': lkrC.text,
|
||||||
|
// 'BeiOrt': beiOrtC.text,
|
||||||
|
// 'OrtInfo': ortInfoC.text,
|
||||||
|
// 'Status': selectedStatus,
|
||||||
|
// 'FFTyp': ffTypC.text,
|
||||||
|
// 'FotoFilm': selectedFotoFilm,
|
||||||
|
// 'MEZ': selectedMEZ,
|
||||||
|
// 'Platzung': selectedPlatzung,
|
||||||
|
// 'KSchloNr': kSchloNrC.text,
|
||||||
|
// 'KontDat': kontDat.toString().split(" ").first,
|
||||||
|
// 'AbbauDat': abbauDat.toString().split(" ").first.replaceAll("null", ""),
|
||||||
|
// 'Auftrag': auftragC.text,
|
||||||
|
// 'KontAbsp': kontAbspC.text,
|
||||||
|
// 'SonstBem': sonstBemC.text,
|
||||||
|
// 'FKontakt1': fKontakt1C.text,
|
||||||
|
// 'FKontakt2': fKontakt2C.text,
|
||||||
|
// 'FKontakt3': fKontakt3C.text,
|
||||||
|
// 'Standort': standortC.text,
|
||||||
|
// 'KTage1': kTage1C.text,
|
||||||
|
// 'KTage2': kTage2C.text,
|
||||||
|
// 'ProtoAm': protoAm.toString().split(" ").first,
|
||||||
|
// 'IntKomm': intKommC.text,
|
||||||
|
// 'Betreuung': betreuungC.text,
|
||||||
|
// 'DECLNG': currentPosition.longitude,
|
||||||
|
// 'DECLAT': currentPosition.latitude,
|
||||||
|
// };
|
||||||
//
|
//
|
||||||
// locationEnabled = await Geolocator.isLocationServiceEnabled();
|
// return place;
|
||||||
// if (!locationEnabled && mounted) {
|
|
||||||
// ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
|
||||||
// content: Text(AppLocalizations.of(context)!.locationDisabled)));
|
|
||||||
// return currentPosition;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// permissionGiven = await Geolocator.checkPermission();
|
|
||||||
// if (permissionGiven == LocationPermission.denied) {
|
|
||||||
// permissionGiven = await Geolocator.requestPermission();
|
|
||||||
// if (permissionGiven == LocationPermission.denied && mounted) {
|
|
||||||
// ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
|
||||||
// content: Text(AppLocalizations.of(context)!.locationForbidden)));
|
|
||||||
//
|
|
||||||
// return currentPosition;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (permissionGiven == LocationPermission.deniedForever && mounted) {
|
|
||||||
// ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
|
||||||
// content: Text(AppLocalizations.of(context)!.locationForbidden)));
|
|
||||||
// return currentPosition;
|
|
||||||
// }
|
|
||||||
// return currentPosition = await Geolocator.getCurrentPosition();
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
bool empty = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -167,319 +188,90 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
GeolocatorService.deteterminePosition()
|
GeolocatorService.deteterminePosition()
|
||||||
.then((result) => currentPosition = result);
|
.then((result) => currentPosition = result);
|
||||||
} on LocationDisabledException {
|
} on LocationDisabledException {
|
||||||
SnackBarHelper.showSnackBarMessage(context, AppLocalizations.of(context)!.locationDisabled);
|
SnackBarHelper.showSnackBarMessage(
|
||||||
|
context, AppLocalizations.of(context)!.locationDisabled);
|
||||||
} on LocationForbiddenException {
|
} on LocationForbiddenException {
|
||||||
SnackBarHelper.showSnackBarMessage(context, AppLocalizations.of(context)!.locationForbidden);
|
SnackBarHelper.showSnackBarMessage(
|
||||||
|
context, AppLocalizations.of(context)!.locationForbidden);
|
||||||
}
|
}
|
||||||
|
// TODO ADD THIS AGAIN BUT RIGHT
|
||||||
// If a template is edited this fills in the existing values
|
// If a template is edited this fills in the existing values
|
||||||
if (widget.isTemplate || widget.isFinished && widget.existingData != null) {
|
// if (widget.isTemplate || widget.isFinished && widget.existingData != null) {
|
||||||
cid.text = widget.existingData!['CID'] ?? "";
|
// cid.text = widget.existingData!['CID'] ?? "";
|
||||||
rudelC.text = widget.existingData!['Rudel'] ?? "";
|
// rudelC.text = widget.existingData!['Rudel'] ?? "";
|
||||||
adresse1C.text = widget.existingData!['Adresse1'] ?? "";
|
// adresse1C.text = widget.existingData!['Adresse1'] ?? "";
|
||||||
adresse2C.text = widget.existingData!['Adresse2'] ?? "";
|
// adresse2C.text = widget.existingData!['Adresse2'] ?? "";
|
||||||
adresse3C.text = widget.existingData!['Adresse3'] ?? "";
|
// adresse3C.text = widget.existingData!['Adresse3'] ?? "";
|
||||||
bLandC.text = widget.existingData!['BLand'] ?? "";
|
// bLandC.text = widget.existingData!['BLand'] ?? "";
|
||||||
lkrC.text = widget.existingData!['Lkr'] ?? "";
|
// lkrC.text = widget.existingData!['Lkr'] ?? "";
|
||||||
beiOrtC.text = widget.existingData!['BeiOrt'] ?? "";
|
// beiOrtC.text = widget.existingData!['BeiOrt'] ?? "";
|
||||||
ortInfoC.text = widget.existingData!['OrtInfo'] ?? "";
|
// ortInfoC.text = widget.existingData!['OrtInfo'] ?? "";
|
||||||
selectedStatus = widget.existingData!['Status'] ?? "";
|
// selectedStatus = widget.existingData!['Status'] ?? "";
|
||||||
ffTypC.text = widget.existingData!['FFTyp'] ?? "";
|
// ffTypC.text = widget.existingData!['FFTyp'] ?? "";
|
||||||
selectedFotoFilm = widget.existingData!['FotoFilm'] ?? "";
|
// selectedFotoFilm = widget.existingData!['FotoFilm'] ?? "";
|
||||||
selectedMEZ = widget.existingData!['MEZ'] ?? "";
|
// selectedMEZ = widget.existingData!['MEZ'] ?? "";
|
||||||
selectedPlatzung = widget.existingData!['Platzung'] ?? "";
|
// selectedPlatzung = widget.existingData!['Platzung'] ?? "";
|
||||||
kSchloNrC.text = widget.existingData!['KSchloNr'] ?? "";
|
// kSchloNrC.text = widget.existingData!['KSchloNr'] ?? "";
|
||||||
datum = DateTime.parse(widget.existingData!['Datum']);
|
// datum = DateTime.parse(widget.existingData!['Datum']);
|
||||||
kontDat = widget.existingData!['KontDat'] == ""
|
// kontDat = widget.existingData!['KontDat'] == ""
|
||||||
? null
|
// ? null
|
||||||
: DateTime.parse(widget.existingData!['KontDat']);
|
// : DateTime.parse(widget.existingData!['KontDat']);
|
||||||
abbauDat = widget.existingData!['AbbauDat'] == ""
|
// abbauDat = widget.existingData!['AbbauDat'] == ""
|
||||||
? null
|
// ? null
|
||||||
: DateTime.parse(widget.existingData!['AbbauDat']);
|
// : DateTime.parse(widget.existingData!['AbbauDat']);
|
||||||
auftragC.text = widget.existingData!['Auftrag'] ?? "";
|
// auftragC.text = widget.existingData!['Auftrag'] ?? "";
|
||||||
kontAbspC.text = widget.existingData!['KontAbsp'] ?? "";
|
// kontAbspC.text = widget.existingData!['KontAbsp'] ?? "";
|
||||||
sonstBemC.text = widget.existingData!['SonstBem'] ?? "";
|
// sonstBemC.text = widget.existingData!['SonstBem'] ?? "";
|
||||||
fKontakt1C.text = widget.existingData!['FKontakt1'] ?? "";
|
// fKontakt1C.text = widget.existingData!['FKontakt1'] ?? "";
|
||||||
fKontakt2C.text = widget.existingData!['FKontakt2'] ?? "";
|
// fKontakt2C.text = widget.existingData!['FKontakt2'] ?? "";
|
||||||
fKontakt3C.text = widget.existingData!['FKontakt3'] ?? "";
|
// fKontakt3C.text = widget.existingData!['FKontakt3'] ?? "";
|
||||||
standortC.text = widget.existingData!['Standort'] ?? "";
|
// standortC.text = widget.existingData!['Standort'] ?? "";
|
||||||
kTage1C.text = widget.existingData!['KTage1'].toString();
|
// kTage1C.text = widget.existingData!['KTage1'].toString();
|
||||||
kTage2C.text = widget.existingData!['KTage2'].toString();
|
// kTage2C.text = widget.existingData!['KTage2'].toString();
|
||||||
protoAm = widget.existingData!['ProtoAm'] == null
|
// protoAm = widget.existingData!['ProtoAm'] == null
|
||||||
? null
|
// ? null
|
||||||
: DateTime.parse(widget.existingData!['ProtoAm']);
|
// : DateTime.parse(widget.existingData!['ProtoAm']);
|
||||||
intKommC.text = widget.existingData!['IntKomm'] ?? "";
|
// intKommC.text = widget.existingData!['IntKomm'] ?? "";
|
||||||
betreuungC.text = widget.existingData!['Betreuung'] ?? "";
|
// betreuungC.text = widget.existingData!['Betreuung'] ?? "";
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// void showSnackBarMessage(String message) {
|
|
||||||
// ScaffoldMessenger.of(context)
|
|
||||||
// .showSnackBar(SnackBar(content: Text(message)));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Function to show the dialog where the user has to choose if he want to safe his values as a template
|
|
||||||
// Future<void> showTemplateDialog(List<String> emptyField) async {
|
|
||||||
// return showDialog(
|
|
||||||
// context: context,
|
|
||||||
// barrierDismissible: false,
|
|
||||||
// builder: (BuildContext context) {
|
|
||||||
// return AlertDialog(
|
|
||||||
// title: Text(AppLocalizations.of(context)!.fieldEmpty),
|
|
||||||
// content: SingleChildScrollView(
|
|
||||||
// child: ListBody(children: <Widget>[Text(emptyField.join("; "))]),
|
|
||||||
// ),
|
|
||||||
// actions: <Widget>[
|
|
||||||
// TextButton(
|
|
||||||
// onPressed: () {
|
|
||||||
// Navigator.of(context).pop();
|
|
||||||
// },
|
|
||||||
// child: Text(AppLocalizations.of(context)!.cancel)),
|
|
||||||
// TextButton(
|
|
||||||
// onPressed: () {
|
|
||||||
// saveTemplate(
|
|
||||||
// getPlace(), DatabasesEnum.place, widget.isTemplate);
|
|
||||||
// Navigator.pushNamedAndRemoveUntil(
|
|
||||||
// context, '/home', (route) => false);
|
|
||||||
// },
|
|
||||||
// child: Text(AppLocalizations.of(context)!.template))
|
|
||||||
// ],
|
|
||||||
// );
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Future<dynamic> _showServerErrorDialog() {
|
|
||||||
// bool isLoading = false;
|
|
||||||
//
|
|
||||||
// return showDialog(
|
|
||||||
// context: context,
|
|
||||||
// builder: (context) {
|
|
||||||
// return StatefulBuilder(
|
|
||||||
// builder: (BuildContext context, StateSetter setState) {
|
|
||||||
// return AlertDialog(
|
|
||||||
// title: Text(AppLocalizations.of(context)!.servererrortitle),
|
|
||||||
// content: isLoading
|
|
||||||
// ? const SizedBox(
|
|
||||||
// height: 100,
|
|
||||||
// child: Center(child: CircularProgressIndicator()))
|
|
||||||
// : null,
|
|
||||||
// actions: [
|
|
||||||
// if (!isLoading)
|
|
||||||
// TextButton(
|
|
||||||
// onPressed: () async {
|
|
||||||
// setState(() => isLoading = true);
|
|
||||||
// int errorCode = await HttpRequest.httpRequest(saveDataMap: getPlace());
|
|
||||||
// setState(() => isLoading = false);
|
|
||||||
//
|
|
||||||
// if (errorCode != 201 && context.mounted) {
|
|
||||||
// _showServerErrorDialog();
|
|
||||||
// } else {
|
|
||||||
// if (context.mounted) Navigator.pop(context);
|
|
||||||
// // saveData(true);
|
|
||||||
// SaveMainEntryMethod.saveEntry(entryData: getPlace(), isTemplate: widget.isTemplate);
|
|
||||||
// _showSuccessDialog();
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// child: Text(AppLocalizations.of(context)!.sendagain)),
|
|
||||||
// if (!isLoading)
|
|
||||||
// TextButton(
|
|
||||||
// onPressed: () {
|
|
||||||
// Navigator.pop(context);
|
|
||||||
// },
|
|
||||||
// child: Text(AppLocalizations.of(context)!.cancel))
|
|
||||||
// ],
|
|
||||||
// );
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Future<void> showSaveOptionsDialog() async {
|
|
||||||
// bool isLoading = false;
|
|
||||||
//
|
|
||||||
// return showDialog(
|
|
||||||
// context: context,
|
|
||||||
// barrierDismissible:
|
|
||||||
// false, // Verhindert das Schließen des Dialogs durch den Benutzer
|
|
||||||
// builder: (BuildContext context) {
|
|
||||||
// return StatefulBuilder(
|
|
||||||
// builder: (context, setState) {
|
|
||||||
// return AlertDialog(
|
|
||||||
// title: isLoading
|
|
||||||
// ? Text(AppLocalizations.of(context)!.loading)
|
|
||||||
// : Text(AppLocalizations.of(context)!.savemethod),
|
|
||||||
// content: isLoading
|
|
||||||
// ? const SizedBox(
|
|
||||||
// height: 100,
|
|
||||||
// child: Center(child: CircularProgressIndicator()))
|
|
||||||
// : null,
|
|
||||||
// actions: [
|
|
||||||
// if (!isLoading)
|
|
||||||
// TextButton(
|
|
||||||
// onPressed: () async {
|
|
||||||
// setState(() => isLoading = true);
|
|
||||||
// saveTemplate(getPlace(), DatabasesEnum.place,
|
|
||||||
// widget.isTemplate);
|
|
||||||
// Navigator.pushNamedAndRemoveUntil(
|
|
||||||
// context, '/home', (route) => false);
|
|
||||||
// },
|
|
||||||
// child: Text(AppLocalizations.of(context)!.template)),
|
|
||||||
// if (!isLoading)
|
|
||||||
// TextButton(
|
|
||||||
// onPressed: () async {
|
|
||||||
// setState(() => isLoading = true);
|
|
||||||
// int errorCode = await HttpRequest.httpRequest(saveDataMap: getPlace());
|
|
||||||
// setState(() => isLoading = false);
|
|
||||||
//
|
|
||||||
// if (errorCode != 201 || !context.mounted) {
|
|
||||||
// SaveMainEntryMethod.saveEntry(entryData: getPlace(), isTemplate: widget.isTemplate);
|
|
||||||
// if (context.mounted) DialogHelper.showServerErrorDialog(context, getPlace(), widget.isTemplate);
|
|
||||||
// } else {
|
|
||||||
// SaveMainEntryMethod.saveEntry(entryData: getPlace(), isTemplate: widget.isTemplate, sent: true);
|
|
||||||
// _showSuccessDialog();
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// child:
|
|
||||||
// Text(AppLocalizations.of(context)!.sendtoserver)),
|
|
||||||
// if (!isLoading)
|
|
||||||
// TextButton(
|
|
||||||
// onPressed: () async {
|
|
||||||
// setState(() => isLoading = true);
|
|
||||||
// SaveMainEntryMethod.saveEntry(entryData: getPlace(), isTemplate: widget.isTemplate);
|
|
||||||
// _saveFile();
|
|
||||||
// setState(() => isLoading = false);
|
|
||||||
// },
|
|
||||||
// child: Text(AppLocalizations.of(context)!.saveasfile)),
|
|
||||||
// if (!isLoading)
|
|
||||||
// TextButton(
|
|
||||||
// onPressed: () {
|
|
||||||
// SaveMainEntryMethod.saveEntry(entryData: getPlace(), isTemplate: widget.isTemplate);
|
|
||||||
// Navigator.pushNamedAndRemoveUntil(
|
|
||||||
// context, '/home', (route) => false);
|
|
||||||
// },
|
|
||||||
// child: Text(AppLocalizations.of(context)!.justsave)),
|
|
||||||
// if (!isLoading)
|
|
||||||
// TextButton(
|
|
||||||
// onPressed: () {
|
|
||||||
// Navigator.pop(context);
|
|
||||||
// },
|
|
||||||
// child: Text(AppLocalizations.of(context)!.cancel)),
|
|
||||||
// ],
|
|
||||||
// );
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Future<void> _showSuccessDialog() async {
|
|
||||||
// return showDialog(
|
|
||||||
// context: context,
|
|
||||||
// builder: (context) {
|
|
||||||
// return AlertDialog(
|
|
||||||
// title: Text(AppLocalizations.of(context)!.successful),
|
|
||||||
// actions: [
|
|
||||||
// TextButton(
|
|
||||||
// onPressed: () {
|
|
||||||
// Navigator.pushNamedAndRemoveUntil(
|
|
||||||
// context, '/home', (route) => false);
|
|
||||||
// },
|
|
||||||
// child: Text(AppLocalizations.of(context)!.continueB))
|
|
||||||
// ],
|
|
||||||
// );
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Future<int> _httpRequest() async {
|
|
||||||
// Map<String, dynamic> place = getPlace();
|
|
||||||
//
|
|
||||||
// HttpRequest method = HttpRequest();
|
|
||||||
//
|
|
||||||
// await method.httpRequest(jsonEncode(place));
|
|
||||||
//
|
|
||||||
// return method.errorCode;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void _saveFile() {
|
|
||||||
// try {
|
|
||||||
// SaveMainEntryMethod.saveEntry(
|
|
||||||
// getPlace(), AppLocalizations.of(context)!.justplace, standortC.text);
|
|
||||||
// // TODO change to fileSaved. Also in SaveFileMethod class
|
|
||||||
// SnackBarHelper.showSnackBarMessage(context, AppLocalizations.of(context)!.savefilefailed);
|
|
||||||
// Navigator.pushNamedAndRemoveUntil(context, '/home', (route) => false);
|
|
||||||
// } catch (e) {
|
|
||||||
// SnackBarHelper.showSnackBarMessage(context, AppLocalizations.of(context)!.savefilefailed);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 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
|
||||||
// TODO rewrite
|
// TODO rewrite
|
||||||
List<String> validateData() {
|
// List<String> validateData() {
|
||||||
List<String> emptyFields = <String>[];
|
// List<String> emptyFields = <String>[];
|
||||||
|
|
||||||
Map<String, TextEditingController> fields = {
|
|
||||||
AppLocalizations.of(context)!.camLink: cid,
|
|
||||||
AppLocalizations.of(context)!.rudel: rudelC,
|
|
||||||
AppLocalizations.of(context)!.adresse1: adresse1C,
|
|
||||||
AppLocalizations.of(context)!.bland: bLandC,
|
|
||||||
AppLocalizations.of(context)!.lkr: lkrC,
|
|
||||||
AppLocalizations.of(context)!.beiort: beiOrtC,
|
|
||||||
AppLocalizations.of(context)!.status:
|
|
||||||
TextEditingController(text: selectedStatus),
|
|
||||||
AppLocalizations.of(context)!.fftyp: ffTypC,
|
|
||||||
"${AppLocalizations.of(context)!.foto} / ${AppLocalizations.of(context)!.filelocation}":
|
|
||||||
TextEditingController(text: selectedFotoFilm),
|
|
||||||
AppLocalizations.of(context)!.zeiteinstellung:
|
|
||||||
TextEditingController(text: selectedMEZ),
|
|
||||||
AppLocalizations.of(context)!.platzung:
|
|
||||||
TextEditingController(text: selectedPlatzung),
|
|
||||||
AppLocalizations.of(context)!.ktage1: kTage1C,
|
|
||||||
AppLocalizations.of(context)!.ktage1: kTage2C,
|
|
||||||
AppLocalizations.of(context)!.location: standortC,
|
|
||||||
};
|
|
||||||
|
|
||||||
for (var entry in fields.entries) {
|
|
||||||
if (entry.value.text.isEmpty) {
|
|
||||||
emptyFields.add(entry.key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
empty = false;
|
|
||||||
if (emptyFields.isNotEmpty) empty = true;
|
|
||||||
|
|
||||||
return emptyFields;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the user decides to safe his values as a template this function is called to save the values in the database
|
|
||||||
// If the user already edits a template this template will be upadted otherwise a new one will be created
|
|
||||||
// void saveTemplate() async {
|
|
||||||
// var placeDB = PlaceDBHelper();
|
|
||||||
//
|
//
|
||||||
// Map<String, dynamic> templates = getPlace();
|
// Map<String, TextEditingController> fields = {
|
||||||
|
// AppLocalizations.of(context)!.camLink: cid,
|
||||||
|
// AppLocalizations.of(context)!.rudel: rudelC,
|
||||||
|
// AppLocalizations.of(context)!.adresse1: adresse1C,
|
||||||
|
// AppLocalizations.of(context)!.bland: bLandC,
|
||||||
|
// AppLocalizations.of(context)!.lkr: lkrC,
|
||||||
|
// AppLocalizations.of(context)!.beiort: beiOrtC,
|
||||||
|
// AppLocalizations.of(context)!.status:
|
||||||
|
// TextEditingController(text: selectedStatus),
|
||||||
|
// AppLocalizations.of(context)!.fftyp: ffTypC,
|
||||||
|
// "${AppLocalizations.of(context)!.foto} / ${AppLocalizations.of(context)!.filelocation}":
|
||||||
|
// TextEditingController(text: selectedFotoFilm),
|
||||||
|
// AppLocalizations.of(context)!.zeiteinstellung:
|
||||||
|
// TextEditingController(text: selectedMEZ),
|
||||||
|
// AppLocalizations.of(context)!.platzung:
|
||||||
|
// TextEditingController(text: selectedPlatzung),
|
||||||
|
// AppLocalizations.of(context)!.ktage1: kTage1C,
|
||||||
|
// AppLocalizations.of(context)!.ktage1: kTage2C,
|
||||||
|
// AppLocalizations.of(context)!.location: standortC,
|
||||||
|
// };
|
||||||
//
|
//
|
||||||
// if (widget.isTemplate) {
|
// for (var entry in fields.entries) {
|
||||||
// await placeDB.updateTemplate(templates);
|
// if (entry.value.text.isEmpty) {
|
||||||
// } else {
|
// emptyFields.add(entry.key);
|
||||||
// await placeDB.addTemplate(templates);
|
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// TODO FINISHED HERE
|
|
||||||
// If the user has filled all needed values this function will be called to safe them in the database
|
|
||||||
// * also creates a json string to send it to the server later
|
|
||||||
// void saveData([bool sent = false]) async {
|
|
||||||
// var placeDB = PlaceDBHelper();
|
|
||||||
// Map<String, dynamic> place = getPlace();
|
|
||||||
//
|
//
|
||||||
// // Get the ID of the newly added or updated place
|
// empty = false;
|
||||||
// int newPlaceId = await placeDB.addMainEntry(place);
|
// if (emptyFields.isNotEmpty) empty = true;
|
||||||
//
|
//
|
||||||
// if (sent == true) {
|
// return emptyFields;
|
||||||
// placeDB.updateSent(newPlaceId); // Update 'Sent' using the correct ID
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (widget.isTemplate) {
|
|
||||||
// await placeDB.deleteTemplateById(cid.text);
|
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// The widget tree which gets the shown widget from the ./cam_widgets.dart file
|
// The widget tree which gets the shown widget from the ./cam_widgets.dart file
|
||||||
@@ -498,7 +290,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
child: VarTextField(
|
child: VarTextField(
|
||||||
required: true,
|
required: true,
|
||||||
dbName: "Standort",
|
dbName: "Standort",
|
||||||
textController: standortC,
|
textController: getFieldsController()["Standort"]!,
|
||||||
localization: AppLocalizations.of(context)!.altstort,
|
localization: AppLocalizations.of(context)!.altstort,
|
||||||
dbDesignation: DatabasesEnum.place,
|
dbDesignation: DatabasesEnum.place,
|
||||||
),
|
),
|
||||||
@@ -506,6 +298,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 5,
|
height: 5,
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.bottomLeft,
|
alignment: Alignment.bottomLeft,
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -521,12 +314,13 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
initialStatus: selectedStatus,
|
initialStatus: selectedStatus,
|
||||||
onStatusChanged: (status) {
|
onStatusChanged: (status) {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedStatus = status;
|
getFieldsController()["Status"]!.text = status;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: betreuungC,
|
textController: getFieldsController()["Betreuung"]!,
|
||||||
localization: AppLocalizations.of(context)!.betreuung,
|
localization: AppLocalizations.of(context)!.betreuung,
|
||||||
dbName: "Betreuung",
|
dbName: "Betreuung",
|
||||||
required: false,
|
required: false,
|
||||||
@@ -535,15 +329,17 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: cid,
|
textController: getFieldsController()["CID"]!,
|
||||||
localization: AppLocalizations.of(context)!.camLink,
|
localization: AppLocalizations.of(context)!.camLink,
|
||||||
dbName: "CID",
|
dbName: "CID",
|
||||||
required: true,
|
required: true,
|
||||||
dbDesignation: DatabasesEnum.place,
|
dbDesignation: DatabasesEnum.place,
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: ffTypC,
|
textController: getFieldsController()["FFTyp"]!,
|
||||||
localization: AppLocalizations.of(context)!.fftyp,
|
localization: AppLocalizations.of(context)!.fftyp,
|
||||||
dbName: "FFTyp",
|
dbName: "FFTyp",
|
||||||
required: true,
|
required: true,
|
||||||
@@ -552,6 +348,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 15,
|
height: 15,
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.bottomLeft,
|
alignment: Alignment.bottomLeft,
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -568,14 +365,16 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
onMEZChanged: (mez) {
|
onMEZChanged: (mez) {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedMEZ = mez;
|
selectedMEZ = mez;
|
||||||
|
getFieldsController()["Mez"]!.text = mez;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 15,
|
height: 15,
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: kSchloNrC,
|
textController: getFieldsController()["KSchloNr"]!,
|
||||||
localization: AppLocalizations.of(context)!.kschlonr,
|
localization: AppLocalizations.of(context)!.kschlonr,
|
||||||
dbName: "KSchloNr",
|
dbName: "KSchloNr",
|
||||||
required: false,
|
required: false,
|
||||||
@@ -584,8 +383,9 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 5,
|
height: 5,
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: rudelC,
|
textController: getFieldsController()["Rudel"]!,
|
||||||
localization: AppLocalizations.of(context)!.rudel,
|
localization: AppLocalizations.of(context)!.rudel,
|
||||||
dbName: "Rudel",
|
dbName: "Rudel",
|
||||||
required: true,
|
required: true,
|
||||||
@@ -603,6 +403,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
content: Column(
|
content: Column(
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
|
// TODO MAYBE FIX
|
||||||
children: [
|
children: [
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
@@ -619,12 +420,16 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
.push<LatLng>(
|
.push<LatLng>(
|
||||||
MaterialPageRoute(builder: (context) {
|
MaterialPageRoute(builder: (context) {
|
||||||
return Karte(
|
return Karte(
|
||||||
ortInfoC: ortInfoC,
|
ortInfoC: getFieldsController()["OrtInfo"]!,
|
||||||
beiOrtC: beiOrtC,
|
beiOrtC: getFieldsController()["BeiOrt"]!,
|
||||||
currentPosition: currentPosition,
|
currentPosition: currentPosition,
|
||||||
onPositionChange: (updatedPosition) {
|
onPositionChange: (updatedPosition) {
|
||||||
setState(() {
|
setState(() {
|
||||||
currentPosition = updatedPosition;
|
currentPosition = updatedPosition;
|
||||||
|
getFieldsController()["DECLNG"]!.text =
|
||||||
|
updatedPosition.longitude.toString();
|
||||||
|
getFieldsController()["DECLAT"]!.text =
|
||||||
|
updatedPosition.latitude.toString();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -649,30 +454,34 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
child: Text(AppLocalizations.of(context)!.openMap)),
|
child: Text(AppLocalizations.of(context)!.openMap)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: bLandC,
|
textController: getFieldsController()["Bland"]!,
|
||||||
localization: AppLocalizations.of(context)!.bland,
|
localization: AppLocalizations.of(context)!.bland,
|
||||||
dbName: "BLand",
|
dbName: "BLand",
|
||||||
required: true,
|
required: true,
|
||||||
dbDesignation: DatabasesEnum.place,
|
dbDesignation: DatabasesEnum.place,
|
||||||
defaultValue: "bLand",
|
defaultValue: "bLand",
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: lkrC,
|
textController: getFieldsController()["Lkr"]!,
|
||||||
localization: AppLocalizations.of(context)!.lkr,
|
localization: AppLocalizations.of(context)!.lkr,
|
||||||
dbName: "Lkr",
|
dbName: "Lkr",
|
||||||
required: true,
|
required: true,
|
||||||
dbDesignation: DatabasesEnum.place,
|
dbDesignation: DatabasesEnum.place,
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: beiOrtC,
|
textController: getFieldsController()["BeiOrt"]!,
|
||||||
localization: AppLocalizations.of(context)!.beiort,
|
localization: AppLocalizations.of(context)!.beiort,
|
||||||
dbName: "BeiOrt",
|
dbName: "BeiOrt",
|
||||||
required: true,
|
required: true,
|
||||||
dbDesignation: DatabasesEnum.place,
|
dbDesignation: DatabasesEnum.place,
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: ortInfoC,
|
textController: getFieldsController()["OrtInfo"]!,
|
||||||
localization: AppLocalizations.of(context)!.ortinfo,
|
localization: AppLocalizations.of(context)!.ortinfo,
|
||||||
dbName: "OrtInfo",
|
dbName: "OrtInfo",
|
||||||
required: false,
|
required: false,
|
||||||
@@ -681,6 +490,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 15,
|
height: 15,
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.bottomLeft,
|
alignment: Alignment.bottomLeft,
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -697,6 +507,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
onPlatzungChanged: (platzung) {
|
onPlatzungChanged: (platzung) {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedPlatzung = platzung;
|
selectedPlatzung = platzung;
|
||||||
|
getFieldsController()["Platzung"]!.text = platzung;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -711,20 +522,26 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
initDatum: datum,
|
initDatum: datum,
|
||||||
onDateChanged: (value) {
|
onDateChanged: (value) {
|
||||||
datum = value;
|
datum = value;
|
||||||
|
getFieldsController()["Datum"]!.text =
|
||||||
|
value.toString().split(" ").first;
|
||||||
},
|
},
|
||||||
name: AppLocalizations.of(context)!.pickDate,
|
name: AppLocalizations.of(context)!.pickDate,
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
KontDat(
|
KontDat(
|
||||||
initKontDat: kontDat,
|
initKontDat: kontDat,
|
||||||
onDateChanged: (value) {
|
onDateChanged: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
kontDat = value;
|
kontDat = value;
|
||||||
|
getFieldsController()["KontDat"]!.text =
|
||||||
|
value.toString().split(" ").first;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.bottomLeft,
|
alignment: Alignment.bottomLeft,
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -748,7 +565,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
flex: 4,
|
flex: 4,
|
||||||
child: VarTextField(
|
child: VarTextField(
|
||||||
otherDefault: "24",
|
otherDefault: "24",
|
||||||
textController: kTage1C,
|
textController: getFieldsController()["KTage1"]!,
|
||||||
localization: AppLocalizations.of(context)!.ktage1,
|
localization: AppLocalizations.of(context)!.ktage1,
|
||||||
dbName: "KTage1",
|
dbName: "KTage1",
|
||||||
required: true,
|
required: true,
|
||||||
@@ -767,7 +584,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
flex: 4,
|
flex: 4,
|
||||||
child: VarTextField(
|
child: VarTextField(
|
||||||
otherDefault: "48",
|
otherDefault: "48",
|
||||||
textController: kTage2C,
|
textController: getFieldsController()["KTage2"]!,
|
||||||
localization: AppLocalizations.of(context)!.ktage2,
|
localization: AppLocalizations.of(context)!.ktage2,
|
||||||
dbName: "KTage2",
|
dbName: "KTage2",
|
||||||
required: true,
|
required: true,
|
||||||
@@ -778,12 +595,15 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
AbbauDat(
|
AbbauDat(
|
||||||
initAbbauDat: abbauDat,
|
initAbbauDat: abbauDat,
|
||||||
onDateChanged: (value) {
|
onDateChanged: (value) {
|
||||||
abbauDat = value;
|
abbauDat = value;
|
||||||
|
getFieldsController()["AbbauDat"]!.text =
|
||||||
|
value.toString().split(" ").first;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -791,22 +611,25 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: auftragC,
|
textController: getFieldsController()["Auftrag"]!,
|
||||||
localization: AppLocalizations.of(context)!.auftrag,
|
localization: AppLocalizations.of(context)!.auftrag,
|
||||||
dbName: "Auftrag",
|
dbName: "Auftrag",
|
||||||
required: false,
|
required: false,
|
||||||
dbDesignation: DatabasesEnum.place,
|
dbDesignation: DatabasesEnum.place,
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: kontAbspC,
|
textController: getFieldsController()["KontAbsp"]!,
|
||||||
localization: AppLocalizations.of(context)!.kontabsp,
|
localization: AppLocalizations.of(context)!.kontabsp,
|
||||||
dbName: "KontAbsp",
|
dbName: "KontAbsp",
|
||||||
required: false,
|
required: false,
|
||||||
dbDesignation: DatabasesEnum.place,
|
dbDesignation: DatabasesEnum.place,
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: sonstBemC,
|
textController: getFieldsController()["SonstBem"]!,
|
||||||
localization:
|
localization:
|
||||||
AppLocalizations.of(context)!.sonstbemerkungen,
|
AppLocalizations.of(context)!.sonstbemerkungen,
|
||||||
dbName: "SonstBem",
|
dbName: "SonstBem",
|
||||||
@@ -820,53 +643,59 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
content: Column(
|
content: Column(
|
||||||
children: [
|
children: [
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: adresse1C,
|
textController: getFieldsController()["Adresse1"]!,
|
||||||
localization: AppLocalizations.of(context)!.adresse1,
|
localization: AppLocalizations.of(context)!.adresse1,
|
||||||
dbName: "Adresse1",
|
dbName: "Adresse1",
|
||||||
dbDesignation: DatabasesEnum.place,
|
dbDesignation: DatabasesEnum.place,
|
||||||
required: true,
|
required: true,
|
||||||
defaultValue: "addresse1",
|
defaultValue: "addresse1",
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: adresse2C,
|
textController: getFieldsController()["Adresse2"]!,
|
||||||
localization: AppLocalizations.of(context)!.adresse2,
|
localization: AppLocalizations.of(context)!.adresse2,
|
||||||
dbName: "Adresse2",
|
dbName: "Adresse2",
|
||||||
required: false,
|
required: false,
|
||||||
dbDesignation: DatabasesEnum.place,
|
dbDesignation: DatabasesEnum.place,
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: adresse3C,
|
textController: getFieldsController()["Adresse3"]!,
|
||||||
localization: AppLocalizations.of(context)!.adresse3,
|
localization: AppLocalizations.of(context)!.adresse3,
|
||||||
dbName: "Adresse2",
|
dbName: "Adresse3",
|
||||||
required: false,
|
required: false,
|
||||||
dbDesignation: DatabasesEnum.place,
|
dbDesignation: DatabasesEnum.place,
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 15,
|
height: 15,
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: fKontakt1C,
|
textController: getFieldsController()["FKontakt1"]!,
|
||||||
localization: AppLocalizations.of(context)!.fkontakt1,
|
localization: AppLocalizations.of(context)!.fkontakt1,
|
||||||
dbName: "FKontakt1",
|
dbName: "FKontakt1",
|
||||||
required: false,
|
required: false,
|
||||||
dbDesignation: DatabasesEnum.place,
|
dbDesignation: DatabasesEnum.place,
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: fKontakt2C,
|
textController: getFieldsController()["FKontakt2"]!,
|
||||||
localization: AppLocalizations.of(context)!.fkontakt2,
|
localization: AppLocalizations.of(context)!.fkontakt2,
|
||||||
dbName: "FKontakt2",
|
dbName: "FKontakt2",
|
||||||
required: false,
|
required: false,
|
||||||
dbDesignation: DatabasesEnum.place,
|
dbDesignation: DatabasesEnum.place,
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: fKontakt3C,
|
textController: getFieldsController()["FKontakt3"]!,
|
||||||
localization: AppLocalizations.of(context)!.fkontakt3,
|
localization: AppLocalizations.of(context)!.fkontakt3,
|
||||||
dbName: "FKontakt3",
|
dbName: "FKontakt3",
|
||||||
required: false,
|
required: false,
|
||||||
dbDesignation: DatabasesEnum.place,
|
dbDesignation: DatabasesEnum.place,
|
||||||
),
|
),
|
||||||
|
// --------------------
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: intKommC,
|
textController: getFieldsController()["IntKomm"]!,
|
||||||
localization: AppLocalizations.of(context)!.intkomm,
|
localization: AppLocalizations.of(context)!.intkomm,
|
||||||
dbName: "IntKomm",
|
dbName: "IntKomm",
|
||||||
required: false,
|
required: false,
|
||||||
@@ -906,24 +735,27 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
final isLastStep = currentStep == getSteps().length - 1;
|
final isLastStep = currentStep == getSteps().length - 1;
|
||||||
|
|
||||||
if (!isLastStep) {
|
if (!isLastStep) {
|
||||||
saveTemplate(
|
saveTemplate(getFieldsText(), DatabasesEnum.place,
|
||||||
getPlace(), DatabasesEnum.place, widget.isTemplate);
|
widget.isTemplate);
|
||||||
setState(() {
|
setState(() {
|
||||||
currentStep += 1;
|
currentStep += 1;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
List<String> emptyFields = validateData();
|
// TODO implement validateData again
|
||||||
|
// List<String> emptyFields = validateData();
|
||||||
// ! always filled out
|
// ! always filled out
|
||||||
// empty = false;
|
// empty = false;
|
||||||
if (widget.isSent) {
|
// if (widget.isSent) {
|
||||||
Navigator.pushNamedAndRemoveUntil(
|
// Navigator.pushNamedAndRemoveUntil(
|
||||||
context, '/home', (route) => false);
|
// context, '/home', (route) => false);
|
||||||
} else if (empty == true) {
|
// } else if (empty == true) {
|
||||||
DialogHelper.showTemplateDialog(context, emptyFields, getPlace() );
|
// DialogHelper.showTemplateDialog(
|
||||||
return;
|
// context, emptyFields, getFieldsText();
|
||||||
} else if (empty == false) {
|
// return;
|
||||||
await DialogHelper.showSaveOptionsDialog(context, getPlace(), widget.isTemplate);
|
// } else if (empty == false) {
|
||||||
}
|
// await DialogHelper.showSaveOptionsDialog(
|
||||||
|
// context, getFieldsText(), widget.isTemplate);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onStepCancel: () {
|
onStepCancel: () {
|
||||||
@@ -934,6 +766,9 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
currentStep -= 1;
|
currentStep -= 1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})));
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,8 +85,7 @@ class KarteState extends State<Karte> {
|
|||||||
widget.onPositionChange(updatedPosition!);
|
widget.onPositionChange(updatedPosition!);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// ignore: use_build_context_synchronously
|
if (context.mounted) Navigator.pop(context);
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
},
|
||||||
child: const Icon(Icons.save),
|
child: const Icon(Icons.save),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|||||||
class DialogHelper {
|
class DialogHelper {
|
||||||
// Function to show the dialog where the user has to choose if he want to safe his values as a template
|
// Function to show the dialog where the user has to choose if he want to safe his values as a template
|
||||||
static Future<void> showTemplateDialog(BuildContext context,
|
static Future<void> showTemplateDialog(BuildContext context,
|
||||||
List<String> emptyField, Map<String, dynamic> saveData) async {
|
List<String> emptyField, Map<String, String> saveData) async {
|
||||||
return showDialog(
|
return showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
@@ -39,7 +39,7 @@ class DialogHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Future<dynamic> showServerErrorDialog(
|
static Future<dynamic> showServerErrorDialog(
|
||||||
BuildContext context, Map<String, dynamic> saveData, bool isTemplate) {
|
BuildContext context, Map<String, String> saveData, bool isTemplate) {
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
|
|
||||||
return showDialog(
|
return showDialog(
|
||||||
@@ -89,7 +89,7 @@ class DialogHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Future<void> showSaveOptionsDialog(BuildContext context,
|
static Future<void> showSaveOptionsDialog(BuildContext context,
|
||||||
Map<String, dynamic> saveData, bool isTemplate) async {
|
Map<String, String> saveData, bool isTemplate) async {
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
|
|
||||||
return showDialog(
|
return showDialog(
|
||||||
@@ -155,7 +155,7 @@ class DialogHelper {
|
|||||||
SaveFileMethod.saveFile(
|
SaveFileMethod.saveFile(
|
||||||
saveData,
|
saveData,
|
||||||
AppLocalizations.of(context)!.savefilefailed,
|
AppLocalizations.of(context)!.savefilefailed,
|
||||||
saveData["CID"]);
|
saveData["CID"]!);
|
||||||
setState(() => isLoading = false);
|
setState(() => isLoading = false);
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import 'package:dio/dio.dart';
|
|||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
class HttpRequest {
|
class HttpRequest {
|
||||||
static Future<int> httpRequest({Map<String, dynamic>? saveDataMap, String? saveDataString}) async {
|
static Future<int> httpRequest({Map<String, String>? saveDataMap, String? saveDataString}) async {
|
||||||
// print(jsonEncode(place));
|
// print(jsonEncode(place));
|
||||||
|
|
||||||
final dio = Dio();
|
final dio = Dio();
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import 'package:file_picker/file_picker.dart';
|
|||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
class SaveFileMethod {
|
class SaveFileMethod {
|
||||||
static Future<void> saveFile(Map<String, dynamic> place, String fileNameLocalization, String placeID) async {
|
static Future<void> saveFile(Map<String, String> place, String fileNameLocalization, String placeID) async {
|
||||||
String? selectedDirectory = await FilePicker.platform.getDirectoryPath();
|
String? selectedDirectory = await FilePicker.platform.getDirectoryPath();
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
String jsonPlace = jsonEncode(place);
|
String jsonPlace = jsonEncode(place);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import 'package:fforte/methods/place_db_helper.dart';
|
|||||||
|
|
||||||
class SaveMainEntryMethod {
|
class SaveMainEntryMethod {
|
||||||
static void saveEntry(
|
static void saveEntry(
|
||||||
{required Map<String, dynamic> entryData,
|
{required Map<String, String> entryData,
|
||||||
required bool isTemplate,
|
required bool isTemplate,
|
||||||
bool sent = false}) async {
|
bool sent = false}) async {
|
||||||
var placeDB = PlaceDBHelper();
|
var placeDB = PlaceDBHelper();
|
||||||
@@ -15,7 +15,7 @@ class SaveMainEntryMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isTemplate) {
|
if (isTemplate) {
|
||||||
await placeDB.deleteTemplateById(entryData["CID"]);
|
await placeDB.deleteTemplateById(entryData["CID"]!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import 'package:fforte/interfaces/i_db.dart';
|
|||||||
import 'package:fforte/methods/excursion_db_helper.dart';
|
import 'package:fforte/methods/excursion_db_helper.dart';
|
||||||
import 'package:fforte/methods/place_db_helper.dart';
|
import 'package:fforte/methods/place_db_helper.dart';
|
||||||
|
|
||||||
void saveTemplate(Map<String, dynamic> templateData, DatabasesEnum dbType,
|
void saveTemplate(Map<String, String> templateData, DatabasesEnum dbType,
|
||||||
bool update) async {
|
bool update) async {
|
||||||
IDb dbHelper;
|
IDb dbHelper;
|
||||||
if (dbType == DatabasesEnum.place) {
|
if (dbType == DatabasesEnum.place) {
|
||||||
|
|||||||
Reference in New Issue
Block a user