Eslam Hussein
03/25/2025, 12:53 PMWebView
inside a ModalBottomSheet
using Jetpack Compose and could use some guidance on managing the scroll behavior.
Here’s what I’m aiming for:
1. When the bottom sheet is half-expanded and the user scrolls up inside the WebView, the sheet should expand to full height.
2. When the sheet is fully expanded and the user scrolls down (with the WebView at the top), it should collapse back to half-expanded.
3. WebView should scroll smoothly when the sheet is fully expanded, without being blocked by the sheet.
4. The sheet should still be draggable to dismiss when fully expanded.
5. I need to track the WebView’s scroll position to trigger expansion or collapse accordingly.
Has anyone tackled something similar? Any ideas or tips on how to coordinate the scroll behavior between WebView and the bottom sheet in Compose?
Thanks in advance! 🙏
@Composable
internal fun MapDrawerWebSheetDialog(
modifier: Modifier = Modifier,
url: String
) {
val sheetState = rememberModalBottomSheetState(
skipPartiallyExpanded = false
)
BackHandler(
onBack = {
CommunityPlugin.navigator?.popBackStack()
}
)
ModalBottomSheetWrapper(
onDismissRequest = { CommunityPlugin.navigator?.popBackStack()},
shouldDismissOnBackPress = true,
sheetState = sheetState,
modifier = Modifier.fillMaxSize()
) {
val lazyListState = rememberLazyListState()
LazyColumn(
state = lazyListState,
modifier = Modifier.fillMaxSize()
) {
item {
AndroidView(
factory = { ctx ->
WebView(ctx).apply {
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
applySettings()
webViewClient = WebViewClient()
isHorizontalScrollBarEnabled = true
overScrollMode = WebView.OVER_SCROLL_IF_CONTENT_SCROLLS
loadUrl(url)
}
},
modifier = Modifier
.fillMaxSize()
)
}
}
}
}
Zach Klippenstein (he/him) [MOD]
03/25/2025, 3:56 PMZach Klippenstein (he/him) [MOD]
03/25/2025, 3:56 PMColton Idle
03/26/2025, 8:05 PMEslam Hussein
03/27/2025, 7:25 AM