feat(chat): keep the rail and chat list beside the open chat on wide windows

This commit is contained in:
2026-10-24 14:31:24 +01:00
parent fb481ad740
commit c7852d27d1
9 changed files with 343 additions and 21 deletions
+45 -5
View File
@@ -1,7 +1,10 @@
import '../../shell/destination.dart';
import '../../shell/detail_page.dart';
import '../../shell/list_detail.dart';
import '../../ui/adaptive/host.dart';
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../core/api_gateway.dart';
@@ -165,7 +168,7 @@ class _ChatScreenState extends State<ChatScreen> {
}
}
/// The open chat is a real page above the main screen at every window width.
/// On a phone the open chat is a real page above the main screen.
final DetailPageHost _page = DetailPageHost();
@override
@@ -200,11 +203,13 @@ class _ChatScreenState extends State<ChatScreen> {
@override
Widget build(BuildContext context) {
final selected = _selected;
// Chats are real Navigator pages at every width. Do not swap a conversation
// into the home page and manually emulate Back on tablets/foldables.
// A phone opens a chat as a real Navigator page with stock Back. A wide
// window keeps the destination rail and the chat list beside the open
// chat, which has no Back: another row, `/close` or a route change swaps it.
final beside = showsListBesideDetail(context);
_page.sync(
context,
selected: selected != null,
selected: selected != null && !beside,
destination: AppDestination.chat,
onClosed: _back,
builder: (context) => selected == null
@@ -221,6 +226,41 @@ class _ChatScreenState extends State<ChatScreen> {
activeSessionId: selected,
publishShellBar: true,
);
return list;
if (!beside) return list;
return ListDetailPanes(
list: list,
detail: selected == null
? const _NoChatSelected()
: DetailPane(
key: const ValueKey('chat-detail-pane'),
destination: AppDestination.chat,
implyBack: false,
builder: (context) => _thread(selected, _back),
),
);
}
}
/// The open-chat pane before any chat is chosen.
class _NoChatSelected extends StatelessWidget {
const _NoChatSelected();
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
cupertino
? CupertinoIcons.chat_bubble_2
: Icons.chat_bubble_outline,
),
const SizedBox(height: 12),
const Text('Select a chat to open it here.'),
],
),
);
}
}