fixed dates
This commit is contained in:
@@ -185,8 +185,12 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
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'] == null ? null : DateTime.parse(widget.existingData!['KontDat']);
|
kontDat = widget.existingData!['KontDat'] == null
|
||||||
abbauDat = widget.existingData!['AbbauDat'] == null ? null : DateTime.parse(widget.existingData!['AbbauDat']);
|
? null
|
||||||
|
: DateTime.parse(widget.existingData!['KontDat']);
|
||||||
|
abbauDat = widget.existingData!['AbbauDat'] == null
|
||||||
|
? null
|
||||||
|
: 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'] ?? "";
|
||||||
@@ -196,7 +200,9 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
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 ? null : DateTime.parse(widget.existingData!['ProtoAm']);
|
protoAm = widget.existingData!['ProtoAm'] == null
|
||||||
|
? null
|
||||||
|
: 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'] ?? "";
|
||||||
}
|
}
|
||||||
@@ -240,8 +246,6 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
|
||||||
|
|
||||||
int errorCode = _httpRequest();
|
int errorCode = _httpRequest();
|
||||||
|
|
||||||
if (errorCode != 201) {
|
if (errorCode != 201) {
|
||||||
@@ -279,7 +283,6 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
child: Text(AppLocalizations.of(context)!.template)),
|
child: Text(AppLocalizations.of(context)!.template)),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
|
||||||
int errorCode = _httpRequest();
|
int errorCode = _httpRequest();
|
||||||
|
|
||||||
if (errorCode != 201) {
|
if (errorCode != 201) {
|
||||||
@@ -341,7 +344,6 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int _httpRequest() {
|
int _httpRequest() {
|
||||||
|
|
||||||
Map<String, dynamic> place = getPlace();
|
Map<String, dynamic> place = getPlace();
|
||||||
|
|
||||||
Methods method = Methods();
|
Methods method = Methods();
|
||||||
@@ -566,47 +568,47 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
children: [
|
children: [
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
Text(currentPosition.latitude.toString()),
|
Text(currentPosition.latitude.toString()),
|
||||||
|
Text(currentPosition.longitude.toString()),
|
||||||
Text(currentPosition.longitude.toString()),
|
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(width: 15,),
|
const SizedBox(
|
||||||
ElevatedButton(
|
width: 15,
|
||||||
onPressed: () async {
|
),
|
||||||
final result = await Navigator.of(context)
|
ElevatedButton(
|
||||||
.push<LatLng>(
|
onPressed: () async {
|
||||||
MaterialPageRoute(builder: (context) {
|
final result = await Navigator.of(context)
|
||||||
return Karte(
|
.push<LatLng>(
|
||||||
ortInfoC: ortInfoC,
|
MaterialPageRoute(builder: (context) {
|
||||||
beiOrtC: beiOrtC,
|
return Karte(
|
||||||
currentPosition: currentPosition,
|
ortInfoC: ortInfoC,
|
||||||
onPositionChange: (updatedPosition) {
|
beiOrtC: beiOrtC,
|
||||||
setState(() {
|
currentPosition: currentPosition,
|
||||||
currentPosition = updatedPosition;
|
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,
|
|
||||||
);
|
);
|
||||||
});
|
}));
|
||||||
}
|
if (result != null) {
|
||||||
},
|
setState(() {
|
||||||
child: Text(AppLocalizations.of(context)!.openMap)),
|
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(
|
VarTextField(
|
||||||
@@ -661,9 +663,19 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
content: Column(
|
content: Column(
|
||||||
children: [
|
children: [
|
||||||
Datum(
|
Datum(
|
||||||
datum: datum,
|
initDatum: datum,
|
||||||
|
onDateChanged: (value) {
|
||||||
|
datum = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
KontDat(
|
||||||
|
initKontDat: kontDat,
|
||||||
|
onDateChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
kontDat = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
),
|
),
|
||||||
KontDat(kontDat: kontDat),
|
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
@@ -712,7 +724,12 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
AbbauDat(abbauDat: abbauDat),
|
AbbauDat(
|
||||||
|
initAbbauDat: abbauDat,
|
||||||
|
onDateChanged: (value) {
|
||||||
|
abbauDat = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
|||||||
@@ -155,14 +155,15 @@ class Karte extends StatefulWidget {
|
|||||||
{super.key,
|
{super.key,
|
||||||
required this.currentPosition,
|
required this.currentPosition,
|
||||||
required this.onPositionChange,
|
required this.onPositionChange,
|
||||||
required this.beiOrtC, required this.ortInfoC});
|
required this.beiOrtC,
|
||||||
|
required this.ortInfoC});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
KarteState createState() => KarteState();
|
KarteState createState() => KarteState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class KarteState extends State<Karte> {
|
class KarteState extends State<Karte> {
|
||||||
List<Marker> markers = [ ];
|
List<Marker> markers = [];
|
||||||
LatLng? selectedPosition;
|
LatLng? selectedPosition;
|
||||||
Position? updatedPosition;
|
Position? updatedPosition;
|
||||||
bool saveVisible = false;
|
bool saveVisible = false;
|
||||||
@@ -197,7 +198,7 @@ class KarteState extends State<Karte> {
|
|||||||
List<Placemark> placemarks = await placemarkFromCoordinates(
|
List<Placemark> placemarks = await placemarkFromCoordinates(
|
||||||
selectedPosition!.latitude,
|
selectedPosition!.latitude,
|
||||||
selectedPosition!.longitude);
|
selectedPosition!.longitude);
|
||||||
print(placemarks);
|
print(placemarks);
|
||||||
|
|
||||||
if (selectedPosition != null) {
|
if (selectedPosition != null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -293,16 +294,23 @@ class KarteState extends State<Karte> {
|
|||||||
// datum is the variable where the chosen date is stored
|
// datum is the variable where the chosen date is stored
|
||||||
|
|
||||||
class Datum extends StatefulWidget {
|
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
|
@override
|
||||||
State<Datum> createState() => _DatumState();
|
State<Datum> createState() => _DatumState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DatumState extends State<Datum> {
|
class _DatumState extends State<Datum> {
|
||||||
DateTime? datum = DateTime.now();
|
DateTime? datum;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
datum = widget.initDatum;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -316,6 +324,7 @@ class _DatumState extends State<Datum> {
|
|||||||
final date = await pickDate();
|
final date = await pickDate();
|
||||||
if (date == null) return;
|
if (date == null) return;
|
||||||
setState(() => datum = date);
|
setState(() => datum = date);
|
||||||
|
widget.onDateChanged(date);
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context)!.pickDate)),
|
child: Text(AppLocalizations.of(context)!.pickDate)),
|
||||||
),
|
),
|
||||||
@@ -336,14 +345,8 @@ class _DatumState extends State<Datum> {
|
|||||||
initialDate: datum!,
|
initialDate: datum!,
|
||||||
firstDate: DateTime(2000),
|
firstDate: DateTime(2000),
|
||||||
lastDate: DateTime(5000));
|
lastDate: DateTime(5000));
|
||||||
if (date == null) return null;
|
|
||||||
setState(() => datum = date);
|
|
||||||
|
|
||||||
var place = {'Datum': DateFormat('yyyy-MM-dd').format(datum!)};
|
return date;
|
||||||
|
|
||||||
await DBHelper().addPlace(place);
|
|
||||||
|
|
||||||
return datum;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,11 +476,11 @@ class Platzung extends StatefulWidget {
|
|||||||
final Function(String) onPlatzungChanged;
|
final Function(String) onPlatzungChanged;
|
||||||
final String? initialPlatzung;
|
final String? initialPlatzung;
|
||||||
|
|
||||||
|
const Platzung({
|
||||||
const Platzung(
|
super.key,
|
||||||
{super.key,
|
required this.onPlatzungChanged,
|
||||||
required this.onPlatzungChanged, this.initialPlatzung,
|
this.initialPlatzung,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<Platzung> createState() => _PlatzungState();
|
State<Platzung> createState() => _PlatzungState();
|
||||||
@@ -494,7 +497,6 @@ class _PlatzungState extends State<Platzung> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Column(
|
||||||
@@ -725,16 +727,24 @@ class _MEZState extends State<MEZ> {
|
|||||||
// KontDat
|
// KontDat
|
||||||
|
|
||||||
class KontDat extends StatefulWidget {
|
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
|
@override
|
||||||
State<KontDat> createState() => _KontDatState();
|
State<KontDat> createState() => _KontDatState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _KontDatState extends State<KontDat> {
|
class _KontDatState extends State<KontDat> {
|
||||||
DateTime? kontDat = DateTime.now();
|
DateTime? kontDat;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
kontDat = widget.initKontDat;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -747,7 +757,10 @@ class _KontDatState extends State<KontDat> {
|
|||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final date = await pickDate();
|
final date = await pickDate();
|
||||||
if (date == null) return;
|
if (date == null) return;
|
||||||
setState(() => kontDat = date);
|
setState(() {
|
||||||
|
kontDat = date;
|
||||||
|
});
|
||||||
|
widget.onDateChanged(date);
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context)!.pickkontdat)),
|
child: Text(AppLocalizations.of(context)!.pickkontdat)),
|
||||||
),
|
),
|
||||||
@@ -765,26 +778,21 @@ class _KontDatState extends State<KontDat> {
|
|||||||
Future<DateTime?> pickDate() async {
|
Future<DateTime?> pickDate() async {
|
||||||
final date = await showDatePicker(
|
final date = await showDatePicker(
|
||||||
context: context,
|
context: context,
|
||||||
initialDate: kontDat!,
|
initialDate: kontDat ?? DateTime.now(),
|
||||||
firstDate: DateTime(2000),
|
firstDate: DateTime(2000),
|
||||||
lastDate: DateTime(5000));
|
lastDate: DateTime(5000));
|
||||||
if (date == null) return null;
|
|
||||||
setState(() => kontDat = date);
|
|
||||||
|
|
||||||
var place = {'KontDat': DateFormat('yyyy-MM-dd').format(kontDat!)};
|
return date;
|
||||||
|
|
||||||
await DBHelper().addPlace(place);
|
|
||||||
|
|
||||||
return kontDat;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AbbauDat
|
// AbbauDat
|
||||||
|
|
||||||
class AbbauDat extends StatefulWidget {
|
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
|
@override
|
||||||
State<AbbauDat> createState() => _AbbauDatState();
|
State<AbbauDat> createState() => _AbbauDatState();
|
||||||
@@ -793,6 +801,12 @@ class AbbauDat extends StatefulWidget {
|
|||||||
class _AbbauDatState extends State<AbbauDat> {
|
class _AbbauDatState extends State<AbbauDat> {
|
||||||
DateTime? abbauDat;
|
DateTime? abbauDat;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
abbauDat = widget.initAbbauDat;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Row(
|
return Row(
|
||||||
@@ -805,6 +819,7 @@ class _AbbauDatState extends State<AbbauDat> {
|
|||||||
final date = await pickDate();
|
final date = await pickDate();
|
||||||
if (date == null) return;
|
if (date == null) return;
|
||||||
setState(() => abbauDat = date);
|
setState(() => abbauDat = date);
|
||||||
|
widget.onDateChanged(date);
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context)!.pickabbaudat)),
|
child: Text(AppLocalizations.of(context)!.pickabbaudat)),
|
||||||
),
|
),
|
||||||
@@ -841,7 +856,6 @@ class _AbbauDatState extends State<AbbauDat> {
|
|||||||
firstDate: DateTime(2000),
|
firstDate: DateTime(2000),
|
||||||
lastDate: DateTime(5000));
|
lastDate: DateTime(5000));
|
||||||
if (date == null) return null;
|
if (date == null) return null;
|
||||||
setState(() => abbauDat = date);
|
|
||||||
|
|
||||||
return abbauDat;
|
return abbauDat;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user