diff --git a/app/SafeTrack/lib/screens/activity_log_screen.dart b/app/SafeTrack/lib/screens/activity_log_screen.dart index 28723b7..8431f97 100644 --- a/app/SafeTrack/lib/screens/activity_log_screen.dart +++ b/app/SafeTrack/lib/screens/activity_log_screen.dart @@ -198,6 +198,39 @@ class _ActivityLogScreenState extends State Future _refreshData() async => _loadActivities(); + Future _deleteLog(Map activity) async { + final confirmed = await showDialog( + context: context, + builder: (_) => AlertDialog( + title: const Text('Delete Log?'), + content: const Text('Remove this location entry from the log?'), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context, false), + child: const Text('Cancel'), + ), + TextButton( + onPressed: () => Navigator.pop(context, true), + child: const Text('Delete', style: TextStyle(color: Colors.red)), + ), + ], + ), + ); + if (confirmed != true) return; + final user = _auth.currentUser; + if (user == null) return; + await _databaseRef + .child('deviceLogs') + .child(user.uid) + .child(activity['deviceCode'] as String) + .child(activity['logId'] as String) + .remove(); + if (!mounted) return; + setState(() => _activities.removeWhere( + (a) => a['logId'] == activity['logId'], + )); + } + // ───────────────────────────────────────────────────────────────────────── // EXCEL EXPORT (unchanged) // ───────────────────────────────────────────────────────────────────────── @@ -679,6 +712,7 @@ class _ActivityLogScreenState extends State ), trailing: Icon(Icons.chevron_right, color: Colors.grey[400]), onTap: () => _showActivityDetails(activity), + onLongPress: () => _deleteLog(activity), ), ); }