-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a setting to configure the distance threshold for stopping beacon audio. Fixes #78
- Loading branch information
Showing
7 changed files
with
107 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+126 Bytes
(100%)
apps/ios/GuideDogs/Assets/Localization/en-GB.lproj/Localizable.strings
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
apps/ios/GuideDogs/Code/Visual UI/Views/Settings/Beacon/SettingStepper.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// SettingStepper.swift | ||
// Soundscape | ||
// | ||
// Created by Daniel W. Steinbrook on 8/11/24. | ||
// Copyright © 2024 Soundscape community. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
/// Defines a stepper (increment/decrement buttons) that can be used for settings like Enter Vicinity Distance. | ||
/// Takes a step size, min, max, and localization key for printing the value with units.. | ||
/// `unitsLocalization` should be a localization key like "distance.format.meters". | ||
struct SettingStepper: View { | ||
@Binding var value: Double | ||
private let unitsLocalization: String | ||
private let stepSize: Double | ||
private let minValue: Double | ||
private let maxValue: Double | ||
|
||
init(value: Binding<Double>, unitsLocalization: String, stepSize: Double, minValue: Double, maxValue: Double) { | ||
self._value = value | ||
self.unitsLocalization = unitsLocalization | ||
self.stepSize = stepSize | ||
self.minValue = minValue | ||
self.maxValue = maxValue | ||
} | ||
|
||
// Increment and Decrement actions | ||
private func increment() { | ||
let newValue = value + stepSize | ||
value = min(max(newValue, minValue), maxValue) | ||
} | ||
|
||
private func decrement() { | ||
let newValue = value - stepSize | ||
value = min(max(newValue, minValue), maxValue) | ||
} | ||
|
||
var body: some View { | ||
VStack { | ||
Stepper( | ||
onIncrement: increment, | ||
onDecrement: decrement | ||
) { | ||
// truncate `value` at the decimal point | ||
Text(GDLocalizedString(unitsLocalization, String(format: "%.0f", value))) | ||
.foregroundColor(.primaryForeground) | ||
.font(.body) | ||
.lineLimit(nil) | ||
} | ||
.padding() | ||
.background(Color.primaryBackground) | ||
} | ||
} | ||
} |