Add interactive widget voting and fix warnings/bugs

Widget Features:
- Add inline voting to timeline widget when no entry exists for today
- Show random prompt from notification strings in voting mode
- Update vote widget to use simple icon style for selection
- Make stats bar full width in voted state view
- Add Localizable.strings to widget extension target

Bug Fixes:
- Fix inverted date calculation in InsightsViewModel streak logic
- Replace force unwraps with safe optional handling in widgets
- Replace fatalError calls with graceful error handling
- Fix CSV import safety in SettingsView

Warning Fixes:
- Add @retroactive to Color and Date extension conformances
- Update deprecated onChange(of:perform:) to new syntax
- Replace deprecated applicationIconBadgeNumber with setBadgeCount
- Replace deprecated UIApplication.shared.windows API
- Add @preconcurrency for Swift 6 protocol conformances
- Add missing widget family cases to switch statement
- Remove unused variables and #warning directives

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Trey t
2025-12-10 16:23:12 -06:00
parent aaaf04f05e
commit f822927e98
20 changed files with 317 additions and 220 deletions

View File

@@ -990,16 +990,20 @@ class InsightsViewModel: ObservableObject {
var tempStreak = 1
let today = calendar.startOfDay(for: Date())
let mostRecent = sortedEntries.first!.forDate
if calendar.isDate(mostRecent, inSameDayAs: today) || calendar.isDate(mostRecent, inSameDayAs: calendar.date(byAdding: .day, value: -1, to: today)!) {
guard let mostRecent = sortedEntries.first?.forDate,
let yesterday = calendar.date(byAdding: .day, value: -1, to: today) else {
return (0, 0)
}
if calendar.isDate(mostRecent, inSameDayAs: today) || calendar.isDate(mostRecent, inSameDayAs: yesterday) {
currentStreak = 1
var checkDate = calendar.date(byAdding: .day, value: -1, to: mostRecent)!
var checkDate = calendar.date(byAdding: .day, value: -1, to: mostRecent) ?? mostRecent
for entry in sortedEntries.dropFirst() {
let entryDate = entry.forDate
if calendar.isDate(entryDate, inSameDayAs: checkDate) {
currentStreak += 1
checkDate = calendar.date(byAdding: .day, value: -1, to: checkDate)!
checkDate = calendar.date(byAdding: .day, value: -1, to: checkDate) ?? checkDate
} else {
break
}
@@ -1009,7 +1013,7 @@ class InsightsViewModel: ObservableObject {
for i in 1..<sortedEntries.count {
let currentDate = sortedEntries[i].forDate
let previousDate = sortedEntries[i-1].forDate
let dayDiff = calendar.dateComponents([.day], from: currentDate, to: previousDate).day ?? 0
let dayDiff = calendar.dateComponents([.day], from: previousDate, to: currentDate).day ?? 0
if dayDiff == 1 {
tempStreak += 1
} else {