luc sitzung
This commit is contained in:
@@ -302,20 +302,24 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
try {
|
||||
response = await dio.post(prefs.getString('apiAddress') ?? "",
|
||||
data: jsonEncode(place));
|
||||
print(jsonEncode(place));
|
||||
} on DioException catch (e) {
|
||||
if (e.response?.statusCode == 500) {
|
||||
/* print('-------------------------');
|
||||
print('code 500'); */
|
||||
print('-------------------------');
|
||||
print('code 500');
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (response.statusCode == 201) {
|
||||
// print(response.statusCode);
|
||||
print("------------------");
|
||||
print(response.statusCode);
|
||||
var placeDB = DBHelper();
|
||||
|
||||
await placeDB.updateSent();
|
||||
} else {
|
||||
//print(response.statusCode);
|
||||
print("----------------");
|
||||
print("Anderer code");
|
||||
print(response.statusCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,6 +401,10 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
Map<String, dynamic> place = getPlace();
|
||||
|
||||
await placeDB.addPlace(place);
|
||||
|
||||
if (widget.isTemplate) {
|
||||
await placeDB.deleteTemplate(id.text);
|
||||
}
|
||||
}
|
||||
|
||||
// The widget tree which gets the shown widget from the ./cam_widgets.dart file
|
||||
@@ -412,7 +420,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: RequiredVarTextField(
|
||||
child: VarTextField(
|
||||
required: true,
|
||||
dbName: "Standort",
|
||||
textController: standortC,
|
||||
@@ -452,16 +460,24 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
});
|
||||
},
|
||||
),
|
||||
RequiredVarTextField(textController: betreuungC, localization: AppLocalizations.of(context)!.betreuung, dbName: "KontSum", required: false),
|
||||
Betreuung(betreuungC: betreuungC),
|
||||
VarTextField(
|
||||
textController: betreuungC,
|
||||
localization: AppLocalizations.of(context)!.betreuung,
|
||||
dbName: "KontSum",
|
||||
required: false),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
CamId(id: id),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: FFTyp(ffTypC: ffTypC),
|
||||
),
|
||||
VarTextField(
|
||||
textController: id,
|
||||
localization: AppLocalizations.of(context)!.camLink,
|
||||
dbName: "CID",
|
||||
required: true),
|
||||
VarTextField(
|
||||
textController: ffTypC,
|
||||
localization: AppLocalizations.of(context)!.fftyp,
|
||||
dbName: "FFTyp",
|
||||
required: true),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
@@ -502,14 +518,11 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: KSchloNr(kSchloNrC: kSchloNrC),
|
||||
),
|
||||
VarTextField(textController: kSchloNrC, localization: AppLocalizations.of(context)!.kschlonr, dbName: "KSchloNr", required: false),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Rudel(rudelC: rudelC),
|
||||
VarTextField(textController: rudelC, localization: AppLocalizations.of(context)!.rudel, dbName: "Rudel", required: true),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
@@ -562,22 +575,10 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.openMap)),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: BLand(bLandC: bLandC),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Lkr(lkrC: lkrC),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: BeiOrt(beiOrtC: beiOrtC),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: OrtInfo(ortInfoC: ortInfoC),
|
||||
),
|
||||
VarTextField(textController: bLandC, localization: AppLocalizations.of(context)!.bland, dbName: "BLand", required: true, default_value: "bLand",),
|
||||
VarTextField(textController: lkrC, localization: AppLocalizations.of(context)!.lkr, dbName: "Lkr", required: true),
|
||||
VarTextField(textController: beiOrtC, localization: AppLocalizations.of(context)!.beiort, dbName: "BeiOrt", required: true),
|
||||
VarTextField(textController: ortInfoC, localization: AppLocalizations.of(context)!.ortinfo, dbName: "OrtInfo", required: false),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
@@ -626,7 +627,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
],
|
||||
),
|
||||
),
|
||||
KTage1(kTage1C: kTage1C),
|
||||
VarTextField(textController: kTage1C, localization: AppLocalizations.of(context)!.ktage1, dbName: "KTage1", required: true, default_value: "kTage1",),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
@@ -641,26 +642,28 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
)
|
||||
],
|
||||
)),
|
||||
KTage2(kTage2C: kTage2C),
|
||||
VarTextField(textController: kTage2C, localization: AppLocalizations.of(context)!.ktage2, dbName: "KTage1", required: true, default_value: "kTage2",),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
AbbauDat(abbauDat: abbauDat),
|
||||
Row(
|
||||
children: [
|
||||
AbbauDat(abbauDat: abbauDat),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
abbauDat = null;
|
||||
});
|
||||
},
|
||||
child: const Text("X"))
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Auftrag(auftragC: auftragC),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: KontAbsp(kontAbspC: kontAbspC),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: SonstBem(sonstBemC: sonstBemC),
|
||||
),
|
||||
VarTextField(textController: auftragC, localization: AppLocalizations.of(context)!.auftrag, dbName: "Auftrag", required: false),
|
||||
VarTextField(textController: kontAbspC, localization: AppLocalizations.of(context)!.kontabsp, dbName: "KontAbsp", required: false),
|
||||
VarTextField(textController: sonstBemC, localization: AppLocalizations.of(context)!.sonstbemerkungen, dbName: "SonstBem", required: false),
|
||||
],
|
||||
)),
|
||||
// Fourth step
|
||||
@@ -671,36 +674,16 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Adresse1(adresse1C: adresse1C)),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Adresse2(adresse2C: adresse2C),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Adresse3(adresse3C: adresse3C),
|
||||
),
|
||||
VarTextField(textController: adresse1C, localization: AppLocalizations.of(context)!.adresse1, dbName: "Adresse1", required: true),
|
||||
VarTextField(textController: adresse2C, localization: AppLocalizations.of(context)!.adresse2, dbName: "Adresse2", required: false),
|
||||
VarTextField(textController: adresse3C, localization: AppLocalizations.of(context)!.adresse3, dbName: "Adresse2", required: false),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: FKontakt1(fKontakt1C: fKontakt1C),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: FKontakt2(fKontakt2C: fKontakt2C),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: FKontakt3(fKontakt3C: fKontakt3C),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: IntKomm(intKommC: intKommC),
|
||||
),
|
||||
VarTextField(textController: fKontakt1C, localization: AppLocalizations.of(context)!.fkontakt1, dbName: "FKontakt1", required: false),
|
||||
VarTextField(textController: fKontakt2C, localization: AppLocalizations.of(context)!.fkontakt2, dbName: "FKontakt2", required: false),
|
||||
VarTextField(textController: fKontakt3C, localization: AppLocalizations.of(context)!.fkontakt3, dbName: "FKontakt3", required: false),
|
||||
VarTextField(textController: intKommC, localization: AppLocalizations.of(context)!.intkomm, dbName: "IntKomm", required: false),
|
||||
],
|
||||
))
|
||||
];
|
||||
|
||||
@@ -7,6 +7,7 @@ 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';
|
||||
|
||||
// * Collection of All widgets displayed in the add_cam section
|
||||
|
||||
@@ -16,31 +17,48 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
// * Step 1 place, camera, terretory
|
||||
//
|
||||
|
||||
class RequiredVarTextField extends StatefulWidget {
|
||||
class VarTextField extends StatefulWidget {
|
||||
final TextEditingController textController;
|
||||
final String localization;
|
||||
final String dbName;
|
||||
final String? default_value;
|
||||
final bool required;
|
||||
|
||||
const RequiredVarTextField(
|
||||
const VarTextField(
|
||||
{super.key,
|
||||
required this.textController,
|
||||
required this.localization,
|
||||
required this.dbName, required this.required});
|
||||
required this.dbName,
|
||||
required this.required,
|
||||
this.default_value});
|
||||
|
||||
@override
|
||||
State<RequiredVarTextField> createState() => _RequiredVarTextFieldState();
|
||||
State<VarTextField> createState() => _VarTextFieldState();
|
||||
}
|
||||
|
||||
class _RequiredVarTextFieldState extends State<RequiredVarTextField> {
|
||||
class _VarTextFieldState extends State<VarTextField> {
|
||||
late Future<List<Map<String, dynamic>>> dbVar;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
if (widget.textController.text == "" && widget.default_value != null)
|
||||
_loadPref();
|
||||
|
||||
dbVar = DBHelper().getPlace();
|
||||
}
|
||||
|
||||
void _loadPref() {
|
||||
Future.delayed(Duration.zero, () async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
String bLand = prefs.getString(widget.default_value!) ?? "";
|
||||
setState(() {
|
||||
widget.textController.text = bLand;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
@@ -51,23 +69,29 @@ class _RequiredVarTextFieldState extends State<RequiredVarTextField> {
|
||||
controller: widget.textController,
|
||||
keyboardType: TextInputType.multiline,
|
||||
maxLines: null,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
widget.textController.text = value;
|
||||
});
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
hintText: widget.localization,
|
||||
enabledBorder: widget.required
|
||||
? (widget.textController.text.isEmpty
|
||||
? const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.red))
|
||||
: const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.green)))
|
||||
: const UnderlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
|
||||
focusedBorder: widget.required
|
||||
? (widget.textController.text.isEmpty
|
||||
? const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.red))
|
||||
: const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.green)))
|
||||
: const UnderlineInputBorder(borderSide: BorderSide(color: Colors.grey))
|
||||
),
|
||||
hintText: widget.localization,
|
||||
enabledBorder: widget.required
|
||||
? (widget.textController.text.isEmpty
|
||||
? const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.red))
|
||||
: const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.green)))
|
||||
: const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.grey)),
|
||||
focusedBorder: widget.required
|
||||
? (widget.textController.text.isEmpty
|
||||
? const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.red))
|
||||
: const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.green)))
|
||||
: const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.grey))),
|
||||
)),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
@@ -123,10 +147,10 @@ class Standort extends StatefulWidget {
|
||||
{super.key, required this.standortC, required this.localization});
|
||||
|
||||
@override
|
||||
State<RequiredVarTextField> createState() => _RequiredVarTextFieldState();
|
||||
State<VarTextField> createState() => _StandortState();
|
||||
}
|
||||
|
||||
class _StandortState extends State<RequiredVarTextField> {
|
||||
class _StandortState extends State<VarTextField> {
|
||||
late Future<List<Map<String, dynamic>>> Standort;
|
||||
|
||||
@override
|
||||
@@ -426,6 +450,9 @@ class KarteState extends State<Karte> {
|
||||
Position? updatedPosition;
|
||||
bool saveVisible = false;
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -452,8 +479,13 @@ class KarteState extends State<Karte> {
|
||||
children: [
|
||||
Text(AppLocalizations.of(context)!.saveMap),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
onPressed: () async {
|
||||
|
||||
List<Placemark> placemarks = await placemarkFromCoordinates(selectedPosition!.latitude, selectedPosition!.longitude);
|
||||
print(placemarks);
|
||||
|
||||
if (selectedPosition != null) {
|
||||
|
||||
setState(() {
|
||||
updatedPosition = Position(
|
||||
longitude: selectedPosition!.longitude,
|
||||
@@ -1935,16 +1967,12 @@ class _AbbauDatState extends State<AbbauDat> {
|
||||
Future<DateTime?> pickDate() async {
|
||||
final date = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: abbauDat!,
|
||||
initialDate: DateTime.now(),
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(5000));
|
||||
if (date == null) return null;
|
||||
setState(() => abbauDat = date);
|
||||
|
||||
var place = {'AbbauDat': DateFormat('yyyy-MM-dd').format(abbauDat!)};
|
||||
|
||||
await DBHelper().addPlace(place);
|
||||
|
||||
return abbauDat;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user