mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
LocationSharingScreen: fix indefinite loading on the center to location button in non picker mode (#5469)
This commit is contained in:
@@ -117,10 +117,18 @@ struct LocationSharingScreenViewState: BindableState {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if the user's location has not yet been determined, while location permissions are given or not yet set
|
||||
/// Displays a loader if the user's location has not yet been determined
|
||||
/// Does not work as intended on simulator.
|
||||
var isLocationLoading: Bool {
|
||||
!bindings.hasLoadedUserLocation && bindings.isLocationAuthorized != false
|
||||
if case .picker = interactionMode {
|
||||
// In picker mode permissions are requested immediately so returns true
|
||||
// if the user's location has not yet been determined while location permissions are given or not yet set
|
||||
!bindings.hasLoadedUserLocation && bindings.isLocationAuthorized != false
|
||||
} else {
|
||||
// In other modes permissions are requested only if the center to user button is tapped
|
||||
// So we only display the loader if the user's location has not yet been determined while location permissions are given.
|
||||
!bindings.hasLoadedUserLocation && bindings.isLocationAuthorized == true
|
||||
}
|
||||
}
|
||||
|
||||
var zoomLevel: Double {
|
||||
|
||||
@@ -133,6 +133,8 @@ struct LocationSharingScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
static let pickerViewModel = LocationSharingScreenViewModel.mock(type: .picker)
|
||||
|
||||
static let liveLocationViewModel = LocationSharingScreenViewModel.mock(type: .viewLive)
|
||||
|
||||
static var previews: some View {
|
||||
ElementNavigationStack {
|
||||
LocationSharingScreen(context: pickerViewModel.context)
|
||||
@@ -153,5 +155,10 @@ struct LocationSharingScreen_Previews: PreviewProvider, TestablePreview {
|
||||
LocationSharingScreen(context: pinViewModel.context)
|
||||
}
|
||||
.previewDisplayName("Pin Static Location")
|
||||
|
||||
ElementNavigationStack {
|
||||
LocationSharingScreen(context: liveLocationViewModel.context)
|
||||
}
|
||||
.previewDisplayName("Live Location")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user