Browse Source

last commit with storyboard. fixed duplicate window problem, added changelog.

master
Claire 2 years ago
parent
commit
7daf76cf04
  1. 14
      LunaMac.xcodeproj/project.pbxproj
  2. 5
      LunaMac.xcodeproj/xcuserdata/claire.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  3. 43
      LunaMac/AppDelegate.swift
  4. 29
      LunaMac/Base.lproj/Main.storyboard
  5. 28
      LunaMac/Changelog.xib
  6. 12
      LunaMac/Info.plist
  7. 29
      LunaMac/InfoBox.xib
  8. 12
      LunaMac/Main.xib
  9. 34
      LunaMac/ViewController.swift
  10. 13
      LunaMac/changelog.txt

14
LunaMac.xcodeproj/project.pbxproj

@ -7,6 +7,9 @@
objects = {
/* Begin PBXBuildFile section */
7E0CBEA428DEB998009967CD /* Changelog.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7E0CBEA328DEB998009967CD /* Changelog.xib */; };
7E0CBEA628DEBA80009967CD /* changelog.txt in Resources */ = {isa = PBXBuildFile; fileRef = 7E0CBEA528DEBA80009967CD /* changelog.txt */; };
7E7D006A28DFFAD800CD5D80 /* Main.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7E7D006928DFFAD800CD5D80 /* Main.xib */; };
7E8188BB28DD423B0080C707 /* InfoBox.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7E8188BA28DD423B0080C707 /* InfoBox.xib */; };
7E96D61628DD75BE00999EAE /* LunaMac.icns in Resources */ = {isa = PBXBuildFile; fileRef = 7E96D61528DD75BE00999EAE /* LunaMac.icns */; };
7ECD0D7C28DD2A4100B90958 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ECD0D7B28DD2A4100B90958 /* AppDelegate.swift */; };
@ -34,6 +37,9 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
7E0CBEA328DEB998009967CD /* Changelog.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = Changelog.xib; sourceTree = "<group>"; };
7E0CBEA528DEBA80009967CD /* changelog.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = changelog.txt; sourceTree = "<group>"; };
7E7D006928DFFAD800CD5D80 /* Main.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = Main.xib; sourceTree = "<group>"; };
7E8188BA28DD423B0080C707 /* InfoBox.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = InfoBox.xib; sourceTree = "<group>"; };
7E96D61528DD75BE00999EAE /* LunaMac.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = LunaMac.icns; sourceTree = "<group>"; };
7ECD0D7828DD2A4100B90958 /* LunaMac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LunaMac.app; sourceTree = BUILT_PRODUCTS_DIR; };
@ -98,10 +104,13 @@
7ECD0D7D28DD2A4100B90958 /* ViewController.swift */,
7EF79B3228DE1E4D00FF1F49 /* Assets.xcassets */,
7E96D61528DD75BE00999EAE /* LunaMac.icns */,
7ECD0D8128DD2A4200B90958 /* Main.storyboard */,
7ECD0D8428DD2A4200B90958 /* Info.plist */,
7ECD0D8528DD2A4200B90958 /* LunaMac.entitlements */,
7ECD0D8128DD2A4200B90958 /* Main.storyboard */,
7E7D006928DFFAD800CD5D80 /* Main.xib */,
7E8188BA28DD423B0080C707 /* InfoBox.xib */,
7E0CBEA328DEB998009967CD /* Changelog.xib */,
7E0CBEA528DEBA80009967CD /* changelog.txt */,
);
path = LunaMac;
sourceTree = "<group>";
@ -197,6 +206,7 @@
7E8188BB28DD423B0080C707 /* InfoBox.xib in Resources */,
7EF79BBD28DE395C00FF1F49 /* waxg.png in Resources */,
7EF79BAF28DE395C00FF1F49 /* firstq.png in Resources */,
7E0CBEA628DEBA80009967CD /* changelog.txt in Resources */,
7EF79BB428DE395C00FF1F49 /* new-dark.png in Resources */,
7EF79BB828DE395C00FF1F49 /* wang-dark.png in Resources */,
7EF79BC028DE4D2400FF1F49 /* default-dark.png in Resources */,
@ -204,9 +214,11 @@
7EF79BB628DE395C00FF1F49 /* wanc-dark.png in Resources */,
7EF79BBB28DE395C00FF1F49 /* waxc.png in Resources */,
7EF79BB528DE395C00FF1F49 /* new.png in Resources */,
7E7D006A28DFFAD800CD5D80 /* Main.xib in Resources */,
7EF79BB228DE395C00FF1F49 /* lastq-dark.png in Resources */,
7EF79BB328DE395C00FF1F49 /* lastq.png in Resources */,
7ECD0D8328DD2A4200B90958 /* Main.storyboard in Resources */,
7E0CBEA428DEB998009967CD /* Changelog.xib in Resources */,
7EF79BB028DE395C00FF1F49 /* full-dark.png in Resources */,
7EF79BB128DE395C00FF1F49 /* full.png in Resources */,
7EF79BC128DE4D2400FF1F49 /* default.png in Resources */,

