begin cleanup of view_cams and begin of making it usable with exursion and place

time

refactoring

refactoring again
This commit is contained in:
Nico
2025-05-11 23:25:33 +02:00
parent f3877a583b
commit a5769a7dc0
10 changed files with 641 additions and 594 deletions

View File

@@ -1,3 +1,4 @@
import 'package:fforte/enums/databases.dart';
import 'package:fforte/screens/excursion/excursion_main.dart'; import 'package:fforte/screens/excursion/excursion_main.dart';
import 'package:fforte/screens/addCam/add_cam_main.dart'; import 'package:fforte/screens/addCam/add_cam_main.dart';
import 'package:fforte/screens/intro_screen.dart'; import 'package:fforte/screens/intro_screen.dart';
@@ -46,7 +47,7 @@ class MyApp extends StatelessWidget {
routes: { routes: {
'/home': (context) => const HomePage(), '/home': (context) => const HomePage(),
'/addCamMain': (context) => const AddCamMain(), '/addCamMain': (context) => const AddCamMain(),
'/viewCams': (context) => const ViewCams(), '/viewCams': (context) => const ViewCams(dbType: DatabasesEnum.place,),
'/introScreen': (context) => const IntroScreen(), '/introScreen': (context) => const IntroScreen(),
'/settings': (context) => const Settings(), '/settings': (context) => const Settings(),
'/excursion': (context) => const ExcursionMain(), '/excursion': (context) => const ExcursionMain(),

View File

@@ -1,5 +1,5 @@
import 'package:fforte/enums/databases.dart'; import 'package:fforte/enums/databases.dart';
import 'package:fforte/screens/helper/dialog_helper.dart'; import 'package:fforte/screens/helper/add_entries_dialog_helper.dart';
import 'package:fforte/screens/helper/snack_bar_helper.dart'; import 'package:fforte/screens/helper/snack_bar_helper.dart';
import 'package:fforte/screens/addCam/exceptions/location_disabled_exception.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/exceptions/location_forbidden_exception.dart';
@@ -735,11 +735,11 @@ class _AddCamMainState extends State<AddCamMain> {
bool empty = CheckRequired.checkRequired(rmap); bool empty = CheckRequired.checkRequired(rmap);
if (empty == true) { if (empty == true) {
DialogHelper.showTemplateDialog(context, getFieldsText(), AddEntriesDialogHelper.showTemplateDialog(context, getFieldsText(),
widget.existingData?.isNotEmpty ?? false); widget.existingData?.isNotEmpty ?? false);
return; return;
} else if (empty == false) { } else if (empty == false) {
await DialogHelper.showSaveOptionsDialog( await AddEntriesDialogHelper.showSaveOptionsDialog(
context, getFieldsText(), widget.isTemplate); context, getFieldsText(), widget.isTemplate);
} }
} }

View File

@@ -7,7 +7,7 @@ import 'package:fforte/screens/excursion/widgets/hund_u_leine.dart';
import 'package:fforte/screens/excursion/widgets/letzter_niederschlag.dart'; import 'package:fforte/screens/excursion/widgets/letzter_niederschlag.dart';
import 'package:fforte/screens/excursion/widgets/spur_gefunden.dart'; import 'package:fforte/screens/excursion/widgets/spur_gefunden.dart';
import 'package:fforte/screens/excursion/widgets/strecke_u_spurbedingungen.dart'; import 'package:fforte/screens/excursion/widgets/strecke_u_spurbedingungen.dart';
import 'package:fforte/screens/helper/dialog_helper.dart'; import 'package:fforte/screens/helper/add_entries_dialog_helper.dart';
import 'package:fforte/screens/sharedMethods/check_required.dart'; import 'package:fforte/screens/sharedMethods/check_required.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';
@@ -26,62 +26,62 @@ class _ExcursionMainState extends State<ExcursionMain> {
Map<String, Map<String, dynamic>> rmap = { Map<String, Map<String, dynamic>> rmap = {
// Step 1 // Step 1
"LogDat": { "controller": TextEditingController(), "required": bool, }, "LogDat": {"controller": TextEditingController(), "required": bool},
"Rudel": { "controller": TextEditingController(), "required": bool, }, "Rudel": {"controller": TextEditingController(), "required": bool},
"Teilnehm": { "controller": TextEditingController(), "required": bool, }, "Teilnehm": {"controller": TextEditingController(), "required": bool},
"Jahr": { "controller": TextEditingController(), "required": bool, }, "Jahr": {"controller": TextEditingController(), "required": bool},
"Dauer": { "controller": TextEditingController(), "required": bool, }, "Dauer": {"controller": TextEditingController(), "required": bool},
"MHund": { "controller": TextEditingController(), "required": bool, }, "MHund": {"controller": TextEditingController(), "required": bool},
"MLeine": { "controller": TextEditingController(), "required": bool, }, "MLeine": {"controller": TextEditingController(), "required": bool},
"BLand": { "controller": TextEditingController(), "required": bool, }, "BLand": {"controller": TextEditingController(), "required": bool},
"Lkr": { "controller": TextEditingController(), "required": bool, }, "Lkr": {"controller": TextEditingController(), "required": bool},
"BeiOrt": { "controller": TextEditingController(), "required": bool, }, "BeiOrt": {"controller": TextEditingController(), "required": bool},
"BimaNr": { "controller": TextEditingController(), "required": bool, }, "BimaNr": {"controller": TextEditingController(), "required": bool},
"BimaName": { "controller": TextEditingController(), "required": bool, }, "BimaName": {"controller": TextEditingController(), "required": bool},
"BimaNutzer": { "controller": TextEditingController(), "required": bool, }, "BimaNutzer": {"controller": TextEditingController(), "required": bool},
"BimaAGV": { "controller": TextEditingController(), "required": bool, }, "BimaAGV": {"controller": TextEditingController(), "required": bool},
// Step 2 // Step 2
"Wetter": { "controller": TextEditingController(), "required": bool, }, "Wetter": {"controller": TextEditingController(), "required": bool},
"Temperat": { "controller": TextEditingController(), "required": bool, }, "Temperat": {"controller": TextEditingController(), "required": bool},
"RegenVor": { "controller": TextEditingController(), "required": bool, }, "RegenVor": {"controller": TextEditingController(), "required": bool},
"KmAuto": { "controller": TextEditingController(), "required": bool, }, "KmAuto": {"controller": TextEditingController(), "required": bool},
"KmFuss": { "controller": TextEditingController(), "required": bool, }, "KmFuss": {"controller": TextEditingController(), "required": bool},
"KmRad": { "controller": TextEditingController(), "required": bool, }, "KmRad": {"controller": TextEditingController(), "required": bool},
"KmTotal": { "controller": TextEditingController(), "required": bool, }, "KmTotal": {"controller": TextEditingController(), "required": bool},
"KmAuProz": { "controller": TextEditingController(), "required": bool, }, "KmAuProz": {"controller": TextEditingController(), "required": bool},
"KmFuProz": { "controller": TextEditingController(), "required": bool, }, "KmFuProz": {"controller": TextEditingController(), "required": bool},
"KmRaProz": { "controller": TextEditingController(), "required": bool, }, "KmRaProz": {"controller": TextEditingController(), "required": bool},
// Spur maybe own step? // Spur maybe own step?
"SpGut": { "controller": TextEditingController(), "required": bool, }, "SpGut": {"controller": TextEditingController(), "required": bool},
"SpMittel": { "controller": TextEditingController(), "required": bool, }, "SpMittel": {"controller": TextEditingController(), "required": bool},
"SpSchlecht": { "controller": TextEditingController(), "required": bool, }, "SpSchlecht": {"controller": TextEditingController(), "required": bool},
"SpurFund": { "controller": TextEditingController(), "required": bool, }, "SpurFund": {"controller": TextEditingController(), "required": bool},
"SpurLang": { "controller": TextEditingController(), "required": bool, }, "SpurLang": {"controller": TextEditingController(), "required": bool},
"SpurTiere": { "controller": TextEditingController(), "required": bool, }, "SpurTiere": {"controller": TextEditingController(), "required": bool},
"SpSicher": { "controller": TextEditingController(), "required": bool, }, "SpSicher": {"controller": TextEditingController(), "required": bool},
"WelpenSp": { "controller": TextEditingController(), "required": bool, }, "WelpenSp": {"controller": TextEditingController(), "required": bool},
"WelpenAnz": { "controller": TextEditingController(), "required": bool, }, "WelpenAnz": {"controller": TextEditingController(), "required": bool},
"WpSicher": { "controller": TextEditingController(), "required": bool, }, "WpSicher": {"controller": TextEditingController(), "required": bool},
"LosungGes": { "controller": TextEditingController(), "required": bool, }, "LosungGes": {"controller": TextEditingController(), "required": bool},
"LosungAnz": { "controller": TextEditingController(), "required": bool, }, "LosungAnz": {"controller": TextEditingController(), "required": bool},
"LosungGen": { "controller": TextEditingController(), "required": bool, }, "LosungGen": {"controller": TextEditingController(), "required": bool},
"UrinAnz": { "controller": TextEditingController(), "required": bool, }, "UrinAnz": {"controller": TextEditingController(), "required": bool},
"UrinGen": { "controller": TextEditingController(), "required": bool, }, "UrinGen": {"controller": TextEditingController(), "required": bool},
"OestrAnz": { "controller": TextEditingController(), "required": bool, }, "OestrAnz": {"controller": TextEditingController(), "required": bool},
"OestrGen": { "controller": TextEditingController(), "required": bool, }, "OestrGen": {"controller": TextEditingController(), "required": bool},
"HaarAnz": { "controller": TextEditingController(), "required": bool, }, "HaarAnz": {"controller": TextEditingController(), "required": bool},
"HaarGen": { "controller": TextEditingController(), "required": bool, }, "HaarGen": {"controller": TextEditingController(), "required": bool},
"LosungKm": { "controller": TextEditingController(), "required": bool, }, "LosungKm": {"controller": TextEditingController(), "required": bool},
"GenetiKm": { "controller": TextEditingController(), "required": bool, }, "GenetiKm": {"controller": TextEditingController(), "required": bool},
"Hinweise": { "controller": TextEditingController(), "required": bool, }, "Hinweise": {"controller": TextEditingController(), "required": bool},
// Step 3 // Step 3
"Bemerk": { "controller": TextEditingController(), "required": bool, }, "Bemerk": {"controller": TextEditingController(), "required": bool},
"IntKomm": { "controller": TextEditingController(), "required": bool, }, "IntKomm": {"controller": TextEditingController(), "required": bool},
"FallNum": { "controller": TextEditingController(), "required": bool, }, "FallNum": {"controller": TextEditingController(), "required": bool},
}; };
Map<String, String> getFieldsText() { Map<String, String> getFieldsText() {
@@ -111,9 +111,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
}, },
name: AppLocalizations.of(context)!.date, name: AppLocalizations.of(context)!.date,
), ),
const SizedBox( const SizedBox(height: 10),
height: 10,
),
// ---------- Pack // ---------- Pack
VarTextField( VarTextField(
textController: rmap["Rudel"]!["controller"]!, textController: rmap["Rudel"]!["controller"]!,
@@ -122,9 +120,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
required: false, required: false,
dbDesignation: DatabasesEnum.excursion, dbDesignation: DatabasesEnum.excursion,
), ),
const SizedBox( const SizedBox(height: 10),
height: 10,
),
// ---------- Participants // ---------- Participants
VarTextField( VarTextField(
textController: rmap["Teilnehm"]!["controller"]!, textController: rmap["Teilnehm"]!["controller"]!,
@@ -133,9 +129,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
required: false, required: false,
dbDesignation: DatabasesEnum.excursion, dbDesignation: DatabasesEnum.excursion,
), ),
const SizedBox( const SizedBox(height: 10),
height: 10,
),
// ---------- Duration // ---------- Duration
VarTextField( VarTextField(
textController: rmap["Dauer"]!["controller"]!, textController: rmap["Dauer"]!["controller"]!,
@@ -144,17 +138,15 @@ class _ExcursionMainState extends State<ExcursionMain> {
required: false, required: false,
dbDesignation: DatabasesEnum.excursion, dbDesignation: DatabasesEnum.excursion,
), ),
const SizedBox( const SizedBox(height: 10),
height: 10,
),
// ---------- Dog(leash) // ---------- Dog(leash)
HundULeine(onMHundChanged: (mHund, mLeine) { HundULeine(
onMHundChanged: (mHund, mLeine) {
rmap["MHund"]!["controller"]!.text = mHund; rmap["MHund"]!["controller"]!.text = mHund;
rmap["MLeine"]!["controller"]!.text = mLeine; rmap["MLeine"]!["controller"]!.text = mLeine;
}), },
const SizedBox(
height: 10,
), ),
const SizedBox(height: 10),
// ---------- State // ---------- State
VarTextField( VarTextField(
textController: rmap["BLand"]!["controller"]!, textController: rmap["BLand"]!["controller"]!,
@@ -163,9 +155,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
required: false, required: false,
dbDesignation: DatabasesEnum.excursion, dbDesignation: DatabasesEnum.excursion,
), ),
const SizedBox( const SizedBox(height: 10),
height: 10,
),
// ---------- Country // ---------- Country
VarTextField( VarTextField(
textController: rmap["Lkr"]!["controller"]!, textController: rmap["Lkr"]!["controller"]!,
@@ -174,9 +164,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
required: false, required: false,
dbDesignation: DatabasesEnum.excursion, dbDesignation: DatabasesEnum.excursion,
), ),
const SizedBox( const SizedBox(height: 10),
height: 10,
),
// ---------- By State // ---------- By State
VarTextField( VarTextField(
textController: rmap["BeiOrt"]!["controller"]!, textController: rmap["BeiOrt"]!["controller"]!,
@@ -185,14 +173,10 @@ class _ExcursionMainState extends State<ExcursionMain> {
required: false, required: false,
dbDesignation: DatabasesEnum.excursion, dbDesignation: DatabasesEnum.excursion,
), ),
const SizedBox( const SizedBox(height: 10),
height: 10,
),
// ---------- Bima number // ---------- Bima number
const Divider(), const Divider(),
const SizedBox( const SizedBox(height: 10),
height: 10,
),
VarTextField( VarTextField(
textController: rmap["BimaNr"]!["controller"]!, textController: rmap["BimaNr"]!["controller"]!,
localization: AppLocalizations.of(context)!.bimaNr, localization: AppLocalizations.of(context)!.bimaNr,
@@ -200,9 +184,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
required: false, required: false,
dbDesignation: DatabasesEnum.excursion, dbDesignation: DatabasesEnum.excursion,
), ),
const SizedBox( const SizedBox(height: 10),
height: 10,
),
// ---------- Bima name // ---------- Bima name
VarTextField( VarTextField(
textController: rmap["BimaName"]!["controller"]!, textController: rmap["BimaName"]!["controller"]!,
@@ -211,18 +193,16 @@ class _ExcursionMainState extends State<ExcursionMain> {
required: false, required: false,
dbDesignation: DatabasesEnum.excursion, dbDesignation: DatabasesEnum.excursion,
), ),
const SizedBox( const SizedBox(height: 10),
height: 10,
),
// ---------- Bima user // ---------- Bima user
BimaNutzer(onBimaNutzerChanged: (value) { BimaNutzer(
onBimaNutzerChanged: (value) {
setState(() { setState(() {
rmap["BimaNutzer"]!["controller"]!.text = value; rmap["BimaNutzer"]!["controller"]!.text = value;
}); });
}), },
const SizedBox(
height: 10,
), ),
const SizedBox(height: 10),
// ---------- Bima AGV // ---------- Bima AGV
VarTextField( VarTextField(
textController: rmap["BimaAGV"]!["controller"]!, textController: rmap["BimaAGV"]!["controller"]!,
@@ -230,9 +210,10 @@ class _ExcursionMainState extends State<ExcursionMain> {
dbName: "BimaAGV", dbName: "BimaAGV",
required: false, required: false,
dbDesignation: DatabasesEnum.excursion, dbDesignation: DatabasesEnum.excursion,
) ),
], ],
)), ),
),
Step( Step(
title: const Text("step2"), title: const Text("step2"),
content: Column( content: Column(
@@ -267,9 +248,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
spMittelController: rmap["SpMittel"]!["controller"]!, spMittelController: rmap["SpMittel"]!["controller"]!,
spSchlechtController: rmap["SpSchlecht"]!["controller"]!, spSchlechtController: rmap["SpSchlecht"]!["controller"]!,
), ),
const SizedBox( const SizedBox(height: 20),
height: 20,
),
const Divider(), const Divider(),
// ---------- Track found // ---------- Track found
SpurGefunden( SpurGefunden(
@@ -279,10 +258,9 @@ class _ExcursionMainState extends State<ExcursionMain> {
spSicher: rmap["SpSicher"]!["controller"]!, spSicher: rmap["SpSicher"]!["controller"]!,
welpenSp: rmap["WelpenSp"]!["controller"]!, welpenSp: rmap["WelpenSp"]!["controller"]!,
welpenAnz: rmap["WelpenAnz"]!["controller"]!, welpenAnz: rmap["WelpenAnz"]!["controller"]!,
wpSicher: rmap["WpSicher"]!["controller"]!), wpSicher: rmap["WpSicher"]!["controller"]!,
const SizedBox(
height: 20,
), ),
const SizedBox(height: 20),
// ---------- Counts // ---------- Counts
Anzahlen( Anzahlen(
losungAnz: rmap["LosungAnz"]!["controller"]!, losungAnz: rmap["LosungAnz"]!["controller"]!,
@@ -295,25 +273,18 @@ class _ExcursionMainState extends State<ExcursionMain> {
haarAnz: rmap["HaarAnz"]!["controller"]!, haarAnz: rmap["HaarAnz"]!["controller"]!,
haarGen: rmap["HaarGen"]!["controller"]!, haarGen: rmap["HaarGen"]!["controller"]!,
), ),
const SizedBox( const SizedBox(height: 20),
height: 20,
),
const Divider(), const Divider(),
const SizedBox( const SizedBox(height: 20),
height: 20,
),
// ---------- Clues // ---------- Clues
Align( Align(
alignment: Alignment.bottomLeft, alignment: Alignment.bottomLeft,
child: Text( child: Text(
AppLocalizations.of(context)!.hinweise, AppLocalizations.of(context)!.hinweise,
style: style: Theme.of(context).textTheme.titleMedium,
Theme.of(context).textTheme.titleMedium,
), ),
), ),
Hinweise( Hinweise(hinweise: rmap["Hinweise"]!["controller"]!),
hinweise: rmap["Hinweise"]!["controller"]!,
),
], ],
), ),
), ),
@@ -329,9 +300,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
required: false, required: false,
dbDesignation: DatabasesEnum.excursion, dbDesignation: DatabasesEnum.excursion,
), ),
const SizedBox( const SizedBox(height: 20),
height: 20,
),
// ---------- Internal communication // ---------- Internal communication
VarTextField( VarTextField(
textController: rmap["IntKomm"]!["controller"]!, textController: rmap["IntKomm"]!["controller"]!,
@@ -347,13 +316,14 @@ class _ExcursionMainState extends State<ExcursionMain> {
// Begin of widget tree // Begin of widget tree
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: Text(AppLocalizations.of(context)!.excursion)),
title: Text(AppLocalizations.of(context)!.excursion),
),
body: PageTransitionSwitcher( body: PageTransitionSwitcher(
duration: const Duration(microseconds: 800), duration: const Duration(microseconds: 800),
transitionBuilder: (Widget child, Animation<double> animation, transitionBuilder: (
Animation<double> secondaryAnimation) { Widget child,
Animation<double> animation,
Animation<double> secondaryAnimation,
) {
return SharedAxisTransition( return SharedAxisTransition(
animation: animation, animation: animation,
secondaryAnimation: secondaryAnimation, secondaryAnimation: secondaryAnimation,
@@ -380,9 +350,17 @@ class _ExcursionMainState extends State<ExcursionMain> {
} else { } else {
bool empty = CheckRequired.checkRequired(rmap); bool empty = CheckRequired.checkRequired(rmap);
if (empty) { if (empty) {
await DialogHelper.showTemplateDialog(context, getFieldsText(), false); await AddEntriesDialogHelper.showTemplateDialog(
context,
getFieldsText(),
false,
);
} else { } else {
await DialogHelper.showSaveOptionsDialog(context, getFieldsText(), false); await AddEntriesDialogHelper.showSaveOptionsDialog(
context,
getFieldsText(),
false,
);
} }
} }
}, },
@@ -396,6 +374,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
} }
}, },
), ),
)); ),
);
} }
} }

