-
Notifications
You must be signed in to change notification settings - Fork 503
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
[Location Sharing]: Pin drop location sharing #5957
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8be37f7
5858: Add pin drop feature
MaximeEvrard42 a4e7992
5858: Modification of the event send according to coordinate type
MaximeEvrard42 d8a67e5
5858: Resolve issue with bad import
MaximeEvrard42 6dc3284
5858: Move file on the right target
MaximeEvrard42 b17333c
5858: Fix tests
MaximeEvrard42 b258450
5858: Factorise some code according to PR comments
MaximeEvrard42 35db79b
5858: Add specific type for pin location
MaximeEvrard42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
Riot/Assets/Images.xcassets/Room/Location/location_center_map_icon.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "location_center_map_icon.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
Binary file added
BIN
+733 Bytes
...ts/Room/Location/location_center_map_icon.imageset/location_center_map_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
RiotSwiftUI/Modules/Common/Extensions/CLLocationCoordinate2D.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// 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 Foundation | ||
import CoreLocation | ||
|
||
extension CLLocationCoordinate2D { | ||
|
||
/// Compare two coordinates | ||
/// - parameter coordinate: another coordinate to compare | ||
/// - parameter precision:it represente how close you want the two coordinates | ||
/// - return: bool value | ||
func isEqual(to coordinate: CLLocationCoordinate2D, precision: Double) -> Bool { | ||
|
||
if fabs(self.latitude - coordinate.latitude) <= precision && fabs(self.longitude - coordinate.longitude) <= precision { | ||
return true | ||
} | ||
return false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,14 +19,22 @@ import SwiftUI | |
import Combine | ||
import CoreLocation | ||
|
||
// This is the equivalent of MXEventAssetType in the MatrixSDK | ||
enum LocationSharingCoordinateType { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can make just 2 cases in the app side. |
||
case user | ||
case pin | ||
} | ||
|
||
enum LocationSharingViewAction { | ||
case cancel | ||
case share | ||
case sharePinLocation | ||
case goToUserLocation | ||
} | ||
|
||
enum LocationSharingViewModelResult { | ||
case cancel | ||
case share(latitude: Double, longitude: Double) | ||
case share(latitude: Double, longitude: Double, coordinateType: LocationSharingCoordinateType) | ||
} | ||
|
||
enum LocationSharingViewError { | ||
|
@@ -45,17 +53,19 @@ struct LocationSharingViewState: BindableState { | |
/// Current user avatarData | ||
let userAvatarData: AvatarInputProtocol | ||
|
||
/// User map annotation to display existing location | ||
let userAnnotation: UserLocationAnnotation? | ||
/// Shared annotation to display existing location | ||
let sharedAnnotation: LocationAnnotation? | ||
|
||
/// Map annotations to display on map | ||
var annotations: [UserLocationAnnotation] | ||
var annotations: [LocationAnnotation] | ||
|
||
/// Map annotation to focus on | ||
var highlightedAnnotation: UserLocationAnnotation? | ||
var highlightedAnnotation: LocationAnnotation? | ||
|
||
/// Indicates whether the user has moved around the map to drop a pin somewhere other than their current location | ||
var isPinDropSharing: Bool = false | ||
var isPinDropSharing: Bool { | ||
return bindings.pinLocation != nil | ||
} | ||
|
||
var showLoadingIndicator: Bool = false | ||
|
||
|
@@ -70,7 +80,7 @@ struct LocationSharingViewState: BindableState { | |
} | ||
|
||
var displayExistingLocation: Bool { | ||
return userAnnotation != nil | ||
return sharedAnnotation != nil | ||
} | ||
|
||
var shareButtonEnabled: Bool { | ||
|
@@ -85,6 +95,7 @@ struct LocationSharingViewState: BindableState { | |
struct LocationSharingViewStateBindings { | ||
var alertInfo: AlertInfo<LocationSharingAlertType>? | ||
var userLocation: CLLocationCoordinate2D? | ||
var pinLocation: CLLocationCoordinate2D? | ||
} | ||
|
||
enum LocationSharingAlertType { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have to create the intermediate
class PinLocationAnnotation: LocationAnnotation
.UserLocationAnnotation
can be casted asLocationAnnotation
and if we add a new kind of annotation likePOIAnnotation
we will not be able to distinct them.