didats / OAStatusItemKit

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OAStatusItemKit


CI Status codecov.io Version License Platform


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, o.arrabi@me.com

License

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

About

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

License:MIT License


Languages

Language:Swift 94.4%Language:Ruby 3.2%Language:Makefile 1.4%Language:Objective-C 1.0%