Repository navigation
FlexibleBottomSheet 0.4.0
Every open issue is closed in this release. The headline is a new rendering mode.
Inline sheet host
Until now the sheet was always rendered in a platform window of its own, an Android TYPE_APPLICATION_PANEL or a Popup elsewhere. A separate window is always above the app, owns its own text selection context, its own popup coordinate origin and its own touch region, which is the single root cause behind ten of the reports below.
FlexibleSheetHost.Inline renders the sheet inside the composition that declared it instead:
val sheetState = rememberFlexibleBottomSheetState(
sheetHost = FlexibleSheetHost.Inline,
isModal = false,
)
Box(modifier = Modifier.fillMaxSize()) {
MapContent()
FlexibleBottomSheet(onDismissRequest = { }, sheetState = sheetState) {
LocationDetails()
}
}An inline sheet behaves like any other composable. It layers by composition order, so anything composed after it draws above it. It is confined to its parent, so a sheet in Scaffold content stops above the bottom bar. It shares the host window, so a TextField gets the normal copy and paste toolbar and dropdowns anchor correctly. A non modal inline sheet only receives the touches that actually land on it.
FlexibleSheetHost.Window remains the default, so existing behavior is unchanged unless you opt in. Full guide: https://skydoves.github.io/FlexibleBottomSheet/sheet-host/
Resolves #75, #71, #70, #63, #66, #50, #37, #20, #98 and #97.
Fixes
- Non modal sheets no longer jump and animate back when a drag starts. The
FullyExpandedanchor was derived from the measured sheet height, so it collapsed onto the resting state's anchor and every anchor moved at once when the container grew. (#68, #67) - The scrim no longer flickers on a fast dismiss fling. Its alpha now follows the live sheet offset instead of cross fading a boolean through a tween that a fling restarts. (#59)
- A dismissed but still composed sheet no longer swallows the touches, key events and IME requests meant for the content behind it. (#15)
- Back no longer crashes a sheet created with
skipHiddenState = true, and is no longer consumed by a sheet that cannot act on it. The sheet window also adopts a newonDismissRequestinstead of holding the one captured during its first composition. (#92) - The software keyboard reaches the sheet window, and a modal sheet now resizes with it instead of losing the whole keyboard height on top of its own share. (#16)
Behavior changes
- Binary incompatible.
FlexibleSheetState's constructor andrememberFlexibleBottomSheetStategained asheetHostparameter. Source compatible, but dependents need to recompile. - The modal scrim now fades with the sheet's own animation spec rather than a fixed 300ms tween, and no longer changes at all between two visible states.
onBackPressedfires after the state change inflexible-bottomsheet-material, matchingflexible-bottomsheet-material3. It previously fired first.- A sheet with nowhere left to collapse to and no hidden state no longer claims the back gesture, so back reaches the host instead of doing nothing.
sheetPaddingsmeasures against the same basis as the sheet. A window hosted modal sheet withcontainSystemBars = false,fullyExpandedbelow 1.0 and the keyboard open getsime * (1 - fullyExpanded)less bottom padding than before.
Known limitations
- An inline sheet fills its container, so place it in a
Boxwith a bounded height. In aColumnorRowit takes the remaining space from its siblings, and in a scrollable parent it falls back to the screen height and logs a warning. OnBackPressedDispatcherinvokes callbacks last registered first, so a navigation host composed after an inline sheet takes back before it. A window hosted sheet always wins.- A window hosted sheet dismisses on Escape on desktop, because its
PopupsetsdismissOnBackPress. An inline sheet has no window to carry that. - For window hosted sheets the sizing basis is the configuration height, which excludes the system bars, while the sheet's window includes them. That leaves a system bar sized disagreement.
Testing
The library went from 20 to 60 automated tests, plus 9 Android instrumented tests. CI now runs the unit and Compose UI suites, which it previously did not run at all.
The inline host resolves #63, #66, #50 and #97 by removing the separate window, and that reasoning is verified on Android for layering and touch. The text selection toolbar, popup placement and the iOS safe area case were not individually re-run on a device. Please reopen those issues if they persist.
Thanks
To everyone who reported these, and in particular to those who dug into the cause themselves.