updated the UI for the live locations distance to match designs.

This commit is contained in:
Mauro Romito
2026-04-21 11:51:55 +02:00
committed by Mauro
parent 45d9eb4065
commit 4edebeeb75
7 changed files with 62 additions and 20 deletions

View File

@@ -283,9 +283,9 @@
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>%1$d meter</string>
<string>Every %1$d meter</string>
<key>other</key>
<string>%1$d meters</string>
<string>Every %1$d meters</string>
</dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@COUNT@</string>

View File

@@ -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 { }

View File

@@ -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)

View File

@@ -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)
}

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c30282bd1093590cb60fda722552305473fd3cacad999bed81044c2eccc9d57c
size 171794
oid sha256:7cf54519ba66ea01ee0fbb2cac517ad99bdb0018409d6a70e66c5d6f383ecf8f
size 192815

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3d02782eb9595efd43c2fff296316cae7b350ef8bb9d14aefabefcbef29f0da7
size 211907
oid sha256:5f9ebe7f8b2081eaa353a8c6cc491d9667e9d58785d792d05dceb1c6b499285c
size 241765

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:497c7f492ee43082bb72ec58ff20353e72d33be936b66ff9478eda5b653332a0
size 125423
oid sha256:0727ef553dcdd695436b11d8f167d035636678dddeaf55326b23ed88060b0ec3
size 136037