mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-24 22:45:20 +00:00
fix(ui): Show acquiring location state instead of unavailable (#621)
* fix(ui): Show acquiring location state instead of unavailable This change updates the LocationNotesSheetPresenter to display an 'Acquiring Location' sheet when location permissions are granted but the location is still loading. This prevents the misleading 'Location Unavailable' error on devices with slow GPS start-up (e.g., GrapheneOS). Fixes #578 * Adjust text --------- Co-authored-by: a1denvalu3 <>
This commit is contained in:
co-authored by
a1denvalu3 <>
parent
db26b673ee
commit
a13109970d
@@ -28,6 +28,8 @@ fun LocationNotesSheetPresenter(
|
||||
val context = LocalContext.current
|
||||
val locationManager = remember { LocationChannelManager.getInstance(context) }
|
||||
val availableChannels by locationManager.availableChannels.collectAsStateWithLifecycle()
|
||||
val permissionState by locationManager.permissionState.collectAsStateWithLifecycle()
|
||||
val isLoadingLocation by locationManager.isLoadingLocation.collectAsStateWithLifecycle()
|
||||
val nickname by viewModel.nickname.collectAsStateWithLifecycle()
|
||||
|
||||
// iOS pattern: notesGeohash ?? LocationChannelManager.shared.availableChannels.first(where: { $0.level == .building })?.geohash
|
||||
@@ -45,6 +47,8 @@ fun LocationNotesSheetPresenter(
|
||||
nickname = nickname,
|
||||
onDismiss = onDismiss
|
||||
)
|
||||
} else if (permissionState == LocationChannelManager.PermissionState.AUTHORIZED && isLoadingLocation) {
|
||||
LocationNotesAcquiringSheet(onDismiss = onDismiss)
|
||||
} else {
|
||||
// No building geohash available - show error state (matches iOS)
|
||||
LocationNotesErrorSheet(
|
||||
@@ -54,6 +58,43 @@ fun LocationNotesSheetPresenter(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loading sheet when location is being acquired
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
private fun LocationNotesAcquiringSheet(
|
||||
onDismiss: () -> Unit
|
||||
) {
|
||||
BitchatBottomSheet(
|
||||
onDismissRequest = onDismiss,
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(24.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text(
|
||||
text = "Acquiring Location",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
color = MaterialTheme.colorScheme.onSurface
|
||||
)
|
||||
Spacer(modifier = Modifier.height(24.dp))
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier.size(48.dp),
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
Spacer(modifier = Modifier.height(24.dp))
|
||||
Text(
|
||||
text = "Please wait while your location is being determined",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error sheet when location is unavailable
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user