finished excursion view so far. Just need to test everything
time
This commit is contained in:
@@ -86,13 +86,14 @@ class HomePage extends StatelessWidget {
|
||||
onPressed: () => Navigator.pushNamed(context, '/viewCams'),
|
||||
child: Text(AppLocalizations.of(context)!.viewplaces),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
minimumSize: const Size(250, 40),
|
||||
),
|
||||
onPressed: () => Navigator.pushNamed(context, '/viewExcursionen'),
|
||||
child: Text(AppLocalizations.of(context)!.viewplaces),
|
||||
child: Text(AppLocalizations.of(context)!.viewExcursionen),
|
||||
),
|
||||
|
||||
const SizedBox(height: 10),
|
||||
|
||||
@@ -13,7 +13,7 @@ abstract interface class IDb {
|
||||
|
||||
Future<void> updateSent(int id);
|
||||
|
||||
Future<void> addTemplate(Map<String, String> templates);
|
||||
Future<int> addTemplate(Map<String, String> templates);
|
||||
|
||||
Future<void> updateTemplate(Map<String, String> template);
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@
|
||||
"sendfile": "Datei zum Server senden",
|
||||
"pickfile": "Datei auswählen",
|
||||
"placedata": "Standortdaten",
|
||||
"excursionData": "Exursions daten",
|
||||
"sent": "Gesendet",
|
||||
"fileSaved": "Datei gespeichtert bei: ",
|
||||
"savefilefailed": "Fehler. Bitte nochmal versuchen",
|
||||
|
||||
@@ -434,6 +434,11 @@
|
||||
"description": "view data placedata header"
|
||||
},
|
||||
|
||||
"excursionData": "Excursion data",
|
||||
"@camdata": {
|
||||
"description": "view data placedata header"
|
||||
},
|
||||
|
||||
"sent": "Sent",
|
||||
"@sent": {
|
||||
"description": "view data sent header"
|
||||
|
||||
@@ -641,6 +641,12 @@ abstract class AppLocalizations {
|
||||
/// **'Place data'**
|
||||
String get placedata;
|
||||
|
||||
/// No description provided for @excursionData.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Excursion data'**
|
||||
String get excursionData;
|
||||
|
||||
/// view data sent header
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
|
||||
@@ -281,6 +281,9 @@ class AppLocalizationsDe extends AppLocalizations {
|
||||
@override
|
||||
String get placedata => 'Standortdaten';
|
||||
|
||||
@override
|
||||
String get excursionData => 'Exursions daten';
|
||||
|
||||
@override
|
||||
String get sent => 'Gesendet';
|
||||
|
||||
|
||||
@@ -281,6 +281,9 @@ class AppLocalizationsEn extends AppLocalizations {
|
||||
@override
|
||||
String get placedata => 'Place data';
|
||||
|
||||
@override
|
||||
String get excursionData => 'Excursion data';
|
||||
|
||||
@override
|
||||
String get sent => 'Sent';
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ 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:fforte/screens/viewEntries/view_cams.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flex_color_scheme/flex_color_scheme.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
|
||||
@@ -37,10 +37,10 @@ class ExcursionDBHelper implements IDb {
|
||||
@override
|
||||
onCreateDatabases(Database excursionDB, int version) async {
|
||||
await excursionDB.execute(
|
||||
'CREATE TABLE excursion (ID INTEGER PRIMARY KEY AUTOINCREMENT, LogDat TEXT, Rudel TEXT, Teilnehmer TEXT, Jahr TEXT, Dauer TEXT, MHund INTEGER, MLeine TEXT, BLand TEXT, Lkr TEXT, BeiOrt, TEXT, BimaName TEXT, Wetter TEXT, Temperat TEXT, RegenVor TEXT, KmRad TEXT, KmAuto TEXT, KmFuss TEXT, KmTotal TEXT, KmAuProz TEXT, KmFuProz TEXT, KmRaProz TEXT, SpGut TEXT, SpMittel, SpSchlecht TEXT, SpurFund TEXT, SpurLang TEXT, SpurTiere Text, SpSicher TEXT, WelpenSp TEXT, WelpenAnz TEXT, WpSicher TEXT, LosungGes TEXT, LosungAnz TEXT, LosungGen 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, BimaNutzer TEXT, BimaAGV TEXT, FallNum INTEGER, HinweiseSonstiges TEXT, Sent INTEGER DEFAULT 0)',
|
||||
'CREATE TABLE excursion (ID INTEGER PRIMARY KEY AUTOINCREMENT, LogDat TEXT, Rudel TEXT, Teilnehmer TEXT, Jahr TEXT, Dauer TEXT, MHund INTEGER, MLeine TEXT, BLand TEXT, Lkr TEXT, BeiOrt TEXT, BimaName TEXT, Wetter TEXT, Temperat TEXT, RegenVor TEXT, KmRad TEXT, KmAuto TEXT, KmFuss TEXT, KmTotal TEXT, KmAuProz TEXT, KmFuProz TEXT, KmRaProz TEXT, SpGut TEXT, SpMittel, SpSchlecht TEXT, SpurFund TEXT, SpurLang TEXT, SpurTiere Text, SpSicher TEXT, WelpenSp TEXT, WelpenAnz TEXT, WpSicher TEXT, LosungGes TEXT, LosungAnz TEXT, LosungGen 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, BimaNutzer TEXT, BimaAGV TEXT, FallNum INTEGER, Sent INTEGER DEFAULT 0)',
|
||||
);
|
||||
await excursionDB.execute(
|
||||
'CREATE TABLE excursionTemplates (ID INTEGER PRIMARY KEY AUTOINCREMENT, LogDat TEXT, Rudel TEXT, Teilnehmer TEXT, Jahr TEXT, Dauer TEXT, MHund INTEGER, MLeine TEXT, BLand TEXT, Lkr TEXT, BeiOrt, TEXT, BimaName TEXT, Wetter TEXT, Temperat TEXT, RegenVor TEXT, KmRad TEXT, KmAuto TEXT, KmFuss TEXT, KmTotal TEXT, KmAuProz TEXT, KmFuProz TEXT, KmRaProz TEXT, SpGut TEXT, SpMittel, SpSchlecht TEXT, SpurFund TEXT, SpurLang TEXT, SpurTiere Text, SpSicher TEXT, WelpenSp TEXT, WelpenAnz TEXT, WpSicher TEXT, LosungGes TEXT, LosungAnz TEXT, LosungGen 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, BimaNutzer TEXT, BimaAGV TEXT, FallNum INTEGER, HinweiseSonstiges TEXT)',
|
||||
'CREATE TABLE excursionTemplates (ID INTEGER PRIMARY KEY AUTOINCREMENT, LogDat TEXT, Rudel TEXT, Teilnehmer TEXT, Jahr TEXT, Dauer TEXT, MHund INTEGER, MLeine TEXT, BLand TEXT, Lkr TEXT, BeiOrt TEXT, BimaName TEXT, Wetter TEXT, Temperat TEXT, RegenVor TEXT, KmRad TEXT, KmAuto TEXT, KmFuss TEXT, KmTotal TEXT, KmAuProz TEXT, KmFuProz TEXT, KmRaProz TEXT, SpGut TEXT, SpMittel, SpSchlecht TEXT, SpurFund TEXT, SpurLang TEXT, SpurTiere Text, SpSicher TEXT, WelpenSp TEXT, WelpenAnz TEXT, WpSicher TEXT, LosungGes TEXT, LosungAnz TEXT, LosungGen 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, BimaNutzer TEXT, BimaAGV TEXT, FallNum INTEGER)',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ class ExcursionDBHelper implements IDb {
|
||||
|
||||
// same thing as before but with templatews
|
||||
@override
|
||||
Future<void> addTemplate(Map<String, String> templates) async {
|
||||
Future<int> addTemplate(Map<String, String> templates) async {
|
||||
var excursionDBClient = await dB;
|
||||
|
||||
// final existingCID = await excursionDBClient.query(
|
||||
@@ -107,11 +107,12 @@ class ExcursionDBHelper implements IDb {
|
||||
// return;
|
||||
// }
|
||||
|
||||
await excursionDBClient.insert(
|
||||
int id = await excursionDBClient.insert(
|
||||
'excursionTemplates',
|
||||
templates,
|
||||
// conflictAlgorithm: ConflictAlgorithm.replace,
|
||||
);
|
||||
return id;
|
||||
}
|
||||
|
||||
// Updates a existing template
|
||||
|
||||
@@ -82,7 +82,7 @@ class PlaceDBHelper implements IDb{
|
||||
|
||||
// same thing as before but with templatews
|
||||
@override
|
||||
Future<void> addTemplate(Map<String, String> templates) async {
|
||||
Future<int> addTemplate(Map<String, String> templates) async {
|
||||
var placeDBClient = await dB;
|
||||
|
||||
// final existingCID = await placeDBClient.query(
|
||||
@@ -94,11 +94,12 @@ class PlaceDBHelper implements IDb{
|
||||
// return;
|
||||
// }
|
||||
|
||||
await placeDBClient.insert(
|
||||
int id = await placeDBClient.insert(
|
||||
'placeTemplates',
|
||||
templates,
|
||||
// conflictAlgorithm: ConflictAlgorithm.replace,
|
||||
);
|
||||
return id;
|
||||
}
|
||||
|
||||
// Updates a existing template
|
||||
|
||||
@@ -40,6 +40,7 @@ class AddCamMain extends StatefulWidget {
|
||||
class _AddCamMainState extends State<AddCamMain> {
|
||||
// var declaration
|
||||
int currentStep = 0;
|
||||
late bool isTemplate;
|
||||
|
||||
String selectedStatus = 'aktiv';
|
||||
String selectedFotoFilm = 'Foto';
|
||||
@@ -149,6 +150,8 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
rmap["DECLAT"]!["controller"]!.text = currentPosition.latitude.toString();
|
||||
rmap["DECLNG"]!["controller"]!.text = currentPosition.longitude.toString();
|
||||
|
||||
isTemplate = widget.isTemplate;
|
||||
|
||||
// If a template is edited this fills in the existing values
|
||||
if (widget.existingData?.isNotEmpty ?? false) {
|
||||
for (var key in widget.existingData!.keys) {
|
||||
@@ -595,11 +598,14 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
final isLastStep = currentStep == getSteps().length - 1;
|
||||
|
||||
if (!isLastStep) {
|
||||
saveTemplate(
|
||||
var res = await saveTemplate(
|
||||
getFieldsText(),
|
||||
DatabasesEnum.place,
|
||||
);
|
||||
|
||||
isTemplate = true;
|
||||
setState(() {
|
||||
rmap["ID"]!["controller"]!.text = res.toString();
|
||||
currentStep += 1;
|
||||
});
|
||||
} else {
|
||||
@@ -614,7 +620,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
}
|
||||
|
||||
bool empty = CheckRequired.checkRequired(rmap);
|
||||
// TODO for debugging always true
|
||||
// TODO for debugging always false
|
||||
empty = false;
|
||||
|
||||
if (empty == true) {
|
||||
@@ -627,7 +633,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
||||
await AddEntriesDialogHelper.showSaveOptionsDialog(
|
||||
context,
|
||||
getFieldsText(),
|
||||
widget.isTemplate,
|
||||
isTemplate,
|
||||
DatabasesEnum.place,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -33,9 +33,11 @@ class ExcursionMain extends StatefulWidget {
|
||||
|
||||
class _ExcursionMainState extends State<ExcursionMain> {
|
||||
int currentStep = 0;
|
||||
late bool isTemplate;
|
||||
|
||||
// all TextEditingController because its easier
|
||||
Map<String, Map<String, dynamic>> rmap = {
|
||||
"ID": {"controller": TextEditingController(), "required": false},
|
||||
// Step 1
|
||||
"LogDat": {"controller": TextEditingController(), "required": false},
|
||||
"Rudel": {"controller": TextEditingController(), "required": false},
|
||||
@@ -93,6 +95,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
"Bemerk": {"controller": TextEditingController(), "required": false},
|
||||
"IntKomm": {"controller": TextEditingController(), "required": false},
|
||||
"FallNum": {"controller": TextEditingController(), "required": false},
|
||||
"Sent": {"controller": TextEditingController(), "required": false},
|
||||
};
|
||||
|
||||
@override
|
||||
@@ -103,6 +106,9 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
widget.existingData?[key].toString() ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
isTemplate = widget.isTemplate;
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@@ -373,11 +379,14 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
final isLastStep = currentStep == getSteps().length - 1;
|
||||
|
||||
if (!isLastStep) {
|
||||
saveTemplate(
|
||||
var res = await saveTemplate(
|
||||
getFieldsText(),
|
||||
DatabasesEnum.excursion,
|
||||
);
|
||||
|
||||
isTemplate = true;
|
||||
setState(() {
|
||||
rmap["ID"]!["controller"]!.text = res.toString();
|
||||
currentStep += 1;
|
||||
});
|
||||
} else {
|
||||
@@ -392,7 +401,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
}
|
||||
|
||||
bool empty = CheckRequired.checkRequired(rmap);
|
||||
// TODO for debugging always true
|
||||
// TODO for debugging always false
|
||||
empty = false;
|
||||
|
||||
if (empty == true) {
|
||||
|
||||
@@ -22,7 +22,7 @@ class SaveMainEntryMethod {
|
||||
if (isTemplate) await placeDB!.deleteTemplateById(entryData["ID"]!);
|
||||
|
||||
int entryId;
|
||||
if (entryData["ID"] == "") {
|
||||
if (entryData["ID"] == "" || isTemplate) {
|
||||
entryData.remove("ID");
|
||||
entryId = await placeDB!.addMainEntry(entryData);
|
||||
// await placeDB.deleteTemplateById(entryData["CID"]!);
|
||||
|
||||
@@ -3,22 +3,25 @@ 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, String> templateData, DatabasesEnum dbType,) async {
|
||||
Future<int> saveTemplate(Map<String, String> templateData, DatabasesEnum dbType,) async {
|
||||
IDb dbHelper;
|
||||
int id =templateData["ID"]! != "" ? int.parse(templateData["ID"]!) : -1;
|
||||
if (dbType == DatabasesEnum.place) {
|
||||
dbHelper = PlaceDBHelper();
|
||||
} else if (dbType == DatabasesEnum.excursion) {
|
||||
dbHelper = ExcursionDBHelper();
|
||||
} else {
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
templateData.remove("Sent");
|
||||
|
||||
if (templateData["ID"]! == "") {
|
||||
if (templateData["ID"]! == "" || templateData["ID"]! == "-1") {
|
||||
templateData.remove("ID");
|
||||
await dbHelper.addTemplate(templateData);
|
||||
id = await dbHelper.addTemplate(templateData);
|
||||
} else {
|
||||
await dbHelper.updateTemplate(templateData);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -1,338 +0,0 @@
|
||||
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/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:fforte/screens/sharedMethods/delete_templates.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fforte/l10n/app_localizations.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
// * Site that shows all entries in the databases
|
||||
|
||||
class ViewEntries extends StatefulWidget {
|
||||
final DatabasesEnum dbType;
|
||||
const ViewEntries({super.key, required this.dbType});
|
||||
|
||||
@override
|
||||
State<ViewEntries> createState() => _ViewEntriesState();
|
||||
}
|
||||
|
||||
class _ViewEntriesState extends State<ViewEntries> {
|
||||
// var declaration
|
||||
List<Map<String, dynamic>> mainEntries = [];
|
||||
List<Map<String, dynamic>> templates = [];
|
||||
late List<Marker> markers;
|
||||
|
||||
// loads the entries
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
reloadAllEntries();
|
||||
}
|
||||
|
||||
Future<void> reloadAllEntries() async {
|
||||
IDb? db;
|
||||
|
||||
if (widget.dbType == DatabasesEnum.place) {
|
||||
db = PlaceDBHelper();
|
||||
} else if (widget.dbType == DatabasesEnum.excursion) {
|
||||
db = ExcursionDBHelper();
|
||||
}
|
||||
|
||||
mainEntries = await db!.getAllMainEntries();
|
||||
templates = await db.getAllTemplates();
|
||||
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
// The widet tree with taps to differentiate between templates and finished entries
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultTabController(
|
||||
length: 2,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
bottom: TabBar(
|
||||
tabs: [
|
||||
Tab(text: AppLocalizations.of(context)!.completed),
|
||||
Tab(text: AppLocalizations.of(context)!.uncompleted),
|
||||
// Tab(text: AppLocalizations.of(context)!.map),
|
||||
],
|
||||
),
|
||||
title: Text(AppLocalizations.of(context)!.viewplacesappbar),
|
||||
),
|
||||
body: TabBarView(
|
||||
children: [
|
||||
Tab(
|
||||
// child: FutureBuilder<List<Map<String, dynamic>>>(
|
||||
// future: mainEntries,
|
||||
// builder: (context, snapshot) {
|
||||
// if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
// return const CircularProgressIndicator();
|
||||
// } else if (snapshot.hasError) {
|
||||
// return Text('Error: ${snapshot.error}');
|
||||
// } else {
|
||||
// List<Map<String, dynamic>> placeList = List.of(
|
||||
// snapshot.data!,
|
||||
// );
|
||||
// return
|
||||
child: Scaffold(
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: const Icon(Icons.delete),
|
||||
onPressed: () {
|
||||
ViewEntriesDialogHelper.deleteAllMainEntries(
|
||||
context,
|
||||
widget.dbType,
|
||||
);
|
||||
},
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const SizedBox(width: 10),
|
||||
if (widget.dbType == DatabasesEnum.place)
|
||||
Text(
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
AppLocalizations.of(context)!.placedata,
|
||||
),
|
||||
if (widget.dbType == DatabasesEnum.excursion)
|
||||
Text(
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
// TODO localization
|
||||
AppLocalizations.of(context)!.homePageTitle,
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
AppLocalizations.of(context)!.sent,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: mainEntries.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Slidable(
|
||||
startActionPane: ActionPane(
|
||||
motion: const ScrollMotion(),
|
||||
children: [
|
||||
SlidableAction(
|
||||
onPressed: (context) {
|
||||
DeleteMainEntries.deleteSingle(
|
||||
widget.dbType,
|
||||
mainEntries[index]['ID'.toString()],
|
||||
);
|
||||
setState(() {
|
||||
reloadAllEntries();
|
||||
});
|
||||
},
|
||||
backgroundColor: Colors.red,
|
||||
foregroundColor: Colors.white,
|
||||
icon: Icons.delete,
|
||||
label:
|
||||
AppLocalizations.of(context)!.justdelete,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ListTile(
|
||||
title: Text('Standort ${index + 1}'),
|
||||
subtitle: Text(
|
||||
'ID: ${mainEntries[index]['ID']} DATUM: ${mainEntries[index]['Datum']}',
|
||||
),
|
||||
trailing: Checkbox(
|
||||
value: mainEntries[index]['Sent'] == 0 ? false : true,
|
||||
onChanged: null,
|
||||
),
|
||||
onTap: () async {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder:
|
||||
(context) => AddCamMain(
|
||||
isSent:
|
||||
mainEntries[index]['Sent'] == 1
|
||||
? true
|
||||
: false,
|
||||
existingData: mainEntries[index],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// } // REMOVE
|
||||
// }, // REMOVE
|
||||
// ), // REMOVE
|
||||
),
|
||||
Tab(
|
||||
// child: FutureBuilder<List<Map<String, dynamic>>>(
|
||||
// future: templates,
|
||||
// builder: (context, snapshot) {
|
||||
// if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
// return const CircularProgressIndicator();
|
||||
// } else if (snapshot.hasError) {
|
||||
// return Text('Error: ${snapshot.error}');
|
||||
// } else {
|
||||
// return Scaffold(
|
||||
child: Scaffold(
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: const Icon(Icons.delete),
|
||||
onPressed: () {
|
||||
ViewEntriesDialogHelper.deleteAllTemplates(
|
||||
context,
|
||||
widget.dbType,
|
||||
);
|
||||
},
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: templates.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Slidable(
|
||||
startActionPane: ActionPane(
|
||||
motion: const ScrollMotion(),
|
||||
children: [
|
||||
SlidableAction(
|
||||
onPressed: (context) {
|
||||
DeleteTemplates.deleteSingle(
|
||||
widget.dbType,
|
||||
templates[index]['ID'].toString(),
|
||||
);
|
||||
setState(() {
|
||||
reloadAllEntries();
|
||||
});
|
||||
},
|
||||
backgroundColor: Colors.red,
|
||||
foregroundColor: Colors.white,
|
||||
icon: Icons.delete,
|
||||
label:
|
||||
AppLocalizations.of(context)!.justdelete,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ListTile(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder:
|
||||
(context) => AddCamMain(
|
||||
isTemplate: true,
|
||||
existingData: templates[index],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
title: Text('Place ${index + 1}'),
|
||||
subtitle: Text(
|
||||
'ID: ${templates[index]['CID']} DATUM: ${templates[index]['Datum']} RUDEL: ${templates[index]['Rudel']} STATUS: ${templates[index]['Status']}',
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// } // REMOVE
|
||||
// }, // REMOVE
|
||||
// ), // REMOVE
|
||||
),
|
||||
// Tab(
|
||||
// child: FutureBuilder(
|
||||
// future: mainEntries,
|
||||
// builder: (context, snapshot) {
|
||||
// if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
// return const CircularProgressIndicator();
|
||||
// } else if (snapshot.hasError) {
|
||||
// return Text("Error ${snapshot.error}");
|
||||
// } else {
|
||||
// if (snapshot.data != null) {
|
||||
// markers =
|
||||
// snapshot.data!.map((e) {
|
||||
// return Marker(
|
||||
// width: 80.0,
|
||||
// height: 80.0,
|
||||
// point: LatLng(
|
||||
// double.parse(e['DECLAT'].toString()),
|
||||
// double.parse(e['DECLNG'].toString()),
|
||||
// ),
|
||||
// child: Column(
|
||||
// children: [
|
||||
// const Icon(
|
||||
// Icons.location_on,
|
||||
// color: Colors.red,
|
||||
// ),
|
||||
// Text(
|
||||
// "ID: ${e['ID'].toString()}",
|
||||
// style: const TextStyle(color: Colors.black),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }).toList();
|
||||
// }
|
||||
// return FlutterMap(
|
||||
// options: MapOptions(
|
||||
// initialCenter:
|
||||
// markers.isEmpty
|
||||
// ? const LatLng(50, 10)
|
||||
// : markers.first.point,
|
||||
// interactionOptions: const InteractionOptions(
|
||||
// flags:
|
||||
// InteractiveFlag.pinchZoom |
|
||||
// InteractiveFlag.drag |
|
||||
// InteractiveFlag.pinchMove,
|
||||
// ),
|
||||
// ),
|
||||
// children: [
|
||||
// TileLayer(
|
||||
// urlTemplate:
|
||||
// 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
// userAgentPackageName: 'com.example.app',
|
||||
// ),
|
||||
// MarkerLayer(markers: markers),
|
||||
// ],
|
||||
// );
|
||||
// } // REMOVE
|
||||
// }, // REMOVE
|
||||
// ), // REMOVE
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
410
lib/screens/viewEntries/view_cams.dart
Normal file
410
lib/screens/viewEntries/view_cams.dart
Normal file
@@ -0,0 +1,410 @@
|
||||
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/methods/place_db_helper.dart';
|
||||
import 'package:fforte/screens/excursion/excursion_main.dart';
|
||||
import 'package:fforte/screens/helper/view_entries_dialog_helper.dart';
|
||||
import 'package:fforte/screens/sharedMethods/delete_main_entries.dart';
|
||||
import 'package:fforte/screens/sharedMethods/delete_templates.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fforte/l10n/app_localizations.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
// * Site that shows all entries in the databases
|
||||
|
||||
class ViewEntries extends StatefulWidget {
|
||||
final DatabasesEnum dbType;
|
||||
const ViewEntries({super.key, required this.dbType});
|
||||
|
||||
@override
|
||||
State<ViewEntries> createState() => _ViewEntriesState();
|
||||
}
|
||||
|
||||
class _ViewEntriesState extends State<ViewEntries> {
|
||||
// var declaration
|
||||
List<Map<String, dynamic>> mainEntries = [];
|
||||
List<Map<String, dynamic>> templates = [];
|
||||
List<Marker> marker = [];
|
||||
|
||||
// loads the entries
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
reloadAllEntries();
|
||||
}
|
||||
|
||||
Future<void> reloadAllEntries() async {
|
||||
IDb? db;
|
||||
|
||||
if (widget.dbType == DatabasesEnum.place) {
|
||||
db = PlaceDBHelper();
|
||||
} else if (widget.dbType == DatabasesEnum.excursion) {
|
||||
db = ExcursionDBHelper();
|
||||
}
|
||||
|
||||
mainEntries = await db!.getAllMainEntries();
|
||||
templates = await db.getAllTemplates();
|
||||
|
||||
if (widget.dbType == DatabasesEnum.place) {
|
||||
for (var element in mainEntries) {
|
||||
marker.add(
|
||||
Marker(
|
||||
width: 80.0,
|
||||
height: 80.0,
|
||||
point: LatLng(
|
||||
double.parse(element['DECLAT'].toString()),
|
||||
double.parse(element['DECLNG'].toString()),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
const Icon(Icons.location_on, color: Colors.red),
|
||||
Text(
|
||||
"ID: ${element['ID'].toString()}",
|
||||
style: const TextStyle(color: Colors.black),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
// The widet tree with taps to differentiate between templates and finished entries
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultTabController(
|
||||
length: widget.dbType == DatabasesEnum.place ? 3 : 2,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
bottom: TabBar(
|
||||
tabs: [
|
||||
Tab(text: AppLocalizations.of(context)!.completed),
|
||||
Tab(text: AppLocalizations.of(context)!.uncompleted),
|
||||
if (widget.dbType == DatabasesEnum.place)
|
||||
Tab(text: AppLocalizations.of(context)!.map),
|
||||
],
|
||||
),
|
||||
title: Text(AppLocalizations.of(context)!.viewplacesappbar),
|
||||
),
|
||||
body: TabBarView(
|
||||
children: [
|
||||
Tab(
|
||||
child: Scaffold(
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: const Icon(Icons.delete),
|
||||
onPressed: () {
|
||||
ViewEntriesDialogHelper.deleteAllMainEntries(
|
||||
context,
|
||||
widget.dbType,
|
||||
);
|
||||
},
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const SizedBox(width: 10),
|
||||
if (widget.dbType == DatabasesEnum.place)
|
||||
Text(
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
AppLocalizations.of(context)!.placedata,
|
||||
),
|
||||
if (widget.dbType == DatabasesEnum.excursion)
|
||||
Text(
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
AppLocalizations.of(context)!.excursionData,
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
AppLocalizations.of(context)!.sent,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: mainEntries.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Slidable(
|
||||
startActionPane: ActionPane(
|
||||
motion: const ScrollMotion(),
|
||||
children: [
|
||||
SlidableAction(
|
||||
onPressed: (context) {
|
||||
DeleteMainEntries.deleteSingle(
|
||||
widget.dbType,
|
||||
mainEntries[index]['ID'.toString()],
|
||||
);
|
||||
setState(() {
|
||||
reloadAllEntries();
|
||||
});
|
||||
},
|
||||
backgroundColor: Colors.red,
|
||||
foregroundColor: Colors.white,
|
||||
icon: Icons.delete,
|
||||
label:
|
||||
AppLocalizations.of(context)!.justdelete,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ListTile(
|
||||
title: Text('Standort ${index + 1}'),
|
||||
subtitle: Text(
|
||||
'ID: ${mainEntries[index]['ID']} DATUM: ${widget.dbType == DatabasesEnum.place ? mainEntries[index]['Datum'] : mainEntries[index]["LogDat"]}',
|
||||
),
|
||||
trailing: Checkbox(
|
||||
value:
|
||||
mainEntries[index]['Sent'] == 0
|
||||
? false
|
||||
: true,
|
||||
onChanged: null,
|
||||
),
|
||||
onTap: () async {
|
||||
if (widget.dbType == DatabasesEnum.place) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder:
|
||||
(context) => AddCamMain(
|
||||
isSent:
|
||||
mainEntries[index]['Sent'] == 1
|
||||
? true
|
||||
: false,
|
||||
existingData: mainEntries[index],
|
||||
),
|
||||
),
|
||||
);
|
||||
} else if (widget.dbType ==
|
||||
DatabasesEnum.excursion) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder:
|
||||
(context) => ExcursionMain(
|
||||
isSent:
|
||||
mainEntries[index]['Sent'] == 1
|
||||
? true
|
||||
: false,
|
||||
existingData: mainEntries[index],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Tab(
|
||||
child: Scaffold(
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: const Icon(Icons.delete),
|
||||
onPressed: () {
|
||||
ViewEntriesDialogHelper.deleteAllTemplates(
|
||||
context,
|
||||
widget.dbType,
|
||||
);
|
||||
},
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: templates.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Slidable(
|
||||
startActionPane: ActionPane(
|
||||
motion: const ScrollMotion(),
|
||||
children: [
|
||||
SlidableAction(
|
||||
onPressed: (context) {
|
||||
DeleteTemplates.deleteSingle(
|
||||
widget.dbType,
|
||||
templates[index]['ID'].toString(),
|
||||
);
|
||||
setState(() {
|
||||
reloadAllEntries();
|
||||
});
|
||||
},
|
||||
backgroundColor: Colors.red,
|
||||
foregroundColor: Colors.white,
|
||||
icon: Icons.delete,
|
||||
label:
|
||||
AppLocalizations.of(context)!.justdelete,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ListTile(
|
||||
onTap: () {
|
||||
|
||||
if (widget.dbType == DatabasesEnum.place) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder:
|
||||
(context) => AddCamMain(
|
||||
isTemplate: true,
|
||||
existingData: templates[index],
|
||||
),
|
||||
),
|
||||
);
|
||||
} else if (widget.dbType ==
|
||||
DatabasesEnum.excursion) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder:
|
||||
(context) => ExcursionMain(
|
||||
isTemplate: true,
|
||||
existingData: templates[index],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(
|
||||
// builder:
|
||||
// (context) => AddCamMain(
|
||||
// isTemplate: true,
|
||||
// existingData: templates[index],
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
},
|
||||
|
||||
|
||||
|
||||
title: Text('Place ${index + 1}'),
|
||||
subtitle: Text(
|
||||
'ID: ${templates[index]['CID']} DATUM: ${templates[index]['Datum']} RUDEL: ${templates[index]['Rudel']} STATUS: ${templates[index]['Status']}',
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (widget.dbType == DatabasesEnum.place)
|
||||
Tab(
|
||||
child: FlutterMap(
|
||||
options: MapOptions(
|
||||
initialCenter:
|
||||
marker.isEmpty
|
||||
? const LatLng(50, 10)
|
||||
: marker.first.point,
|
||||
interactionOptions: const InteractionOptions(
|
||||
flags:
|
||||
InteractiveFlag.pinchZoom |
|
||||
InteractiveFlag.drag |
|
||||
InteractiveFlag.pinchMove,
|
||||
),
|
||||
),
|
||||
children: [
|
||||
TileLayer(
|
||||
urlTemplate:
|
||||
'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
userAgentPackageName: 'com.example.app',
|
||||
),
|
||||
MarkerLayer(markers: marker),
|
||||
],
|
||||
),
|
||||
// ),
|
||||
// child: FutureBuilder(
|
||||
// future: mainEntries,
|
||||
// builder: (context, snapshot) {
|
||||
// if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
// return const CircularProgressIndicator();
|
||||
// } else if (snapshot.hasError) {
|
||||
// return Text("Error ${snapshot.error}");
|
||||
// } else {
|
||||
// if (snapshot.data != null) {
|
||||
// markers =
|
||||
// snapshot.data!.map((e) {
|
||||
// return Marker(
|
||||
// width: 80.0,
|
||||
// height: 80.0,
|
||||
// point: LatLng(
|
||||
// double.parse(e['DECLAT'].toString()),
|
||||
// double.parse(e['DECLNG'].toString()),
|
||||
// ),
|
||||
// child: Column(
|
||||
// children: [
|
||||
// const Icon(
|
||||
// Icons.location_on,
|
||||
// color: Colors.red,
|
||||
// ),
|
||||
// Text(
|
||||
// "ID: ${e['ID'].toString()}",
|
||||
// style: const TextStyle(color: Colors.black),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }).toList();
|
||||
// }
|
||||
// return FlutterMap(
|
||||
// options: MapOptions(
|
||||
// initialCenter:
|
||||
// markers.isEmpty
|
||||
// ? const LatLng(50, 10)
|
||||
// : markers.first.point,
|
||||
// interactionOptions: const InteractionOptions(
|
||||
// flags:
|
||||
// InteractiveFlag.pinchZoom |
|
||||
// InteractiveFlag.drag |
|
||||
// InteractiveFlag.pinchMove,
|
||||
// ),
|
||||
// ),
|
||||
// children: [
|
||||
// TileLayer(
|
||||
// urlTemplate:
|
||||
// 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
// userAgentPackageName: 'com.example.app',
|
||||
// ),
|
||||
// MarkerLayer(markers: markers),
|
||||
// ],
|
||||
// );
|
||||
// } // REMOVE
|
||||
// }, // REMOVE
|
||||
// ), // REMOVE
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user