fix(chat): use stock Navigator Back at every screen width
This commit is contained in:
@@ -846,7 +846,6 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
final title = widget.title.trim();
|
||||
return ShellBar(
|
||||
title: title.isEmpty ? null : title,
|
||||
onBack: widget.onBack,
|
||||
actions: [
|
||||
if (hasModel)
|
||||
ConstrainedBox(
|
||||
|
||||
@@ -165,7 +165,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
/// The open chat is its own page over the tabs on a phone.
|
||||
/// The open chat is a real page above the main screen at every window width.
|
||||
final DetailPageHost _page = DetailPageHost();
|
||||
|
||||
@override
|
||||
@@ -200,12 +200,11 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final selected = _selected;
|
||||
// On a phone an open chat is its own page over the tabs; a wide window
|
||||
// keeps it in the tab, beside the destination rail.
|
||||
final narrow = MediaQuery.sizeOf(context).width < kDetailPageMaxWidth;
|
||||
// Chats are real Navigator pages at every width. Do not swap a conversation
|
||||
// into the home page and manually emulate Back on tablets/foldables.
|
||||
_page.sync(
|
||||
context,
|
||||
selected: selected != null && narrow,
|
||||
selected: selected != null,
|
||||
destination: AppDestination.chat,
|
||||
onClosed: _back,
|
||||
builder: (context) => selected == null
|
||||
@@ -220,14 +219,8 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
onOpen: _open,
|
||||
onSessions: _adoptRows,
|
||||
activeSessionId: selected,
|
||||
publishShellBar: narrow || selected == null,
|
||||
);
|
||||
if (narrow) return list;
|
||||
return Stack(
|
||||
children: [
|
||||
Offstage(offstage: selected != null, child: list),
|
||||
if (selected != null) _thread(selected, _back),
|
||||
],
|
||||
publishShellBar: true,
|
||||
);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user