Skip to content

Instantly share code, notes, and snippets.

@Arunshaik2001
Created October 8, 2022 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arunshaik2001/2988260679d4dfe5417c7d223b820703 to your computer and use it in GitHub Desktop.
Save Arunshaik2001/2988260679d4dfe5417c7d223b820703 to your computer and use it in GitHub Desktop.
val locationPermissionsState = rememberMultiplePermissionsState(
listOf(
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION,
)
)
if (locationPermissionsState.allPermissionsGranted){
if (!locationUtil.dataLoaded.value)
item { TextWidget(contentModifier,"Thanks! I can access your exact location :D") }
else{
item { CardWidget(
modifier = contentModifier,
title = locationUtil.data.value.name ,
weatherDescription = locationUtil.data.value.weatherDescription,
time = locationUtil.data.value.time , temperature = 12.0)
}
}
}
else{
val allPermissionsRevoked =
locationPermissionsState.permissions.size ==
locationPermissionsState.revokedPermissions.size
val textToShow = if (!allPermissionsRevoked) {
"Yay! Thanks for letting me access your approximate location. " +
"But you know what would be great? If you allow me to know where you " +
"exactly are. Thank you!"
} else if (locationPermissionsState.shouldShowRationale) {
"Getting your exact location is important for this app. " +
"Please grant us fine location. Thank you :D"
} else {
"This feature requires location permission"
}
item { TextExample(contentModifier,textToShow) }
item { ButtonWidget(contentModifier, iconModifier){
locationPermissionsState.launchMultiplePermissionRequest()
} }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment