{"id":20541007,"url":"https://github.com/sentryco/pagecontrollerview","last_synced_at":"2025-04-14T08:39:33.656Z","repository":{"id":226335406,"uuid":"768409484","full_name":"sentryco/PageControllerView","owner":"sentryco","description":"📖 SwiftUI TabView support for macOS","archived":false,"fork":false,"pushed_at":"2024-11-06T12:46:21.000Z","size":47,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-11-06T13:50:20.627Z","etag":null,"topics":["nspageviewcontroller","onboarding","swiftui","tabview"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sentryco.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-03-07T02:58:00.000Z","updated_at":"2024-11-06T12:46:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"c72f0cd2-b51c-4d1f-b95e-9c0ba87ae869","html_url":"https://github.com/sentryco/PageControllerView","commit_stats":null,"previous_names":["sentryco/pagecontrollerview"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sentryco%2FPageControllerView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sentryco%2FPageControllerView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sentryco%2FPageControllerView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sentryco%2FPageControllerView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sentryco","download_url":"https://codeload.github.com/sentryco/PageControllerView/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224863643,"owners_count":17382400,"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":["nspageviewcontroller","onboarding","swiftui","tabview"],"created_at":"2024-11-16T01:18:49.567Z","updated_at":"2024-11-16T01:18:50.304Z","avatar_url":"https://github.com/sentryco.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Tests](https://github.com/sentryco/PageControllerView/actions/workflows/Tests.yml/badge.svg)](https://github.com/sentryco/PageControllerView/actions/workflows/Tests.yml)\n[![codebeat badge](https://codebeat.co/badges/d79fbf42-4e64-46f5-936b-ce8e4a95669c)](https://codebeat.co/projects/github-com-sentryco-pagecontrollerview-main)\n\n# 📖 PageControllerView\n\nPageControllerView is a Swift library that provides `tab view like` support for macOS applications using SwiftUI. It primarily solves the issue of swiping left and right for macOS onboarding.\n\n## Architecture\n\n- **Data Source**: Define any properties needed for your `NSPageController`. Replace with your data source.\n- **Current Page**: This should change page from the caller. Use this to get callbacks when page changes, and also use it to set pages.\n- **MakeView**: Callback to make content for each page. Here we make a callback, that takes index and returns View for the `NSHostingController` to use. The idea is to make this more like swiftui `tabview` api.\n\n## Example Usage\n\nHere is an example of how to use the `PageControllerView` in a SwiftUI view:\n\n\u003e [!NOTE]\n\u003e Swiping does not work properly in Xcode preview canvas. To see the swipe effect, build and run the app target for macOS.\n\n```swift\n#if os(macOS)\n@main\n\nstruct MacApp: App {\n   @State var curPageIndex: Int = 0\n   var body: some Scene {\n      WindowGroup {\n         PageControllerView(dataSource: [\"green\", \"blue\", \"red\"], currentPage: $curPageIndex ) { identifier in\n             var rootView: Color\n             switch identifier {\n             case \"green\":\n                 rootView = .green\n             case \"red\":\n                 rootView = .red\n             default:\n                 rootView = .blue\n             }\n             return AnyView(rootView)\n         }\n         .onChange(of: curPageIndex) { _, _ in // debugging to see that we get callbacks from the binding\n             Swift.print(\"curPageIndex: \\(curPageIndex)\")\n         }\n      }\n      .windowStyle(.hiddenTitleBar) // Hides the top bar\n      .windowToolbarStyle(.unifiedCompact(showsTitle: false)) // Hides the top bar text and more compact vertical sizing than .unified\n   }\n}\n#endif\n```\n\n## References\n- [iPages](https://github.com/benjaminsage/iPages/)\n- [BigUIPaging](https://github.com/notsobigcompany/BigUIPaging/)\n\n## Links\n- The onboarding API is fairly abstract / modular to support \"whats new intro\" in the future etc\n- Apple docs: https://developer.apple.com/documentation/uikit/uipageviewcontroller/\n- Use `UIPageViewController` https://spin.atomicobject.com/2015/12/23/swift-uipageviewcontroller-tutorial/ And: https://milanbrankovic.medium.com/creating-an-embedded-carousel-with-uipageviewcontroller-9549bd2319c7 and code here: https://github.com/srfunksensei/CarouselSample and https://medium.com/@anitaa_1990/create-a-horizontal-paging-uiscrollview-with-uipagecontrol-swift-4-xcode-9-a3dddc845e92 and https://fabcoding.com/2019/03/14/creating-an-onboarding-screen/ and https://github.com/gabrieltheodoropoulos/iOS-Swift-PageControl and  https://itnext.io/ios-uipageviewcontroller-easy-dd559c51ffa Simple UIPageViewCon... https://github.com/ThornTechPublic/Onboarding-With-UIPageViewController-Final\n- Similar but uses `UICollectionView` etc: https://vijaysharma.ca/create-an-onboarding-screen-in-swift/ We could probably use Horizontal UIColelctionView, with flow? https://github.com/eonist/flowlayout\n- For `SwiftUI`: https://blckbirds.com/post/how-to-create-a-onboarding-screen-in-swiftui-1/\n- Sliding cards via constraints and gestures: https://github.com/eonist/Celestial\n\n## Todo: \n- Add dedicated UITests\n- remove unit tests\n- Code Refactoring: Refactoring for Modern Swift Practices: The PageControllerView+NSViewControllerRepresentable.swift and other related files suggest improvements like using modern Swift syntax and possibly refactoring to reduce dependency on NSPageController specifics, making the code more modular and easier to manage.\n- Improving Error Handling: The current implementation does not robustly handle potential errors or exceptional cases, particularly in delegate methods and view controller management.\n- Integration and Build Process: GitHub Actions Workflow: The .github/workflows/Tests.yml file indicates that tests are temporarily disabled due to compatibility issues with Swift 5.9. Resolving this and ensuring continuous integration passes could prevent future bugs from being introduced.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsentryco%2Fpagecontrollerview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsentryco%2Fpagecontrollerview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsentryco%2Fpagecontrollerview/lists"}