mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-28 20:26:57 +02:00
6071: Add timeout selector when start live sharing
This commit is contained in:
@@ -30,7 +30,7 @@ enum LocationSharingViewAction {
|
||||
case share
|
||||
case sharePinLocation
|
||||
case goToUserLocation
|
||||
case shareLiveLocation
|
||||
case shareLiveLocation(timeout: TimeInterval)
|
||||
}
|
||||
|
||||
enum LocationSharingViewModelResult {
|
||||
|
||||
@@ -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,8 @@ 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 .shareLiveLocation(let timeout):
|
||||
completion?(.shareLiveLocation(timeout: timeout))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,11 +20,21 @@ import CoreLocation
|
||||
@available(iOS 14.0, *)
|
||||
struct LocationSharingView: View {
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
private enum Constants {
|
||||
// Timer are in milliseconde because timestamp are in millisecond in Matrix SDK
|
||||
static let liveLocationSharingShortTimeout: TimeInterval = 900000 // 15 minutes
|
||||
static let liveLocationSharingMediumTimeout: TimeInterval = 3600000 // 1 hour
|
||||
static let liveLocationSharingLongTimeout: TimeInterval = 28800000 // 8 hours
|
||||
}
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
// MARK: Private
|
||||
|
||||
@Environment(\.theme) private var theme: ThemeSwiftUI
|
||||
@State private var showingTimerSelector = false
|
||||
|
||||
// MARK: Public
|
||||
|
||||
@@ -112,7 +122,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)
|
||||
showingTimerSelector = true
|
||||
} buttonIcon: {
|
||||
Image(uiImage: Asset.Images.locationLiveIcon.image)
|
||||
.resizable()
|
||||
@@ -129,6 +139,24 @@ struct LocationSharingView: View {
|
||||
.disabled(!context.viewState.shareButtonEnabled)
|
||||
}
|
||||
}
|
||||
.actionSheet(isPresented: $showingTimerSelector) {
|
||||
ActionSheet(title: Text(VectorL10n.locationSharingLiveTimerSelectorTitle),
|
||||
buttons: [
|
||||
.default(Text(VectorL10n.locationSharingLiveTimerSelectorShort)) {
|
||||
context.send(viewAction: .shareLiveLocation(timeout: Constants.liveLocationSharingShortTimeout))
|
||||
|
||||
},
|
||||
.default(Text(VectorL10n.locationSharingLiveTimerSelectorMedium)) {
|
||||
context.send(viewAction: .shareLiveLocation(timeout: Constants.liveLocationSharingMediumTimeout))
|
||||
|
||||
},
|
||||
.default(Text(VectorL10n.locationSharingLiveTimerSelectorLong)) {
|
||||
context.send(viewAction: .shareLiveLocation(timeout: Constants.liveLocationSharingLongTimeout))
|
||||
|
||||
},
|
||||
.cancel()
|
||||
])
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user