SceneStrategy


public fun interface SceneStrategy<T extends Object>

Known direct subclasses
DialogSceneStrategy

A SceneStrategy that displays entries that have added dialog to their NavEntry.metadata within a Dialog instance.

SinglePaneSceneStrategy

A SceneStrategy that always creates a 1-entry Scene simply displaying the last entry in the list.


A strategy that tries to calculate a Scene given a list of NavEntrys or another Scene.

Summary

Public methods

abstract Scene<@NonNull T>
calculateScene(
    @NonNull SceneStrategyScope<@NonNull T> receiver,
    @NonNull List<@NonNull NavEntry<@NonNull T>> entries
)

Given a SceneStrategyScope, calculate whether this SceneStrategy should take on the task of rendering one or more of the entries in the scope.

default @NonNull Scene<@NonNull T>
decorateScene(
    @NonNull SceneStrategyScope<@NonNull T> receiver,
    @NonNull Scene<@NonNull T> scene
)

Decorates the given Scene.

default @NonNull SceneStrategy<@NonNull T>
then(@NonNull SceneStrategy<@NonNull T> sceneStrategy)

Chains this SceneStrategy with another sceneStrategy to return a combined SceneStrategy.

Public methods

calculateScene

Added in 1.0.0
abstract Scene<@NonNull T> calculateScene(
    @NonNull SceneStrategyScope<@NonNull T> receiver,
    @NonNull List<@NonNull NavEntry<@NonNull T>> entries
)

Given a SceneStrategyScope, calculate whether this SceneStrategy should take on the task of rendering one or more of the entries in the scope.

By returning a non-null Scene, your Scene takes on the responsibility of rendering the set of entries you declare in Scene.entries. If you return null, the next available SceneStrategy will be called.

Parameters
@NonNull List<@NonNull NavEntry<@NonNull T>> entries

The entries on the back stack that should be considered valid to render via a returned Scene.

decorateScene

Added in 1.1.0-alpha03
default @NonNull Scene<@NonNull T> decorateScene(
    @NonNull SceneStrategyScope<@NonNull T> receiver,
    @NonNull Scene<@NonNull T> scene
)

Decorates the given Scene.

The newly returned Scene may or may not include the content of the given scene.

This will always return a non-null Scene because a Scene returned by calculateScene passes through every SceneStrategy linked by then. So if a SceneStrategy does not want to decorate the scene, it should just return the passed in scene.

Parameters
@NonNull Scene<@NonNull T> scene

The scene to be decorated

then

Added in 1.0.0
default @NonNull SceneStrategy<@NonNull T> then(@NonNull SceneStrategy<@NonNull T> sceneStrategy)

Chains this SceneStrategy with another sceneStrategy to return a combined SceneStrategy. For the returned SceneStrategy, calculateScene will use the first non-null result from the calculation, while the decorateScene will be called for every SceneStrategy in the chain.

For SceneStrategys that wish to be calculated with another scene, the calling SceneStrategy is first and the given SceneStrategy receives the result of the calculation. This means that the result is cumulative, with each consecutive SceneStrategy using the result of the previous one.