fixed delete in view_app. Also some other things but i forgot everything
This commit is contained in:
@@ -5,6 +5,7 @@ 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';
|
||||
@@ -25,11 +26,11 @@ class _ViewCamsState extends State<ViewCams> {
|
||||
late Future<List<Map<String, dynamic>>> mainEntries;
|
||||
late Future<List<Map<String, dynamic>>> templates;
|
||||
late List<Marker> markers;
|
||||
IDb? db;
|
||||
|
||||
// loads the entries
|
||||
@override
|
||||
void initState() {
|
||||
IDb? db;
|
||||
super.initState();
|
||||
if (widget.dbType == DatabasesEnum.place) {
|
||||
db = PlaceDBHelper();
|
||||
@@ -37,8 +38,12 @@ class _ViewCamsState extends State<ViewCams> {
|
||||
db = ExcursionDBHelper();
|
||||
}
|
||||
|
||||
reloadAllEntries();
|
||||
}
|
||||
|
||||
Future<void> reloadAllEntries() async {
|
||||
mainEntries = db!.getAllMainEntries();
|
||||
templates = db.getAllTemplates();
|
||||
templates = db!.getAllTemplates();
|
||||
}
|
||||
|
||||
// The widet tree with taps to differentiate between templates and finished entries
|
||||
@@ -89,24 +94,24 @@ class _ViewCamsState extends State<ViewCams> {
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline),
|
||||
AppLocalizations.of(context)!.placedata),
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
AppLocalizations.of(context)!.placedata,
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline),
|
||||
AppLocalizations.of(context)!.sent),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
AppLocalizations.of(context)!.sent,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -128,6 +133,9 @@ class _ViewCamsState extends State<ViewCams> {
|
||||
widget.dbType,
|
||||
place['ID'.toString()],
|
||||
);
|
||||
setState(() {
|
||||
reloadAllEntries();
|
||||
});
|
||||
},
|
||||
backgroundColor: Colors.red,
|
||||
foregroundColor: Colors.white,
|
||||
@@ -158,7 +166,6 @@ class _ViewCamsState extends State<ViewCams> {
|
||||
place['Sent'] == 1
|
||||
? true
|
||||
: false,
|
||||
isFinished: true,
|
||||
existingData: place,
|
||||
),
|
||||
),
|
||||
@@ -203,23 +210,47 @@ class _ViewCamsState extends State<ViewCams> {
|
||||
itemBuilder: (context, index) {
|
||||
Map<String, dynamic> templates =
|
||||
snapshot.data![index];
|
||||
return ListTile(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder:
|
||||
(context) => AddCamMain(
|
||||
isTemplate: true,
|
||||
isFinished: false,
|
||||
existingData: templates,
|
||||
),
|
||||
return Slidable(
|
||||
startActionPane: ActionPane(
|
||||
motion: const ScrollMotion(),
|
||||
children: [
|
||||
SlidableAction(
|
||||
onPressed: (context) {
|
||||
DeleteTemplates.deleteSingle(
|
||||
widget.dbType,
|
||||
templates['ID'].toString(),
|
||||
);
|
||||
setState(() {
|
||||
reloadAllEntries();
|
||||
});
|
||||
},
|
||||
backgroundColor: Colors.red,
|
||||
foregroundColor: Colors.white,
|
||||
icon: Icons.delete,
|
||||
label:
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
)!.justdelete,
|
||||
),
|
||||
);
|
||||
},
|
||||
title: Text('Place ${index + 1}'),
|
||||
subtitle: Text(
|
||||
'ID: ${templates['CID']} DATUM: ${templates['Datum']} RUDEL: ${templates['Rudel']} STATUS: ${templates['Status']}',
|
||||
],
|
||||
),
|
||||
child: ListTile(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder:
|
||||
(context) => AddCamMain(
|
||||
isTemplate: true,
|
||||
existingData: templates,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
title: Text('Place ${index + 1}'),
|
||||
subtitle: Text(
|
||||
'ID: ${templates['CID']} DATUM: ${templates['Datum']} RUDEL: ${templates['Rudel']} STATUS: ${templates['Status']}',
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -241,29 +272,31 @@ class _ViewCamsState extends State<ViewCams> {
|
||||
} else if (snapshot.hasError) {
|
||||
return Text("Error ${snapshot.error}");
|
||||
} else {
|
||||
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();
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user