Open active chat when Chat is reselected
Route destination re-selections through the adaptive shell so Chat can restore its retained workspace and focus the composer. Add shell and phone coverage plus implementation notes for the empty-list behavior and verification limits.
This commit is contained in:
@@ -21,6 +21,7 @@ class AdaptiveShell extends StatefulWidget {
|
||||
this.destinationBodies = const {},
|
||||
this.destination,
|
||||
this.onDestinationSelected,
|
||||
this.onDestinationReselected,
|
||||
this.onClosePage,
|
||||
this.onSearch,
|
||||
this.onOpenChat,
|
||||
@@ -43,6 +44,11 @@ class AdaptiveShell extends StatefulWidget {
|
||||
/// selection, which preserves the plain-shell tests and native composition.
|
||||
final AppDestination? destination;
|
||||
final ValueChanged<AppDestination>? onDestinationSelected;
|
||||
|
||||
/// Runs when a destination's control is tapped while that destination is
|
||||
/// already shown (a re-select). The host decides what it means; Chat reopens
|
||||
/// its active chats. Null keeps re-selects as plain selections.
|
||||
final ValueChanged<AppDestination>? onDestinationReselected;
|
||||
final VoidCallback? onClosePage;
|
||||
|
||||
/// Opens the transient Search page. Null hides the action, so the plain
|
||||
@@ -105,6 +111,18 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
}
|
||||
}
|
||||
|
||||
/// The entry every tab control calls when tapped: a destination shown
|
||||
/// already is re-selected (see [AdaptiveShell.onDestinationReselected]), any
|
||||
/// other is selected.
|
||||
void _tapDestination(AppDestination destination) {
|
||||
final reselected = widget.onDestinationReselected;
|
||||
if (destination == _selected && reselected != null) {
|
||||
reselected(destination);
|
||||
return;
|
||||
}
|
||||
_select(destination);
|
||||
}
|
||||
|
||||
void _select(AppDestination destination) {
|
||||
final callback = widget.onDestinationSelected;
|
||||
if (callback != null) {
|
||||
@@ -201,7 +219,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
child: FloatingDestinationBar(
|
||||
showLabels: true,
|
||||
currentIndex: index,
|
||||
onTap: (value) => _select(shellTabDestinations[value]),
|
||||
onTap: (value) => _tapDestination(shellTabDestinations[value]),
|
||||
items: _destinationItems(),
|
||||
alignment: split ? AlignmentDirectional.bottomStart : null,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user