Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,13 @@

import Testing
import SnapshotTesting

import Foundation
@testable import TestingHost

@MainActor
@Suite(.snapshots(record: .never, diffTool: diffTool))
struct NamedColorUITests {
@Test(.disabled {
#if os(macOS)
true
#else
false
#endif
})
@Test
func namedColor() {
openSwiftUIAssertSnapshot(
of: Color("custom")
)
openSwiftUIAssertSnapshot(of: NamedColorExample())
}
}
322 changes: 320 additions & 2 deletions Example/Shared/Assets/Assets.xcassets/custom.colorset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,329 @@
"components" : {
"alpha" : "1.000",
"blue" : "0x00",
"green" : "0xFB",
"red" : "0xFE"
"green" : "0x00",
"red" : "0xFF"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "light"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x00",
"green" : "0xCC",
"red" : "0x00"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xCC",
"green" : "0x00",
"red" : "0x00"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "contrast",
"value" : "high"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x00",
"green" : "0x88",
"red" : "0xFF"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "light"
},
{
"appearance" : "contrast",
"value" : "high"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xCC",
"green" : "0xCC",
"red" : "0x00"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
},
{
"appearance" : "contrast",
"value" : "high"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xCC",
"green" : "0x00",
"red" : "0xCC"
}
},
"idiom" : "universal"
},
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xB4",
"green" : "0x69",
"red" : "0xFF"
}
},
"idiom" : "iphone"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "light"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x7F",
"green" : "0xFF",
"red" : "0x00"
}
},
"idiom" : "iphone"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xCD",
"green" : "0x5A",
"red" : "0x6A"
}
},
"idiom" : "iphone"
},
{
"appearances" : [
{
"appearance" : "contrast",
"value" : "high"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x00",
"green" : "0xD7",
"red" : "0xFF"
}
},
"idiom" : "iphone"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "light"
},
{
"appearance" : "contrast",
"value" : "high"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xD0",
"green" : "0xE0",
"red" : "0x40"
}
},
"idiom" : "iphone"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
},
{
"appearance" : "contrast",
"value" : "high"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xEE",
"green" : "0x82",
"red" : "0xEE"
}
},
"idiom" : "iphone"
},
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x6B",
"green" : "0x6B",
"red" : "0xFF"
}
},
"idiom" : "mac"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "light"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x00",
"green" : "0xCC",
"red" : "0x88"
}
},
"idiom" : "mac"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x88",
"green" : "0x00",
"red" : "0x00"
}
},
"idiom" : "mac"
},
{
"appearances" : [
{
"appearance" : "contrast",
"value" : "high"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x00",
"green" : "0xAA",
"red" : "0xFF"
}
},
"idiom" : "mac"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "light"
},
{
"appearance" : "contrast",
"value" : "high"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x88",
"green" : "0x88",
"red" : "0x00"
}
},
"idiom" : "mac"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
},
{
"appearance" : "contrast",
"value" : "high"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xCC",
"green" : "0x00",
"red" : "0x88"
}
},
"idiom" : "mac"
}
],
"info" : {
Expand Down
2 changes: 1 addition & 1 deletion Example/Shared/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import SwiftUI

struct ContentView: View {
var body: some View {
SunsetSceneExample()
NamedColorExample()
}
}
29 changes: 29 additions & 0 deletions Example/Shared/Graphics/Color/NamedColorExample.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// NamedColorExample.swift
// Shared

#if OPENSWIFTUI
import OpenSwiftUI
#else
import SwiftUI
#endif

struct NamedColorExample: View {
let name = "custom"
var body: some View {
VStack(spacing: 0) {
Color(name)
.environment(\.colorScheme, .light)
.environment(\._colorSchemeContrast, .standard)
Color(name)
.environment(\.colorScheme, .dark)
.environment(\._colorSchemeContrast, .standard)
Color(name)
.environment(\.colorScheme, .light)
.environment(\._colorSchemeContrast, .increased)
Color(name)
.environment(\.colorScheme, .dark)
.environment(\._colorSchemeContrast, .increased)
}
}
}
Loading
Loading