updated the UI for the live locations distance to match designs.
This commit is contained in:
@@ -61,6 +61,7 @@ protocol AdvancedSettingsProtocol: AnyObject {
|
||||
var sharePresence: Bool { get set }
|
||||
var optimizeMediaUploads: Bool { get set }
|
||||
var liveLocationMinimumDistanceUpdate: Int { get set }
|
||||
var liveLocationSharingEnabled: Bool { get set }
|
||||
}
|
||||
|
||||
extension AppSettings: AdvancedSettingsProtocol { }
|
||||
|
||||
@@ -10,6 +10,13 @@ import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct AdvancedSettingsScreen: View {
|
||||
static let measurementFormatter = {
|
||||
let formatter = MeasurementFormatter()
|
||||
formatter.unitOptions = .providedUnit
|
||||
formatter.unitStyle = .short
|
||||
return formatter
|
||||
}()
|
||||
|
||||
@Bindable var context: AdvancedSettingsScreenViewModel.Context
|
||||
|
||||
var body: some View {
|
||||
@@ -37,7 +44,9 @@ struct AdvancedSettingsScreen: View {
|
||||
|
||||
moderationAndSafetySection
|
||||
timelineMediaSection
|
||||
liveLocationSection
|
||||
if context.liveLocationSharingEnabled {
|
||||
liveLocationSection
|
||||
}
|
||||
}
|
||||
.compoundList()
|
||||
.navigationTitle(L10n.commonAdvancedSettings)
|
||||
@@ -86,15 +95,41 @@ struct AdvancedSettingsScreen: View {
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var liveLocationSection: some View {
|
||||
let binding = Binding(get: {
|
||||
Double(context.liveLocationMinimumDistanceUpdate)
|
||||
}, set: { newValue in
|
||||
context.liveLocationMinimumDistanceUpdate = Int(newValue)
|
||||
})
|
||||
|
||||
Section {
|
||||
ListRow(kind: .custom {
|
||||
Stepper(L10n.screenAdvancedSettingsLiveLocationUpdateDistance(context.liveLocationMinimumDistanceUpdate),
|
||||
value: $context.liveLocationMinimumDistanceUpdate, in: 1...100)
|
||||
.font(.compound.bodyLG)
|
||||
.foregroundStyle(.compound.textPrimary)
|
||||
.padding(.horizontal, ListRowPadding.horizontal)
|
||||
.padding(.vertical, ListRowPadding.vertical)
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
Text(L10n.screenAdvancedSettingsLiveLocationUpdateDistance(context.liveLocationMinimumDistanceUpdate))
|
||||
.font(.compound.bodyLG)
|
||||
.foregroundStyle(.compound.textPrimary)
|
||||
// The internal hidden label of the slider will read voice over
|
||||
.accessibilityHidden(true)
|
||||
Slider(value: binding, in: 1...100) {
|
||||
Text(L10n.screenAdvancedSettingsLiveLocationUpdateDistance(context.liveLocationMinimumDistanceUpdate))
|
||||
} minimumValueLabel: {
|
||||
Text(Self.measurementFormatter.string(from: .init(value: 1,
|
||||
unit: UnitLength.meters)))
|
||||
.font(.compound.bodyLG)
|
||||
.foregroundStyle(.compound.textSecondary)
|
||||
.padding(.trailing, 15)
|
||||
} maximumValueLabel: {
|
||||
Text(Self.measurementFormatter.string(from: .init(value: 100,
|
||||
unit: UnitLength.meters)))
|
||||
.font(.compound.bodyLG)
|
||||
.foregroundStyle(.compound.textSecondary)
|
||||
.padding(.leading, 15)
|
||||
}
|
||||
.tint(.compound.iconAccentPrimary)
|
||||
}
|
||||
.padding(.horizontal, ListRowPadding.horizontal)
|
||||
.padding(.vertical, ListRowPadding.vertical)
|
||||
})
|
||||
} header: {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
@@ -127,10 +162,16 @@ private extension AppAppearance {
|
||||
// MARK: - Previews
|
||||
|
||||
struct AdvancedSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = AdvancedSettingsScreenViewModel(advancedSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
clientProxy: ClientProxyMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
static let viewModel = {
|
||||
AppSettings.resetAllSettings()
|
||||
let appSettings = AppSettings()
|
||||
appSettings.liveLocationSharingEnabled = true
|
||||
return AdvancedSettingsScreenViewModel(advancedSettings: appSettings,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
clientProxy: ClientProxyMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
}()
|
||||
|
||||
static var previews: some View {
|
||||
ElementNavigationStack {
|
||||
AdvancedSettingsScreen(context: viewModel.context)
|
||||
|
||||
@@ -173,7 +173,7 @@ class LiveLocationManager: NSObject, LiveLocationManagerProtocol, CLLocationMana
|
||||
|
||||
appSettings.$liveLocationMinimumDistanceUpdate
|
||||
.removeDuplicates()
|
||||
.debounce(for: .seconds(3), scheduler: DispatchQueue.main)
|
||||
.debounce(for: .seconds(1), scheduler: DispatchQueue.main)
|
||||
.sink { [weak self] minimumDistance in
|
||||
self?.setupMinimumDistance(minimumDistance)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user