feat: added an option to set colors for the State widget

This commit is contained in:
Serhiy Mytrovtsiy
2022-09-22 18:19:49 +02:00
parent 1e15d6590a
commit b48dd05543
2 changed files with 66 additions and 1 deletions

View File

@@ -172,6 +172,14 @@ extension Color: CaseIterable {
]
}
public static var allColors: [Color] {
return [.clear, .white, .black, .gray, .secondGray, .darkGray, .lightGray,
.red, .secondRed, .green, .secondGreen, .blue, .secondBlue, .yellow, .secondYellow,
.orange, .secondOrange, .purple, .secondPurple, .brown, .secondBrown,
.cyan, .magenta, .pink, .teal, .indigo
]
}
public static func fromString(_ key: String, defaultValue: Color = .systemAccent) -> Color {
return Color.allCases.first{ $0.key == key } ?? defaultValue
}