Albert Chang
09/09/2024, 2:37 PMMitch Ware
09/09/2024, 2:48 PMQamar Khan
09/09/2024, 6:55 PMsealed class
with a when
condition to display the appropriate content based on the type of the sheet:
@Composable
fun SingleBottomSheetWithMultipleContents(sealedClassType: SheetType) {
ModelBottomSheet( // here we need to have only one Model Sheet
when (sealedClassType) {
SheetType.Type1 -> { /* Content for sheet type 1 */ }
SheetType.Type2 -> { /* Content for sheet type 2 */ }
SheetType.Type3 -> { /* Content for sheet type 3 */ }
// Continue for other sheet types
}
)
}
Approach 2:
Use a separate composable function for each type of bottom sheet, as suggested in the documentation:
For this Approach Each composable function contains ModalBottomSheet
@Composablefun SheetType1() { ModalBottomSheet { // Content specific to this sheet type } }
@Composablefun SheetType2() { ModalBottomSheet { // Content specific to this sheet type } }
@Composablefun SheetType1() { ModalBottomSheet { // Content specific to this sheet type } } and soo on
What the suggested method would be preferred to handle such case. Actually i am looking for a recommended solution by google.