Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@Composable
internal fun SampleScreen() {
val permissions = remember { listOf(Manifest.permission.CAMERA) }
val permissionsHandler = remember(permissions) { PermissionsHandler() }
val permissionsStates by permissionsHandler.state.collectAsState()
HandlePermissionsRequest(permissions = permissions, permissionsHandler = permissionsHandler)
Box {
if (permissionsStates.multiplePermissionsState?.allPermissionsGranted == true) {
Text(text = "Permission Granted")
} else {
Button (onClick = {permissionsHandler.onEvent(PermissionsHandler.Event.PermissionRequired)}) {
Text(text = "Request Permission")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment