{"id":18362479,"url":"https://github.com/igormuzyka/menubar","last_synced_at":"2025-04-06T15:30:42.579Z","repository":{"id":77598386,"uuid":"153294828","full_name":"IgorMuzyka/MenuBar","owner":"IgorMuzyka","description":"A declarative wrapper for your macOS app to easily define MenuBar","archived":false,"fork":false,"pushed_at":"2020-12-14T21:42:17.000Z","size":48,"stargazers_count":15,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-22T02:01:31.537Z","etag":null,"topics":["dsl","macos","menubar","swift"],"latest_commit_sha":null,"homepage":"","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/IgorMuzyka.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-16T13:57:30.000Z","updated_at":"2024-04-17T05:06:09.000Z","dependencies_parsed_at":"2023-03-12T01:12:16.743Z","dependency_job_id":null,"html_url":"https://github.com/IgorMuzyka/MenuBar","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IgorMuzyka%2FMenuBar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IgorMuzyka%2FMenuBar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IgorMuzyka%2FMenuBar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IgorMuzyka%2FMenuBar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IgorMuzyka","download_url":"https://codeload.github.com/IgorMuzyka/MenuBar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247502752,"owners_count":20949322,"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":["dsl","macos","menubar","swift"],"created_at":"2024-11-05T22:40:54.060Z","updated_at":"2025-04-06T15:30:42.574Z","avatar_url":"https://github.com/IgorMuzyka.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Menu Bar\n\nA declarative wrapper to easily define your **MenuBar**.\n\n## Installation\n\nTo install it, simply add the following line to your Podfile:\n\n```ruby\npod 'MenuBar', :git =\u003e 'https://github.com/IgorMuzyka/MenuBar.git'\n```\n\n## Usage\n\nIn order to construct your **MenuBar** you'll need to use **Descriptor** and **Parameter** values. **Descriptors** define ***items*** of the ***menu*** while **Parameters** allow to _configure_ the ***item***.\n\n```swift\npublic enum Descriptor {\n    case menu([Parameter], [Descriptor])\n    case item([Parameter])\n    case separator\n}\n```\n\n```swift\npublic enum Parameter {\n    case action(() -\u003e Void)\n    case title(String)\n    case enabled(Bool)\n    case state(NSControl.StateValue)\n}\n```\n\nTo construct a **MenuBar** simply create an instance like this.\n\n```swift\nlet menuBar = MenuBar(descriptors: [\n    .item([.title(\"This is a title of an item of a menu bar\")]),\n    .item([.enabled(false), .title(\"You can set the enabled status of the item\")]),\n    .item([.state(.on), .title(\"Also you can mark a item with a on or off state\")]),\n    .item([.action({ print(\"click\") }), .title(\"This is how you set action to be executed when item is clicked\")]),\n    .separator, // and this is just a separator that will be visible between the items\n    .menu([.title(\"And this is a menu or a submenu in this case\")], [\n        .item([.title(\"Items in which can be configured in the same exact way\")])\n    ])\n])\n```\n\nIn order to interact with a **MenuBar** you'll need to also give it an **image** or a **title** so that it can appear in the **MenuBar**.\n\n```swift\nmenuBar.title = \"Your app name\"\n```\n\nor\n\n```swift\nmenuBar.image = NSImage(named: \"You app MenuBar icon\")\n```\n\n![Example](example.png)\n\n\u003e This is how the **MenuBar** we just created looks like.\n\n\n\nAlso **keep in mind** that you should **hold** the instance of **MenuBar** in order for it to **exist** and work properly. (App Delegate is an okay place to hold it).\n\nWhenever you want to update the **MenuBar** just overwrite it's **descriptors** property.\n\n```swift\nmenuBar.descriptors = [\n    .item([.title(\"Now this is the only item in menu bar\")])\n]\n```\n\n## Author\n\nIgor Muzyka, igormuzyka42@gmail.com\n\n## License\n\nMenuBar is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figormuzyka%2Fmenubar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figormuzyka%2Fmenubar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figormuzyka%2Fmenubar/lists"}