6071: Add timeout selector when start live sharing

This commit is contained in:
MaximeE
2022-05-03 15:21:51 +02:00
parent b5e878c3df
commit 39f8f1aeb5
5 changed files with 52 additions and 10 deletions
@@ -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()
}