diff --git a/LunaMac.xcodeproj/project.pbxproj b/LunaMac.xcodeproj/project.pbxproj index 001e5f5..80e18a7 100644 --- a/LunaMac.xcodeproj/project.pbxproj +++ b/LunaMac.xcodeproj/project.pbxproj @@ -202,8 +202,8 @@ children = ( 7ED5E24428E8AD0A00FF26EB /* dark */, 7ED5E23528E8AD0A00FF26EB /* darkalt */, - 7ED5E24E28E8AD0A00FF26EB /* default */, 7ED5E27728E8ADCC00FF26EB /* emoji */, + 7ED5E24E28E8AD0A00FF26EB /* default */, ); path = png; sourceTree = ""; diff --git a/LunaMac/AppDelegate.swift b/LunaMac/AppDelegate.swift index 9c40b6a..45bde8c 100644 --- a/LunaMac/AppDelegate.swift +++ b/LunaMac/AppDelegate.swift @@ -86,9 +86,15 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate { showLog() } + // get system-wide menu bar + let statusBar = NSStatusBar.system + // make sure applet stays in memory var statusBarItem: NSStatusItem? + // create a menu for the icon + let statusBarMenu = NSMenu(title: "LunaMac Menu") + // create empty timer for event loop var lunaTimer = Timer() @@ -110,6 +116,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate { // start the the timer for keeping the icon updated automatically startTimer() + + // set icon size to square + statusBarItem = statusBar.statusItem(withLength: NSStatusItem.squareLength) } // start the timer for auto-updating the icon @@ -127,17 +136,10 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate { } @objc func buildMenu(key: String = "default") { - // create a menu for the icon - let statusBarMenu = NSMenu(title: "LunaMac Menu") + statusBarMenu.removeAllItems() statusBarMenu.delegate = self - // get system-wide menu bar - let statusBar = NSStatusBar.system - - // set icon size to square - statusBarItem = statusBar.statusItem(withLength: NSStatusItem.squareLength) - // filename suffix /* -dark dark mode @@ -151,17 +153,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate { // if iconPref is set to emoji if (defaults.string(forKey: "iconPref") == "emoji") { - // change font size - // still not aligned properly - /* - let iconString = phaseArray[key]?["icon"] as String? ?? "⨂" - let iconAttrib = [ NSAttributedString.Key.font: NSFont.menuFont(ofSize: 12.0) ] - let iconAttrString = NSAttributedString(string: iconString, attributes: iconAttrib) - statusBarItem?.button?.attributedTitle = iconAttrString - */ suffix += "-emoji" } - // otherwise use icons + // otherwise use monochrome icons else { // check for dark mode and set the right image file if #available(OSX 10.14, *) { diff --git a/LunaMac/Info.plist b/LunaMac/Info.plist index d0dad0b..f5064b6 100644 --- a/LunaMac/Info.plist +++ b/LunaMac/Info.plist @@ -21,9 +21,9 @@ CFBundleDisplayName LunaMac CFBundleShortVersionString - 1.4.1 + 1.4.2 CFBundleVersion - 1.4.1 + 1.4.2 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSHumanReadableCopyright diff --git a/LunaMac/InfoBox.xib b/LunaMac/InfoBox.xib index 0c1d80f..30338d8 100644 --- a/LunaMac/InfoBox.xib +++ b/LunaMac/InfoBox.xib @@ -31,7 +31,7 @@ - + diff --git a/readme.md b/readme.md index 78778fc..5afebe0 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,24 @@ # LunaMac -![](LunaMac/Assets.xcassets/AppIcon.appiconset/fullmoon128.png) + A MacOS menu bar app for the phases of the moon. LunaMac calculates the current moon phase using your computer's system time. If the menu bar icon is a Ⓧ, something went wrong and LunaMac couldn't calculate the moon phase. You can try reloading from the icon's menu. +
-For a comprehensive breakdown of this project's code, check out the [wiki](/ABG/LunaMac/wiki). + + +This project covers a number of basic use cases: + +* Programmatically creating a status icon in the system menu bar +* Working with datetime objects, including datetime math +* Loading contents of a file packaged with the application +* Using a timer to run periodic background updates +* Setting and using user preferences to build the UI + +There are some useful implementations for those new to Apple's programming paradigms. Swift adopts a lot of Objective-C concepts, which themselves are likely foreign if don't already have a working knowledge of Objective-C. + +* Using interface builder **actions** and **outlets** to work with window elements +* Working with **object delegation** +* Implementing a **view controller** to interact with windows + +For a comprehensive breakdown of this project's code, check out the [wiki](/ABG/LunaMac/wiki). \ No newline at end of file