Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Flavio Alescio committed Mar 2, 2023
1 parent b2e12b7 commit 560a9b5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct LiveLocationSharingViewerViewState: BindableState {
/// Live location list items
var listItemsViewData: [LiveLocationListItemViewData]

/// Behavior mode of the current user's location, can be hidden, only shown and shown following the user
var showsUserLocationMode: ShowUserLocationMode = .hide

var isCurrentUserShared: Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ class LiveLocationSharingViewerViewModel: LiveLocationSharingViewerViewModelType
guard let foundUserAnnotation = foundUserAnnotation else {
return
}

/*
if the map is currently following the current user's location,
we want to switch back to only showing the marker,
so the the highlited shared location can be centered
*/
if state.showsUserLocationMode == .follow {
state.showsUserLocationMode = .show
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import Combine
import Mapbox
import SwiftUI

/*
Behavior mode of the current user's location, can be hidden, only shown and shown following the user
*/
enum ShowUserLocationMode {
case follow
case show
Expand Down Expand Up @@ -45,7 +48,7 @@ struct LocationSharingMapView: UIViewRepresentable {
/// Current user avatar data, used to replace current location annotation view with the user avatar
let userAvatarData: AvatarInputProtocol?

/// True to indicate to show and follow current user location
/// Behavior mode of the current user's location, can be hidden, only shown and shown following the user
var showsUserLocationMode: ShowUserLocationMode = .hide

/// True to indicate that a touch on user annotation can show a callout
Expand Down Expand Up @@ -81,6 +84,11 @@ struct LocationSharingMapView: UIViewRepresentable {
mapView.vc_removeAllAnnotations()
mapView.addAnnotations(annotations)

/*
if there is an highlighted annotation,
and the current user's location it's either hidden or only shown,
we can center to the highlighted annotation
*/
if let highlightedAnnotation = highlightedAnnotation, showsUserLocationMode != .follow {
mapView.setCenter(highlightedAnnotation.coordinate, zoomLevel: Constants.mapZoomLevel, animated: true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct LocationSharingViewState: BindableState {

var showLoadingIndicator = false

/// True to indicate to show and follow current user location
/// Behavior mode of the current user's location, can be hidden, only shown and shown following the user
var showsUserLocationMode: ShowUserLocationMode = .hide

/// Used to hide live location sharing features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct StaticLocationViewingViewState: BindableState {
/// Shared annotation to display existing location
let sharedAnnotation: LocationAnnotation

/// Behavior mode of the current user's location, can be hidden, only shown and shown following the user
var showsUserLocationMode: ShowUserLocationMode = .hide

var showLoadingIndicator = false
Expand Down

0 comments on commit 560a9b5

Please sign in to comment.