Skip to content

Commit a30837b

Browse files
authored
Merge pull request #4 from mcode10/dark-fix
This fixes the dark mode bug. * I could not find how to fix the bug with storyboard, so I used code. * Fixes #3 * This update adds the help window, but is incomplete.
2 parents 801868e + f6050fa commit a30837b

File tree

5 files changed

+116
-7
lines changed

5 files changed

+116
-7
lines changed

macOS Calculator/macOS Calculator.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
190BF6A52299EAD10072D44A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 190BF6A32299EAD10072D44A /* Main.storyboard */; };
1414
190BF6AE2299F33A0072D44A /* CalcEngineProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 190BF6AD2299F3390072D44A /* CalcEngineProtocol.swift */; };
1515
190BF6B02299F34F0072D44A /* CalculatorEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 190BF6AF2299F34F0072D44A /* CalculatorEngine.swift */; };
16+
19B3533F22E3C401007D3582 /* helpView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19B3533E22E3C401007D3582 /* helpView.swift */; };
1617
/* End PBXBuildFile section */
1718

1819
/* Begin PBXFileReference section */
@@ -25,6 +26,7 @@
2526
190BF6A72299EAD10072D44A /* macOS_Calculator.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = macOS_Calculator.entitlements; sourceTree = "<group>"; };
2627
190BF6AD2299F3390072D44A /* CalcEngineProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CalcEngineProtocol.swift; sourceTree = "<group>"; };
2728
190BF6AF2299F34F0072D44A /* CalculatorEngine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CalculatorEngine.swift; sourceTree = "<group>"; };
29+
19B3533E22E3C401007D3582 /* helpView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = helpView.swift; sourceTree = "<group>"; };
2830
/* End PBXFileReference section */
2931

3032
/* Begin PBXFrameworksBuildPhase section */
@@ -65,6 +67,7 @@
6567
190BF6A32299EAD10072D44A /* Main.storyboard */,
6668
190BF6A62299EAD10072D44A /* Info.plist */,
6769
190BF6A72299EAD10072D44A /* macOS_Calculator.entitlements */,
70+
19B3533E22E3C401007D3582 /* helpView.swift */,
6871
);
6972
path = "macOS Calculator";
7073
sourceTree = "<group>";
@@ -142,6 +145,7 @@
142145
190BF6AE2299F33A0072D44A /* CalcEngineProtocol.swift in Sources */,
143146
190BF6B02299F34F0072D44A /* CalculatorEngine.swift in Sources */,
144147
190BF6A02299EACF0072D44A /* ViewController.swift in Sources */,
148+
19B3533F22E3C401007D3582 /* helpView.swift in Sources */,
145149
190BF69E2299EACF0072D44A /* AppDelegate.swift in Sources */,
146150
);
147151
runOnlyForDeploymentPostprocessing = 0;

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

Lines changed: 84 additions & 3 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">
@@ -532,6 +532,17 @@
532532
<action selector="cf:" target="XfG-lQ-9wD" id="o6R-AX-bYt"/>
533533
</connections>
534534
</button>
535+
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="l2g-1f-W4c">
536+
<rect key="frame" x="26" y="46" width="88" height="32"/>
537+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
538+
<buttonCell key="cell" type="push" title="Help!?" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="dJ1-XI-Bae">
539+
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
540+
<font key="font" metaFont="system"/>
541+
</buttonCell>
542+
<connections>
543+
<segue destination="2GD-88-htM" kind="show" id="obK-WS-jNa"/>
544+
</connections>
545+
</button>
535546
</subviews>
536547
</view>
537548
<connections>
@@ -542,5 +553,75 @@
542553
</objects>
543554
<point key="canvasLocation" x="75" y="655"/>
544555
</scene>
556+
<!--Window Controller-->
557+
<scene sceneID="EK2-3F-QeS">
558+
<objects>
559+
<windowController id="2GD-88-htM" sceneMemberID="viewController">
560+
<window key="window" title="Help" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="EfP-K1-6Sr">
561+
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
562+
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
563+
<rect key="contentRect" x="163" y="208" width="480" height="270"/>
564+
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="800"/>
565+
<connections>
566+
<outlet property="delegate" destination="2GD-88-htM" id="oOv-pu-YBO"/>
567+
</connections>
568+
</window>
569+
<connections>
570+
<segue destination="ij5-SR-twu" kind="relationship" relationship="window.shadowedContentViewController" id="CC1-7m-V5R"/>
571+
</connections>
572+
</windowController>
573+
<customObject id="GR0-Xs-vS8" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
574+
</objects>
575+
<point key="canvasLocation" x="661" y="250"/>
576+
</scene>
577+
<!--Help View Controller-->
578+
<scene sceneID="hdo-5y-bcj">
579+
<objects>
580+
<viewController id="ij5-SR-twu" customClass="helpViewController" customModule="macOS_Calculator" customModuleProvider="target" sceneMemberID="viewController">
581+
<view key="view" id="0so-Yz-yjj">
582+
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
583+
<autoresizingMask key="autoresizingMask"/>
584+
<subviews>
585+
<scrollView appearanceType="aqua" fixedFrame="YES" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" translatesAutoresizingMaskIntoConstraints="NO" id="KGs-K7-5ul">
586+
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
587+
<autoresizingMask key="autoresizingMask"/>
588+
<clipView key="contentView" ambiguous="YES" drawsBackground="NO" copiesOnScroll="NO" id="jKk-F5-uSY">
589+
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
590+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
591+
<subviews>
592+
<textView ambiguous="YES" editable="NO" verticallyResizable="YES" findStyle="bar" allowsDocumentBackgroundColorChange="YES" spellingCorrection="YES" id="gYj-mf-n2C">
593+
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
594+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
595+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
596+
<size key="minSize" width="480" height="270"/>
597+
<size key="maxSize" width="480" height="10000000"/>
598+
<attributedString key="textStorage">
599+
<fragment content="Welcome to the MacOS Calculator Help!">
600+
<attributes>
601+
<font key="NSFont" size="24" name="Avenir-Book"/>
602+
<paragraphStyle key="NSParagraphStyle" alignment="natural" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0"/>
603+
</attributes>
604+
</fragment>
605+
</attributedString>
606+
<color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
607+
</textView>
608+
</subviews>
609+
</clipView>
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">
615+
<rect key="frame" x="464" y="0.0" width="16" height="270"/>
616+
<autoresizingMask key="autoresizingMask"/>
617+
</scroller>
618+
</scrollView>
619+
</subviews>
620+
</view>
621+
</viewController>
622+
<customObject id="KTG-wh-yvT" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
623+
</objects>
624+
<point key="canvasLocation" x="1368" y="225"/>
625+
</scene>
545626
</scenes>
546627
</document>

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: 8 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,13 +46,13 @@ 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) {
4752
display_Panel.stringValue = calcEngine.cf(original: Double(display_Panel.stringValue)!)
4853
}
4954

55+
5056
@IBAction func operators(_ sender: NSButtonCell) {
5157
//TODO Make a library full of code linked to CalcEngine and
5258
// CalcEngineProtocol
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// helpView.swift
3+
// macOS Calculator
4+
//
5+
// Created by Manas Paranjape on 7/20/19.
6+
// Copyright © 2019 DesignX6. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import Cocoa
11+
12+
class helpViewController: NSViewController {
13+
override func viewDidLoad() {
14+
super.viewDidLoad()
15+
view.wantsLayer = true
16+
view.layer?.backgroundColor = NSColor.white.cgColor
17+
}
18+
}

0 commit comments

Comments
 (0)