Skip to content

Commit e3cb069

Browse files
committed
Bugfix: fix step message appearing at wrong times and add formatting to step values
1 parent 236f2fb commit e3cb069

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

InfiniLink/Core/Components/Charts/Steps/StepChartView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ struct StepChartView: View {
167167
Section {
168168
let steps = Int(chartManager.stepPoints().last?.steps ?? 0)
169169

170-
if stepCountManager.hasReachedStepGoal {
170+
if bleManager.stepCount >= deviceManager.settings.stepsGoal {
171171
Text("Great job, you reached your daily step goal today! You've walked \(String(format: "%.2f", fitnessCalculator.calculateDistance(steps: steps))) \(personalizationController.units == .imperial ? "miles" : "kilometers") and burned around \(fitnessCalculator.calculateCaloriesBurned(steps: steps)) kcal.")
172172
} else {
173173
let stepsRemaining = stepCountManager.stepGoal - steps

InfiniLink/Core/StepsView.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ struct StepsView: View {
1919

2020
let exerciseCalculator = FitnessCalculator()
2121

22+
func formattedSteps(_ steps: Int) -> String {
23+
Formatter.localizedDecimal.string(from: NSNumber(value: steps)) ?? "\(steps)"
24+
}
2225
func steps() -> Int {
2326
let stepCount = chartManager.stepsToday()
2427
if let stepCount = stepCount {
@@ -31,7 +34,7 @@ struct StepsView: View {
3134
GeometryReader { geo in
3235
List {
3336
Section {
34-
DetailHeaderView(Header(title: "\(steps())", subtitle: String(deviceManager.settings.stepsGoal), units: "Steps", icon: "figure.walk", accent: .blue), width: geo.size.width) {
37+
DetailHeaderView(Header(title: "\(formattedSteps(steps()))", subtitle: formattedSteps(Int(deviceManager.settings.stepsGoal)), units: "Steps", icon: "figure.walk", accent: .blue), width: geo.size.width) {
3538
LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible())]) {
3639
let units = personalizationController.units == .imperial ? "mi" : "km"
3740
let distance = exerciseCalculator.calculateDistance(steps: steps())

InfiniLink/Utils/StepCountManager.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ class StepCountManager: ObservableObject {
2020
var stepGoal: Int {
2121
return Int(DeviceManager.shared.settings.stepsGoal)
2222
}
23-
var hasReachedStepGoal: Bool {
24-
return BLEManager.shared.stepCount >= stepGoal
25-
}
2623

2724
// The following two functions need to use the viewContext to save because the objects they're updating were fetched on that context
2825
func setStepCount(steps: Int32, isArbitrary: Bool, for date: Date) {

0 commit comments

Comments
 (0)