To use the AppBottomSheet composable function you've defined, you need to integrate it into your application's UI. Below is a step-by-step guide on how to use it, including an example of how to trigger the bottom sheet when clicking on the AnimatedStarViewWithFlag.
Step 1: Define State for the Bottom Sheet
First, you need to define a state to control the visibility of the bottom sheet.
kotlin
@Composable
fun MyScreen() {
var showBottomSheet by remember { mutableStateOf(false) }
Column(
modifier = Modifier
.fillMaxSize()
.padding(16.dp)
) {
// Your other UI elements
AnimatedStarViewWithFlag(
primaryColor = MaterialTheme.colorScheme.primary,
secondaryColor = MaterialTheme.colorScheme.secondary,
boxPadding = PaddingValues(start = 8.dp, end = 8.dp),
boxSize = 42.dp,
flagSize = 25.dp,
boxClickable = true,
onBoxClick = { showBottomSheet = true },
vibration = VibType.TICK,
showCountryFlag = true
)
AppBottomSheet(
showBottomSheet = showBottomSheet,
onDismiss = { showBottomSheet = false },
sheetContent = {
// Content of the bottom sheet
Text("This is the bottom sheet content")
}
)
}
}
Step 2: Implement the AppBottomSheet Composable
You've already defined the AppBottomSheet composable. Make sure it is correctly imported and used as shown above.
Step 3: Ensure Dependencies are Included
Make sure you have the necessary dependencies in your build.gradle file to use ModalBottomSheet and other Material 3 components.