View File

@@ -0,0 +1,74 @@
import 'package:fforte/enums/databases.dart';
import 'package:fforte/l10n/app_localizations.dart';
import 'package:fforte/screens/sharedMethods/delete_main_entries.dart';
import 'package:fforte/screens/sharedMethods/delete_templates.dart';
import 'package:flutter/material.dart';
class ViewEntriesDialogHelper {
static void deleteAllMainEntries(
BuildContext context,
DatabasesEnum dbType,
) async {
return showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
title: Text(AppLocalizations.of(context)!.deleteEverything),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Text(AppLocalizations.of(context)!.deleteEverythingContent),
],
),
),
actions: <Widget>[
TextButton(
onPressed: () {
DeleteMainEntries.deleteAll(dbType);
Navigator.of(context).pop();
},
child: Text(AppLocalizations.of(context)!.deleteEverything),
),
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text(AppLocalizations.of(context)!.cancel),
),
],
);
},
);
}
static void deleteAllTemplates(BuildContext context, DatabasesEnum dbType) async{
return showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
title: Text(AppLocalizations.of(context)!.deleteEverything),
content: SingleChildScrollView(
child: ListBody(children: <Widget>[
Text(AppLocalizations.of(context)!.deleteEverythingContent)
]),
),
actions: <Widget>[
TextButton(
onPressed: () {
DeleteTemplates.deleteAll(dbType);
Navigator.of(context).pop();
},
child: Text(AppLocalizations.of(context)!.deleteEverything)),
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text(AppLocalizations.of(context)!.cancel))
],
);
});
}
}

