Browse Source

v1.4.2 updates

master
Claire 2 years ago
parent
commit
fad92f6aeb
  1. 2
      LunaMac.xcodeproj/project.pbxproj
  2. 28
      LunaMac/AppDelegate.swift
  3. 4
      LunaMac/Info.plist
  4. 2
      LunaMac/InfoBox.xib
  5. 21
      readme.md

2
LunaMac.xcodeproj/project.pbxproj

@ -202,8 +202,8 @@
children = (
7ED5E24428E8AD0A00FF26EB /* dark */,
7ED5E23528E8AD0A00FF26EB /* darkalt */,
7ED5E24E28E8AD0A00FF26EB /* default */,
7ED5E27728E8ADCC00FF26EB /* emoji */,
7ED5E24E28E8AD0A00FF26EB /* default */,
);
path = png;
sourceTree = "<group>";

28
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, *) {

4
LunaMac/Info.plist

@ -21,9 +21,9 @@
<key>CFBundleDisplayName</key>
<string>LunaMac</string>
<key>CFBundleShortVersionString</key>
<string>1.4.1</string>
<string>1.4.2</string>
<key>CFBundleVersion</key>
<string>1.4.1</string>
<string>1.4.2</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>

2
LunaMac/InfoBox.xib

@ -31,7 +31,7 @@
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="24S-3e-fTg">
<rect key="frame" x="26" y="188" width="212" height="19"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="Using LunaMac 1.4" id="3Ea-1B-yru">
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="Using LunaMac 1.4.2" 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"/>

21
readme.md

@ -1,7 +1,24 @@
# LunaMac
![](LunaMac/Assets.xcassets/AppIcon.appiconset/fullmoon128.png)
<img src="LunaMac/Assets.xcassets/AppIcon.appiconset/fullmoon128.png" align="left">
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.
<br clear="left"/>
For a comprehensive breakdown of this project's code, check out the [wiki](/ABG/LunaMac/wiki).
<img src="https://abettergeek.com/_media/wiki/git/lunamac/prefmenu.png" align="right">
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).
Loading…
Cancel
Save