OAStatusItemKit 0.4.0

OAStatusItemKit 0.4.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Mar 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by oarrabi.



  • By
  • Omar Abdelhafith

OAStatusItemKit



OAStatusItemKit allows you to easily create mac status bar apps with a swifty flavour.

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

OAStatusItemKit is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "OAStatusItemKit"

Usage

First, import OAStatusItemKit

Then create a StatusBarItemView

let statusBarItem =
StatusBarItemView(brightStatusImage: NSImage(named: "Icon-bright")!,
darkStatusImage: NSImage(named: "Icon-dark")!)

Pass the created status bar item to a value of StatusBarWindowStyle enum.

StatusBarWindowStyle.Popup
.createPresenter(withXibName: "Panel", statusItem: statusBarItem)

Finally, you need to make your app a mac agent app. to do so open Info.plist. Add a new key “Application is agent (UIElement)” and set it’s value to YES.

image

Thats it, enjoy.

Documentation

Bellow is a quick and dirty introduction, check the full documentation here

StatusBarItemView

StatusBarItemView is the class responsible for representing a status bar view.

Example usage:

let statusItem = StatusBarItemView(brightStatusImage: BrightImage,
darkStatusImage: DarkImage)

let statusItem = StatusBarItemView(statusImage: AnyImage)

To change the width of the view, use itemWidth

statusItem.itemWidth = 200

StatusBarWindowStyle

StatusBarWindowStyle is a class responsible for displaying the status bar view.

The status ber view can be displayed in a popup, or in a window.

To display in a popup, use the following:

StatusBarWindowStyle.Popup.createPresenter(withXibName:statusItem:)

If however you want to display it in a window, you have two choices:

StatusBarWindowStyle.Window(StatusWindowPlacement)
StatusBarWindowStyle.WindowWithSize(StatusWindowPlacement, NSSize)

For example, you can do the following:

StatusBarWindowStyle.Window(.StatusBarItemCenter)
.createPresenter(withXibName: "NAME", statusItem: statusBarItem)

//or

StatusBarWindowStyle.WindowWithSize(.StatusBarItemCenter, NSSize(width: 400, height: 400))
.createPresenter(withXibName: "NAME", statusItem: statusBarItem)

StatusWindowPlacement is used to determine the placement of the window in the screen, the values are described here

StatusBarViewControllerType

If your view controller implements the StatusBarViewControllerType protocol, then StatusBarViewPresenter will set its statusViewPresenter field.

This is useful if you want to show/hide the status bar window from inside your view controller.

Tests

To run tests execute make test

Author

Omar Abdelhafith, [email protected]

License

OAStatusItemKit is available under the MIT license. See the LICENSE file for more info.