add web label color selections and choose a random color as the initial selection

This commit is contained in:
Satindar Dhillon 2022-04-13 15:28:09 -07:00
parent a75c8e91a4
commit f8ba24bc79

View file

@ -102,7 +102,12 @@ struct CreateLabelView: View {
GridItem(.fixed(70))
]
let swatches = swatchHexes.map { Color(hex: $0) ?? .clear }.shuffled()
let swatches: [Color] = {
let webSwatches = webSwatchHexes.map { Color(hex: $0) ?? .clear }
var additionalSwatches = swatchHexes.map { Color(hex: $0) ?? .clear }.shuffled()
let firstSwatch = additionalSwatches.remove(at: 0)
return [firstSwatch] + webSwatches + additionalSwatches
}()
var body: some View {
NavigationView {
@ -174,10 +179,22 @@ struct CreateLabelView: View {
#if os(iOS)
.navigationBarTitleDisplayMode(.inline)
#endif
.onAppear {
newLabelColor = swatches.first ?? .clear
}
}
}
}
private let webSwatchHexes = [
"#FF5D99",
"#7CFF7B",
"#FFD234",
"#7BE4FF",
"#CE88EF",
"#EF8C43"
]
private let swatchHexes = [
"#fff034",
"#efff34",