Programmer123
Programmer123

Reputation: 123

Fixed footer in Bottomsheet Compose

I'm trying to add a fixed button at the bottom of compose bottomsheet. The button should be visible at all times in collapsed state and should stay static at the bottom as the user slides up through the sheet.

Sample behavior: https://medium.com/@KaneCheshire/sticky-ui-in-android-bottom-sheet-3d65ea1d20dc

I have tried using a subcompose layout and placed the button by subtracting button height from visible sheet height like so;

constraints.maxHeight - sheetState.offset.value - ctaPlaceable.height

but with this I cant achieve the desired transition when the sheet is sliding down from collapsed to dismissed as the button remain fixed at their position. I want the buttons to slide down when the sheet is being dismissed and remain fixed in their position when the sheet is sliding up.

Can anyone help?

Upvotes: 4

Views: 1264

Answers (1)

Mahmoud Elsayed
Mahmoud Elsayed

Reputation: 1

i dont know if you still face the problem, but you can just add coerceAtLeast(0f) and it the footer slides down with the sheet and you could find it here: https://github.com/MahmoudElsayedEssa/BottomSheetPinnedFooter/blob/main/app/src/main/java/com/example/bottomsheetpinnedfooter/BottomSheetWithPinnedFooterLinkedLike.kt

Upvotes: 0

Related Questions