luc sitzung

This commit is contained in:
nico
2024-04-24 21:45:13 +02:00
parent 3f61b740b8
commit 3be74688fd
12 changed files with 195 additions and 130 deletions

View File

@@ -1,33 +1,31 @@
todo:
<<<<<<< HEAD
TEST SEND FILE TO SERVER FUNCTION
maybe auch vorschläge aus templates in dropdown menüs anzeigen
im englischen abändern
zurückfeld in datenansicht
überschriften für view cams
dropdown menü fixen (ai fragen)
=======
>>>>>>> d6ae86598dd9d031af9fe29680dc050c5bb2946f
fehler beim speichern anzeigen
nach koordinaten lkr auswählen (esri-leaflet-geocoder)
fix ktage und nebeneinander positioniere
textdateien auch an server senden
<<<<<<< HEAD
error check wenn dateiauswahl abgebrochen wurde einfügen
save option einfügen nur zum speichern
=======
ausvon und ausbis fixen (falsches datum übergeben (20000-01-01))
zurückfeld in datenansicht
maybe auch vorschläge aus templates in dropdown menüs anzeigen
im englischen abändern
>>>>>>> d6ae86598dd9d031af9fe29680dc050c5bb2946f
einzelnen eintrag löschen
alle datumsfelder in 1 klasse und überarbeiten dass entfernen funktioniert und knöpfe bissl breiter
keine ahnung obs funktioniert:
dropdown menü fixen (ai fragen)
TEST SEND FILE TO SERVER FUNCTION
eintrg in db wenn http response (in sent column)
not to do:
standartwert in textfeld
überschriften für view cams
schritte latlang umbenennen
gespeicherten ordner anzeigen

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View File

@@ -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),
],
))
];

View File

@@ -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;
}
}

View File

