Merge develop in 6081_lls_screen_integration

This commit is contained in:
SBiOSoftWhare
2022-05-04 16:53:49 +02:00
18 changed files with 263 additions and 40 deletions
@@ -25,12 +25,20 @@ enum LocationSharingCoordinateType {
case pin
}
enum LiveLocationSharingTimeout: TimeInterval {
// Timer are in milliseconde because timestamp are in millisecond in Matrix SDK
case short = 900000 // 15 minutes
case medium = 3600000 // 1 hour
case long = 28800000 // 8 hours
}
enum LocationSharingViewAction {
case cancel
case share
case sharePinLocation
case goToUserLocation
case shareLiveLocation
case startLiveSharing
case shareLiveLocation(timeout: LiveLocationSharingTimeout)
}
enum LocationSharingViewModelResult {
@@ -87,6 +95,7 @@ struct LocationSharingViewStateBindings {
var alertInfo: AlertInfo<LocationSharingAlertType>?
var userLocation: CLLocationCoordinate2D?
var pinLocation: CLLocationCoordinate2D?
var showingTimerSelector = false
}
enum LocationSharingAlertType {
@@ -25,12 +25,6 @@ typealias LocationSharingViewModelType = StateStoreViewModel<LocationSharingView
@available(iOS 14, *)
class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingViewModelProtocol {
// MARK: - Constants
private enum Constants {
static let liveLocationSharingDefaultTimeout: TimeInterval = 300 // 5 minutes
}
// MARK: - Properties
// MARK: Private
@@ -80,8 +74,11 @@ class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingVie
completion?(.share(latitude: pinLocation.latitude, longitude: pinLocation.longitude, coordinateType: .pin))
case .goToUserLocation:
state.bindings.pinLocation = nil
case .shareLiveLocation:
completion?(.shareLiveLocation(timeout: Constants.liveLocationSharingDefaultTimeout))
case .startLiveSharing:
state.bindings.showingTimerSelector = true
case .shareLiveLocation(let timeout):
state.bindings.showingTimerSelector = false
completion?(.shareLiveLocation(timeout: timeout.rawValue))
}
}
@@ -112,7 +112,7 @@ struct LocationSharingView: View {
// Hide for now until live location sharing is finished
if context.viewState.isLiveLocationSharingEnabled {
LocationSharingOptionButton(text: VectorL10n.locationSharingLiveShareTitle) {
context.send(viewAction: .shareLiveLocation)
context.send(viewAction: .startLiveSharing)
} buttonIcon: {
Image(uiImage: Asset.Images.locationLiveIcon.image)
.resizable()
@@ -129,6 +129,24 @@ struct LocationSharingView: View {
.disabled(!context.viewState.shareButtonEnabled)
}
}
.actionSheet(isPresented: $context.showingTimerSelector) {
ActionSheet(title: Text(VectorL10n.locationSharingLiveTimerSelectorTitle),
buttons: [
.default(Text(VectorL10n.locationSharingLiveTimerSelectorShort)) {
context.send(viewAction: .shareLiveLocation(timeout: .short))
},
.default(Text(VectorL10n.locationSharingLiveTimerSelectorMedium)) {
context.send(viewAction: .shareLiveLocation(timeout: .medium))
},
.default(Text(VectorL10n.locationSharingLiveTimerSelectorLong)) {
context.send(viewAction: .shareLiveLocation(timeout: .long))
},
.cancel()
])
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding()
}
@@ -41,6 +41,5 @@ class StaticLocationViewingUITests: MockScreenTest {
func verifyInitialExistingLocation() {
XCTAssertTrue(app.buttons["Cancel"].exists, "The cancel button should exist.")
XCTAssertTrue(app.buttons["shareButton"].exists, "The share button should exist.")
}
}