Fix 8 audit items: remove force-unwraps, improve accessibility and concurrency
- Replace force-unwrap HK types with modern HKQuantityType(_:) initializer - Replace Calendar.date force-unwraps with guard/let in HealthService, HeaderPercView, MoodStreakActivity, DayViewViewModel, MonthTotalTemplate - Extract DayViewViewModel.countEntries into testable static method with safe flatMap - Replace DispatchQueue.main.asyncAfter with Task.sleep in CelebrationAnimations - Add .minimumScaleFactor(0.5) to SmallRollUpHeaderView for Dynamic Type - Add VoiceOver accessibility labels to HeaderPercView mood percentages - Fix @testable import iFeel → Feels in Tests_iOS.swift - Add 4 unit tests for countEntries (TDD) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -32,10 +32,10 @@ struct HeaderPercView: View {
|
||||
if fakeData {
|
||||
moodEntries = DataController.shared.randomEntries(count: 10)
|
||||
} else {
|
||||
var daysAgo = Calendar.current.date(byAdding: .day, value: -backDays, to: Date())!
|
||||
daysAgo = Calendar.current.date(bySettingHour: 0, minute: 0, second: 0, of: daysAgo)!
|
||||
|
||||
moodEntries = DataController.shared.getData(startDate: daysAgo, endDate: Date(), includedDays: [1,2,3,4,5,6,7])
|
||||
if let daysAgoRaw = Calendar.current.date(byAdding: .day, value: -backDays, to: Date()),
|
||||
let daysAgo = Calendar.current.date(bySettingHour: 0, minute: 0, second: 0, of: daysAgoRaw) {
|
||||
moodEntries = DataController.shared.getData(startDate: daysAgo, endDate: Date(), includedDays: [1,2,3,4,5,6,7])
|
||||
}
|
||||
}
|
||||
|
||||
if let moodEntries = moodEntries {
|
||||
@@ -57,6 +57,7 @@ struct HeaderPercView: View {
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(moodTint.color(forMood: model.mood))
|
||||
.frame(maxWidth: .infinity)
|
||||
.accessibilityLabel("\(model.mood.strValue) \(Int(model.percent)) percent")
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
@@ -67,6 +68,7 @@ struct HeaderPercView: View {
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(moodTint.color(forMood: model.mood))
|
||||
.frame(maxWidth: .infinity)
|
||||
.accessibilityLabel("\(model.mood.strValue) \(Int(model.percent)) percent")
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
@@ -82,6 +84,7 @@ struct HeaderPercView: View {
|
||||
bgColor: moodTint.color(forMood: model.mood),
|
||||
textColor: textColor)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.accessibilityLabel("\(model.mood.strValue) \(Int(model.percent)) percent")
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
@@ -91,6 +94,7 @@ struct HeaderPercView: View {
|
||||
bgColor: moodTint.color(forMood: model.mood),
|
||||
textColor: textColor)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.accessibilityLabel("\(model.mood.strValue) \(Int(model.percent)) percent")
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
|
||||
Reference in New Issue
Block a user