View File

@@ -0,0 +1,29 @@
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';
class DeleteMainEntries {
static void deleteAll(DatabasesEnum dbType) {
IDb? db;
if (dbType == DatabasesEnum.place) {
db = PlaceDBHelper();
} else if (dbType == DatabasesEnum.excursion) {
db = ExcursionDBHelper();
}
db!.deleteAllMainEntries();
}
static void deleteSingle(DatabasesEnum dbType, int id) {
IDb? db;
if (dbType == DatabasesEnum.place) {
db = PlaceDBHelper();
} else if (dbType == DatabasesEnum.excursion) {
db = ExcursionDBHelper();
}
db!.deleteMainEntryById(id.toString());
}
}

View File

@@ -0,0 +1,18 @@
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';
class DeleteTemplates {
static void deleteAll(DatabasesEnum dbType) {
IDb? db;
if (dbType == DatabasesEnum.place) {
db = PlaceDBHelper();
} else if (dbType == DatabasesEnum.excursion) {
db = ExcursionDBHelper();
}
db!.deleteAllMainEntries();
}
}

View File

@@ -1,5 +1,10 @@
import 'package:fforte/enums/databases.dart';
import 'package:fforte/interfaces/i_db.dart';
import 'package:fforte/methods/excursion_db_helper.dart';
import 'package:fforte/screens/addCam/add_cam_main.dart'; import 'package:fforte/screens/addCam/add_cam_main.dart';
import 'package:fforte/methods/place_db_helper.dart'; import 'package:fforte/methods/place_db_helper.dart';
import 'package:fforte/screens/helper/view_entries_dialog_helper.dart';
import 'package:fforte/screens/sharedMethods/delete_main_entries.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fforte/l10n/app_localizations.dart'; import 'package:fforte/l10n/app_localizations.dart';
import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map/flutter_map.dart';
@@ -8,7 +13,8 @@ import 'package:latlong2/latlong.dart';
// * Site that shows all entries in the databases // * Site that shows all entries in the databases
class ViewCams extends StatefulWidget { class ViewCams extends StatefulWidget {
const ViewCams({super.key}); final DatabasesEnum dbType;
const ViewCams({super.key, required this.dbType});
@override @override
State<ViewCams> createState() => _ViewCamsState(); State<ViewCams> createState() => _ViewCamsState();
@@ -16,91 +22,23 @@ class ViewCams extends StatefulWidget {
class _ViewCamsState extends State<ViewCams> { class _ViewCamsState extends State<ViewCams> {
// var declaration // var declaration
late Future<List<Map<String, dynamic>>> place; late Future<List<Map<String, dynamic>>> mainEntries;
late Future<List<Map<String, dynamic>>> templates; late Future<List<Map<String, dynamic>>> templates;
late List<Marker> markers; late List<Marker> markers;
// loads the entries // loads the entries
@override @override
void initState() { void initState() {
IDb? db;
super.initState(); super.initState();
place = PlaceDBHelper().getAllMainEntries(); if (widget.dbType == DatabasesEnum.place) {
templates = PlaceDBHelper().getAllTemplates(); db = PlaceDBHelper();
} else if (widget.dbType == DatabasesEnum.excursion) {
db = ExcursionDBHelper();
} }
// functions to delete all entries LOCALLY mainEntries = db!.getAllMainEntries();
void delAllPlaces() async { templates = db.getAllTemplates();
return showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
title: Text(AppLocalizations.of(context)!.deleteEverything),
content: SingleChildScrollView(
child: ListBody(children: <Widget>[
Text(AppLocalizations.of(context)!.deleteEverythingContent)
]),
),
actions: <Widget>[
TextButton(
onPressed: () {
var placeDB = PlaceDBHelper();
placeDB.deleteAllMainEntries();
setState(() {
place = PlaceDBHelper().getAllMainEntries();
});
Navigator.of(context).pop();
},
child: Text(AppLocalizations.of(context)!.deleteEverything)),
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text(AppLocalizations.of(context)!.cancel))
],
);
});
}
void delSinglePlace(int id) async {
PlaceDBHelper().deleteMainEntryById(id.toString());
setState(() {
place = PlaceDBHelper().getAllMainEntries();
});
}
void delAllTemplates() async {
return showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
title: Text(AppLocalizations.of(context)!.deleteEverything),
content: SingleChildScrollView(
child: ListBody(children: <Widget>[
Text(AppLocalizations.of(context)!.deleteEverythingContent)
]),
),
actions: <Widget>[
TextButton(
onPressed: () {
var placeDB = PlaceDBHelper();
placeDB.deleteAllTemplates();
setState(() {
templates = PlaceDBHelper().getAllTemplates();
});
Navigator.of(context).pop();
},
child: Text(AppLocalizations.of(context)!.deleteEverything)),
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text(AppLocalizations.of(context)!.cancel))
],
);
});
} }
// The widet tree with taps to differentiate between templates and finished entries // The widet tree with taps to differentiate between templates and finished entries
@@ -110,40 +48,42 @@ class _ViewCamsState extends State<ViewCams> {
length: 3, length: 3,
child: Scaffold( child: Scaffold(
appBar: AppBar( appBar: AppBar(
bottom: TabBar(tabs: [ bottom: TabBar(
tabs: [
Tab(text: AppLocalizations.of(context)!.completed), Tab(text: AppLocalizations.of(context)!.completed),
Tab( Tab(text: AppLocalizations.of(context)!.uncompleted),
text: AppLocalizations.of(context)!.uncompleted, Tab(text: AppLocalizations.of(context)!.map),
],
), ),
Tab( title: Text(AppLocalizations.of(context)!.viewplacesappbar),
text: AppLocalizations.of(context)!.map,
), ),
]),
title: Text(AppLocalizations.of(context)!.viewplacesappbar)),
body: TabBarView( body: TabBarView(
children: [ children: [
FutureBuilder<List<Map<String, dynamic>>>( Tab(
future: place, child: FutureBuilder<List<Map<String, dynamic>>>(
future: mainEntries,
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) { if (snapshot.connectionState == ConnectionState.waiting) {
return const CircularProgressIndicator(); return const CircularProgressIndicator();
} else if (snapshot.hasError) { } else if (snapshot.hasError) {
return Text('Error: ${snapshot.error}'); return Text('Error: ${snapshot.error}');
} else { } else {
List<Map<String, dynamic>> placeList = List<Map<String, dynamic>> placeList = List.of(
List.of(snapshot.data!); snapshot.data!,
);
return Scaffold( return Scaffold(
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
child: const Icon(Icons.delete), child: const Icon(Icons.delete),
onPressed: () { onPressed: () {
delAllPlaces(); ViewEntriesDialogHelper.deleteAllMainEntries(
context,
widget.dbType,
);
}, },
), ),
body: Column( body: Column(
children: [ children: [
const SizedBox( const SizedBox(height: 10),
height: 10,
),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
@@ -171,9 +111,7 @@ class _ViewCamsState extends State<ViewCams> {
), ),
], ],
), ),
const SizedBox( const SizedBox(height: 15),
height: 15,
),
Expanded( Expanded(
child: ListView.builder( child: ListView.builder(
itemCount: placeList.length, itemCount: placeList.length,
@@ -186,20 +124,26 @@ class _ViewCamsState extends State<ViewCams> {
children: [ children: [
SlidableAction( SlidableAction(
onPressed: (context) { onPressed: (context) {
delSinglePlace( DeleteMainEntries.deleteSingle(
place['ID'.toString()]); widget.dbType,
place['ID'.toString()],
);
}, },
backgroundColor: Colors.red, backgroundColor: Colors.red,
foregroundColor: Colors.white, foregroundColor: Colors.white,
icon: Icons.delete, icon: Icons.delete,
label: AppLocalizations.of(context)! label:
.justdelete, AppLocalizations.of(
) context,
]), )!.justdelete,
),
],
),
child: ListTile( child: ListTile(
title: Text('Standort ${index + 1}'), title: Text('Standort ${index + 1}'),
subtitle: Text( subtitle: Text(
'ID: ${place['ID']} DATUM: ${place['Datum']}'), 'ID: ${place['ID']} DATUM: ${place['Datum']}',
),
trailing: Checkbox( trailing: Checkbox(
value: place['Sent'] == 0 ? false : true, value: place['Sent'] == 0 ? false : true,
onChanged: null, onChanged: null,
@@ -208,23 +152,32 @@ class _ViewCamsState extends State<ViewCams> {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => AddCamMain( builder:
isSent: place['Sent'] == 1 ? true : false, (context) => AddCamMain(
isSent:
place['Sent'] == 1
? true
: false,
isFinished: true, isFinished: true,
existingData: place, existingData: place,
))); ),
),
);
}, },
), ),
); );
}, },
)) ),
),
], ],
), ),
); );
} }
}, },
), ),
FutureBuilder<List<Map<String, dynamic>>>( ),
Tab(
child: FutureBuilder<List<Map<String, dynamic>>>(
future: templates, future: templates,
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) { if (snapshot.connectionState == ConnectionState.waiting) {
@@ -236,7 +189,10 @@ class _ViewCamsState extends State<ViewCams> {
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
child: const Icon(Icons.delete), child: const Icon(Icons.delete),
onPressed: () { onPressed: () {
delAllTemplates(); ViewEntriesDialogHelper.deleteAllTemplates(
context,
widget.dbType,
);
}, },
), ),
body: Column( body: Column(
@@ -252,38 +208,48 @@ class _ViewCamsState extends State<ViewCams> {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => builder:
AddCamMain( (context) => AddCamMain(
isTemplate: true, isTemplate: true,
isFinished: false, isFinished: false,
existingData: templates, existingData: templates,
))); ),
),
);
}, },
title: Text('Place ${index + 1}'), title: Text('Place ${index + 1}'),
subtitle: Text( subtitle: Text(
'ID: ${templates['CID']} DATUM: ${templates['Datum']} RUDEL: ${templates['Rudel']} STATUS: ${templates['Status']}'), 'ID: ${templates['CID']} DATUM: ${templates['Datum']} RUDEL: ${templates['Rudel']} STATUS: ${templates['Status']}',
),
); );
}), },
) ),
),
], ],
), ),
); );
} }
}), },
FutureBuilder( ),
future: place, ),
Tab(
child: FutureBuilder(
future: mainEntries,
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) { if (snapshot.connectionState == ConnectionState.waiting) {
return const CircularProgressIndicator(); return const CircularProgressIndicator();
} else if (snapshot.hasError) { } else if (snapshot.hasError) {
return Text("Error ${snapshot.error}"); return Text("Error ${snapshot.error}");
} else { } else {
markers = snapshot.data!.map((e) { markers =
snapshot.data!.map((e) {
return Marker( return Marker(
width: 80.0, width: 80.0,
height: 80.0, height: 80.0,
point: LatLng(double.parse(e['DECLAT'].toString()), point: LatLng(
double.parse(e['DECLNG'].toString())), double.parse(e['DECLAT'].toString()),
double.parse(e['DECLNG'].toString()),
),
child: Column( child: Column(
children: [ children: [
const Icon( const Icon(
@@ -293,31 +259,40 @@ class _ViewCamsState extends State<ViewCams> {
Text( Text(
"ID: ${e['ID'].toString()}", "ID: ${e['ID'].toString()}",
style: const TextStyle(color: Colors.black), style: const TextStyle(color: Colors.black),
) ),
], ],
)); ),
);
}).toList(); }).toList();
return FlutterMap( return FlutterMap(
options: MapOptions( options: MapOptions(
initialCenter: markers.isEmpty initialCenter:
markers.isEmpty
? const LatLng(50, 10) ? const LatLng(50, 10)
: markers.first.point, : markers.first.point,
interactionOptions: const InteractionOptions( interactionOptions: const InteractionOptions(
flags: InteractiveFlag.pinchZoom | flags:
InteractiveFlag.pinchZoom |
InteractiveFlag.drag | InteractiveFlag.drag |
InteractiveFlag.pinchMove)), InteractiveFlag.pinchMove,
),
),
children: [ children: [
TileLayer( TileLayer(
urlTemplate: urlTemplate:
'https://tile.openstreetmap.org/{z}/{x}/{y}.png', 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
userAgentPackageName: 'com.example.app', userAgentPackageName: 'com.example.app',
), ),
MarkerLayer(markers: markers) MarkerLayer(markers: markers),
]);
}
})
], ],
)), );
}
},
),
),
],
),
),
); );
} }
} }

View File

@@ -1,30 +0,0 @@
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility in the flutter_test package. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fforte/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}

View File

@@ -79,3 +79,4 @@
7. mai 2h 45min 7. mai 2h 45min
9. mai 3h 40min 9. mai 3h 40min
10.mai 4h 15min 10.mai 4h 15min
11.mai 1h 15min