ThreePaneScaffoldNavigator
@ExperimentalMaterial3AdaptiveApi
interface ThreePaneScaffoldNavigator<T>
The common interface of the default navigation implementations for different ThreePaneScaffold
.
In general, we suggest you to use rememberListDetailPaneScaffoldNavigator
or
rememberSupportingPaneScaffoldNavigator
to get remembered default instances of this interface
for ListDetailPaneScaffold
and SupportingPaneScaffold
, respectively. Those default
implementations work independently from any navigation frameworks.
If you need to integrate with existing navigation frameworks or implement your own custom navigation logic, usually creating whole new APIs that's tailored for your own solution will be recommended, instead of implementing this interface. But we recommend you refer to the API design and the default implementation to get better understanding and address the intricacies of navigation in an adaptive scenario.
This type must be storable in a Bundle.
Parameters
T | the type representing the content (or id of the content) for a navigation destination. |
Properties
val scaffoldState: ThreePaneScaffoldState
The current scaffold state provided by the navigator.
Implementors of this interface should ensure this value is updated whenever a navigation operation is performed.
val currentDestination: ThreePaneScaffoldDestinationItem<T>?
The current destination as tracked by the navigator.
Implementors of this interface should ensure this value is updated whenever a navigation operation is performed.
var isDestinationHistoryAware: Boolean
Indicates if the navigator should be aware of pane destination history when deciding the
result ThreePaneScaffoldValue
by a navigation operation. If the value is false
, only
the current destination will be considered in the scaffold value calculation.
Functions
fun navigateTo(pane: ThreePaneScaffoldRole, content: T? = null)
Navigates to a new destination. The new destination is supposed to have the highest
priority when calculating the new scaffoldState
. When implementing this method, please
ensure the new destination pane will be expanded or adapted in a reasonable way so it
provides users the sense that the new destination is the pane under current usage.
destination.
Parameters
pane | the new destination pane. |
content | the optional content, or an id representing the content of the new |
fun canNavigateBack(
backNavigationBehavior: BackNavigationBehavior =
BackNavigationBehavior.PopUntilScaffoldValueChange
): Boolean
Returns true
if there is a previous destination to navigate back to.
Implementors of this interface should ensure the logic of this function is consistent with
navigateBack
.
during the back navigation. See BackNavigationBehavior
.
Parameters
backNavigationBehavior | the behavior describing which backstack entries may be skipped |
fun navigateBack(
backNavigationBehavior: BackNavigationBehavior =
BackNavigationBehavior.PopUntilScaffoldValueChange
): Boolean
Navigates to the previous destination. Returns true
if there is a previous destination to
navigate back to. When implementing this function, please make sure the logic is consistent
with canNavigateBack
.
Implementors of this interface should ensure the logic of this function is consistent with
canNavigateBack
.
during the back navigation. See BackNavigationBehavior
.
Parameters
backNavigationBehavior | the behavior describing which backstack entries may be skipped |