Skip to content
Merged
Show file tree
Hide file tree
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
Binary file added analyze_out_new.txt
Binary file not shown.
7 changes: 7 additions & 0 deletions lib/constants/colours.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ final functionsBackgroundColor = Colors.white;
const instructionsBarColor = Colors.transparent;
const instructionsUnselectedColor = Colors.grey;

<<<<<<< feature/delete-all-history-65
const border = Color(0xFFF5E0C8);

/// A color for error messages or destructive actions.
const error = Colors.redAccent;
=======
final historyIncidentalColor = Colors.grey[600];
const historyDeleteColor = Colors.redAccent;
final historyNoneColor = Colors.grey.withValues(alpha: 0.5);
>>>>>>> dev
81 changes: 81 additions & 0 deletions lib/widgets/history.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import 'package:solidui/solidui.dart';

import 'package:innerpod/constants/colours.dart';
import 'package:innerpod/utils/session_logic.dart';
import 'package:innerpod/constants/colours.dart' as colours;

class History extends StatefulWidget {
const History({super.key});
Expand Down Expand Up @@ -139,6 +140,8 @@ class _HistoryState extends State<History> {
ElevatedButton(
onPressed: () => Navigator.pop(context, true),
style: ElevatedButton.styleFrom(
backgroundColor: colours.error.withValues(alpha: 0.1),
foregroundColor: colours.error,
elevation: 0,
),
child: const Text('Delete'),
Expand Down Expand Up @@ -181,6 +184,70 @@ class _HistoryState extends State<History> {
}
}

Future<void> _deleteAllSessions() async {
final confirmed = await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
title: const Text('Delete All Sessions'),
content: const Text(
'Are you sure you want to delete ALL sessions? This action cannot be undone.',
style: TextStyle(fontSize: 16),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('Cancel'),
),
ElevatedButton(
onPressed: () => Navigator.pop(context, true),
style: ElevatedButton.styleFrom(
backgroundColor: colours.error.withValues(alpha: 0.1),
foregroundColor: colours.error,
elevation: 0,
),
child: const Text('Delete All'),
),
],
),
);

if (confirmed == true) {
await _performDeleteAll();
}
}

Future<void> _performDeleteAll() async {
setState(() => _isLoading = true);
try {
final newContent = serializeSessions([]);
await writePod(
'sessions.ttl',
newContent,
overwrite: true,
);
await _loadSessions();
} on SecurityKeyNotAvailableException {
debugPrint(
'Security key missing - cannot write sessions.ttl for bulk deletion',
);
if (mounted) {
await getKeyFromUserIfRequired(context, widget);
if (mounted) {
await _performDeleteAll();
}
}
} catch (e) {
debugPrint('Error deleting all sessions: $e');
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Failed to delete all sessions: $e')),
);
}
} finally {
if (mounted) setState(() => _isLoading = false);
}
}

Future<void> _editSession(Map<String, String> session) async {
final titleController = TextEditingController(text: session['title']);
final descriptionController =
Expand Down Expand Up @@ -278,8 +345,18 @@ class _HistoryState extends State<History> {
title: const Text('Session History'),
automaticallyImplyLeading: false, // Don't show back button
actions: [
if (_sessions.isNotEmpty)
IconButton(
icon: const Icon(
Icons.delete_sweep_outlined,
color: colours.error,
),
tooltip: 'Delete all sessions',
onPressed: _deleteAllSessions,
),
IconButton(
icon: const Icon(Icons.refresh),
tooltip: 'Refresh',
onPressed: _loadSessions,
),
const SizedBox(width: 8),
Expand Down Expand Up @@ -407,7 +484,11 @@ class _HistoryState extends State<History> {
icon: const Icon(
Icons.delete_outline,
size: 20,
<<<<<<< feature/delete-all-history-65
color: colours.error,
=======
color: historyDeleteColor,
>>>>>>> dev
),
onPressed: () =>
_deleteSession(session['rawStart']!),
Expand Down
Loading