mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 15:22:39 +00:00
Merge pull request #6394 from vector-im/steve/6108_map_credits
Location sharing: Update map credits display and behavior (PSG-234)
This commit is contained in:
commit
ccf2a2280e
11 changed files with 89 additions and 7 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -56,6 +56,7 @@ struct LiveLocationSharingViewerViewState: BindableState {
|
|||
|
||||
struct LiveLocationSharingViewerViewStateBindings {
|
||||
var alertInfo: AlertInfo<LocationSharingAlertType>?
|
||||
var showMapCreditsSheet = false
|
||||
}
|
||||
|
||||
enum LiveLocationSharingViewerViewAction {
|
||||
|
@ -63,4 +64,5 @@ enum LiveLocationSharingViewerViewAction {
|
|||
case stopSharing
|
||||
case tapListItem(_ userId: String)
|
||||
case share(_ annotation: UserLocationAnnotation)
|
||||
case mapCreditsDidTap
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -86,6 +86,8 @@ class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingVie
|
|||
case .userDidPan:
|
||||
state.showsUserLocation = false
|
||||
state.isPinDropSharing = true
|
||||
case .mapCreditsDidTap:
|
||||
state.bindings.showMapCreditsSheet.toggle()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
])
|
||||
}
|
||||
}
|
|
@ -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]))
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
1
changelog.d/6108.change
Normal file
1
changelog.d/6108.change
Normal file
|
@ -0,0 +1 @@
|
|||
Location sharing: Update map credits display and behavior.
|
Loading…
Reference in a new issue