@@ -32,7 +32,7 @@ class HomePage extends StatelessWidget {
),
body: Column(
children: [
Image.asset('assets/images/reconix.png'),
Image.asset('assets/images/reconix_small.png'),
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,

View File

@@ -19,6 +19,8 @@ void main() async {
WidgetsFlutterBinding.ensureInitialized();
SharedPreferences prefs = await SharedPreferences.getInstance();
bool isFirstLaunch = prefs.getBool('isFirstLaunch') ?? true;
await prefs.setString('kTage1', "28");
await prefs.setString('kTage2', "48");
runApp(MyApp(isFirstLaunch: isFirstLaunch));
}
@@ -26,6 +28,8 @@ class MyApp extends StatelessWidget {
final bool isFirstLaunch;
const MyApp({super.key, required this.isFirstLaunch});
@override
Widget build(BuildContext context) {
return MaterialApp(

View File

@@ -9,13 +9,12 @@ import 'package:path/path.dart';
class DBHelper {
static Database? _placeDB;
// checks if the databses are existing and creates them with the initPlaceDatabase function if not
Future<Database> get placeDB async {
if (_placeDB != null) {
return _placeDB!;
}
_placeDB = await initPlaceDatabase();
_placeDB = await initPlaceDatabase();
return _placeDB!;
}
@@ -31,12 +30,11 @@ class DBHelper {
// The function that helps
_onCreatePlace(Database placeDB, int version) async {
await placeDB.execute(
'CREATE TABLE place (CID TEXT PRIMARY KEY UNIQUE NOT NULL, Standort TEXT, Rudel TEXT, Datum DATE, Adresse1 TEXT, Adresse2 TEXT, Adresse3 TEXT, BLand TEXT, Lkr TEXT, BeiOrt TEXT, OrtInfo TEXT, Status TEXT, STTyp TEXT, FFTyp TEXT, FotoFilm TEXT, MEZ TEXT, Platzung TEXT, KSchloNr TEXT, Bearsafe TEXT, KontDat DATE, Betreuung TEXT, AbbauDat DATE, Auftrag TEXT, KontAbsp TEXT, SonstBem TEXT, FKontakt1 TEXT, FKontakt2 TEXT, FKontakt3 TEXT, KTage1 INTEGER, KTage2 INTEGER, ProtoAm DATE, IntKomm TEXT, DECLNG DECIMALS(4,8), DECLAT DECIMALS(4,8), Sent INTEGER DEFAULT 0)');
'CREATE TABLE place (CID TEXT PRIMARY KEY UNIQUE NOT NULL, Standort TEXT, Rudel TEXT, Datum DATE, Adresse1 TEXT, Adresse2 TEXT, Adresse3 TEXT, BLand TEXT, Lkr TEXT, BeiOrt TEXT, OrtInfo TEXT, Status TEXT, STTyp TEXT, FFTyp TEXT, FotoFilm TEXT, MEZ TEXT, Platzung TEXT, KSchloNr TEXT, Bearsafe TEXT, KontDat DATE, Betreuung TEXT, AbbauDat DATE, Auftrag TEXT, KontAbsp TEXT, SonstBem TEXT, FKontakt1 TEXT, FKontakt2 TEXT, FKontakt3 TEXT, KTage1 INTEGER, KTage2 INTEGER, ProtoAm DATE, IntKomm TEXT, DECLNG DECIMALS(4,8), DECLAT DECIMALS(4,8), Sent INTEGER DEFAULT 0)');
await placeDB.execute(
'CREATE TABLE templates (CID TEXT PRIMARY KEY UNIQUE NOT NULL, Standort TEXT, Rudel TEXT, Datum DATE, Adresse1 TEXT, Adresse2 TEXT, Adresse3 TEXT, BLand TEXT, Lkr TEXT, BeiOrt TEXT, OrtInfo TEXT, Status TEXT, STTyp TEXT, FFTyp TEXT, FotoFilm TEXT, MEZ TEXT, Platzung TEXT, KSchloNr TEXT, Bearsafe TEXT, KontDat DATE, Betreuung TEXT, AbbauDat DATE, Auftrag TEXT, KontAbsp TEXT, SonstBem TEXT, FKontakt1 TEXT, FKontakt2 TEXT, FKontakt3 TEXT, KTage1 INTEGER, KTage2 INTEGER, ProtoAm DATE, IntKomm TEXT, DECLNG DECIMALS(4,8), DECLAT DECIMALS(4,8))');
}
// Function to add a finished entrie
Future<void> addPlace(Map<String, dynamic> place) async {
var placeDBClient = await placeDB;
@@ -50,6 +48,7 @@ class DBHelper {
// checks if the camid var from before is empty to avoid double entries
if (existingCID.isNotEmpty) {
//throw Exception("Eintrag existiert schon");
return;
}
@@ -59,7 +58,7 @@ class DBHelper {
place,
// replaces the entrie with the new onw if a unique value exists and conflicts
conflictAlgorithm: ConflictAlgorithm.replace,
// conflictAlgorithm: ConflictAlgorithm.replace,
);
}
@@ -67,7 +66,8 @@ class DBHelper {
Future<void> updateSent() async {
var placeDBClient = await placeDB;
placeDBClient.update('place', true as Map<String, Object?>, where: 'CID = ?', whereArgs: ['CID']);
placeDBClient.update('place', true as Map<String, Object?>,
where: 'CID = ?', whereArgs: ['CID']);
}
// same thing as before but with templatews
@@ -86,7 +86,7 @@ class DBHelper {
await placeDBClient.insert(
'templates',
templates,
conflictAlgorithm: ConflictAlgorithm.replace,
// conflictAlgorithm: ConflictAlgorithm.replace,
);
}
@@ -102,7 +102,6 @@ class DBHelper {
);
}
// get the finished entries from db
Future<List<Map<String, dynamic>>> getPlace() async {
var placeDBClient = await placeDB;
@@ -126,4 +125,24 @@ class DBHelper {
var placeDBClient = await placeDB;
await placeDBClient.delete('templates');
}
// delete specific template
Future<void> deleteTemplate(String cid) async {
var placeDBClient = await placeDB;
await placeDBClient.delete(
'templates',
where: 'CID = ?',
whereArgs: [cid],
);
}
// delete specific place
Future<void> deletePlace(String cid) async {
var placeDBClient = await placeDB;
await placeDBClient.delete(
'place',
where: 'CID = ?',
whereArgs: [cid],
);
}
}

View File

@@ -22,7 +22,6 @@ class _SettingsState extends State<Settings> {
@override
Widget build(BuildContext context) {
return Scaffold(

View File

@@ -1,6 +1,8 @@
import 'package:fforte/addCam/add_cam_main.dart';
import 'package:fforte/other/db_helper.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_popup_card/flutter_popup_card.dart';
// * Site that shows all entries in the databases
@@ -132,11 +134,14 @@ class _ViewCamsState extends State<ViewCams> {
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(AppLocalizations.of(context)!.placedata),
const SizedBox(
width: 250,
),
Text(AppLocalizations.of(context)!.sent),
Expanded(
flex: 2,
child: Text(
AppLocalizations.of(context)!.placedata)),
Expanded(
flex: 2,
child:
Text(AppLocalizations.of(context)!.sent)),
],
),
const SizedBox(

View File

@@ -197,6 +197,38 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
geocoding:
dependency: "direct main"
description:
name: geocoding
sha256: d580c801cba9386b4fac5047c4c785a4e19554f46be42f4f5e5b7deacd088a66
url: "https://pub.dev"
source: hosted
version: "3.0.0"
geocoding_android:
dependency: transitive
description:
name: geocoding_android
sha256: "4e1539a136c6ab4c44963cfc631970ee499f706a03654fc1d446b2100caf7221"
url: "https://pub.dev"
source: hosted
version: "3.3.0"
geocoding_ios:
dependency: transitive
description:
name: geocoding_ios
sha256: "94ddba60387501bd1c11e18dca7c5a9e8c645d6e3da9c38b9762434941870c24"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
geocoding_platform_interface:
dependency: transitive
description:
name: geocoding_platform_interface
sha256: "8c2c8226e5c276594c2e18bfe88b19110ed770aeb7c1ab50ede570be8b92229b"
url: "https://pub.dev"
source: hosted
version: "3.2.0"
geolocator:
dependency: "direct main"
description:

View File

@@ -48,6 +48,7 @@ dependencies:
file_picker: ^6.2.0
http: ^1.2.1
dio: ^5.4.1
geocoding: ^3.0.0
dev_dependencies:
flutter_lints: ^3.0.1

View File

@@ -46,9 +46,5 @@
21 mär 4h 15 min
23 mär 2h 15 min
24 mär 1h
<<<<<<< HEAD
26 mär 45 min
20 mär 1h 30 min
=======
17 apr 45 min
>>>>>>> d6ae86598dd9d031af9fe29680dc050c5bb2946f