This repository has been archived on 2026-06-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
FabledApp/lib/screens/notes/note_detail_screen.dart
T
bvandeusen 45768e9bb8 Add master-detail layout for Notes and Chat on wide screens
On screens ≥600dp, Notes and Chat show a two-pane layout:
- Left pane (300dp): scrollable list with selection highlight
- Right pane: inline detail (NoteDetailScreen / ChatScreen)

Tapping a list item selects it in wide mode instead of pushing a route.
Creating a new conversation on wide screen auto-selects it in the pane.
Deleting a selected note/conversation clears the right pane.
NoteDetailScreen gains an optional onDeleted callback used by the
embedded pane to clear selection rather than call context.pop().
Tasks keep push-based navigation (edit form has save/pop semantics
that require a full-screen context).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-01 12:48:45 -05:00

79 lines
2.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import '../../core/constants.dart';
import '../../providers/notes_provider.dart';
class NoteDetailScreen extends ConsumerWidget {
final int noteId;
// Provided when embedded in master-detail: called instead of context.pop().
final VoidCallback? onDeleted;
const NoteDetailScreen({super.key, required this.noteId, this.onDeleted});
@override
Widget build(BuildContext context, WidgetRef ref) {
final noteAsync = ref.watch(noteDetailProvider(noteId));
return Scaffold(
appBar: AppBar(
title: noteAsync.maybeWhen(
data: (n) => Text(n.title),
orElse: () => const Text('Note'),
),
actions: [
noteAsync.maybeWhen(
data: (note) => Row(
children: [
IconButton(
icon: const Icon(Icons.edit),
onPressed: () => context.push(
Routes.noteEdit.replaceFirst(':id', '$noteId'),
),
),
IconButton(
icon: const Icon(Icons.delete),
onPressed: () async {
final confirm = await showDialog<bool>(
context: context,
builder: (_) => AlertDialog(
title: const Text('Delete note?'),
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('Cancel'),
),
TextButton(
onPressed: () => Navigator.pop(context, true),
child: const Text('Delete'),
),
],
),
);
if (confirm == true) {
await ref.read(notesProvider.notifier).delete(noteId);
if (context.mounted) {
onDeleted != null ? onDeleted!() : context.pop();
}
}
},
),
],
),
orElse: () => const SizedBox.shrink(),
),
],
),
body: noteAsync.when(
loading: () => const Center(child: CircularProgressIndicator()),
error: (e, _) => Center(child: Text('Error: $e')),
data: (note) => Markdown(
data: note.body,
selectable: true,
),
),
);
}
}