diff --git a/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/LiveLocationSharingViewerModels.swift b/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/LiveLocationSharingViewerModels.swift index 09d37e71a..3cf3271cc 100644 --- a/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/LiveLocationSharingViewerModels.swift +++ b/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/LiveLocationSharingViewerModels.swift @@ -57,6 +57,8 @@ struct LiveLocationSharingViewerViewState: BindableState { var isBottomSheetVisible: Bool { return isAllLocationSharingEnded == false } + + var showMapLoadingError: Bool = false let errorSubject = PassthroughSubject() diff --git a/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/LiveLocationSharingViewerViewModel.swift b/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/LiveLocationSharingViewerViewModel.swift index 6de4ba7fe..9a20870d6 100644 --- a/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/LiveLocationSharingViewerViewModel.swift +++ b/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/LiveLocationSharingViewerViewModel.swift @@ -105,6 +105,10 @@ class LiveLocationSharingViewerViewModel: LiveLocationSharingViewerViewModelType return } + if case .failedLoadingMap = error { + state.showMapLoadingError = true + } + let alertInfo = mapViewErrorAlertInfoBuilder.build(with: error) { [weak self] in switch error { diff --git a/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/View/LiveLocationSharingViewer.swift b/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/View/LiveLocationSharingViewer.swift index caaff19ba..8edf153bd 100644 --- a/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/View/LiveLocationSharingViewer.swift +++ b/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/View/LiveLocationSharingViewer.swift @@ -37,40 +37,53 @@ struct LiveLocationSharingViewer: View { var body: some View { ZStack(alignment: .bottom) { - LocationSharingMapView(tileServerMapURL: viewModel.viewState.mapStyleURL, - annotations: viewModel.viewState.annotations, - highlightedAnnotation: viewModel.viewState.highlightedAnnotation, - userAvatarData: nil, - showsUserLocation: false, - userAnnotationCanShowCallout: true, - userLocation: Binding.constant(nil), - mapCenterCoordinate: Binding.constant(nil), - onCalloutTap: { annotation in - if let userLocationAnnotation = annotation as? UserLocationAnnotation { - viewModel.send(viewAction: .share(userLocationAnnotation)) - } - }, - errorSubject: viewModel.viewState.errorSubject) - if viewModel.viewState.isBottomSheetVisible { - VStack(alignment: .center) { - Spacer() - MapCreditsView(action: { - viewModel.send(viewAction: .mapCreditsDidTap) - }) - .offset(y: -(bottomSheetCollapsedHeight)) // Put the copyright action above the collapsed bottom sheet - .padding(.bottom, 10) + if !viewModel.viewState.showMapLoadingError { + LocationSharingMapView(tileServerMapURL: viewModel.viewState.mapStyleURL, + annotations: viewModel.viewState.annotations, + highlightedAnnotation: viewModel.viewState.highlightedAnnotation, + userAvatarData: nil, + showsUserLocation: false, + userAnnotationCanShowCallout: true, + userLocation: Binding.constant(nil), + mapCenterCoordinate: Binding.constant(nil), + onCalloutTap: { annotation in + if let userLocationAnnotation = annotation as? UserLocationAnnotation { + viewModel.send(viewAction: .share(userLocationAnnotation)) + } + }, + errorSubject: viewModel.viewState.errorSubject) + + // Show map credits above collapsed bottom sheet height if bottom sheet is visible + if viewModel.viewState.isBottomSheetVisible { + VStack(alignment: .center) { + Spacer() + MapCreditsView(action: { + viewModel.send(viewAction: .mapCreditsDidTap) + }) + .offset(y: -(bottomSheetCollapsedHeight)) // Put the copyright action above the collapsed bottom sheet + .padding(.bottom, 10) + } + .ignoresSafeArea() } - .ignoresSafeArea() + + } else { + MapLoadingErrorView() + .padding(.bottom, viewModel.viewState.isBottomSheetVisible ? bottomSheetCollapsedHeight : 0) } if viewModel.viewState.isAllLocationSharingEnded { VStack(alignment: .center) { Spacer() - MapCreditsView(action: { - viewModel.send(viewAction: .mapCreditsDidTap) - }) - .padding(.bottom, 5) + + // Show map credits only if map is visible + if !viewModel.viewState.showMapLoadingError { + MapCreditsView(action: { + viewModel.send(viewAction: .mapCreditsDidTap) + }) + .padding(.bottom, 5) + } + HStack(spacing: 10) { Image(uiImage: Asset.Images.locationLiveCellIcon.image) .renderingMode(.template) @@ -96,6 +109,7 @@ struct LiveLocationSharingViewer: View { } } .accentColor(theme.colors.accent) + .background(theme.colors.system.ignoresSafeArea()) .bottomSheet(sheet, if: viewModel.viewState.isBottomSheetVisible) .actionSheet(isPresented: $viewModel.showMapCreditsSheet) { return MapCreditsActionSheet(openURL: { url in