escodro
03/05/2021, 12:18 PMModalBottomSheetLayout
that I want to appear on top of my Scaffold
. The Scaffold
has 4 tabs and I want each one to have a different content for this Modal.
The solution I made is:
val (sheetContent, setSheetContent) = remember { mutableStateOf<@Composable () -> Unit>({}) }
AlkaaBottomSheetLayout(bottomSheetContent = currentSection) {
Scaffold {
when (tab) {
HomeSection.Tasks -> TaskListSection(bottomSheetContent = setCurrentSection)
HomeSection.Search -> SearchSection(bottomSheetContent = setCurrentSection)
HomeSection.Categories -> CategoriesSection(bottomSheetContent = setCurrentSection)
HomeSection.Settings -> SettingSection(bottomSheetContent = setCurrentSection)
Is it the correct way to delegate the composable function?
Thanks a lot in advance! ❤️jim
03/12/2021, 6:02 PMescodro
03/12/2021, 6:07 PMescodro
03/12/2021, 6:18 PMrememberSaveable
with this approach? Is it possible to write a custom Saver
to a lambda?jim
03/12/2021, 6:23 PMrememberSaveable
will do what you want here, as it helps with process restarts but not with things being added/removed AFAIK. I think you would want to hoist the state of your composables up into your app, so you can retain the state when switching tabs. Take a look at the discussion of state hoisting in https://developer.android.com/jetpack/compose/state#stateless-composablesescodro
03/12/2021, 7:01 PM