Skip's named color handling parses the .colorset resource, but only handles when the "Input Method" is "Floating Point". For example, this setting:
Will create this Sources/Showcase/Resources/Module.xcassets/CustomRed.colorset/Contents.json file:
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.733",
"green" : "0.067",
"red" : "0.580"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.474",
"green" : "0.493",
"red" : "1.000"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
But if you switch the "Input Method" to "8-bit hexadecimal":
It will create the following contents with hex encoding:
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xBB",
"green" : "0x11",
"red" : "0x94"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.474",
"green" : "0.493",
"red" : "1.000"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Skip's color parsing does not handle this:
|
struct ColorComponents : Decodable { |
|
let red: String? |
|
let green: String? |
|
let blue: String? |
|
let alpha: String? |
|
|
|
var color: Color { |
|
let redValue = Double(red ?? "") ?? 0.0 |
|
let greenValue = Double(green ?? "") ?? 0.0 |
|
let blueValue = Double(blue ?? "") ?? 0.0 |
|
let alphaValue = Double(alpha ?? "") ?? 1.0 |
|
return Color(red: redValue, green: greenValue, blue: blueValue, opacity: alphaValue) |
|
} |
|
} |
This results in the color just appearing black. We should handle all the Input Method variants that can be represented in the .colorset file.
This was reported in the Slack at: https://skiptools.slack.com/archives/C078X69G8F2/p1741638916826529?thread_ts=1741636875.710679&cid=C078X69G8F2
Skip's named color handling parses the .colorset resource, but only handles when the "Input Method" is "Floating Point". For example, this setting:
Will create this
Sources/Showcase/Resources/Module.xcassets/CustomRed.colorset/Contents.jsonfile:{ "colors" : [ { "color" : { "color-space" : "srgb", "components" : { "alpha" : "1.000", "blue" : "0.733", "green" : "0.067", "red" : "0.580" } }, "idiom" : "universal" }, { "appearances" : [ { "appearance" : "luminosity", "value" : "dark" } ], "color" : { "color-space" : "srgb", "components" : { "alpha" : "1.000", "blue" : "0.474", "green" : "0.493", "red" : "1.000" } }, "idiom" : "universal" } ], "info" : { "author" : "xcode", "version" : 1 } }But if you switch the "Input Method" to "8-bit hexadecimal":
It will create the following contents with hex encoding:
{ "colors" : [ { "color" : { "color-space" : "srgb", "components" : { "alpha" : "1.000", "blue" : "0xBB", "green" : "0x11", "red" : "0x94" } }, "idiom" : "universal" }, { "appearances" : [ { "appearance" : "luminosity", "value" : "dark" } ], "color" : { "color-space" : "srgb", "components" : { "alpha" : "1.000", "blue" : "0.474", "green" : "0.493", "red" : "1.000" } }, "idiom" : "universal" } ], "info" : { "author" : "xcode", "version" : 1 } }Skip's color parsing does not handle this:
skip-ui/Sources/SkipUI/SkipUI/Color/Color.swift
Lines 603 to 616 in 63bc24a
This results in the color just appearing black. We should handle all the Input Method variants that can be represented in the
.colorsetfile.This was reported in the Slack at: https://skiptools.slack.com/archives/C078X69G8F2/p1741638916826529?thread_ts=1741636875.710679&cid=C078X69G8F2