Close the phone chat page explicitly from its Back button
The chat page's Back had no handler and relied on the stock Back popping the nearest route, while the system gesture went through the app's own back handling. Back now pops the page's own route (or leaves the open chat), the same path the gesture takes.
This commit is contained in:
@@ -349,6 +349,8 @@ class _ChatScreenState extends State<ChatScreen>
|
||||
/// On a phone the open chat is a real page above the main screen.
|
||||
final DetailPageHost _page = DetailPageHost();
|
||||
|
||||
void _closeChat() => _page.open ? _page.close() : _back();
|
||||
|
||||
/// The list rows the phone's chat page grows from and shrinks back into:
|
||||
/// the open chat's row, also after the page switched to another chat.
|
||||
final ContainerTransformSources _rowSources = ContainerTransformSources();
|
||||
@@ -410,13 +412,15 @@ class _ChatScreenState extends State<ChatScreen>
|
||||
sessionId: selected,
|
||||
placement: ChatPanePlacement(
|
||||
syncToken: widget.syncToken,
|
||||
onBack: _back,
|
||||
// Back from a chat page pops that page itself (its completion runs
|
||||
// [_back]); otherwise it leaves the open chat directly. The button
|
||||
// never falls back to popping whichever route is nearest.
|
||||
onBack: _closeChat,
|
||||
onNewSession: _startedNewSession,
|
||||
onSessionClosed: () => _closed(selected),
|
||||
onNextChat: _nextAfter(selected) != null
|
||||
? () => _openNext(selected)
|
||||
: null,
|
||||
useNativeBack: _page.open,
|
||||
pasteTarget: _workspaceVisible && pane.id == _workspace.activePaneId,
|
||||
showBackButton: _page.open || !showsListBesideDetail(context),
|
||||
paneCommands: _paneCommands,
|
||||
|
||||
Reference in New Issue
Block a user