{"id":20597898,"url":"https://github.com/pkasila/poweredtouchbar","last_synced_at":"2025-04-15T00:16:10.074Z","repository":{"id":129731150,"uuid":"350113533","full_name":"pkasila/PoweredTouchBar","owner":"pkasila","description":"PoweredTouchBar is a library which lets you easily and more powerfully use Touch Bar on macOS with SwiftUI","archived":false,"fork":false,"pushed_at":"2021-03-22T16:35:01.000Z","size":31,"stargazers_count":16,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-15T00:15:52.823Z","etag":null,"topics":["macos","swiftui","touchbar"],"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/pkasila.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"patreon":"pkosilo"}},"created_at":"2021-03-21T20:40:15.000Z","updated_at":"2024-12-17T22:41:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"6f315c30-68ce-4815-be17-b6bbd63f40e3","html_url":"https://github.com/pkasila/PoweredTouchBar","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkasila%2FPoweredTouchBar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkasila%2FPoweredTouchBar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkasila%2FPoweredTouchBar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkasila%2FPoweredTouchBar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pkasila","download_url":"https://codeload.github.com/pkasila/PoweredTouchBar/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248981268,"owners_count":21193147,"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","swiftui","touchbar"],"created_at":"2024-11-16T08:24:19.588Z","updated_at":"2025-04-15T00:16:10.067Z","avatar_url":"https://github.com/pkasila.png","language":"Swift","funding_links":["https://patreon.com/pkosilo"],"categories":[],"sub_categories":[],"readme":"# PoweredTouchBar\n\nPoweredTouchBar is a library which lets you easily and more powerfully use Touch Bar on macOS with SwiftUI.\n\n\u003cimg width=\"700\" alt=\"image\" src=\"https://user-images.githubusercontent.com/17158860/112017767-f9cb1000-8b3e-11eb-82ca-14ad2705f4a8.png\"\u003e\n\n## How to use it?\nThere is a simple example of how to use `PoweredTouchBar` library:\n\n\u003cimg width=\"703\" alt=\"image\" src=\"https://user-images.githubusercontent.com/17158860/112017959-28e18180-8b3f-11eb-92dc-e629964a4360.png\"\u003e\n\n```swift\nimport SwiftUI\n\nstruct ContentView: View {\n    @State var text: String = \"\"\n    var body: some View {\n        TextEditor(text: $text)\n            .poweredTouchBar {\n                PoweredTouchBarButton(\n                    identifier: \"HelloWorld.text\",\n                    title: \"Hello World!\",\n                    action: {\n                        print(\"You've pressed the button with text\")\n                    }\n                )\n                PoweredTouchBarButton(\n                    identifier: \"HelloWorld.image\",\n                    image: NSImage(systemSymbolName: \"star.fill\", accessibilityDescription: nil)!,\n                    action: {\n                        print(\"You've pressed the button with image\")\n                    }\n                )\n            }\n    }\n}\n```\n\n## How to create your own `PoweredTouchBarItem`?\n`PoweredTouchBarItem` is a protocol which basically allows you to create items for Touch Bar.\nYou can use it to wrap any `NSTouchBarItem` to do so you just need to make a method to get\nan identifier (`getIdentifier`) and to get item itself (`touchBarItem`). There is an example below\nwhich shows how you can create a simple wrapper for `NSTouchBarItem` to use them with \n`PoweredTouchBar` (It's already available by importing `PoweredTouchBar`):\n```swift\nimport AppKit\n\npublic class PoweredNSTouchBarItem: PoweredTouchBarItem {\n    \n    var item: NSTouchBarItem\n    \n    public init(_ item: () -\u003e NSTouchBarItem) {\n        self.item = item()\n    }\n    \n    public func touchBarItem() -\u003e NSTouchBarItem {\n        return item\n    }\n    \n    public func getIdentifier() -\u003e NSTouchBarItem.Identifier {\n        return item.identifier\n    }\n}\n```\nYou can also check out how `NSButtonTouchBarItem` is wrapped in [`PoweredTouchBarButton`](https://github.com/pkosilo/PoweredTouchBar/blob/main/Sources/PoweredTouchBar/PoweredTouchBarItems/PoweredTouchBarButton.swift) to make it work in `PoweredTouchBar`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkasila%2Fpoweredtouchbar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpkasila%2Fpoweredtouchbar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkasila%2Fpoweredtouchbar/lists"}