LayeredDialogSessions

Does the bulk of the work of maintaining a set of Dialogs to reflect lists of Overlay, constrained to cover only the bounds of a single View. This is the work modeled by BodyAndOverlaysScreen and executed by BodyAndOverlaysContainer. This class is public to allow implementation of custom Overlay-based layouts if BodyAndOverlaysContainer is too restrictive.

Supports recursion (e.g. nesting a smaller BodyAndOverlaysScreen in the body field of another) by sharing a single DialogCollator instance across multiple instances of LayeredDialogSessions. See DialogCollator for details.

Lifecycle of a managed Dialog

When update is called with an Overlay that is not Compatible with an existing Dialog, the appropriate OverlayDialogFactory instance is fetched from the ViewEnvironment. That factory builds (but does not show) a new Dialog, wrapped in an OverlayDialogHolder. The holder in turn is held by a DialogSession instance. There is a 1:1:1 relationship between the Dialog, the OverlayDialogHolder which can update it, and the DialogSession that manages its LifecycleOwner and persistence.

When a new DialogSession begins:

The DialogSession is maintained (and its two flavors of View state are recorded as prompted by the Android runtime) so long as update is called with a Compatible rendering.

When update is called without a matching Overlay, or the parent Lifecycle ends, the DialogSession ends, its LifecycleOwner is destroyed, and the Dialog is dismissed.

Parameters

bounds

made available to managed dialogs via the ViewEnvironmentKeycom.squareup.workflow1.ui.ViewEnvironmentKey, which drives OverlayDialogHolder.onUpdateBounds.

cancelEvents

function to be called when a modal session starts -- that is, when update is first called with a ModalOverlay member, or called again with one after calls with none.

getParentLifecycleOwner

provides the LifecycleOwner to serve as an ancestor to those created for managed Dialogs.

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Properties

Link copied to clipboard

While this is true, clients should ignore UI events targeting the body view beneath the Dialog windows they manage. It reflects that a ModalOverlay is (or soon will be) showing over the body.

Functions

Link copied to clipboard
fun onAttachedToWindow(savedStateParentKey: String, view: View)

Must be called whenever the owning view is attached to a window. Must eventually be matched with a call to onDetachedFromWindow.

Link copied to clipboard

Must be called whenever the owning view is detached from a window. Must be matched with a call to onAttachedToWindow.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun update(overlays: List<Overlay>, viewEnvironment: ViewEnvironment, updateBody: (environment: ViewEnvironment) -> Unit)

Updates the managed set of Dialog instances to reflect overlays. Opens new dialogs, updates existing ones, and dismisses those that match no member of that list.