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:
a1denvalu3 2026-01-15 17:02:26 +01:00 committed by GitHub
parent db26b673ee
commit a13109970d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
*/