begin cleanup add_cam_main. dont remember if anything more
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
<application
|
<application
|
||||||
android:label="fforte"
|
android:label="fforte"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
import 'package:fforte/screens/Excursion/excursion_main.dart';
|
|
||||||
import 'package:fforte/screens/addCam/add_cam_main.dart';
|
|
||||||
import 'package:fforte/screens/intro_screen.dart';
|
|
||||||
import 'package:fforte/screens/settings.dart';
|
|
||||||
import 'package:fforte/screens/viewCam/view_cams.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flex_color_scheme/flex_color_scheme.dart';
|
|
||||||
mport 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
|
|
||||||
import 'home.dart';
|
|
||||||
import 'l10n/l10n.dart';
|
|
||||||
|
|
||||||
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");
|
|
||||||
await prefs.setString(
|
|
||||||
'apiAddress', 'http://192.168.1.106/www.dbb-wolf.de/data/app24.php');
|
|
||||||
runApp(MyApp(isFirstLaunch: isFirstLaunch));
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
|
||||||
final bool isFirstLaunch;
|
|
||||||
const MyApp({super.key, required this.isFirstLaunch});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return MaterialApp(
|
|
||||||
title: 'FFOrte',
|
|
||||||
theme: FlexThemeData.light(scheme: FlexScheme.gold, useMaterial3: true),
|
|
||||||
darkTheme:
|
|
||||||
FlexThemeData.dark(scheme: FlexScheme.greenM3, useMaterial3: true),
|
|
||||||
themeMode: ThemeMode.system,
|
|
||||||
initialRoute: isFirstLaunch ? '/introScreen' : '/home',
|
|
||||||
supportedLocales: L10n.all,
|
|
||||||
localizationsDelegates: const [
|
|
||||||
AppLocalizations.delegate,
|
|
||||||
GlobalMaterialLocalizations.delegate,
|
|
||||||
GlobalCupertinoLocalizations.delegate,
|
|
||||||
GlobalWidgetsLocalizations.delegate,
|
|
||||||
],
|
|
||||||
routes: {
|
|
||||||
'/home': (context) => const HomePage(),
|
|
||||||
'/addCamMain': (context) => const AddCamMain(),
|
|
||||||
'/viewCams': (context) => const ViewCams(),
|
|
||||||
'/introScreen': (context) => const IntroScreen(),
|
|
||||||
'/settings': (context) => const Settings(),
|
|
||||||
'/excursion': (context) => const ExcursionMain(),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:fforte/methods/http_request.dart';
|
import 'package:fforte/screens/sharedMethods/http_request.dart';
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
|||||||
32
lib/interfaces/i_db.dart
Normal file
32
lib/interfaces/i_db.dart
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import 'package:sqflite/sqflite.dart';
|
||||||
|
|
||||||
|
abstract interface class IDb {
|
||||||
|
Future<Database> get dB;
|
||||||
|
|
||||||
|
initDatabases();
|
||||||
|
|
||||||
|
onCreateDatabases(Database excursionDB, int version);
|
||||||
|
|
||||||
|
Future<int> addMainEntry(Map<String, dynamic> excursion);
|
||||||
|
|
||||||
|
Future<void> updateMainEntry(Map<String, dynamic> excursion);
|
||||||
|
|
||||||
|
Future<void> updateSent(int id);
|
||||||
|
|
||||||
|
Future<void> addTemplate(Map<String, dynamic> templates);
|
||||||
|
|
||||||
|
Future<void> updateTemplate(Map<String, dynamic> template);
|
||||||
|
|
||||||
|
Future<List<Map<String, dynamic>>> getAllMainEntries();
|
||||||
|
|
||||||
|
Future<List<Map<String, dynamic>>> getAllTemplates();
|
||||||
|
|
||||||
|
Future<void> deleteAllMainEntries();
|
||||||
|
|
||||||
|
Future<void> deleteAllTemplates();
|
||||||
|
|
||||||
|
Future<void> deleteTemplateById(String id);
|
||||||
|
|
||||||
|
Future<void> deleteMainEntryById(String id);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -90,6 +90,7 @@
|
|||||||
"pickfile": "Datei auswählen",
|
"pickfile": "Datei auswählen",
|
||||||
"placedata": "Standortdaten",
|
"placedata": "Standortdaten",
|
||||||
"sent": "Gesendet",
|
"sent": "Gesendet",
|
||||||
|
"fileSaved": "Datei gespeichtert bei: ",
|
||||||
"savefilefailed": "Fehler. Bitte nochmal versuchen",
|
"savefilefailed": "Fehler. Bitte nochmal versuchen",
|
||||||
"justplace": "Standort",
|
"justplace": "Standort",
|
||||||
"justsave": "Nur speichern",
|
"justsave": "Nur speichern",
|
||||||
|
|||||||
@@ -434,6 +434,11 @@
|
|||||||
"description": "view data sent header"
|
"description": "view data sent header"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"fileSaved": "File saved at: ",
|
||||||
|
"@fileSaved": {
|
||||||
|
"description": "file successfully saved"
|
||||||
|
},
|
||||||
|
|
||||||
"savefilefailed": "Error. Please try again",
|
"savefilefailed": "Error. Please try again",
|
||||||
"@savefilefailed": {
|
"@savefilefailed": {
|
||||||
"description": "save as file failed snackbar"
|
"description": "save as file failed snackbar"
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:fforte/interfaces/i_db.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:sqflite/sqflite.dart';
|
import 'package:sqflite/sqflite.dart';
|
||||||
import 'dart:io' as io;
|
import 'dart:io' as io;
|
||||||
@@ -6,29 +7,32 @@ import 'package:path/path.dart';
|
|||||||
// * Gives the complete functionality for the databases
|
// * Gives the complete functionality for the databases
|
||||||
// ! functions may not be named complete correctly
|
// ! functions may not be named complete correctly
|
||||||
|
|
||||||
class ExcursionDBHelper {
|
class ExcursionDBHelper implements IDb{
|
||||||
static Database? _excursionDB;
|
static Database? _excursionDB;
|
||||||
|
|
||||||
// checks if the databses are existing and creates them with the initPlaceDatabase function if not
|
// checks if the databses are existing and creates them with the initPlaceDatabase function if not
|
||||||
Future<Database> get excursionDB async {
|
@override
|
||||||
|
Future<Database> get dB async {
|
||||||
if (_excursionDB != null) {
|
if (_excursionDB != null) {
|
||||||
return _excursionDB!;
|
return _excursionDB!;
|
||||||
}
|
}
|
||||||
_excursionDB = await initExcursionDatabase();
|
_excursionDB = await initDatabases();
|
||||||
return _excursionDB!;
|
return _excursionDB!;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates the databases with help from the _onCreateExcursion function
|
// Creates the databases with help from the _onCreateExcursion function
|
||||||
initExcursionDatabase() async {
|
@override
|
||||||
|
initDatabases() async {
|
||||||
io.Directory documentsDirectory = await getApplicationCacheDirectory();
|
io.Directory documentsDirectory = await getApplicationCacheDirectory();
|
||||||
String path = join(documentsDirectory.path, 'excursionDB.db');
|
String path = join(documentsDirectory.path, 'excursionDB.db');
|
||||||
var excursionDB =
|
var excursionDB =
|
||||||
await openDatabase(path, version: 1, onCreate: _onCreateExcursion);
|
await openDatabase(path, version: 1, onCreate: onCreateDatabases);
|
||||||
return excursionDB;
|
return excursionDB;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The function that helps
|
// The function that helps
|
||||||
_onCreateExcursion(Database excursionDB, int version) async {
|
@override
|
||||||
|
onCreateDatabases(Database excursionDB, int version) async {
|
||||||
await excursionDB.execute(
|
await excursionDB.execute(
|
||||||
'CREATE TABLE excursion (ID INTEGER PRIMARY KEY AUTOINCREMENT, Datum TEXT, Rudel TEXT, Teilnehmer TEXT, Jahr TEXT, Mjahr TEXT, Monat INTEGER, Saison TEXT, Dauer TEXT, BLjahr TEXT, BLand, TEXT, Lkr TEXT, BeiOrt TEXT, Wetter TEXT, Temperat TEXT, RegenVor TEXT, KmAuto TEXT, KmFuss TEXT, KmRad TEXT, KmTotal TEXT, KmAuProf TEXT, KmFuProz TEXT, KmRaProz TEXT, SpGut TEXT, SpSchlecht TEXT, SpurFund TEXT, SpurLang TEXT, SpurTiere Text, SpSicher TEXT, WelpenSp TEXT, WelpenAnz TEXT, WpSicher TEXT, LosungGes TEXT, LosunAnz TEXT, LosunGen TEXT, UrinAnz TEXT, UrinGen TEXT, OestrAnz TEXT, OestrGen TEXT, HaarAnz TEXT, HaarGen TEXT, LosungKm TEXT, GenetiKm TEXT, Hinweise TEXT, Bemerk TEXT, IntKomm TEXT, BimaNr TEXT, BimaName TEXT, BimaNutzer TEXT, BimaAGV TEXT, FallNum INTEGER, MHund TEXT, MLeine TEXT, LogDat TEXT, HinweiseSonstiges TEXT)');
|
'CREATE TABLE excursion (ID INTEGER PRIMARY KEY AUTOINCREMENT, Datum TEXT, Rudel TEXT, Teilnehmer TEXT, Jahr TEXT, Mjahr TEXT, Monat INTEGER, Saison TEXT, Dauer TEXT, BLjahr TEXT, BLand, TEXT, Lkr TEXT, BeiOrt TEXT, Wetter TEXT, Temperat TEXT, RegenVor TEXT, KmAuto TEXT, KmFuss TEXT, KmRad TEXT, KmTotal TEXT, KmAuProf TEXT, KmFuProz TEXT, KmRaProz TEXT, SpGut TEXT, SpSchlecht TEXT, SpurFund TEXT, SpurLang TEXT, SpurTiere Text, SpSicher TEXT, WelpenSp TEXT, WelpenAnz TEXT, WpSicher TEXT, LosungGes TEXT, LosunAnz TEXT, LosunGen TEXT, UrinAnz TEXT, UrinGen TEXT, OestrAnz TEXT, OestrGen TEXT, HaarAnz TEXT, HaarGen TEXT, LosungKm TEXT, GenetiKm TEXT, Hinweise TEXT, Bemerk TEXT, IntKomm TEXT, BimaNr TEXT, BimaName TEXT, BimaNutzer TEXT, BimaAGV TEXT, FallNum INTEGER, MHund TEXT, MLeine TEXT, LogDat TEXT, HinweiseSonstiges TEXT)');
|
||||||
await excursionDB.execute(
|
await excursionDB.execute(
|
||||||
@@ -36,8 +40,9 @@ class ExcursionDBHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Function to add a finished entry and return its ID
|
// Function to add a finished entry and return its ID
|
||||||
Future<int> addExcursion(Map<String, dynamic> excursion) async {
|
@override
|
||||||
var excursionDBClient = await excursionDB;
|
Future<int> addMainEntry(Map<String, dynamic> excursion) async {
|
||||||
|
var excursionDBClient = await dB;
|
||||||
final existingID = await excursionDBClient.query(
|
final existingID = await excursionDBClient.query(
|
||||||
'excursion',
|
'excursion',
|
||||||
where: 'ID = ?',
|
where: 'ID = ?',
|
||||||
@@ -45,7 +50,7 @@ class ExcursionDBHelper {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (existingID.isNotEmpty) {
|
if (existingID.isNotEmpty) {
|
||||||
updateExcursion(excursion);
|
updateMainEntry(excursion);
|
||||||
return existingID.first['ID'] as int; // Return existing ID
|
return existingID.first['ID'] as int; // Return existing ID
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,24 +63,27 @@ class ExcursionDBHelper {
|
|||||||
return id; // Return the ID of the newly inserted entry
|
return id; // Return the ID of the newly inserted entry
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateExcursion(Map<String, dynamic> excursion) async {
|
@override
|
||||||
var excursionDBClient = await excursionDB;
|
Future<void> updateMainEntry(Map<String, dynamic> excursion) async {
|
||||||
|
var excursionDBClient = await dB;
|
||||||
|
|
||||||
await excursionDBClient
|
await excursionDBClient
|
||||||
.update('excursion', excursion, where: "ID = ?", whereArgs: [excursion['ID']]);
|
.update('excursion', excursion, where: "ID = ?", whereArgs: [excursion['ID']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// function to update the sent value
|
// function to update the sent value
|
||||||
|
@override
|
||||||
Future<void> updateSent(int id) async {
|
Future<void> updateSent(int id) async {
|
||||||
var excursionDBClient = await excursionDB;
|
var excursionDBClient = await dB;
|
||||||
|
|
||||||
await excursionDBClient.update('excursion', {'Sent': 1},
|
await excursionDBClient.update('excursion', {'Sent': 1},
|
||||||
where: 'ID = ?', whereArgs: [id]);
|
where: 'ID = ?', whereArgs: [id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// same thing as before but with templatews
|
// same thing as before but with templatews
|
||||||
|
@override
|
||||||
Future<void> addTemplate(Map<String, dynamic> templates) async {
|
Future<void> addTemplate(Map<String, dynamic> templates) async {
|
||||||
var excursionDBClient = await excursionDB;
|
var excursionDBClient = await dB;
|
||||||
|
|
||||||
final existingCID = await excursionDBClient.query(
|
final existingCID = await excursionDBClient.query(
|
||||||
'excursionTemplates',
|
'excursionTemplates',
|
||||||
@@ -94,8 +102,9 @@ class ExcursionDBHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Updates a existing template
|
// Updates a existing template
|
||||||
|
@override
|
||||||
Future<void> updateTemplate(Map<String, dynamic> template) async {
|
Future<void> updateTemplate(Map<String, dynamic> template) async {
|
||||||
var excursionDBClient = await excursionDB;
|
var excursionDBClient = await dB;
|
||||||
|
|
||||||
await excursionDBClient.update(
|
await excursionDBClient.update(
|
||||||
'excursionTemplates',
|
'excursionTemplates',
|
||||||
@@ -106,32 +115,37 @@ class ExcursionDBHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get the finished entries from db
|
// get the finished entries from db
|
||||||
Future<List<Map<String, dynamic>>> getExcursionen() async {
|
@override
|
||||||
var excursionDBClient = await excursionDB;
|
Future<List<Map<String, dynamic>>> getAllMainEntries() async {
|
||||||
|
var excursionDBClient = await dB;
|
||||||
return await excursionDBClient.query('excursion');
|
return await excursionDBClient.query('excursion');
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the finished templates from db
|
// get the finished templates from db
|
||||||
Future<List<Map<String, dynamic>>> getTemplates() async {
|
@override
|
||||||
var excursionDBClient = await excursionDB;
|
Future<List<Map<String, dynamic>>> getAllTemplates() async {
|
||||||
|
var excursionDBClient = await dB;
|
||||||
return await excursionDBClient.query('excursionTemplates');
|
return await excursionDBClient.query('excursionTemplates');
|
||||||
}
|
}
|
||||||
|
|
||||||
// deletes all finished entries from the db LOCALLY
|
// deletes all finished entries from the db LOCALLY
|
||||||
Future<void> deleteAllExcursionen() async {
|
@override
|
||||||
var excursionDBClient = await excursionDB;
|
Future<void> deleteAllMainEntries() async {
|
||||||
|
var excursionDBClient = await dB;
|
||||||
await excursionDBClient.delete('excursion');
|
await excursionDBClient.delete('excursion');
|
||||||
}
|
}
|
||||||
|
|
||||||
// deletes all templates from the db LOCALLY
|
// deletes all templates from the db LOCALLY
|
||||||
|
@override
|
||||||
Future<void> deleteAllTemplates() async {
|
Future<void> deleteAllTemplates() async {
|
||||||
var excursionDBClient = await excursionDB;
|
var excursionDBClient = await dB;
|
||||||
await excursionDBClient.delete('excursionTemplates');
|
await excursionDBClient.delete('excursionTemplates');
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete specific template
|
// delete specific template
|
||||||
Future<void> deleteTemplate(String id) async {
|
@override
|
||||||
var excursionDBClient = await excursionDB;
|
Future<void> deleteTemplateById(String id) async {
|
||||||
|
var excursionDBClient = await dB;
|
||||||
await excursionDBClient.delete(
|
await excursionDBClient.delete(
|
||||||
'excursionTemplates',
|
'excursionTemplates',
|
||||||
where: 'ID = ?',
|
where: 'ID = ?',
|
||||||
@@ -140,8 +154,9 @@ class ExcursionDBHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// delete specific excursion
|
// delete specific excursion
|
||||||
Future<void> deleteExcursion(String id) async {
|
@override
|
||||||
var excursionDBClient = await excursionDB;
|
Future<void> deleteMainEntryById(String id) async {
|
||||||
|
var excursionDBClient = await dB;
|
||||||
await excursionDBClient.delete(
|
await excursionDBClient.delete(
|
||||||
'excursion',
|
'excursion',
|
||||||
where: 'ID = ?',
|
where: 'ID = ?',
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:fforte/interfaces/i_db.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:sqflite/sqflite.dart';
|
import 'package:sqflite/sqflite.dart';
|
||||||
import 'dart:io' as io;
|
import 'dart:io' as io;
|
||||||
@@ -6,40 +7,42 @@ import 'package:path/path.dart';
|
|||||||
// * Gives the complete functionality for the databases
|
// * Gives the complete functionality for the databases
|
||||||
// ! functions may not be named complete correctly
|
// ! functions may not be named complete correctly
|
||||||
|
|
||||||
class PlaceDBHelper {
|
class PlaceDBHelper implements IDb{
|
||||||
static Database? _placeDB;
|
static Database? _dB;
|
||||||
|
|
||||||
// checks if the databses are existing and creates them with the initPlaceDatabase function if not
|
// checks if the databses are existing and creates them with the initPlaceDatabase function if not
|
||||||
Future<Database> get placeDB async {
|
@override
|
||||||
if (_placeDB != null) {
|
Future<Database> get dB async {
|
||||||
return _placeDB!;
|
if (_dB != null) {
|
||||||
|
return _dB!;
|
||||||
}
|
}
|
||||||
_placeDB = await initPlaceDatabase();
|
_dB = await initDatabases();
|
||||||
return _placeDB!;
|
return _dB!;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates the databases with help from the _onCreatePlace function
|
// Creates the databases with help from the _onCreatePlace function
|
||||||
initPlaceDatabase() async {
|
@override
|
||||||
|
initDatabases() async {
|
||||||
io.Directory documentsDirectory = await getApplicationCacheDirectory();
|
io.Directory documentsDirectory = await getApplicationCacheDirectory();
|
||||||
String path = join(documentsDirectory.path, 'placeDB.db');
|
String path = join(documentsDirectory.path, 'placeDB.db');
|
||||||
var placeDB =
|
var placeDB =
|
||||||
await openDatabase(path, version: 1, onCreate: _onCreatePlace);
|
await openDatabase(path, version: 1, onCreate: onCreateDatabases);
|
||||||
return placeDB;
|
return placeDB;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The function that helps
|
// The function that helps
|
||||||
_onCreatePlace(Database placeDB, int version) async {
|
@override
|
||||||
|
onCreateDatabases(Database placeDB, int version) async {
|
||||||
await placeDB.execute(
|
await placeDB.execute(
|
||||||
'CREATE TABLE place (ID INTEGER PRIMARY KEY AUTOINCREMENT, CID TEXT, Standort TEXT, Rudel TEXT, Datum DATE, Adresse1 TEXT, Adresse2 TEXT, Adresse3 TEXT, BLand TEXT, Lkr TEXT, BeiOrt TEXT, OrtInfo TEXT, Status TEXT, FFTyp TEXT, FotoFilm TEXT, MEZ TEXT, Platzung TEXT, KSchloNr 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 (ID INTEGER PRIMARY KEY AUTOINCREMENT, CID TEXT, Standort TEXT, Rudel TEXT, Datum DATE, Adresse1 TEXT, Adresse2 TEXT, Adresse3 TEXT, BLand TEXT, Lkr TEXT, BeiOrt TEXT, OrtInfo TEXT, Status TEXT, FFTyp TEXT, FotoFilm TEXT, MEZ TEXT, Platzung TEXT, KSchloNr 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(
|
await placeDB.execute(
|
||||||
'CREATE TABLE placeTemplates (ID INTEGER PRIMARY KEY AUTOINCREMENT, CID TEXT, Standort TEXT, Rudel TEXT, Datum DATE, Adresse1 TEXT, Adresse2 TEXT, Adresse3 TEXT, BLand TEXT, Lkr TEXT, BeiOrt TEXT, OrtInfo TEXT, Status TEXT, FFTyp TEXT, FotoFilm TEXT, MEZ TEXT, Platzung TEXT, KSchloNr 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))');
|
'CREATE TABLE placeTemplates (ID INTEGER PRIMARY KEY AUTOINCREMENT, CID TEXT, Standort TEXT, Rudel TEXT, Datum DATE, Adresse1 TEXT, Adresse2 TEXT, Adresse3 TEXT, BLand TEXT, Lkr TEXT, BeiOrt TEXT, OrtInfo TEXT, Status TEXT, FFTyp TEXT, FotoFilm TEXT, MEZ TEXT, Platzung TEXT, KSchloNr 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))');
|
||||||
await placeDB.execute(
|
|
||||||
'CREATE TABLE excursion (ID INTEGER PRIMARY KEY AUTOINCREMENT, Datum TEXT, Rudel TEXT, Teilnehmer TEXT, Jahr TEXT, Mjahr TEXT, Monat INTEGER, Saison TEXT, Dauer TEXT, BLjahr TEXT, BLand, TEXT, Lkr TEXT, BeiOrt TEXT, Wetter TEXT, Temperat TEXT, RegenVor TEXT, KmAuto TEXT, KmFuss TEXT, KmRad TEXT, KmTotal TEXT, KmAuProf TEXT, KmFuProz TEXT, KmRaProz TEXT, SpGut TEXT, SpSchlecht TEXT, SpurFund TEXT, SpurLang TEXT, SpurTiere Text, SpSicher TEXT, WelpenSp TEXT, WelpenAnz TEXT, WpSicher TEXT, LosungGes TEXT, LosunAnz TEXT, LosunGen TEXT, UrinAnz TEXT, UrinGen TEXT, OestrAnz TEXT, OestrGen TEXT, HaarAnz TEXT, HaarGen TEXT, LosungKm TEXT, GenetiKm TEXT, Hinweise TEXT, Bemerk TEXT, IntKomm TEXT, BimaNr TEXT, BimaName TEXT, BimaNutzer TEXT, BimaAGV TEXT, FallNum INTEGER, MHund TEXT, MLeine TEXT, LogDat TEXT)');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to add a finished entry and return its ID
|
// Function to add a finished entry and return its ID
|
||||||
Future<int> addPlace(Map<String, dynamic> place) async {
|
@override
|
||||||
var placeDBClient = await placeDB;
|
Future<int> addMainEntry(Map<String, dynamic> place) async {
|
||||||
|
var placeDBClient = await dB;
|
||||||
final existingID = await placeDBClient.query(
|
final existingID = await placeDBClient.query(
|
||||||
'place',
|
'place',
|
||||||
where: 'ID = ?',
|
where: 'ID = ?',
|
||||||
@@ -47,7 +50,7 @@ class PlaceDBHelper {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (existingID.isNotEmpty) {
|
if (existingID.isNotEmpty) {
|
||||||
updatePlace(place);
|
updateMainEntry(place);
|
||||||
return existingID.first['ID'] as int; // Return existing ID
|
return existingID.first['ID'] as int; // Return existing ID
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,24 +63,27 @@ class PlaceDBHelper {
|
|||||||
return id; // Return the ID of the newly inserted entry
|
return id; // Return the ID of the newly inserted entry
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updatePlace(Map<String, dynamic> place) async {
|
@override
|
||||||
var placeDBClient = await placeDB;
|
Future<void> updateMainEntry(Map<String, dynamic> place) async {
|
||||||
|
var placeDBClient = await dB;
|
||||||
|
|
||||||
await placeDBClient
|
await placeDBClient
|
||||||
.update('place', place, where: "ID = ?", whereArgs: [place['ID']]);
|
.update('place', place, where: "ID = ?", whereArgs: [place['ID']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// function to update the sent value
|
// function to update the sent value
|
||||||
|
@override
|
||||||
Future<void> updateSent(int id) async {
|
Future<void> updateSent(int id) async {
|
||||||
var placeDBClient = await placeDB;
|
var placeDBClient = await dB;
|
||||||
|
|
||||||
await placeDBClient.update('place', {'Sent': 1},
|
await placeDBClient.update('place', {'Sent': 1},
|
||||||
where: 'ID = ?', whereArgs: [id]);
|
where: 'ID = ?', whereArgs: [id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// same thing as before but with templatews
|
// same thing as before but with templatews
|
||||||
|
@override
|
||||||
Future<void> addTemplate(Map<String, dynamic> templates) async {
|
Future<void> addTemplate(Map<String, dynamic> templates) async {
|
||||||
var placeDBClient = await placeDB;
|
var placeDBClient = await dB;
|
||||||
|
|
||||||
final existingCID = await placeDBClient.query(
|
final existingCID = await placeDBClient.query(
|
||||||
'placeTemplates',
|
'placeTemplates',
|
||||||
@@ -96,8 +102,9 @@ class PlaceDBHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Updates a existing template
|
// Updates a existing template
|
||||||
|
@override
|
||||||
Future<void> updateTemplate(Map<String, dynamic> template) async {
|
Future<void> updateTemplate(Map<String, dynamic> template) async {
|
||||||
var placeDBClient = await placeDB;
|
var placeDBClient = await dB;
|
||||||
|
|
||||||
await placeDBClient.update(
|
await placeDBClient.update(
|
||||||
'placeTemplates',
|
'placeTemplates',
|
||||||
@@ -108,32 +115,37 @@ class PlaceDBHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get the finished entries from db
|
// get the finished entries from db
|
||||||
Future<List<Map<String, dynamic>>> getPlace() async {
|
@override
|
||||||
var placeDBClient = await placeDB;
|
Future<List<Map<String, dynamic>>> getAllMainEntries() async {
|
||||||
|
var placeDBClient = await dB;
|
||||||
return await placeDBClient.query('place');
|
return await placeDBClient.query('place');
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the finished templates from db
|
// get the finished templates from db
|
||||||
Future<List<Map<String, dynamic>>> getTemplates() async {
|
@override
|
||||||
var placeDBClient = await placeDB;
|
Future<List<Map<String, dynamic>>> getAllTemplates() async {
|
||||||
|
var placeDBClient = await dB;
|
||||||
return await placeDBClient.query('placeTemplates');
|
return await placeDBClient.query('placeTemplates');
|
||||||
}
|
}
|
||||||
|
|
||||||
// deletes all finished entries from the db LOCALLY
|
// deletes all finished entries from the db LOCALLY
|
||||||
Future<void> deleteAllPlaces() async {
|
@override
|
||||||
var placeDBClient = await placeDB;
|
Future<void> deleteAllMainEntries() async {
|
||||||
|
var placeDBClient = await dB;
|
||||||
await placeDBClient.delete('place');
|
await placeDBClient.delete('place');
|
||||||
}
|
}
|
||||||
|
|
||||||
// deletes all templates from the db LOCALLY
|
// deletes all templates from the db LOCALLY
|
||||||
|
@override
|
||||||
Future<void> deleteAllTemplates() async {
|
Future<void> deleteAllTemplates() async {
|
||||||
var placeDBClient = await placeDB;
|
var placeDBClient = await dB;
|
||||||
await placeDBClient.delete('placeTemplates');
|
await placeDBClient.delete('placeTemplates');
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete specific template
|
// delete specific template
|
||||||
Future<void> deleteTemplate(String id) async {
|
@override
|
||||||
var placeDBClient = await placeDB;
|
Future<void> deleteTemplateById(String id) async {
|
||||||
|
var placeDBClient = await dB;
|
||||||
await placeDBClient.delete(
|
await placeDBClient.delete(
|
||||||
'placeTemplates',
|
'placeTemplates',
|
||||||
where: 'ID = ?',
|
where: 'ID = ?',
|
||||||
@@ -142,8 +154,9 @@ class PlaceDBHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// delete specific place
|
// delete specific place
|
||||||
Future<void> deletePlace(String id) async {
|
@override
|
||||||
var placeDBClient = await placeDB;
|
Future<void> deleteMainEntryById(String id) async {
|
||||||
|
var placeDBClient = await dB;
|
||||||
await placeDBClient.delete(
|
await placeDBClient.delete(
|
||||||
'place',
|
'place',
|
||||||
where: 'ID = ?',
|
where: 'ID = ?',
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class ExcursionMain extends StatefulWidget {
|
|||||||
class _ExcursionMainState extends State<ExcursionMain> {
|
class _ExcursionMainState extends State<ExcursionMain> {
|
||||||
// all TextEditingController because its easier
|
// all TextEditingController because its easier
|
||||||
|
|
||||||
Map<String, TextEditingController> getTextFields() {
|
Map<String, TextEditingController> getFieldsController() {
|
||||||
Map<String, TextEditingController> rmap = {
|
Map<String, TextEditingController> rmap = {
|
||||||
// Step 1
|
// Step 1
|
||||||
"LogDat": TextEditingController(),
|
"LogDat": TextEditingController(),
|
||||||
@@ -99,7 +99,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
|||||||
Datum(
|
Datum(
|
||||||
initDatum: DateTime.now(),
|
initDatum: DateTime.now(),
|
||||||
onDateChanged: (date) {
|
onDateChanged: (date) {
|
||||||
getTextFields()["LogDat"]!.text = date.toString();
|
getFieldsController()["LogDat"]!.text = date.toString();
|
||||||
},
|
},
|
||||||
name: AppLocalizations.of(context)!.date,
|
name: AppLocalizations.of(context)!.date,
|
||||||
),
|
),
|
||||||
@@ -108,7 +108,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
|||||||
),
|
),
|
||||||
// ---------- Pack
|
// ---------- Pack
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: getTextFields()["Rudel"]!,
|
textController: getFieldsController()["Rudel"]!,
|
||||||
localization: AppLocalizations.of(context)!.rudel,
|
localization: AppLocalizations.of(context)!.rudel,
|
||||||
dbName: "Rudel",
|
dbName: "Rudel",
|
||||||
required: false,
|
required: false,
|
||||||
@@ -119,7 +119,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
|||||||
),
|
),
|
||||||
// ---------- Participants
|
// ---------- Participants
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: getTextFields()["Teilnehm"]!,
|
textController: getFieldsController()["Teilnehm"]!,
|
||||||
localization: AppLocalizations.of(context)!.teilnehmer,
|
localization: AppLocalizations.of(context)!.teilnehmer,
|
||||||
dbName: "Teilnehm",
|
dbName: "Teilnehm",
|
||||||
required: false,
|
required: false,
|
||||||
@@ -130,7 +130,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
|||||||
),
|
),
|
||||||
// ---------- Duration
|
// ---------- Duration
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: getTextFields()["Dauer"]!,
|
textController: getFieldsController()["Dauer"]!,
|
||||||
localization: AppLocalizations.of(context)!.dauer,
|
localization: AppLocalizations.of(context)!.dauer,
|
||||||
dbName: "Dauer",
|
dbName: "Dauer",
|
||||||
required: false,
|
required: false,
|
||||||
@@ -141,15 +141,15 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
|||||||
),
|
),
|
||||||
// ---------- Dog(leash)
|
// ---------- Dog(leash)
|
||||||
HundULeine(onMHundChanged: (mHund, mLeine) {
|
HundULeine(onMHundChanged: (mHund, mLeine) {
|
||||||
getTextFields()["MHund"]!.text = mHund;
|
getFieldsController()["MHund"]!.text = mHund;
|
||||||
getTextFields()["MLeine"]!.text = mLeine;
|
getFieldsController()["MLeine"]!.text = mLeine;
|
||||||
}),
|
}),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 10,
|
height: 10,
|
||||||
),
|
),
|
||||||
// ---------- State
|
// ---------- State
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: getTextFields()["BLand"]!,
|
textController: getFieldsController()["BLand"]!,
|
||||||
localization: AppLocalizations.of(context)!.bland,
|
localization: AppLocalizations.of(context)!.bland,
|
||||||
dbName: "BLand",
|
dbName: "BLand",
|
||||||
required: false,
|
required: false,
|
||||||
@@ -160,7 +160,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
|||||||
),
|
),
|
||||||
// ---------- Country
|
// ---------- Country
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: getTextFields()["Lkr"]!,
|
textController: getFieldsController()["Lkr"]!,
|
||||||
localization: AppLocalizations.of(context)!.lkr,
|
localization: AppLocalizations.of(context)!.lkr,
|
||||||
dbName: "Lkr",
|
dbName: "Lkr",
|
||||||
required: false,
|
required: false,
|
||||||
@@ -171,7 +171,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
|||||||
),
|
),
|
||||||
// ---------- By State
|
// ---------- By State
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: getTextFields()["BeiOrt"]!,
|
textController: getFieldsController()["BeiOrt"]!,
|
||||||
localization: AppLocalizations.of(context)!.beiort,
|
localization: AppLocalizations.of(context)!.beiort,
|
||||||
dbName: "BeiOrt",
|
dbName: "BeiOrt",
|
||||||
required: false,
|
required: false,
|
||||||
@@ -186,7 +186,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
|||||||
height: 10,
|
height: 10,
|
||||||
),
|
),
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: getTextFields()["BimaNr"]!,
|
textController: getFieldsController()["BimaNr"]!,
|
||||||
localization: AppLocalizations.of(context)!.bimaNr,
|
localization: AppLocalizations.of(context)!.bimaNr,
|
||||||
dbName: "BimaNr",
|
dbName: "BimaNr",
|
||||||
required: false,
|
required: false,
|
||||||
@@ -197,7 +197,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
|||||||
),
|
),
|
||||||
// ---------- Bima name
|
// ---------- Bima name
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: getTextFields()["BimaName"]!,
|
textController: getFieldsController()["BimaName"]!,
|
||||||
localization: AppLocalizations.of(context)!.bimaName,
|
localization: AppLocalizations.of(context)!.bimaName,
|
||||||
dbName: "BimaName",
|
dbName: "BimaName",
|
||||||
required: false,
|
required: false,
|
||||||
@@ -209,7 +209,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
|||||||
// ---------- Bima user
|
// ---------- Bima user
|
||||||
BimaNutzer(onBimaNutzerChanged: (value) {
|
BimaNutzer(onBimaNutzerChanged: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
getTextFields()["BimaNutzer"]!.text = value;
|
getFieldsController()["BimaNutzer"]!.text = value;
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
@@ -217,7 +217,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
|||||||
),
|
),
|
||||||
// ---------- Bima AGV
|
// ---------- Bima AGV
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: getTextFields()["BimaAGV"]!,
|
textController: getFieldsController()["BimaAGV"]!,
|
||||||
localization: AppLocalizations.of(context)!.bimaAGV,
|
localization: AppLocalizations.of(context)!.bimaAGV,
|
||||||
dbName: "BimaAGV",
|
dbName: "BimaAGV",
|
||||||
required: false,
|
required: false,
|
||||||
@@ -231,7 +231,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
|||||||
children: [
|
children: [
|
||||||
// ---------- Weather
|
// ---------- Weather
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: getTextFields()["Wetter"]!,
|
textController: getFieldsController()["Wetter"]!,
|
||||||
localization: AppLocalizations.of(context)!.wetter,
|
localization: AppLocalizations.of(context)!.wetter,
|
||||||
dbName: "Wetter",
|
dbName: "Wetter",
|
||||||
required: false,
|
required: false,
|
||||||
@@ -240,7 +240,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
|||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
// ---------- Temperature
|
// ---------- Temperature
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: getTextFields()["Temperat"]!,
|
textController: getFieldsController()["Temperat"]!,
|
||||||
localization: AppLocalizations.of(context)!.temperatur,
|
localization: AppLocalizations.of(context)!.temperatur,
|
||||||
dbName: "Temperat",
|
dbName: "Temperat",
|
||||||
required: false,
|
required: false,
|
||||||
@@ -248,16 +248,16 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
// ---------- Last precipitation
|
// ---------- Last precipitation
|
||||||
LetzterNiederschlag(controller: getTextFields()["RegenVor"]!),
|
LetzterNiederschlag(controller: getFieldsController()["RegenVor"]!),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
// ---------- Track conditions
|
// ---------- Track conditions
|
||||||
StreckeUSpurbedingungen(
|
StreckeUSpurbedingungen(
|
||||||
kmAutoController: getTextFields()["KmAuto"]!,
|
kmAutoController: getFieldsController()["KmAuto"]!,
|
||||||
kmFussController: getTextFields()["KmFuss"]!,
|
kmFussController: getFieldsController()["KmFuss"]!,
|
||||||
kmRadController: getTextFields()["KmRad"]!,
|
kmRadController: getFieldsController()["KmRad"]!,
|
||||||
spGutController: getTextFields()["SpGut"]!,
|
spGutController: getFieldsController()["SpGut"]!,
|
||||||
spMittelController: getTextFields()["SpMittel"]!,
|
spMittelController: getFieldsController()["SpMittel"]!,
|
||||||
spSchlechtController: getTextFields()["SpSchlecht"]!,
|
spSchlechtController: getFieldsController()["SpSchlecht"]!,
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
@@ -265,27 +265,27 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
|||||||
const Divider(),
|
const Divider(),
|
||||||
// ---------- Track found
|
// ---------- Track found
|
||||||
SpurGefunden(
|
SpurGefunden(
|
||||||
spurFund: getTextFields()["SpurFund"]!,
|
spurFund: getFieldsController()["SpurFund"]!,
|
||||||
spurLang: getTextFields()["SpurLang"]!,
|
spurLang: getFieldsController()["SpurLang"]!,
|
||||||
spurTiere: getTextFields()["SpurTiere"]!,
|
spurTiere: getFieldsController()["SpurTiere"]!,
|
||||||
spSicher: getTextFields()["SpSicher"]!,
|
spSicher: getFieldsController()["SpSicher"]!,
|
||||||
welpenSp: getTextFields()["WelpenSp"]!,
|
welpenSp: getFieldsController()["WelpenSp"]!,
|
||||||
welpenAnz: getTextFields()["WelpenAnz"]!,
|
welpenAnz: getFieldsController()["WelpenAnz"]!,
|
||||||
wpSicher: getTextFields()["WpSicher"]!),
|
wpSicher: getFieldsController()["WpSicher"]!),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
// ---------- Counts
|
// ---------- Counts
|
||||||
Anzahlen(
|
Anzahlen(
|
||||||
losungAnz: getTextFields()["LosungAnz"]!,
|
losungAnz: getFieldsController()["LosungAnz"]!,
|
||||||
losungGes: getTextFields()["LosungGes"]!,
|
losungGes: getFieldsController()["LosungGes"]!,
|
||||||
losungGen: getTextFields()["LosungGen"]!,
|
losungGen: getFieldsController()["LosungGen"]!,
|
||||||
urinAnz: getTextFields()["UrinAnz"]!,
|
urinAnz: getFieldsController()["UrinAnz"]!,
|
||||||
urinGen: getTextFields()["UrinGen"]!,
|
urinGen: getFieldsController()["UrinGen"]!,
|
||||||
oestrAnz: getTextFields()["OestrAnz"]!,
|
oestrAnz: getFieldsController()["OestrAnz"]!,
|
||||||
oestrGen: getTextFields()["OestrGen"]!,
|
oestrGen: getFieldsController()["OestrGen"]!,
|
||||||
haarAnz: getTextFields()["HaarAnz"]!,
|
haarAnz: getFieldsController()["HaarAnz"]!,
|
||||||
haarGen: getTextFields()["HaarGen"]!,
|
haarGen: getFieldsController()["HaarGen"]!,
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
@@ -304,7 +304,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Hinweise(
|
Hinweise(
|
||||||
hinweise: getTextFields()["Hinweise"]!,
|
hinweise: getFieldsController()["Hinweise"]!,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -315,7 +315,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
|||||||
children: [
|
children: [
|
||||||
// ---------- Remarks
|
// ---------- Remarks
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: getTextFields()["Bemerk"]!,
|
textController: getFieldsController()["Bemerk"]!,
|
||||||
localization: AppLocalizations.of(context)!.sonstbemerkungen,
|
localization: AppLocalizations.of(context)!.sonstbemerkungen,
|
||||||
dbName: "Bemerk",
|
dbName: "Bemerk",
|
||||||
required: false,
|
required: false,
|
||||||
@@ -326,7 +326,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
|||||||
),
|
),
|
||||||
// ---------- Internal communication
|
// ---------- Internal communication
|
||||||
VarTextField(
|
VarTextField(
|
||||||
textController: getTextFields()["IntKomm"]!,
|
textController: getFieldsController()["IntKomm"]!,
|
||||||
localization: AppLocalizations.of(context)!.intkomm,
|
localization: AppLocalizations.of(context)!.intkomm,
|
||||||
dbName: "IntKomm",
|
dbName: "IntKomm",
|
||||||
required: false,
|
required: false,
|
||||||
|
|||||||
@@ -1,19 +1,21 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
|
||||||
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/methods/place_db_helper.dart';
|
import 'package:fforte/methods/place_db_helper.dart';
|
||||||
import 'package:fforte/methods/http_request.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_forbidden_exception.dart';
|
||||||
|
import 'package:fforte/screens/addCam/services/geolocator_service.dart';
|
||||||
|
import 'package:fforte/screens/sharedMethods/save_file.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';
|
||||||
import 'package:file_picker/file_picker.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
import 'package:latlong2/latlong.dart';
|
import 'package:latlong2/latlong.dart';
|
||||||
import 'package:animations/animations.dart';
|
import 'package:animations/animations.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
|
|
||||||
class AddCamMain extends StatefulWidget {
|
class AddCamMain extends StatefulWidget {
|
||||||
final bool isTemplate;
|
final bool isTemplate;
|
||||||
@@ -125,46 +127,49 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
bool empty = false;
|
bool empty = false;
|
||||||
|
|
||||||
// determine live position with checks for denied permission and turned off location service
|
// determine live position with checks for denied permission and turned off location service
|
||||||
Future<Position> _deteterminePosition() async {
|
// Future<Position> _deteterminePosition() async {
|
||||||
bool locationEnabled;
|
// bool locationEnabled;
|
||||||
LocationPermission permissionGiven;
|
// LocationPermission permissionGiven;
|
||||||
|
//
|
||||||
locationEnabled = await Geolocator.isLocationServiceEnabled();
|
// locationEnabled = await Geolocator.isLocationServiceEnabled();
|
||||||
if (!locationEnabled && mounted) {
|
// if (!locationEnabled && mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
// ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
content: Text(AppLocalizations.of(context)!.locationDisabled)));
|
// content: Text(AppLocalizations.of(context)!.locationDisabled)));
|
||||||
return currentPosition;
|
// return currentPosition;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
permissionGiven = await Geolocator.checkPermission();
|
// permissionGiven = await Geolocator.checkPermission();
|
||||||
if (permissionGiven == LocationPermission.denied) {
|
// if (permissionGiven == LocationPermission.denied) {
|
||||||
permissionGiven = await Geolocator.requestPermission();
|
// permissionGiven = await Geolocator.requestPermission();
|
||||||
if (permissionGiven == LocationPermission.denied && mounted) {
|
// if (permissionGiven == LocationPermission.denied && mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
// ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
content: Text(AppLocalizations.of(context)!.locationForbidden)));
|
// content: Text(AppLocalizations.of(context)!.locationForbidden)));
|
||||||
|
//
|
||||||
return currentPosition;
|
// return currentPosition;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (permissionGiven == LocationPermission.deniedForever && mounted) {
|
// if (permissionGiven == LocationPermission.deniedForever && mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
// ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
content: Text(AppLocalizations.of(context)!.locationForbidden)));
|
// content: Text(AppLocalizations.of(context)!.locationForbidden)));
|
||||||
return currentPosition;
|
// return currentPosition;
|
||||||
}
|
// }
|
||||||
return currentPosition = await Geolocator.getCurrentPosition();
|
// return currentPosition = await Geolocator.getCurrentPosition();
|
||||||
}
|
// }
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
// updates the currentPosition var after the _determine position has finished. Means user view updates with his live location
|
// updates the currentPosition var after the _determine position has finished. Means user view updates with his live location
|
||||||
_deteterminePosition().then((position) {
|
try {
|
||||||
setState(() {
|
GeolocatorService.deteterminePosition()
|
||||||
currentPosition = position;
|
.then((result) => currentPosition = result);
|
||||||
});
|
} on LocationDisabledException {
|
||||||
});
|
showSnackBarMessage(AppLocalizations.of(context)!.locationDisabled);
|
||||||
|
} on LocationForbiddenException {
|
||||||
|
showSnackBarMessage(AppLocalizations.of(context)!.locationForbidden);
|
||||||
|
}
|
||||||
|
|
||||||
// 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) {
|
||||||
@@ -207,6 +212,11 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
// 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 {
|
Future<void> showTemplateDialog(List<String> emptyField) async {
|
||||||
return showDialog(
|
return showDialog(
|
||||||
@@ -226,7 +236,8 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
child: Text(AppLocalizations.of(context)!.cancel)),
|
child: Text(AppLocalizations.of(context)!.cancel)),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
saveTemplate();
|
saveTemplate(
|
||||||
|
getPlace(), DatabasesEnum.place, widget.isTemplate);
|
||||||
Navigator.pushNamedAndRemoveUntil(
|
Navigator.pushNamedAndRemoveUntil(
|
||||||
context, '/home', (route) => false);
|
context, '/home', (route) => false);
|
||||||
},
|
},
|
||||||
@@ -305,7 +316,8 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
setState(() => isLoading = true);
|
setState(() => isLoading = true);
|
||||||
saveTemplate();
|
saveTemplate(getPlace(), DatabasesEnum.place,
|
||||||
|
widget.isTemplate);
|
||||||
Navigator.pushNamedAndRemoveUntil(
|
Navigator.pushNamedAndRemoveUntil(
|
||||||
context, '/home', (route) => false);
|
context, '/home', (route) => false);
|
||||||
},
|
},
|
||||||
@@ -332,7 +344,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
setState(() => isLoading = true);
|
setState(() => isLoading = true);
|
||||||
saveData();
|
saveData();
|
||||||
saveFile();
|
_saveFile();
|
||||||
setState(() => isLoading = false);
|
setState(() => isLoading = false);
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context)!.saveasfile)),
|
child: Text(AppLocalizations.of(context)!.saveasfile)),
|
||||||
@@ -390,42 +402,20 @@ child: Text(AppLocalizations.of(context)!.back)), */
|
|||||||
return method.errorCode;
|
return method.errorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> saveFile() async {
|
void _saveFile() {
|
||||||
String? selectedDirectory = await FilePicker.platform.getDirectoryPath();
|
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
||||||
Map place = getPlace();
|
|
||||||
String jsonPlace = jsonEncode(place);
|
|
||||||
|
|
||||||
if (selectedDirectory == null) {
|
|
||||||
if (mounted) Navigator.pop(context);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await prefs.setString('saveDir', selectedDirectory);
|
|
||||||
|
|
||||||
File file = File(
|
|
||||||
'$selectedDirectory/${mounted ? AppLocalizations.of(context)!.justplace : const Text('')}-${standortC.text}.txt');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await file.writeAsString(jsonPlace);
|
saveFile(
|
||||||
} catch (e) {
|
getPlace(), AppLocalizations.of(context)!.justplace, standortC.text);
|
||||||
if (mounted) {
|
// TODO change to fileSaved
|
||||||
Navigator.pop(context);
|
showSnackBarMessage(AppLocalizations.of(context)!.savefilefailed);
|
||||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
|
||||||
content: Text(AppLocalizations.of(context)!.savefilefailed)));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mounted) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text('Datei gespeichert in $selectedDirectory')));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mounted) {
|
|
||||||
Navigator.pushNamedAndRemoveUntil(context, '/home', (route) => false);
|
Navigator.pushNamedAndRemoveUntil(context, '/home', (route) => false);
|
||||||
|
} catch (e) {
|
||||||
|
showSnackBarMessage(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
|
||||||
List<String> validateData() {
|
List<String> validateData() {
|
||||||
List<String> emptyFields = <String>[];
|
List<String> emptyFields = <String>[];
|
||||||
|
|
||||||
@@ -436,11 +426,15 @@ child: Text(AppLocalizations.of(context)!.back)), */
|
|||||||
AppLocalizations.of(context)!.bland: bLandC,
|
AppLocalizations.of(context)!.bland: bLandC,
|
||||||
AppLocalizations.of(context)!.lkr: lkrC,
|
AppLocalizations.of(context)!.lkr: lkrC,
|
||||||
AppLocalizations.of(context)!.beiort: beiOrtC,
|
AppLocalizations.of(context)!.beiort: beiOrtC,
|
||||||
AppLocalizations.of(context)!.status: TextEditingController(text: selectedStatus),
|
AppLocalizations.of(context)!.status:
|
||||||
|
TextEditingController(text: selectedStatus),
|
||||||
AppLocalizations.of(context)!.fftyp: ffTypC,
|
AppLocalizations.of(context)!.fftyp: ffTypC,
|
||||||
"${AppLocalizations.of(context)!.foto} / ${AppLocalizations.of(context)!.filelocation}": TextEditingController(text: selectedFotoFilm),
|
"${AppLocalizations.of(context)!.foto} / ${AppLocalizations.of(context)!.filelocation}":
|
||||||
AppLocalizations.of(context)!.zeiteinstellung: TextEditingController(text: selectedMEZ),
|
TextEditingController(text: selectedFotoFilm),
|
||||||
AppLocalizations.of(context)!.platzung: TextEditingController(text: selectedPlatzung),
|
AppLocalizations.of(context)!.zeiteinstellung:
|
||||||
|
TextEditingController(text: selectedMEZ),
|
||||||
|
AppLocalizations.of(context)!.platzung:
|
||||||
|
TextEditingController(text: selectedPlatzung),
|
||||||
AppLocalizations.of(context)!.ktage1: kTage1C,
|
AppLocalizations.of(context)!.ktage1: kTage1C,
|
||||||
AppLocalizations.of(context)!.ktage1: kTage2C,
|
AppLocalizations.of(context)!.ktage1: kTage2C,
|
||||||
AppLocalizations.of(context)!.location: standortC,
|
AppLocalizations.of(context)!.location: standortC,
|
||||||
@@ -460,18 +454,19 @@ child: Text(AppLocalizations.of(context)!.back)), */
|
|||||||
|
|
||||||
// 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 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
|
// If the user already edits a template this template will be upadted otherwise a new one will be created
|
||||||
void saveTemplate() async {
|
// void saveTemplate() async {
|
||||||
var placeDB = PlaceDBHelper();
|
// var placeDB = PlaceDBHelper();
|
||||||
|
//
|
||||||
Map<String, dynamic> templates = getPlace();
|
// Map<String, dynamic> templates = getPlace();
|
||||||
|
//
|
||||||
if (widget.isTemplate) {
|
// if (widget.isTemplate) {
|
||||||
await placeDB.updateTemplate(templates);
|
// await placeDB.updateTemplate(templates);
|
||||||
} else {
|
// } else {
|
||||||
await placeDB.addTemplate(templates);
|
// 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
|
// 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
|
// * also creates a json string to send it to the server later
|
||||||
void saveData([bool sent = false]) async {
|
void saveData([bool sent = false]) async {
|
||||||
@@ -479,14 +474,14 @@ child: Text(AppLocalizations.of(context)!.back)), */
|
|||||||
Map<String, dynamic> place = getPlace();
|
Map<String, dynamic> place = getPlace();
|
||||||
|
|
||||||
// Get the ID of the newly added or updated place
|
// Get the ID of the newly added or updated place
|
||||||
int newPlaceId = await placeDB.addPlace(place);
|
int newPlaceId = await placeDB.addMainEntry(place);
|
||||||
|
|
||||||
if (sent == true) {
|
if (sent == true) {
|
||||||
placeDB.updateSent(newPlaceId); // Update 'Sent' using the correct ID
|
placeDB.updateSent(newPlaceId); // Update 'Sent' using the correct ID
|
||||||
}
|
}
|
||||||
|
|
||||||
if (widget.isTemplate) {
|
if (widget.isTemplate) {
|
||||||
await placeDB.deleteTemplate(cid.text);
|
await placeDB.deleteTemplateById(cid.text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -745,31 +740,44 @@ child: Text(AppLocalizations.of(context)!.back)), */
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text( AppLocalizations.of(context)!.ktage1)),
|
child: Text(AppLocalizations.of(context)!.ktage1)),
|
||||||
|
const SizedBox(
|
||||||
const SizedBox(width: 15,),
|
width: 15,
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 4,
|
flex: 4,
|
||||||
child: VarTextField(otherDefault: "24", textController: kTage1C, localization: AppLocalizations.of(context)!.ktage1, dbName: "KTage1", required: true, dbDesignation: DatabasesEnum.place,))
|
child: VarTextField(
|
||||||
|
otherDefault: "24",
|
||||||
|
textController: kTage1C,
|
||||||
|
localization: AppLocalizations.of(context)!.ktage1,
|
||||||
|
dbName: "KTage1",
|
||||||
|
required: true,
|
||||||
|
dbDesignation: DatabasesEnum.place,
|
||||||
|
))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text( AppLocalizations.of(context)!.ktage2)),
|
child: Text(AppLocalizations.of(context)!.ktage2)),
|
||||||
const SizedBox(width: 15,),
|
const SizedBox(
|
||||||
|
width: 15,
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 4,
|
flex: 4,
|
||||||
child: VarTextField(otherDefault: "48", textController: kTage2C, localization: AppLocalizations.of(context)!.ktage2, dbName: "KTage2", required: true, dbDesignation: DatabasesEnum.place,))
|
child: VarTextField(
|
||||||
|
otherDefault: "48",
|
||||||
|
textController: kTage2C,
|
||||||
|
localization: AppLocalizations.of(context)!.ktage2,
|
||||||
|
dbName: "KTage2",
|
||||||
|
required: true,
|
||||||
|
dbDesignation: DatabasesEnum.place,
|
||||||
|
))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
@@ -901,7 +909,8 @@ child: Text(AppLocalizations.of(context)!.back)), */
|
|||||||
final isLastStep = currentStep == getSteps().length - 1;
|
final isLastStep = currentStep == getSteps().length - 1;
|
||||||
|
|
||||||
if (!isLastStep) {
|
if (!isLastStep) {
|
||||||
saveTemplate();
|
saveTemplate(
|
||||||
|
getPlace(), DatabasesEnum.place, widget.isTemplate);
|
||||||
setState(() {
|
setState(() {
|
||||||
currentStep += 1;
|
currentStep += 1;
|
||||||
});
|
});
|
||||||
@@ -910,7 +919,8 @@ child: Text(AppLocalizations.of(context)!.back)), */
|
|||||||
// ! always filled out
|
// ! always filled out
|
||||||
// empty = false;
|
// empty = false;
|
||||||
if (widget.isSent) {
|
if (widget.isSent) {
|
||||||
Navigator.pushNamedAndRemoveUntil(context, '/home', (route) => false);
|
Navigator.pushNamedAndRemoveUntil(
|
||||||
|
context, '/home', (route) => false);
|
||||||
} else if (empty == true) {
|
} else if (empty == true) {
|
||||||
showTemplateDialog(emptyFields);
|
showTemplateDialog(emptyFields);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,892 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
import 'package:fforte/addCam/cam_widgets.dart';
|
|
||||||
import 'package:fforte/other/db_helper.dart';
|
|
||||||
import 'package:fforte/methods/http_request.dart';
|
|
||||||
import 'package:file_picker/file_picker.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
||||||
import 'package:geolocator/geolocator.dart';
|
|
||||||
import 'package:latlong2/latlong.dart';
|
|
||||||
import 'package:animations/animations.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
|
|
||||||
class AddCamMain extends StatefulWidget {
|
|
||||||
final bool isTemplate;
|
|
||||||
final bool isFinished;
|
|
||||||
final bool isSent;
|
|
||||||
final Map<String, dynamic>? existingData;
|
|
||||||
|
|
||||||
const AddCamMain(
|
|
||||||
{super.key,
|
|
||||||
this.isTemplate = false,
|
|
||||||
this.existingData,
|
|
||||||
this.isFinished = false,
|
|
||||||
this.isSent = false});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<AddCamMain> createState() => _AddCamMainState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _AddCamMainState extends State<AddCamMain> {
|
|
||||||
// var declaration
|
|
||||||
int currentStep = 0;
|
|
||||||
// bool isTemplate = false;
|
|
||||||
|
|
||||||
TextEditingController cid = TextEditingController();
|
|
||||||
TextEditingController rudelC = TextEditingController();
|
|
||||||
TextEditingController adresse1C = TextEditingController();
|
|
||||||
TextEditingController adresse2C = TextEditingController();
|
|
||||||
TextEditingController adresse3C = TextEditingController();
|
|
||||||
TextEditingController bLandC = TextEditingController();
|
|
||||||
TextEditingController lkrC = TextEditingController();
|
|
||||||
TextEditingController beiOrtC = TextEditingController();
|
|
||||||
TextEditingController ortInfoC = TextEditingController();
|
|
||||||
TextEditingController ffTypC = TextEditingController();
|
|
||||||
TextEditingController kSchloNrC = TextEditingController();
|
|
||||||
TextEditingController auftragC = TextEditingController();
|
|
||||||
TextEditingController kontAbspC = TextEditingController();
|
|
||||||
TextEditingController sonstBemC = TextEditingController();
|
|
||||||
TextEditingController fKontakt1C = TextEditingController();
|
|
||||||
TextEditingController fKontakt2C = TextEditingController();
|
|
||||||
TextEditingController fKontakt3C = TextEditingController();
|
|
||||||
TextEditingController standortC = TextEditingController();
|
|
||||||
TextEditingController kTage1C = TextEditingController();
|
|
||||||
TextEditingController kTage2C = TextEditingController();
|
|
||||||
TextEditingController intKommC = TextEditingController();
|
|
||||||
TextEditingController betreuungC = TextEditingController();
|
|
||||||
|
|
||||||
String selectedStatus = 'aktiv';
|
|
||||||
String selectedFotoFilm = 'Foto';
|
|
||||||
String selectedMEZ = 'Sommerzeit';
|
|
||||||
String selectedPlatzung = '';
|
|
||||||
|
|
||||||
Position currentPosition = Position(
|
|
||||||
longitude: 10.0,
|
|
||||||
latitude: 51.0,
|
|
||||||
timestamp: DateTime.now(),
|
|
||||||
accuracy: 0.0,
|
|
||||||
altitude: 0.0,
|
|
||||||
heading: 0.0,
|
|
||||||
speed: 0.0,
|
|
||||||
speedAccuracy: 0.0,
|
|
||||||
altitudeAccuracy: 0.0,
|
|
||||||
headingAccuracy: 0.0);
|
|
||||||
|
|
||||||
DateTime? abbauDat;
|
|
||||||
DateTime datum = DateTime.now();
|
|
||||||
DateTime? kontDat = DateTime.now();
|
|
||||||
DateTime? protoAm = DateTime.now();
|
|
||||||
|
|
||||||
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,
|
|
||||||
};
|
|
||||||
|
|
||||||
return place;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool empty = false;
|
|
||||||
|
|
||||||
// determine live position with checks for denied permission and turned off location service
|
|
||||||
Future<Position> _deteterminePosition() async {
|
|
||||||
bool locationEnabled;
|
|
||||||
LocationPermission permissionGiven;
|
|
||||||
|
|
||||||
locationEnabled = await Geolocator.isLocationServiceEnabled();
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
|
|
||||||
// updates the currentPosition var after the _determine position has finished. Means user view updates with his live location
|
|
||||||
_deteterminePosition().then((position) {
|
|
||||||
setState(() {
|
|
||||||
currentPosition = position;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// If a template is edited this fills in the existing values
|
|
||||||
if (widget.isTemplate || widget.isFinished && widget.existingData != null) {
|
|
||||||
cid.text = widget.existingData!['CID'] ?? "";
|
|
||||||
rudelC.text = widget.existingData!['Rudel'] ?? "";
|
|
||||||
adresse1C.text = widget.existingData!['Adresse1'] ?? "";
|
|
||||||
adresse2C.text = widget.existingData!['Adresse2'] ?? "";
|
|
||||||
adresse3C.text = widget.existingData!['Adresse3'] ?? "";
|
|
||||||
bLandC.text = widget.existingData!['BLand'] ?? "";
|
|
||||||
lkrC.text = widget.existingData!['Lkr'] ?? "";
|
|
||||||
beiOrtC.text = widget.existingData!['BeiOrt'] ?? "";
|
|
||||||
ortInfoC.text = widget.existingData!['OrtInfo'] ?? "";
|
|
||||||
selectedStatus = widget.existingData!['Status'] ?? "";
|
|
||||||
ffTypC.text = widget.existingData!['FFTyp'] ?? "";
|
|
||||||
selectedFotoFilm = widget.existingData!['FotoFilm'] ?? "";
|
|
||||||
selectedMEZ = widget.existingData!['MEZ'] ?? "";
|
|
||||||
selectedPlatzung = widget.existingData!['Platzung'] ?? "";
|
|
||||||
kSchloNrC.text = widget.existingData!['KSchloNr'] ?? "";
|
|
||||||
datum = DateTime.parse(widget.existingData!['Datum']);
|
|
||||||
kontDat = widget.existingData!['KontDat'] == ""
|
|
||||||
? null
|
|
||||||
: DateTime.parse(widget.existingData!['KontDat']);
|
|
||||||
abbauDat = widget.existingData!['AbbauDat'] == ""
|
|
||||||
? null
|
|
||||||
: DateTime.parse(widget.existingData!['AbbauDat']);
|
|
||||||
auftragC.text = widget.existingData!['Auftrag'] ?? "";
|
|
||||||
kontAbspC.text = widget.existingData!['KontAbsp'] ?? "";
|
|
||||||
sonstBemC.text = widget.existingData!['SonstBem'] ?? "";
|
|
||||||
fKontakt1C.text = widget.existingData!['FKontakt1'] ?? "";
|
|
||||||
fKontakt2C.text = widget.existingData!['FKontakt2'] ?? "";
|
|
||||||
fKontakt3C.text = widget.existingData!['FKontakt3'] ?? "";
|
|
||||||
standortC.text = widget.existingData!['Standort'] ?? "";
|
|
||||||
kTage1C.text = widget.existingData!['KTage1'].toString();
|
|
||||||
kTage2C.text = widget.existingData!['KTage2'].toString();
|
|
||||||
protoAm = widget.existingData!['ProtoAm'] == null
|
|
||||||
? null
|
|
||||||
: DateTime.parse(widget.existingData!['ProtoAm']);
|
|
||||||
intKommC.text = widget.existingData!['IntKomm'] ?? "";
|
|
||||||
betreuungC.text = widget.existingData!['Betreuung'] ?? "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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();
|
|
||||||
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();
|
|
||||||
setState(() => isLoading = false);
|
|
||||||
|
|
||||||
if (errorCode != 201 && context.mounted) {
|
|
||||||
_showServerErrorDialog();
|
|
||||||
} else {
|
|
||||||
if (context.mounted) Navigator.pop(context);
|
|
||||||
saveData(true);
|
|
||||||
_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();
|
|
||||||
Navigator.pushNamedAndRemoveUntil(
|
|
||||||
context, '/home', (route) => false);
|
|
||||||
},
|
|
||||||
child: Text(AppLocalizations.of(context)!.template)),
|
|
||||||
if (!isLoading)
|
|
||||||
TextButton(
|
|
||||||
onPressed: () async {
|
|
||||||
setState(() => isLoading = true);
|
|
||||||
int errorCode = await _httpRequest();
|
|
||||||
setState(() => isLoading = false);
|
|
||||||
|
|
||||||
if (errorCode != 201 || !context.mounted) {
|
|
||||||
saveData();
|
|
||||||
_showServerErrorDialog();
|
|
||||||
} else {
|
|
||||||
saveData(true);
|
|
||||||
_showSuccessDialog();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child:
|
|
||||||
Text(AppLocalizations.of(context)!.sendtoserver)),
|
|
||||||
if (!isLoading)
|
|
||||||
TextButton(
|
|
||||||
onPressed: () async {
|
|
||||||
setState(() => isLoading = true);
|
|
||||||
saveData();
|
|
||||||
saveFile();
|
|
||||||
setState(() => isLoading = false);
|
|
||||||
},
|
|
||||||
child: Text(AppLocalizations.of(context)!.saveasfile)),
|
|
||||||
if (!isLoading)
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
saveData();
|
|
||||||
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.pop(context);
|
|
||||||
},
|
|
||||||
child: Text(AppLocalizations.of(context)!.back)), */
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> saveFile() async {
|
|
||||||
String? selectedDirectory = await FilePicker.platform.getDirectoryPath();
|
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
||||||
Map place = getPlace();
|
|
||||||
String jsonPlace = jsonEncode(place);
|
|
||||||
|
|
||||||
if (selectedDirectory == null) {
|
|
||||||
if (mounted) Navigator.pop(context);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await prefs.setString('saveDir', selectedDirectory);
|
|
||||||
|
|
||||||
File file = File(
|
|
||||||
'$selectedDirectory/${mounted ? AppLocalizations.of(context)!.justplace : const Text('')}-${standortC.text}.txt');
|
|
||||||
|
|
||||||
try {
|
|
||||||
await file.writeAsString(jsonPlace);
|
|
||||||
} catch (e) {
|
|
||||||
if (mounted) {
|
|
||||||
Navigator.pop(context);
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
|
||||||
content: Text(AppLocalizations.of(context)!.savefilefailed)));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mounted) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text('Datei gespeichert in $selectedDirectory')));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mounted) {
|
|
||||||
Navigator.pushNamedAndRemoveUntil(context, '/home', (route) => false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// checks if required fields are not empty. If one is the name will be returned
|
|
||||||
List<String> validateData() {
|
|
||||||
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 = DBHelper();
|
|
||||||
|
|
||||||
Map<String, dynamic> templates = getPlace();
|
|
||||||
|
|
||||||
if (widget.isTemplate) {
|
|
||||||
await placeDB.updateTemplate(templates);
|
|
||||||
} else {
|
|
||||||
await placeDB.addTemplate(templates);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 = DBHelper();
|
|
||||||
Map<String, dynamic> place = getPlace();
|
|
||||||
|
|
||||||
// Get the ID of the newly added or updated place
|
|
||||||
int newPlaceId = await placeDB.addPlace(place);
|
|
||||||
|
|
||||||
if (sent == true) {
|
|
||||||
placeDB.updateSent(newPlaceId); // Update 'Sent' using the correct ID
|
|
||||||
}
|
|
||||||
|
|
||||||
if (widget.isTemplate) {
|
|
||||||
await placeDB.deleteTemplate(cid.text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The widget tree which gets the shown widget from the ./cam_widgets.dart file
|
|
||||||
// The names of the widgets should be self-explaining
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
// List with the steps. The steps itself will be "shown" later
|
|
||||||
List<Step> getSteps() => [
|
|
||||||
// First step
|
|
||||||
Step(
|
|
||||||
title: Text(AppLocalizations.of(context)!.firststep),
|
|
||||||
content: Column(
|
|
||||||
children: [
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.bottomLeft,
|
|
||||||
child: VarTextField(
|
|
||||||
required: true,
|
|
||||||
dbName: "Standort",
|
|
||||||
textController: standortC,
|
|
||||||
localization: AppLocalizations.of(context)!.altstort,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.bottomLeft,
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Text(AppLocalizations.of(context)!.status),
|
|
||||||
const Text(
|
|
||||||
'*',
|
|
||||||
style: TextStyle(color: Colors.red),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
Status(
|
|
||||||
initialStatus: selectedStatus,
|
|
||||||
onStatusChanged: (status) {
|
|
||||||
setState(() {
|
|
||||||
selectedStatus = status;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
VarTextField(
|
|
||||||
textController: betreuungC,
|
|
||||||
localization: AppLocalizations.of(context)!.betreuung,
|
|
||||||
dbName: "Betreuung",
|
|
||||||
required: false),
|
|
||||||
const SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
VarTextField(
|
|
||||||
textController: cid,
|
|
||||||
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,
|
|
||||||
),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.bottomLeft,
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Text(AppLocalizations.of(context)!.zeiteinstellung),
|
|
||||||
const Text(
|
|
||||||
'*',
|
|
||||||
style: TextStyle(color: Colors.red),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
MEZ(
|
|
||||||
initialMEZ: selectedMEZ,
|
|
||||||
onMEZChanged: (mez) {
|
|
||||||
setState(() {
|
|
||||||
selectedMEZ = mez;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 15,
|
|
||||||
),
|
|
||||||
VarTextField(
|
|
||||||
textController: kSchloNrC,
|
|
||||||
localization: AppLocalizations.of(context)!.kschlonr,
|
|
||||||
dbName: "KSchloNr",
|
|
||||||
required: false),
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
VarTextField(
|
|
||||||
textController: rudelC,
|
|
||||||
localization: AppLocalizations.of(context)!.rudel,
|
|
||||||
dbName: "Rudel",
|
|
||||||
required: true),
|
|
||||||
const SizedBox(
|
|
||||||
height: 15,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
|
|
||||||
// Second step
|
|
||||||
Step(
|
|
||||||
title: Text(AppLocalizations.of(context)!.secondstep),
|
|
||||||
content: Column(
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
Text(currentPosition.latitude.toString()),
|
|
||||||
Text(currentPosition.longitude.toString()),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
width: 15,
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () async {
|
|
||||||
final result = await Navigator.of(context)
|
|
||||||
.push<LatLng>(
|
|
||||||
MaterialPageRoute(builder: (context) {
|
|
||||||
return Karte(
|
|
||||||
ortInfoC: ortInfoC,
|
|
||||||
beiOrtC: beiOrtC,
|
|
||||||
currentPosition: currentPosition,
|
|
||||||
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,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text(AppLocalizations.of(context)!.openMap)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
VarTextField(
|
|
||||||
textController: bLandC,
|
|
||||||
localization: AppLocalizations.of(context)!.bland,
|
|
||||||
dbName: "BLand",
|
|
||||||
required: true,
|
|
||||||
defaultValue: "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,
|
|
||||||
),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.bottomLeft,
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Text(AppLocalizations.of(context)!.platzung),
|
|
||||||
const Text(
|
|
||||||
'*',
|
|
||||||
style: TextStyle(color: Colors.red),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
Platzung(
|
|
||||||
initialPlatzung: selectedPlatzung,
|
|
||||||
onPlatzungChanged: (platzung) {
|
|
||||||
setState(() {
|
|
||||||
selectedPlatzung = platzung;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
// Third step
|
|
||||||
Step(
|
|
||||||
title: Text(AppLocalizations.of(context)!.thirdstep),
|
|
||||||
content: Column(
|
|
||||||
children: [
|
|
||||||
Datum(
|
|
||||||
initDatum: datum,
|
|
||||||
onDateChanged: (value) {
|
|
||||||
datum = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
KontDat(
|
|
||||||
initKontDat: kontDat,
|
|
||||||
onDateChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
kontDat = value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.bottomLeft,
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Text(AppLocalizations.of(context)!.ktage),
|
|
||||||
const Text(
|
|
||||||
'*',
|
|
||||||
style: TextStyle(color: Colors.red),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Text( AppLocalizations.of(context)!.ktage1)),
|
|
||||||
|
|
||||||
const SizedBox(width: 15,),
|
|
||||||
Expanded(
|
|
||||||
flex: 4,
|
|
||||||
child: VarTextField(otherDefault: "24", textController: kTage1C, localization: AppLocalizations.of(context)!.ktage1, dbName: "KTage1", required: true))
|
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Text( AppLocalizations.of(context)!.ktage2)),
|
|
||||||
const SizedBox(width: 15,),
|
|
||||||
Expanded(
|
|
||||||
flex: 4,
|
|
||||||
child: VarTextField(otherDefault: "48", textController: kTage2C, localization: AppLocalizations.of(context)!.ktage2, dbName: "KTage2", required: true))
|
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
const SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
AbbauDat(
|
|
||||||
initAbbauDat: abbauDat,
|
|
||||||
onDateChanged: (value) {
|
|
||||||
abbauDat = value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
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
|
|
||||||
Step(
|
|
||||||
title: Text(AppLocalizations.of(context)!.fourthstep),
|
|
||||||
content: Column(
|
|
||||||
children: [
|
|
||||||
VarTextField(
|
|
||||||
textController: adresse1C,
|
|
||||||
localization: AppLocalizations.of(context)!.adresse1,
|
|
||||||
dbName: "Adresse1",
|
|
||||||
required: true,
|
|
||||||
defaultValue: "addresse1",
|
|
||||||
),
|
|
||||||
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,
|
|
||||||
),
|
|
||||||
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),
|
|
||||||
],
|
|
||||||
))
|
|
||||||
];
|
|
||||||
|
|
||||||
// Here the site is built with the steps from above
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(title: Text(AppLocalizations.of(context)!.addplace)),
|
|
||||||
body: PageTransitionSwitcher(
|
|
||||||
duration: const Duration(milliseconds: 800),
|
|
||||||
transitionBuilder: (Widget child, Animation<double> animation,
|
|
||||||
Animation<double> secondaryAnimation) {
|
|
||||||
return SharedAxisTransition(
|
|
||||||
animation: animation,
|
|
||||||
secondaryAnimation: secondaryAnimation,
|
|
||||||
transitionType: SharedAxisTransitionType.vertical,
|
|
||||||
child: child,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: Stepper(
|
|
||||||
key: ValueKey<int>(currentStep),
|
|
||||||
type: StepperType.vertical,
|
|
||||||
steps: getSteps(),
|
|
||||||
|
|
||||||
// Functions that handle the navigation through the steps
|
|
||||||
currentStep: currentStep,
|
|
||||||
onStepTapped: (value) {
|
|
||||||
setState(() {
|
|
||||||
currentStep = value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onStepContinue: () async {
|
|
||||||
final isLastStep = currentStep == getSteps().length - 1;
|
|
||||||
|
|
||||||
if (!isLastStep) {
|
|
||||||
saveTemplate();
|
|
||||||
setState(() {
|
|
||||||
currentStep += 1;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
List<String> emptyFields = validateData();
|
|
||||||
// ! always filled out
|
|
||||||
// empty = false;
|
|
||||||
if (widget.isSent) {
|
|
||||||
Navigator.pushNamedAndRemoveUntil(context, '/home', (route) => false);
|
|
||||||
} else if (empty == true) {
|
|
||||||
showTemplateDialog(emptyFields);
|
|
||||||
return;
|
|
||||||
} else if (empty == false) {
|
|
||||||
await showSaveOptionsDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onStepCancel: () {
|
|
||||||
if (currentStep == 0) {
|
|
||||||
Navigator.pop(context);
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
currentStep -= 1;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
class LocationDisabledException implements Exception {}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
class LocationForbiddenException implements Exception{}
|
||||||
26
lib/screens/addCam/services/geolocator_service.dart
Normal file
26
lib/screens/addCam/services/geolocator_service.dart
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import 'package:fforte/screens/addCam/exceptions/location_disabled_exception.dart';
|
||||||
|
import 'package:fforte/screens/addCam/exceptions/location_forbidden_exception.dart';
|
||||||
|
import 'package:geolocator/geolocator.dart';
|
||||||
|
|
||||||
|
class GeolocatorService {
|
||||||
|
// determine live position with checks for denied permission and turned off location service
|
||||||
|
static Future<Position> deteterminePosition() async {
|
||||||
|
bool locationEnabled;
|
||||||
|
LocationPermission permissionGiven;
|
||||||
|
|
||||||
|
locationEnabled = await Geolocator.isLocationServiceEnabled();
|
||||||
|
if (!locationEnabled) {
|
||||||
|
throw LocationDisabledException();
|
||||||
|
}
|
||||||
|
|
||||||
|
permissionGiven = await Geolocator.checkPermission();
|
||||||
|
if (permissionGiven == LocationPermission.denied) {
|
||||||
|
permissionGiven = await Geolocator.requestPermission();
|
||||||
|
if (permissionGiven == LocationPermission.denied || permissionGiven == LocationPermission.deniedForever) {
|
||||||
|
throw LocationForbiddenException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return await Geolocator.getCurrentPosition();
|
||||||
|
}
|
||||||
|
}
|
||||||
21
lib/screens/sharedMethods/save_file.dart
Normal file
21
lib/screens/sharedMethods/save_file.dart
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:file_picker/file_picker.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
Future<void> saveFile(
|
||||||
|
Map place, String fileNameLocalization, String placeID) async {
|
||||||
|
String? selectedDirectory = await FilePicker.platform.getDirectoryPath();
|
||||||
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
String jsonPlace = jsonEncode(place);
|
||||||
|
|
||||||
|
if (selectedDirectory == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await prefs.setString('saveDir', selectedDirectory);
|
||||||
|
|
||||||
|
File file = File('$selectedDirectory/$fileNameLocalization-$placeID.txt');
|
||||||
|
|
||||||
|
await file.writeAsString(jsonPlace);
|
||||||
|
}
|
||||||
22
lib/screens/sharedMethods/save_template.dart
Normal file
22
lib/screens/sharedMethods/save_template.dart
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import 'package:fforte/enums/databases.dart';
|
||||||
|
import 'package:fforte/interfaces/i_db.dart';
|
||||||
|
import 'package:fforte/methods/excursion_db_helper.dart';
|
||||||
|
import 'package:fforte/methods/place_db_helper.dart';
|
||||||
|
|
||||||
|
void saveTemplate(Map<String, dynamic> templateData, DatabasesEnum dbType,
|
||||||
|
bool update) async {
|
||||||
|
IDb dbHelper;
|
||||||
|
if (dbType == DatabasesEnum.place) {
|
||||||
|
dbHelper = PlaceDBHelper();
|
||||||
|
} else if (dbType == DatabasesEnum.excursion) {
|
||||||
|
dbHelper = ExcursionDBHelper();
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (update) {
|
||||||
|
await dbHelper.updateTemplate(templateData);
|
||||||
|
} else {
|
||||||
|
await dbHelper.addTemplate(templateData);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -48,12 +48,12 @@ class _VarTextFieldState extends State<VarTextField> {
|
|||||||
|
|
||||||
Future<List<Map<String, dynamic>>> _loadData() async {
|
Future<List<Map<String, dynamic>>> _loadData() async {
|
||||||
if (widget.dbDesignation == DatabasesEnum.excursion) {
|
if (widget.dbDesignation == DatabasesEnum.excursion) {
|
||||||
var entries = await PlaceDBHelper().getPlace();
|
var entries = await PlaceDBHelper().getAllMainEntries();
|
||||||
var templatesEntries = await PlaceDBHelper().getTemplates();
|
var templatesEntries = await PlaceDBHelper().getAllTemplates();
|
||||||
return [...entries, ...templatesEntries];
|
return [...entries, ...templatesEntries];
|
||||||
} else {
|
} else {
|
||||||
var entries = await ExcursionDBHelper().getExcursionen();
|
var entries = await ExcursionDBHelper().getAllMainEntries();
|
||||||
var templatesEntries = await ExcursionDBHelper().getTemplates();
|
var templatesEntries = await ExcursionDBHelper().getAllTemplates();
|
||||||
return [...entries, ...templatesEntries];
|
return [...entries, ...templatesEntries];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ class _ViewCamsState extends State<ViewCams> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
place = PlaceDBHelper().getPlace();
|
place = PlaceDBHelper().getAllMainEntries();
|
||||||
templates = PlaceDBHelper().getTemplates();
|
templates = PlaceDBHelper().getAllTemplates();
|
||||||
}
|
}
|
||||||
|
|
||||||
// functions to delete all entries LOCALLY
|
// functions to delete all entries LOCALLY
|
||||||
@@ -45,9 +45,9 @@ class _ViewCamsState extends State<ViewCams> {
|
|||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
var placeDB = PlaceDBHelper();
|
var placeDB = PlaceDBHelper();
|
||||||
placeDB.deleteAllPlaces();
|
placeDB.deleteAllMainEntries();
|
||||||
setState(() {
|
setState(() {
|
||||||
place = PlaceDBHelper().getPlace();
|
place = PlaceDBHelper().getAllMainEntries();
|
||||||
});
|
});
|
||||||
|
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
@@ -64,9 +64,9 @@ class _ViewCamsState extends State<ViewCams> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void delSinglePlace(int id) async {
|
void delSinglePlace(int id) async {
|
||||||
PlaceDBHelper().deletePlace(id.toString());
|
PlaceDBHelper().deleteMainEntryById(id.toString());
|
||||||
setState(() {
|
setState(() {
|
||||||
place = PlaceDBHelper().getPlace();
|
place = PlaceDBHelper().getAllMainEntries();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ class _ViewCamsState extends State<ViewCams> {
|
|||||||
var placeDB = PlaceDBHelper();
|
var placeDB = PlaceDBHelper();
|
||||||
placeDB.deleteAllTemplates();
|
placeDB.deleteAllTemplates();
|
||||||
setState(() {
|
setState(() {
|
||||||
templates = PlaceDBHelper().getTemplates();
|
templates = PlaceDBHelper().getAllTemplates();
|
||||||
});
|
});
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user