Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust "Enter Vicintiy Distance" setting minimum and widget
Browse files Browse the repository at this point in the history
steinbro committed Aug 31, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 153a8c3 commit d61ec63
Showing 2 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -61,7 +61,7 @@ struct BeaconSelectionView: View {
value: $enterImmediateVicinityDistance,
unitsLocalization: "distance.format.meters",
stepSize: 5.0,
minValue: 5.0,
minValue: 0.0,
maxValue: 50.0
)
.onChange(of: enterImmediateVicinityDistance, perform: { _ in
Original file line number Diff line number Diff line change
@@ -39,16 +39,40 @@ struct SettingStepper: View {

var body: some View {
VStack {
Stepper(
onIncrement: increment,
onDecrement: decrement
) {
/// We don't use the native `Stepper` because the increment/decrement
/// controls can't be styled, and the defaults are low contrast.
HStack {
// truncate `value` at the decimal point
Text(GDLocalizedString(unitsLocalization, String(format: "%.0f", value)))
.foregroundColor(.primaryForeground)
.font(.body)
.lineLimit(nil)

Spacer()

Button(action: decrement) {
Text("-")
.font(.title)
.frame(width: 44, height: 30)
.background(Color.gray.opacity(0.3))
.foregroundColor(.white)
.cornerRadius(8)
}
.accessibilityLabel(Text("Decrease"))
.disabled(value <= self.minValue)

Button(action: increment) {
Text("+")
.font(.title)
.frame(width: 44, height: 30)
.background(Color.gray.opacity(0.3))
.foregroundColor(.white)
.cornerRadius(8)
}
.accessibilityLabel(Text("Increase"))
.disabled(value >= self.maxValue)
}
.accessibilityElement(children: .combine)
.padding()
.background(Color.primaryBackground)
}

0 comments on commit d61ec63

Please sign in to comment.