Skip to content

Commit 87f620a

Browse files
committed
refactor: prepare for adaptive background colors
1 parent f87ef9c commit 87f620a

4 files changed

Lines changed: 50 additions & 2 deletions

File tree

xcode/App-Mac/AppDelegate.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
5858
window.titlebarAppearsTransparent = true
5959
// Initialize webview
6060
window.contentViewController = ViewController()
61-
window.backgroundColor = .clear // DEBUG
61+
// https://developer.apple.com/documentation/uikit/appearance_customization/supporting_dark_mode_in_your_interface#2993897
62+
window.backgroundColor = NSColor(named: NSColor.Name("USBackgroundColor"))
63+
// window.backgroundColor = .clear // DEBUG
6264
window.center()
6365
window.setIsVisible(true)
6466
window.makeMain()
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"colors" : [
3+
{
4+
"color" : {
5+
"color-space" : "srgb",
6+
"components" : {
7+
"alpha" : "1.000",
8+
"blue" : "0x39",
9+
"green" : "0x36",
10+
"red" : "0x32"
11+
}
12+
},
13+
"idiom" : "universal"
14+
},
15+
{
16+
"appearances" : [
17+
{
18+
"appearance" : "luminosity",
19+
"value" : "dark"
20+
}
21+
],
22+
"color" : {
23+
"color-space" : "srgb",
24+
"components" : {
25+
"alpha" : "1.000",
26+
"blue" : "0x39",
27+
"green" : "0x36",
28+
"red" : "0x32"
29+
}
30+
},
31+
"idiom" : "universal"
32+
}
33+
],
34+
"info" : {
35+
"author" : "xcode",
36+
"version" : 1
37+
}
38+
}

xcode/App-Shared/ViewController.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ class ViewController: PlatformViewController, WKNavigationDelegate, WKScriptMess
3939
self.webView = WKWebView(frame: .zero, configuration: configuration)
4040
#if os(iOS)
4141
self.webView.isOpaque = false
42-
self.webView.backgroundColor = .clear
42+
// https://developer.apple.com/documentation/uikit/appearance_customization/supporting_dark_mode_in_your_interface#2993897
43+
self.webView.backgroundColor = UIColor(named: "USBackgroundColor")
44+
// self.webView.backgroundColor = .clear // DEBUG
4345
// self.webView.scrollView.isScrollEnabled = false
4446
#elseif os(macOS)
4547
self.webView.frame = NSRect(x: 0, y: 0, width: 600, height: 600)

0 commit comments

Comments
 (0)