feat: added random Color and data type to the Store

This commit is contained in:
Serhiy Mytrovtsiy
2023-03-25 16:28:21 +01:00
parent 5105c8c20d
commit 895eaba528
2 changed files with 12 additions and 0 deletions

View File

@@ -207,6 +207,10 @@ extension Color: CaseIterable {
]
}
public static var random: Color {
Color.allColors[.random(in: 0...Color.allColors.count)]
}
public static func fromString(_ key: String, defaultValue: Color = .systemAccent) -> Color {
return Color.allCases.first{ $0.key == key } ?? defaultValue
}