diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index ad15ce9e2..a32d1b96f 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -2167,6 +2167,7 @@ Tap the + to start adding people."; To enable access, tap Settings> Location and select Always"; "location_sharing_allow_background_location_validate_action" = "Settings"; "location_sharing_allow_background_location_cancel_action" = "Not now"; +"location_sharing_map_credits_title" = "© Copyright"; // MARK: Live location sharing diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index e468d6a82..f90273a30 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -2907,6 +2907,10 @@ public class VectorL10n: NSObject { public static func locationSharingLocatingUserErrorTitle(_ p1: String) -> String { return VectorL10n.tr("Vector", "location_sharing_locating_user_error_title", p1) } + /// © Copyright + public static var locationSharingMapCreditsTitle: String { + return VectorL10n.tr("Vector", "location_sharing_map_credits_title") + } /// Open in Apple Maps public static var locationSharingOpenAppleMaps: String { return VectorL10n.tr("Vector", "location_sharing_open_apple_maps") diff --git a/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/LiveLocationSharingViewerModels.swift b/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/LiveLocationSharingViewerModels.swift index 7d5a38ab4..9cb66ad7d 100644 --- a/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/LiveLocationSharingViewerModels.swift +++ b/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/LiveLocationSharingViewerModels.swift @@ -56,6 +56,7 @@ struct LiveLocationSharingViewerViewState: BindableState { struct LiveLocationSharingViewerViewStateBindings { var alertInfo: AlertInfo? + var showMapCreditsSheet = false } enum LiveLocationSharingViewerViewAction { @@ -63,4 +64,5 @@ enum LiveLocationSharingViewerViewAction { case stopSharing case tapListItem(_ userId: String) case share(_ annotation: UserLocationAnnotation) + case mapCreditsDidTap } diff --git a/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/LiveLocationSharingViewerViewModel.swift b/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/LiveLocationSharingViewerViewModel.swift index 3a365b627..8da097b41 100644 --- a/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/LiveLocationSharingViewerViewModel.swift +++ b/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/LiveLocationSharingViewerViewModel.swift @@ -69,6 +69,8 @@ class LiveLocationSharingViewerViewModel: LiveLocationSharingViewerViewModelType self.highlighAnnotation(with: userId) case .share(let userLocationAnnotation): completion?(.share(userLocationAnnotation.coordinate)) + case .mapCreditsDidTap: + state.bindings.showMapCreditsSheet.toggle() } } diff --git a/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/View/LiveLocationSharingViewer.swift b/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/View/LiveLocationSharingViewer.swift index 25edbdd82..fed3e4c41 100644 --- a/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/View/LiveLocationSharingViewer.swift +++ b/RiotSwiftUI/Modules/Room/LiveLocationSharingViewer/View/LiveLocationSharingViewer.swift @@ -25,9 +25,13 @@ struct LiveLocationSharingViewer: View { @Environment(\.theme) private var theme: ThemeSwiftUI + @Environment(\.openURL) var openURL + var isBottomSheetVisible = true @State private var isBottomSheetExpanded = false + var bottomSheetCollapsedHeight: CGFloat = 150.0 + // MARK: Public @ObservedObject var viewModel: LiveLocationSharingViewerViewModel.Context @@ -50,9 +54,13 @@ struct LiveLocationSharingViewer: View { errorSubject: viewModel.viewState.errorSubject) VStack(alignment: .center) { Spacer() - MapCreditsView() - .offset(y: -130) + MapCreditsView(action: { + viewModel.send(viewAction: .mapCreditsDidTap) + }) + .offset(y: -(bottomSheetCollapsedHeight)) // Put the copyright action above the collapsed bottom sheet + .padding(.bottom, 10) } + .ignoresSafeArea() } .navigationTitle(VectorL10n.locationSharingLiveViewerTitle) .toolbar { @@ -64,6 +72,11 @@ struct LiveLocationSharingViewer: View { } .accentColor(theme.colors.accent) .bottomSheet(sheet, if: isBottomSheetVisible) + .actionSheet(isPresented: $viewModel.showMapCreditsSheet) { + return MapCreditsActionSheet(openURL: { url in + openURL(url) + }).sheet + } .alert(item: $viewModel.alertInfo) { info in info.alert } @@ -108,7 +121,7 @@ extension LiveLocationSharingViewer { var sheet: some BottomSheetView { BottomSheet( isExpanded: $isBottomSheetExpanded, - minHeight: .points(150), + minHeight: .points(bottomSheetCollapsedHeight), maxHeight: .available, style: sheetStyle) { userLocationList diff --git a/RiotSwiftUI/Modules/Room/LocationSharing/LocationSharingModels.swift b/RiotSwiftUI/Modules/Room/LocationSharing/LocationSharingModels.swift index 82445ac5e..46d694fcf 100644 --- a/RiotSwiftUI/Modules/Room/LocationSharing/LocationSharingModels.swift +++ b/RiotSwiftUI/Modules/Room/LocationSharing/LocationSharingModels.swift @@ -40,6 +40,7 @@ enum LocationSharingViewAction { case startLiveSharing case shareLiveLocation(timeout: LiveLocationSharingTimeout) case userDidPan + case mapCreditsDidTap } enum LocationSharingViewModelResult { @@ -95,6 +96,7 @@ struct LocationSharingViewStateBindings { var userLocation: CLLocationCoordinate2D? var pinLocation: CLLocationCoordinate2D? var showingTimerSelector = false + var showMapCreditsSheet = false } enum LocationSharingAlertType { diff --git a/RiotSwiftUI/Modules/Room/LocationSharing/LocationSharingViewModel.swift b/RiotSwiftUI/Modules/Room/LocationSharing/LocationSharingViewModel.swift index 6261f9e6b..1fc7242c3 100644 --- a/RiotSwiftUI/Modules/Room/LocationSharing/LocationSharingViewModel.swift +++ b/RiotSwiftUI/Modules/Room/LocationSharing/LocationSharingViewModel.swift @@ -86,6 +86,8 @@ class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingVie case .userDidPan: state.showsUserLocation = false state.isPinDropSharing = true + case .mapCreditsDidTap: + state.bindings.showMapCreditsSheet.toggle() } } diff --git a/RiotSwiftUI/Modules/Room/LocationSharing/MapCreditsActionSheet.swift b/RiotSwiftUI/Modules/Room/LocationSharing/MapCreditsActionSheet.swift new file mode 100644 index 000000000..3f08da5ac --- /dev/null +++ b/RiotSwiftUI/Modules/Room/LocationSharing/MapCreditsActionSheet.swift @@ -0,0 +1,37 @@ +// +// Copyright 2022 New Vector Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import SwiftUI + +struct MapCreditsActionSheet { + + // Open URL action + let openURL: (URL) -> Void + + // Map credits action sheet + var sheet: ActionSheet { + ActionSheet(title: Text(VectorL10n.locationSharingMapCreditsTitle), + buttons: [ + .default(Text("© MapTiler")) { + openURL(URL(string: "https://www.maptiler.com/copyright/")!) + }, + .default(Text("© OpenStreetMap")) { + openURL(URL(string: "https://www.openstreetmap.org/copyright")!) + }, + .cancel() + ]) + } +} diff --git a/RiotSwiftUI/Modules/Room/LocationSharing/View/LocationSharingView.swift b/RiotSwiftUI/Modules/Room/LocationSharing/View/LocationSharingView.swift index 70d31f6da..c5e3c4b29 100644 --- a/RiotSwiftUI/Modules/Room/LocationSharing/View/LocationSharingView.swift +++ b/RiotSwiftUI/Modules/Room/LocationSharing/View/LocationSharingView.swift @@ -25,6 +25,8 @@ struct LocationSharingView: View { @Environment(\.theme) private var theme: ThemeSwiftUI + @Environment(\.openURL) var openURL + // MARK: Public @ObservedObject var context: LocationSharingViewModel.Context @@ -34,7 +36,15 @@ struct LocationSharingView: View { ZStack(alignment: .bottom) { mapView VStack(spacing: 0) { - MapCreditsView() + MapCreditsView(action: { + context.send(viewAction: .mapCreditsDidTap) + }) + .padding(.bottom, 10.0) + .actionSheet(isPresented: $context.showMapCreditsSheet) { + return MapCreditsActionSheet(openURL: { url in + openURL(url) + }).sheet + } buttonsView .background(theme.colors.background) .clipShape(RoundedCornerShape(radius: 8, corners: [.topLeft, .topRight])) diff --git a/RiotSwiftUI/Modules/Room/LocationSharing/View/MapCreditsView.swift b/RiotSwiftUI/Modules/Room/LocationSharing/View/MapCreditsView.swift index da8509918..3edb2fbfc 100644 --- a/RiotSwiftUI/Modules/Room/LocationSharing/View/MapCreditsView.swift +++ b/RiotSwiftUI/Modules/Room/LocationSharing/View/MapCreditsView.swift @@ -26,12 +26,20 @@ struct MapCreditsView: View { // MARK: Public + var action: (() -> Void)? + var body: some View { HStack { - Link("© MapTiler", destination: URL(string: "https://www.maptiler.com/copyright/")!) - Link("© OpenStreetMap contributors", destination: URL(string: "https://www.openstreetmap.org/copyright")!) + Spacer() + Button { + action?() + } label: { + Text(VectorL10n.locationSharingMapCreditsTitle) + .font(theme.fonts.footnote) + .foregroundColor(theme.colors.accent) + } + .padding(.horizontal) } - .font(theme.fonts.caption1) } } diff --git a/changelog.d/6108.change b/changelog.d/6108.change new file mode 100644 index 000000000..ba3e87f10 --- /dev/null +++ b/changelog.d/6108.change @@ -0,0 +1 @@ +Location sharing: Update map credits display and behavior.