[Navigation Material] (0.29.0-alpha) With BottomSheetNavigator.navigatorSheetState.offset removed, there doesn't seem to be a way to access sheet offset/position
Description
We were using bottomSheetNavigator.navigatorSheetState.offset.value to reposition a "sticky" content view inside the content.
Is this a wrong approach or is there a way to derive this with the new update? :)
Steps to reproduce
bottomSheetNavigator.navigatorSheetState.offset annotated as error now.
Expected behavior Handle to access the BottomSheets current offset/drag position on screen.
Additional context None
@MarcLFJ Do you have a code example of what you were doing before, and possibly a mockup of the use case?
@jossiwolf Sorry about the delayed reply, our intention is to have a button be sticky to the bottom of the window, so if the sheet starts half expanded, the button is still visible and when the user drags the sheet to top, the footer sticks to the bottom of the window.
Here is a barebone example of what we were doing in 0.28.0, let me know if it's too barebone. 😅
@OptIn(ExperimentalMaterialNavigationApi::class)
@Composable
fun SheetWithSticky(
bottomSheetNavigator: BottomSheetNavigator,
stickyFooter: (@Composable () -> Unit)? = null,
content: @Composable () -> Unit
) {
val bottomSheetOffset = bottomSheetNavigator.navigatorSheetState.offset.value
var stickyContainerHeight by remember { mutableStateOf(0) }
Box(
Modifier.heightIn(max = LocalConfiguration.current.screenHeightDp.dp)
) {
Column(
// Ensure content is padded above sticky footer height
modifier = Modifier.padding(
bottom = with(LocalDensity.current) { stickyContainerHeight.toDp() }
)
) {
/*Generic header view and other views here ...*/
content()
}
stickyFooter?.let { footer ->
Box(
modifier = Modifier
.onGloballyPositioned { stickyContainerHeight = it.size.height }
.offset { IntOffset(0, -bottomSheetOffset.toInt()) }
.align(Alignment.BottomCenter)
) {
footer()
}
}
}
}
Edited screenshot from design:

Using the following accompanist dependencies:
com.google.accompanist:accompanist-navigation-material
and Material3: androidx.compose.material3:material3:1.1.0-alpha03
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
@jossiwolf Any update on this? :) Is it not an intended usecase or is there a better way? Mainly the problem trying to be solved is listening to the actual offset position of the bottomsheet and react to it. 👍
Same issue here, but a different usecase. Want to animate certain elements of the layout based on the sheet offset to create a smooth animation
Same issue here
This looks like a really important feature, should provide some way to migrate, not the best way to downgrade Compose version.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Not stale
While we're all waiting for Google for a solution, I came with a super ugly hack to make offset work in newer Compose version, since I cannot wait for this as all dependencies are going to get outdated.
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@OptIn(ExperimentalMaterialNavigationApi::class, ExperimentalMaterialApi::class)
fun BottomSheetNavigatorSheetState.getOffset() = sheetState.requireOffset()
Hope this helps people in this thread.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Not stale
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
.
.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
.
How is this closed if I left a comment
@jossiwolf Please reopen. Not only is this bot annoying, it also doesn't work correctly
@ianhanniballake Could you reopen, since this was referred in #1582 as being the issue to track progress on. :)
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Hello, has what's the state of this issue, if some work pr research has been done on it?
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
var offset = Float.POSITIVE_INFINITY try { offset = sheetState.requireOffset() } catch (e: IllegalStateException) { log.d("MODAL BOTTOM SHEET", "${e.printStackTrace()}") } // offset is 1568.9 val outside = it.y < offset this works for me
With the release of Compose Material 1.7.0-alpha04, the Material team has added a new artifact: androidx.compose.material:material-navigation, which fully replaces Accompanist Navigation Material.
As such, we are closing all issues here on Accompanist and will be fully deprecating Accompanist Navigation Material in an upcoming release.
This issue was not fixed as part of the migration, so if you're still interested in this, please file an issue and the Material team will take a look.
Include the link here so that others can star it!