{"id":13479494,"url":"https://github.com/iSapozhnik/Popover","last_synced_at":"2025-03-27T09:32:43.089Z","repository":{"id":46124144,"uuid":"252293188","full_name":"iSapozhnik/Popover","owner":"iSapozhnik","description":"Custom macOS Popover 💬","archived":false,"fork":false,"pushed_at":"2021-11-12T12:42:56.000Z","size":357,"stargazers_count":124,"open_issues_count":4,"forks_count":18,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-08T16:48:41.787Z","etag":null,"topics":["macos","macos-app","menubar","nspanel","nspopover","nsstatusbarbutton","nsstatusitem","nswindow","osx","popover","statusbar","windows"],"latest_commit_sha":null,"homepage":"https://isapozhnik.com/articles/status-item/","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iSapozhnik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-01T21:42:52.000Z","updated_at":"2024-09-13T10:16:19.000Z","dependencies_parsed_at":"2022-09-24T17:31:06.239Z","dependency_job_id":null,"html_url":"https://github.com/iSapozhnik/Popover","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iSapozhnik%2FPopover","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iSapozhnik%2FPopover/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iSapozhnik%2FPopover/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iSapozhnik%2FPopover/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iSapozhnik","download_url":"https://codeload.github.com/iSapozhnik/Popover/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245817637,"owners_count":20677326,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["macos","macos-app","menubar","nspanel","nspopover","nsstatusbarbutton","nsstatusitem","nswindow","osx","popover","statusbar","windows"],"created_at":"2024-07-31T16:02:17.557Z","updated_at":"2025-03-27T09:32:42.794Z","avatar_url":"https://github.com/iSapozhnik.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# Popover\n\n\u003cdiv align=\"center\"\u003e\n\n![Swift](https://img.shields.io/badge/%20in-swift%205.0-orange.svg)\n![macOS](https://img.shields.io/badge/macOS-10.12-green.svg)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n\u003c/div\u003e\n\n\u003eCustom macOS popover.\n\n![alt text](popover.png \"Popover\")\n\n# Install\n\nSince this is a Swift Package, the installation process is pretty stright forward.\n\n### Manual way\nUpdate your `Package.swift` dependencies:\n\n```\ndependencies: [\n    .package(url: \"https://github.com/iSapozhnik/Popover\", from: \"1.1.1\")\n]\n```\n\n### Via Xcode:\n1. Go to `File -\u003e Swift Packages -\u003e Add Package Dependency`. \n2. Put GitHub URL `https://github.com/iSapozhnik/Popover` and click `Next`\n3. Select the latest version\n4. Click `Finish`\n\n# How to use\n\n1. In your `AppDelegate` import Popover\n2. Create a view you want to put into a status bar.\n3. Create a content view controller which would be embedded inside Popover\n4. Optionally create menu items\n5. Create a Popover instance. Here you can use either standard configuration (you don't need to pass `windowConfiguration` parameter in this case) or you can subclass `DefaultConfiguration`, override some properties and pass a new instance as a parameter. If in step 4 you have created menu items, pass it here as well. You can see them by making right click on menu bar item. \n6. Call `prepare` to set everything up.\n\nAnd here is how typical `AppDelegate` may look like:\n\n```swift\nimport Cocoa\nimport Popover\n\nclass MyPopoverConfiguration: DefaultConfiguration {\n    override var backgroundColor: NSColor {\n        return NSColor.systemRed\n    }\n\n    override var borderColor: NSColor? {\n        return NSColor.red\n    }\n}\n\n@NSApplicationMain\nclass AppDelegate: NSObject, NSApplicationDelegate {\n    var popover: Popover!\n\n    func applicationDidFinishLaunching(_ aNotification: Notification) {\n        let statusItemView = StatusItemView(frame: NSRect(width: 22.0, height: 20))\n\n        let viewController = MainViewController()\n\n        let menuItems: [Popover.MenuItemType] = [\n            .item(Popover.MenuItem(title: \"Settings\", action: viewController.showSettings)),\n            .separator,\n            .item(Popover.MenuItem(title: \"Quit\", key: \"q\", action: viewController.quit))\n        ]\n\n        popover = Popover(with: MyPopoverConfiguration(), menuItems: menuItems)\n        popover.prepare(with: statusItemView, contentViewController: viewController)\n    }\n}\n\n```\n\n# What can be customized?\n\nQuite a lot of things:\n\n```swift\npublic protocol PopoverConfiguration {\n    /// The distance from Popover's arrow to a status item.\n    var popoverToStatusItemMargin:  CGFloat { get }\n\n    /// Popover's background color.\n    var backgroundColor:            NSColor { get }\n\n    /// Popover's border color.\n    /// - Important:\n    ///     If `borderColor` returns `nil`, settings `borderWidth` won't make any effect. See also: `borderWidth`.\n    var borderColor:                NSColor? { get }\n\n    /// Popover's border width.\n    /// - Important:\n    ///      If Popover's border color is set to `nil`, setting `borderWidth` won't make any effect.\n    var borderWidth:                CGFloat { get }\n\n    /// Defines Popover arrow height.\n    var arrowHeight:                CGFloat { get }\n\n    /// Defines Popover arrow width.\n    var arrowWidth:                 CGFloat { get }\n\n    /// Defines Popover corner radius.\n    /// - Warning:\n    ///     If this value is too big and if the Popover's status item (menu bar view) is too close to the right edge, the appearence of the Popover might be odd.\n    var cornerRadius:               CGFloat { get }\n\n    /// Defines Popover content edge insets.\n    var contentEdgeInsets:          NSEdgeInsets { get }\n\n    /// The distance from the right side of the Popover to the screen's edge.\n    /// - Warning:\n    ///     If this value is too big and if the Popover's status item (menu bar view) is too close to the right edge, the appearence of the Popover might be odd.\n    var rightEdgeMargin:            CGFloat { get }\n}\n```\n\n## Mentions\n- [AppCoda Weekly - Issue #172](http://digest.appcoda.com/issues/appcoda-weekly-issue-172-239907)\n\n## Credits\n\nCreated and maintained by [**@iSapozhnik**](https://twitter.com/iSapozhnik).\n\n## License\n\nReleased under the MIT License. See `LICENSE` for details.\n\n\u003e**Copyright \u0026copy; 2020-present Sapozhnik Ivan.**\n\nHeavily inspired by [CCNStatusItem](https://github.com/phranck/CCNStatusItem)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FiSapozhnik%2FPopover","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FiSapozhnik%2FPopover","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FiSapozhnik%2FPopover/lists"}