Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions app/SafeTrack/lib/screens/activity_log_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,39 @@ class _ActivityLogScreenState extends State<ActivityLogScreen>

Future<void> _refreshData() async => _loadActivities();

Future<void> _deleteLog(Map<String, dynamic> activity) async {
final confirmed = await showDialog<bool>(
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)
// ─────────────────────────────────────────────────────────────────────────
Expand Down Expand Up @@ -679,6 +712,7 @@ class _ActivityLogScreenState extends State<ActivityLogScreen>
),
trailing: Icon(Icons.chevron_right, color: Colors.grey[400]),
onTap: () => _showActivityDetails(activity),
onLongPress: () => _deleteLog(activity),
),
);
}
Expand Down