Skip to content

Commit f6050fa

Browse files
committed
This fixes the dark mode bug.
* I could not find how to fix the bug with storyboard, so I used code.
1 parent 7bf885c commit f6050fa

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

macOS Calculator/macOS Calculator/Base.lproj/Main.storyboard

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
66
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
77
</dependencies>
88
<scenes>
@@ -205,7 +205,7 @@
205205
<menuItem title="Show Sidebar" keyEquivalent="s" id="kIP-vf-haE">
206206
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
207207
<connections>
208-
<action selector="toggleSourceList:" target="Ady-hI-5gd" id="iwa-gc-5KM"/>
208+
<action selector="toggleSidebar:" target="Ady-hI-5gd" id="iwa-gc-5KM"/>
209209
</connections>
210210
</menuItem>
211211
<menuItem title="Enter Full Screen" keyEquivalent="f" id="4J7-dP-txa">
@@ -607,7 +607,11 @@
607607
</textView>
608608
</subviews>
609609
</clipView>
610-
<scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="uDS-93-Jy8">
610+
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="GP5-AW-ICx">
611+
<rect key="frame" x="-100" y="-100" width="480" height="16"/>
612+
<autoresizingMask key="autoresizingMask"/>
613+
</scroller>
614+
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="uDS-93-Jy8">
611615
<rect key="frame" x="464" y="0.0" width="16" height="270"/>
612616
<autoresizingMask key="autoresizingMask"/>
613617
</scroller>

macOS Calculator/macOS Calculator/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.0</string>
20+
<string>1.2</string>
2121
<key>CFBundleVersion</key>
22-
<string>1</string>
22+
<string>001</string>
2323
<key>LSMinimumSystemVersion</key>
2424
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
2525
<key>NSHumanReadableCopyright</key>

macOS Calculator/macOS Calculator/ViewController.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,19 @@ class ViewController: NSViewController {
1313
var calcEngine = getCalcEngine()
1414
var answer = ""
1515
var operation:operatorCases = .add
16+
var inDarkMode: Bool {
17+
let mode = UserDefaults.standard.string(forKey: "AppleInterfaceStyle")
18+
return mode == "Dark"
19+
}
1620

1721
@IBOutlet var display_Panel: NSTextField!
1822

1923
override func viewDidLoad() {
2024
super.viewDidLoad()
2125
view.wantsLayer = true
22-
view.layer?.backgroundColor = NSColor.white.cgColor
26+
if !inDarkMode {
27+
view.layer?.backgroundColor = NSColor.white.cgColor
28+
}
2329
}
2430

2531
override var representedObject: Any? {
@@ -40,7 +46,6 @@ var operation:operatorCases = .add
4046

4147
@IBAction func fc(_ sender: NSButton) {
4248
display_Panel.stringValue = calcEngine.fc(original: Double(display_Panel.stringValue)!)
43-
answer = display_Panel.stringValue
4449
}
4550

4651
@IBAction func cf(_ sender: NSButton) {

0 commit comments

Comments
 (0)