Post

Replies

Boosts

Views

Activity

Creating A Card View Tutorial Theme Issue
Hi all, I'm following this tutorial to the letter -- https://developer.apple.com/tutorials/app-dev-training/creating-a-card-view#Create-a-Color-Theme -- however, I cannot get the theme colors to change. I've tracked down the issue to this line of code -- var mainColor: Color { Color(rawValue) } -- which is in the Theme.swift file I am asked to create. I have tripled checked the syntax, references, and such. And it works when I pass it a literal value like this: var mainColor: Color { Color(.yellow) } Here is my entire Theme.swift file: import SwiftUI enum Theme: String { case bubblegum case buttercup case indigo case lavender case magenta case navy case orange case oxblood case periwinkle case poppy case purple case seafoam case sky case tan case teal case yellow var accentColor: Color { switch self { case .bubblegum, .buttercup, .lavender, .orange, .periwinkle, .poppy, .seafoam, .sky, .tan, .teal, .yellow: return .black case .indigo, .magenta, .navy, .oxblood, .purple: return .white } } var mainColor: Color { Color(rawValue) } } And this is what is used in the tutorial. Is there something I'm missing? I'm using macOS Big Sur 11.6.2 and Xcode 13.2.1. Thanks!
4
5
4.2k
Jan ’22