fixed value reset error in add_cam
This commit is contained in:
@@ -42,11 +42,6 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
int currentStep = 0;
|
||||
late bool isTemplate;
|
||||
|
||||
String selectedStatus = 'aktiv';
|
||||
String selectedFotoFilm = 'Foto';
|
||||
String selectedMEZ = 'Sommerzeit';
|
||||
String selectedPlatzung = '';
|
||||
|
||||
Position currentPosition = Position(
|
||||
longitude: 10.0,
|
||||
latitude: 51.0,
|
||||
@@ -60,10 +55,6 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
headingAccuracy: 0.0,
|
||||
);
|
||||
|
||||
DateTime? abbauDat;
|
||||
DateTime datum = DateTime.now();
|
||||
DateTime? kontDat = DateTime.now();
|
||||
DateTime? protoAm = DateTime.now();
|
||||
|
||||
Map<String, Map<String, dynamic>> rmap = {
|
||||
"ID": {"controller": TextEditingController(), "required": false},
|
||||
@@ -145,8 +136,6 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
return currentPosition;
|
||||
});
|
||||
// select initial werte
|
||||
rmap["MEZ"]!["controller"]!.text = selectedMEZ;
|
||||
rmap["Status"]!["controller"]!.text = selectedStatus;
|
||||
rmap["DECLAT"]!["controller"]!.text = currentPosition.latitude.toString();
|
||||
rmap["DECLNG"]!["controller"]!.text = currentPosition.longitude.toString();
|
||||
|
||||
@@ -158,6 +147,13 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
rmap[key]!["controller"]!.text =
|
||||
widget.existingData?[key].toString() ?? "";
|
||||
}
|
||||
} else {
|
||||
// If it is not a template set default values
|
||||
rmap["Datum"]!["controller"]!.text = DateTime.now().toString();
|
||||
rmap["Status"]!["controller"]!.text = "aktiv";
|
||||
rmap["FotoFilm"]!["controller"]!.text = "Foto";
|
||||
rmap["MEZ"]!["controller"]!.text = "Sommerzeit";
|
||||
rmap["Platzung"]!["controller"]!.text = "";
|
||||
}
|
||||
|
||||
super.initState();
|
||||
@@ -205,7 +201,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
),
|
||||
),
|
||||
Status(
|
||||
initialStatus: selectedStatus,
|
||||
initialStatus: rmap["Status"]!["controller"]!.text,
|
||||
onStatusChanged: (status) {
|
||||
setState(() {
|
||||
rmap["Status"]!["controller"]!.text = status;
|
||||
@@ -249,10 +245,9 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
),
|
||||
),
|
||||
MEZ(
|
||||
initialMEZ: selectedMEZ,
|
||||
initialMEZ: rmap["MEZ"]!["controller"]!.text,
|
||||
onMEZChanged: (mez) {
|
||||
setState(() {
|
||||
selectedMEZ = mez;
|
||||
rmap["MEZ"]!["controller"]!.text = mez;
|
||||
});
|
||||
},
|
||||
@@ -375,10 +370,9 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
),
|
||||
),
|
||||
Platzung(
|
||||
initialPlatzung: selectedPlatzung,
|
||||
initialPlatzung: rmap["Platzung"]!["controller"]!.text,
|
||||
onPlatzungChanged: (platzung) {
|
||||
setState(() {
|
||||
selectedPlatzung = platzung;
|
||||
rmap["Platzung"]!["controller"]!.text = platzung;
|
||||
});
|
||||
},
|
||||
@@ -392,20 +386,17 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
content: Column(
|
||||
children: [
|
||||
Datum(
|
||||
initDatum: datum,
|
||||
initDatum: DateTime.parse(rmap["Datum"]!["controller"]!.text),
|
||||
onDateChanged: (value) {
|
||||
datum = value;
|
||||
rmap["Datum"]!["controller"]!.text =
|
||||
value.toString().split(" ").first;
|
||||
rmap["Datum"]!["controller"]!.text = value;
|
||||
},
|
||||
name: AppLocalizations.of(context)!.pickDate,
|
||||
),
|
||||
// --------------------
|
||||
KontDat(
|
||||
initKontDat: kontDat,
|
||||
initKontDat: rmap["KontDat"]!["controller"]!.text == "" ? DateTime.now() : DateTime.parse(rmap["KontDat"]!["controller"]!.text),
|
||||
onDateChanged: (value) {
|
||||
setState(() {
|
||||
kontDat = value;
|
||||
rmap["KontDat"]!["controller"]!.text =
|
||||
value.toString().split(" ").first;
|
||||
});
|
||||
@@ -461,9 +452,8 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
Row(
|
||||
children: [
|
||||
AbbauDat(
|
||||
initAbbauDat: abbauDat,
|
||||
initAbbauDat: rmap["AbbauDat"]!["controller"]!.text == "" ? null : DateTime.parse(rmap["AbbauDat"]!["controller"]!.text),
|
||||
onDateChanged: (value) {
|
||||
abbauDat = value;
|
||||
rmap["AbbauDat"]!["controller"]!.text =
|
||||
value.toString().split(" ").first;
|
||||
},
|
||||
@@ -620,8 +610,8 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
}
|
||||
|
||||
bool empty = CheckRequired.checkRequired(rmap);
|
||||
// for debugging always false
|
||||
// empty = false;
|
||||
// TODO for debugging always false
|
||||
empty = false;
|
||||
|
||||
if (empty == true) {
|
||||
AddEntriesDialogHelper.showTemplateDialog(
|
||||
|
||||
Reference in New Issue
Block a user