Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to find own location in map views #7337

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ struct LiveLocationSharingViewerViewState: BindableState {

var showLoadingIndicator = false

var isSharingOwnLocation: Bool

var shareButtonEnabled: Bool {
!showLoadingIndicator
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class LiveLocationSharingViewerViewModel: LiveLocationSharingViewerViewModelType
// MARK: - Setup

init(mapStyleURL: URL, service: LiveLocationSharingViewerServiceProtocol) {
let viewState = LiveLocationSharingViewerViewState(mapStyleURL: mapStyleURL, annotations: [], highlightedAnnotation: nil, listItemsViewData: [])
let viewState = LiveLocationSharingViewerViewState(mapStyleURL: mapStyleURL, annotations: [], highlightedAnnotation: nil, listItemsViewData: [], isSharingOwnLocation: false)

liveLocationSharingViewerService = service
mapViewErrorAlertInfoBuilder = MapViewErrorAlertInfoBuilder()
Expand Down Expand Up @@ -198,6 +198,7 @@ class LiveLocationSharingViewerViewModel: LiveLocationSharingViewerViewModelType
state.annotations = annotations
state.highlightedAnnotation = highlightedAnnotation
state.listItemsViewData = listViewItems
state.isSharingOwnLocation = annotations.first { liveLocationSharingViewerService.isCurrentUserId($0.userId) } != nil
}

private func highlighAnnotation(with userId: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct LiveLocationSharingViewer: View {
@Environment(\.openURL) var openURL

@State private var isBottomSheetExpanded = false
@State private var showsUserLocation = false

var bottomSheetCollapsedHeight: CGFloat = 150.0

Expand All @@ -41,7 +42,7 @@ struct LiveLocationSharingViewer: View {
annotations: viewModel.viewState.annotations,
highlightedAnnotation: viewModel.viewState.highlightedAnnotation,
userAvatarData: nil,
showsUserLocation: false,
showsUserLocation: showsUserLocation,
userAnnotationCanShowCallout: true,
userLocation: Binding.constant(nil),
mapCenterCoordinate: Binding.constant(nil),
Expand Down Expand Up @@ -105,6 +106,16 @@ struct LiveLocationSharingViewer: View {
viewModel.send(viewAction: .done)
}
}
ToolbarItemGroup(placement: .navigationBarTrailing) {
if !viewModel.viewState.isSharingOwnLocation {
Button {
showsUserLocation = true
} label: {
// TODO: Replace icon
Image(uiImage: Asset.Images.locationPinIcon.image)
}
}
}
}
.accentColor(theme.colors.accent)
.background(theme.colors.system.ignoresSafeArea())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ struct StaticLocationView: View {

@ObservedObject var viewModel: StaticLocationViewingViewModel.Context

@State private var showsUserLocation = false

// MARK: Views

var body: some View {
Expand All @@ -36,7 +38,7 @@ struct StaticLocationView: View {
annotations: [viewModel.viewState.sharedAnnotation],
highlightedAnnotation: viewModel.viewState.sharedAnnotation,
userAvatarData: viewModel.viewState.userAvatarData,
showsUserLocation: false,
showsUserLocation: showsUserLocation,
userLocation: Binding.constant(nil),
mapCenterCoordinate: Binding.constant(nil),
errorSubject: viewModel.viewState.errorSubject)
Expand All @@ -54,6 +56,14 @@ struct StaticLocationView: View {
.font(.headline)
.foregroundColor(theme.colors.primaryContent)
}
ToolbarItem(placement: .navigationBarTrailing) {
Button {
showsUserLocation = true
} label: {
// TODO: Replace icon
Image(uiImage: Asset.Images.locationPinIcon.image)
}
}
ToolbarItem(placement: .navigationBarTrailing) {
Button {
viewModel.send(viewAction: .share)
Expand Down
1 change: 1 addition & 0 deletions changelog.d/pr-7337.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add option to find own location in map views