-
-
Save Arunshaik2001/2988260679d4dfe5417c7d223b820703 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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