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 <noreply@anthropic.com>
This commit is contained in:
@@ -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`.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user