5
LunaMac.xcodeproj/xcuserdata/claire.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>

43
LunaMac/AppDelegate.swift

@ -81,14 +81,38 @@ class AppDelegate: NSObject, NSApplicationDelegate {
]
]
@IBAction func clickClick(_ sender: NSButtonCell) {
// show changelog
showLog()
}
// make sure applet stays in memory
var statusBarItem: NSStatusItem?
// create empty timer for event loop
var lunaTimer = Timer()
// is the info box open?
var infoOpen = false
// is the changelog open?
var logOpen = false
func applicationDidFinishLaunching(_ aNotification: Notification) {
// build the icon and menu
updateIcon()
// listen for theme changes (dark and light)
themeListener()
// start the the timer for keeping the icon updated automatically
startTimer()
}
// start the timer for auto-updating the icon
func startTimer() {
lunaTimer = Timer.scheduledTimer(timeInterval: 10, target: self, selector: #selector(updateIcon), userInfo: nil, repeats: true)
RunLoop.current.add(lunaTimer, forMode: RunLoop.Mode.common)
}
@objc func buildMenu(key: String = "default") {
@ -158,8 +182,23 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
@objc func showAbout() {
let aboutWin = NSWindowController(windowNibName: "InfoBox")
aboutWin.loadWindow()
if (!infoOpen) {
// create infobox window object
let aboutWin = NSWindowController(windowNibName: "InfoBox")
aboutWin.loadWindow()
}
NSApp.activate(ignoringOtherApps: true)
}
@objc func showLog() {
if (!logOpen) {
// create changelog window object
// this creates duplicate windows
let logWin = NSWindowController(windowNibName: "Changelog")
logWin.loadWindow()
}
NSApp.activate(ignoringOtherApps: true)
}

29
LunaMac/Base.lproj/Main.storyboard

@ -729,32 +729,6 @@
<view key="view" id="m2S-Jp-Qdl">
<rect key="frame" x="0.0" y="0.0" width="249" height="274"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="zPd-dZ-JB6">
<rect key="frame" x="18" y="20" width="213" height="89"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" selectable="YES" alignment="left" id="N9O-b1-UB3">
<font key="font" metaFont="system"/>
<string key="title">LunaMac calculates the current moon phase when it launches. If you see a 🌙 instead of a moon phase, try again from the status bar icon's menu.</string>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="beZ-L9-iwv">
<rect key="frame" x="58" y="167" width="131" height="87"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="LunaMac" id="Uf6-kq-taq"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="KAY-LC-WF7">
<rect key="frame" x="18" y="127" width="212" height="19"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="Using LunaMac 1.0" id="IeD-MK-19W">
<font key="font" metaFont="system" size="15"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
</view>
</viewController>
<customObject id="rPt-NT-nkU" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
@ -762,7 +736,4 @@
<point key="canvasLocation" x="75.5" y="798"/>
</scene>
</scenes>
<resources>
<image name="LunaMac" width="512" height="512"/>
</resources>
</document>

28
LunaMac/Changelog.xib

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner"/>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Changelog" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="480" height="270"/>
<rect key="screenRect" x="0.0" y="0.0" width="1366" height="745"/>
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
<autoresizingMask key="autoresizingMask"/>
</view>
<point key="canvasLocation" x="226" y="145"/>
</window>
<viewController id="E4t-Te-Ks6" customClass="ViewController" customModule="LunaMac" customModuleProvider="target">
<connections>
<outlet property="view" destination="EiT-Mj-1SZ" id="edO-V9-RBV"/>
</connections>
</viewController>
</objects>
</document>

12
LunaMac/Info.plist

@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSMainNibFile</key>
<string>Main</string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
@ -17,22 +19,16 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.1</string>
<string>1.2</string>
<key>CFBundleVersion</key>
<string>1.1</string>
<string>1.2</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>LSUIElement</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2022 A Better Geek. All rights reserved.</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSServices</key>
<array>
<dict/>
</array>
</dict>
</plist>

29
LunaMac/InfoBox.xib

@ -11,12 +11,23 @@
<window title="About LunaMac" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" titleVisibility="hidden" id="QvC-M9-y7g">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<windowPositionMask key="initialPositionMask" topStrut="YES"/>
<rect key="contentRect" x="591" y="408" width="235" height="262"/>
<rect key="contentRect" x="591" y="408" width="235" height="265"/>
<rect key="screenRect" x="0.0" y="0.0" width="1366" height="745"/>
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="235" height="262"/>
<rect key="frame" x="0.0" y="0.0" width="235" height="265"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="OpR-pc-qnX">
<rect key="frame" x="69" y="157" width="97" height="97"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="LunaMac" imagePosition="overlaps" alignment="center" imageScaling="proportionallyUpOrDown" inset="2" id="ewn-Jd-BGA">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<connections>
<action selector="clickClick:" target="-1" id="59F-4l-knP"/>
</connections>
</buttonCell>
</button>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Jwa-x9-RgK">
<rect key="frame" x="18" y="20" width="199" height="89"/>
<autoresizingMask key="autoresizingMask"/>
@ -27,15 +38,10 @@
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="hA4-I6-tXE">
<rect key="frame" x="52" y="155" width="131" height="87"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="LunaMac" id="NoG-dJ-hxH"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="24S-3e-fTg">
<rect key="frame" x="11" y="121" width="212" height="19"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="Using LunaMac 1.1" id="3Ea-1B-yru">
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="Using LunaMac" id="3Ea-1B-yru">
<font key="font" metaFont="system" size="15"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
@ -43,8 +49,13 @@
</textField>
</subviews>
</view>
<point key="canvasLocation" x="36.5" y="179"/>
<point key="canvasLocation" x="36.5" y="180.5"/>
</window>
<viewController id="1Dw-mw-LdK" customClass="ViewController" customModule="LunaMac" customModuleProvider="target">
<connections>
<outlet property="view" destination="EiT-Mj-1SZ" id="2sl-F5-ehU"/>
</connections>
</viewController>
</objects>
<resources>
<image name="LunaMac" width="512" height="512"/>

12
LunaMac/Main.xib

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner"/>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customObject id="Umm-9I-rkJ" customClass="AppDelegate" customModule="LunaMac" customModuleProvider="target"/>
</objects>
</document>

34
LunaMac/ViewController.swift

@ -8,20 +8,40 @@
import Cocoa
class ViewController: NSViewController {
class ViewController: NSViewController, NSWindowDelegate {
let appDelegate = NSApplication.shared.delegate as! AppDelegate
override func viewDidLoad() {
print("view did load")
super.viewDidLoad()
// Do any additional setup after loading the view.
toggleWindow(boolShow: true)
}
override func viewDidAppear() {
self.view.window?.delegate = self
}
// triggers when window is closed
override func viewWillDisappear() {
print("view will disappear")
toggleWindow(boolShow: false)
}
override var representedObject: Any? {
didSet {
// Update the view, if already loaded.
func toggleWindow(boolShow: Bool = false) {
// get the window title to set the right bool
// window title is in self.view.window.title
let winTitle = self.view.window?.title
if (winTitle?.contains("About") ?? false) {
appDelegate.infoOpen = boolShow
}
else if (winTitle?.contains("Changelog") ?? false) {
appDelegate.logOpen = boolShow
}
}
}

13
LunaMac/changelog.txt

@ -0,0 +1,13 @@
====== Changelog ======
v1.2
- Added automatic icon update as phase changes
- Added changelog
- Fixed window duplication problem
v1.1
- Updated icons to use images instead of emoji
- Fixed About window to display on top when opened
v1.0
- Initial release
Loading…
Cancel
Save