From 8f6980df13227dc8472d87fb1e31adf3a57f927a Mon Sep 17 00:00:00 2001 From: kutesir Date: Thu, 9 Jul 2026 02:19:32 +0300 Subject: [PATCH] fix(theme): add AppColors.coffeeBrown -- Color(r:g:b:) is file-private (KC-57) Build error: Color(r:g:b:) is a private extension scoped to DesignTokens.swift (only UIColor's sibling init is also private, both file-scoped by design). KC-55/56 called it directly from SettingsView.swift and OnboardingView.swift for the coffee icon color -- invisible there, so the compiler fell back to unrelated overloads ('Cannot convert Int to Color', 'Extra argument b'). Added AppColors.coffeeBrown (defined where the private init is visible), replacing both inline Color(r:g:b:) call sites -- matches how every other color in the app is centralized and accessible everywhere. Co-Authored-By: Claude Opus 4.8 --- KisaniCal/ISSUES.md | 27 +++++++++++++++++++++++++++ KisaniCal/Theme/DesignTokens.swift | 1 + KisaniCal/Views/OnboardingView.swift | 2 +- KisaniCal/Views/SettingsView.swift | 2 +- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/KisaniCal/ISSUES.md b/KisaniCal/ISSUES.md index 857ab21..76ed4b7 100644 --- a/KisaniCal/ISSUES.md +++ b/KisaniCal/ISSUES.md @@ -1938,3 +1938,30 @@ parens checked programmatically; `logHabitDone`/`habitDoneCount` intentionally left without `@MainActor` to match the existing nonisolated handler functions (`markTaskComplete`, `snoozeTask`) they run alongside in the notification delegate callback. + +--- + +## KC-57 — Build error: Color(r:g:b:) used outside its file (coffee brown) + +**Status:** Fixed (not build-verified) +**Reported by:** User (Xcode build errors: "Cannot convert value of type +'Int' to expected argument type 'Color'", "Extra argument 'b' in call") + +### Root cause +`Color(r:g:b:)` (Double) is declared as `private extension Color` inside +`DesignTokens.swift` — invisible outside that file by design (only `UIColor`'s +`init(r:g:b:)` sibling is `private` too, both file-scoped). KC-55/56 used +`Color(r: 122, g: 84, b: 52)` directly in `SettingsView.swift` and +`OnboardingView.swift` for the coffee icon's brown background — neither file +can see the private initializer, so the compiler fell back to unrelated +overloads and produced the confusing "Cannot convert Int to Color" errors. + +### Fix +Added `AppColors.coffeeBrown` (defined inside `DesignTokens.swift`, where the +private init IS visible) alongside the other fixed accent colors +(accent/green/blue/yellow/red). Both call sites now reference +`AppColors.coffeeBrown` instead of constructing the color inline — matches +how every other color in the app is centralized, and is accessible from any +file. + +Files: `DesignTokens.swift`, `SettingsView.swift`, `OnboardingView.swift`. diff --git a/KisaniCal/Theme/DesignTokens.swift b/KisaniCal/Theme/DesignTokens.swift index 613a94f..88743fa 100644 --- a/KisaniCal/Theme/DesignTokens.swift +++ b/KisaniCal/Theme/DesignTokens.swift @@ -9,6 +9,7 @@ struct AppColors { static let blue = Color(r: 77, g: 157, b: 224) static let yellow = Color(r: 232, g: 184, b: 42) static let red = Color(r: 232, g: 66, b: 66) + static let coffeeBrown = Color(r: 122, g: 84, b: 52) static let accentSoft = Color(UIColor { $0.userInterfaceStyle == .dark ? UIColor(r: 52, g: 28, b: 14) // dark: deep warm orange diff --git a/KisaniCal/Views/OnboardingView.swift b/KisaniCal/Views/OnboardingView.swift index cd91585..762b05f 100644 --- a/KisaniCal/Views/OnboardingView.swift +++ b/KisaniCal/Views/OnboardingView.swift @@ -531,7 +531,7 @@ struct OnboardingView: View { isOn: $bedReminderEnabled) Divider().background(AppColors.border(cs)).padding(.leading, 53) OnboardingHabitToggle( - icon: "cup.and.saucer.fill", iconColor: .white, iconBg: Color(r: 122, g: 84, b: 52), + icon: "cup.and.saucer.fill", iconColor: .white, iconBg: AppColors.coffeeBrown, title: "Coffee reminders", subtitle: "Track when you usually reach for a cup", isOn: $coffeeReminderEnabled) diff --git a/KisaniCal/Views/SettingsView.swift b/KisaniCal/Views/SettingsView.swift index c87581e..8fa63cd 100644 --- a/KisaniCal/Views/SettingsView.swift +++ b/KisaniCal/Views/SettingsView.swift @@ -1000,7 +1000,7 @@ private struct HabitRemindersSheet: View { HStack(spacing: 11) { Image(systemName: "cup.and.saucer.fill") .font(.system(size: 13)).foregroundColor(.white) - .frame(width: 28, height: 28).background(Color(r: 122, g: 84, b: 52)).cornerRadius(8) + .frame(width: 28, height: 28).background(AppColors.coffeeBrown).cornerRadius(8) VStack(alignment: .leading, spacing: 1) { HStack(spacing: 6) { Text("Coffee reminders").font(AppFonts.sans(13)).foregroundColor(AppColors.text(cs))