From b6dc991f99b0b7b66f14de02541c0cbe96efbf3b Mon Sep 17 00:00:00 2001 From: nico Date: Wed, 1 May 2024 15:34:16 +0200 Subject: [PATCH] delete single entry function added --- Todo.txt | 4 +- fforte_data/.~lock.fforte_2023_08_15.xlsx# | 1 - lib/l10n/app_de.arb | 3 +- lib/l10n/app_en.arb | 5 ++ lib/viewCam/view_cams.dart | 61 +++++++++++++++------- 5 files changed, 51 insertions(+), 23 deletions(-) delete mode 100644 fforte_data/.~lock.fforte_2023_08_15.xlsx# diff --git a/Todo.txt b/Todo.txt index 523bad6..796c96a 100644 --- a/Todo.txt +++ b/Todo.txt @@ -1,9 +1,8 @@ todo: -im englischen abändern -einzelnen eintrag löschen sandorte ansehen in karte (extra tab) Platzierung garnix als standart aber pflichtfeld fix send file to server +im englischen abändern keine ahnung obs funktioniert: TEST SEND FILE TO SERVER FUNCTION @@ -11,6 +10,7 @@ eintrg in db wenn http response (in sent column) not to do: +einzelnen eintrag löschen zurückfeld in datenansicht maybe auch vorschläge aus templates in dropdown menüs anzeigen ausvon und ausbis fixen (falsches datum übergeben (20000-01-01)) diff --git a/fforte_data/.~lock.fforte_2023_08_15.xlsx# b/fforte_data/.~lock.fforte_2023_08_15.xlsx# deleted file mode 100644 index b398597..0000000 --- a/fforte_data/.~lock.fforte_2023_08_15.xlsx# +++ /dev/null @@ -1 +0,0 @@ -,nico,nico-end,01.05.2024 00:11,file:///home/nico/.config/libreoffice/7.3.1; \ No newline at end of file diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index eac3c74..fd21ac1 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -92,5 +92,6 @@ "savefilefailed": "Fehler. Bitte nochmal versuchen", "justplace": "Standort", "justsave": "Nur speichern", - "finishedentrie": "Bereits fertiger Eintrag" + "finishedentrie": "Bereits fertiger Eintrag", + "justdelete": "Löschen" } \ No newline at end of file diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 3827491..6e55266 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -447,6 +447,11 @@ "finishedentrie": "Already finished entrie", "@finishedentrie": { "description": "already finished entrie options dialog header" + }, + + "justdelete": "Delete", + "@justdelete": { + "description": "just delete action pane label" } } \ No newline at end of file diff --git a/lib/viewCam/view_cams.dart b/lib/viewCam/view_cams.dart index f15b3d7..9edf8c0 100644 --- a/lib/viewCam/view_cams.dart +++ b/lib/viewCam/view_cams.dart @@ -2,6 +2,7 @@ import 'package:fforte/addCam/add_cam_main.dart'; import 'package:fforte/other/db_helper.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_slidable/flutter_slidable.dart'; // * Site that shows all entries in the databases class ViewCams extends StatefulWidget { @@ -59,6 +60,13 @@ class _ViewCamsState extends State { }); } + void delSinglePlace(int id) async { + DBHelper().deletePlace(id.toString()); + setState(() { + place = DBHelper().getPlace(); + }); + } + void delAllTemplates() async { return showDialog( context: context, @@ -116,6 +124,7 @@ class _ViewCamsState extends State { } else if (snapshot.hasError) { return Text('Error: ${snapshot.error}'); } else { + List> placeList = List.of(snapshot.data!); return Scaffold( floatingActionButton: FloatingActionButton( child: const Icon(Icons.delete), @@ -146,27 +155,41 @@ class _ViewCamsState extends State { ), Expanded( child: ListView.builder( - itemCount: snapshot.data!.length, + itemCount: placeList.length, itemBuilder: (context, index) { - Map place = - snapshot.data![index]; - return ListTile( - title: Text('Standort ${index + 1}'), - subtitle: Text( - 'ID: ${place['CID']} DATUM: ${place['Datum']}'), - trailing: Checkbox( - value: place['Sent'] == 0 ? false : true, - onChanged: null, + Map place = snapshot.data![index]; + return Slidable( + startActionPane: ActionPane( + motion: const ScrollMotion(), + children: [ + SlidableAction( + onPressed: (context) { + delSinglePlace(place['ID'.toString()]); + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + icon: Icons.delete, + label: AppLocalizations.of(context)!.justdelete, + ) + ]), + child: ListTile( + title: Text('Standort ${index + 1}'), + subtitle: Text( + 'ID: ${place['ID']} DATUM: ${place['Datum']}'), + trailing: Checkbox( + value: place['Sent'] == 0 ? false : true, + onChanged: null, + ), + onTap: () async { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => AddCamMain( + isFinished: true, + existingData: place, + ))); + }, ), - onTap: () async { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => AddCamMain( - isFinished: true, - existingData: place, - ))); - }, ); }, ))