RequireLocation

fun RequireLocation(onChanged: (Boolean) -> Unit = {}, contentWithoutLocation: @Composable () -> Unit = { LocationPermissionRequiredView() }, content: @Composable (isLocationRequiredAndDisabled: Boolean) -> Unit)

A wrapper for composables that require Location.

Location is required for Bluetooth LE scanning from Android 6 Marshmallow. Starting from Android 12 location may not be required if BLUETOOTH_SCAN permission was requested with neverForLocation flag.

This composable will display a view based on the state of the location.

Example:

RequireBluetooth(
onChanged = { onScanningStateChanged(it) }
) {
RequireLocation(
onChanged = { onScanningStateChanged(it) }
) {
// Bluetooth scanner views
}
}

Parameters

onChanged

A callback that will be called when the state of the location changes.

contentWithoutLocation

A composable that will be displayed when location is not available.

content

A composable that will be displayed when location is available.