Skip to content

Commit

Permalink
Add parameter to handle bottom sheet header view (#314)
Browse files Browse the repository at this point in the history
Co-authored-by: Siddharth Agarwal <[email protected]>
  • Loading branch information
siddh1004 and Siddharth Agarwal authored Oct 11, 2024
1 parent 647f86a commit 668a98d
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ fun BottomSheetShell(
headerTextAlignment: TextAlign = TextAlign.Center,
scrollableContainerMinHeight: Dp = Spacing0,
scrollableContainerMaxHeight: Dp = InternalSizeValues.Size386,
animateHeaderOnKeyboardAppearance: Boolean = true,
onSearchQueryChanged: ((String) -> Unit)? = null,
onSearch: ((String) -> Unit)? = null,
onDismiss: () -> Unit,
Expand All @@ -175,7 +176,15 @@ fun BottomSheetShell(
val keyboardState by keyboardAsState()

var isKeyboardOpen by remember { mutableStateOf(false) }
val showHeader by remember { derivedStateOf { !title.isNullOrBlank() && !isKeyboardOpen } }
val showHeader by remember {
derivedStateOf {
if (animateHeaderOnKeyboardAppearance) {
!title.isNullOrBlank() && !isKeyboardOpen
} else {
!title.isNullOrBlank()
}
}
}

LaunchedEffect(keyboardState) {
isKeyboardOpen = keyboardState == Keyboard.Opened
Expand Down

0 comments on commit 668a98d

Please sign in to comment.