{"id":16948629,"url":"https://github.com/timoliver/beeline","last_synced_at":"2025-03-22T13:31:13.304Z","repository":{"id":48557316,"uuid":"386859777","full_name":"TimOliver/Beeline","owner":"TimOliver","description":"An extremely lean implementation on the classic iOS router pattern.","archived":false,"fork":false,"pushed_at":"2023-01-24T15:03:51.000Z","size":215,"stargazers_count":63,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-18T11:38:52.053Z","etag":null,"topics":["ios","mac-catalyst","swift","tvos","uikit"],"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/TimOliver.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},"funding":{"github":"timoliver","custom":"https://tim.dev/paypal"}},"created_at":"2021-07-17T06:42:56.000Z","updated_at":"2025-02-23T21:25:28.000Z","dependencies_parsed_at":"2023-02-12T13:01:39.511Z","dependency_job_id":null,"html_url":"https://github.com/TimOliver/Beeline","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/TimOliver%2FBeeline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimOliver%2FBeeline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimOliver%2FBeeline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimOliver%2FBeeline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TimOliver","download_url":"https://codeload.github.com/TimOliver/Beeline/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244962794,"owners_count":20539226,"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":["ios","mac-catalyst","swift","tvos","uikit"],"created_at":"2024-10-13T21:51:41.892Z","updated_at":"2025-03-22T13:31:12.936Z","avatar_url":"https://github.com/TimOliver.png","language":"Swift","funding_links":["https://github.com/sponsors/timoliver","https://tim.dev/paypal"],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"title.png\" alt=\"Beeline\" /\u003e\n\n\u003cspan align=\"center\"\u003e\n\n[![CI](https://github.com/TimOliver/Beeline/workflows/CI/badge.svg)](https://github.com/TimOliver/Beeline/actions?query=workflow%3ACI)\n[![Version](https://img.shields.io/cocoapods/v/Beeline.svg?style=flat)](http://cocoadocs.org/docsets/Beeline)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/TimOliver/Beeline/main/LICENSE)\n[![Platform](https://img.shields.io/cocoapods/p/Beeline.svg?style=flat)](http://cocoadocs.org/docsets/Beeline)\n    \n\u003c/span\u003e\n\nBeeline is a very small library that aims to provide a lean, automatic implementation of the classic iOS router pattern. It extends `UIViewController` to retain a `Router` object that serves as the source of truth for controlling navigation flows for all of the view controller's children. When a child view controller wishes to transition to a new screen, it can call `show()` on itself and this request is passed up the view controller chain to the routing view controller.\n\n# Instructions\n\nA very basic custom implementation looks as the following. First, we create a Swift enum conforming to `Route` where we can define the types of destinations with which we want to move:\n\n```swift\nenum AppRoute: Route {\n    case viewController(number: Int)\n}\n```\nThanks to Swift associated enums, we can also include any custom parameters the new destination may need.\n\nWe then also make a new class which subclasses `Router`, which serves as our single point of truth for controlling the app flow based off the destinations we defined above:\n\n```swift\npublic class AppRouter: Router {\n    override func show(_ route: Route,\n                        from sourceViewController: UIViewController?) -\u003e Bool {\n\n        // Optionally, filter out routes we don't support\n        guard let appRoute = route as? AppRoute else { return false }\n\n        // Check the requested enum, and perform the transition\n        switch appRoute {\n        case .viewController(let number):\n            let newViewController = ViewController(number: number)\n            sourceViewController?\n                .navigationController?\n                .pushViewController(newViewController, animated: true)\n        }\n\n        return true\n    }\n}\n\n```\n\nUsing Objective-C associated objects, we can assign this router to any parent view controller that contains all of the view controllers that might want to perform these transitions:\n\n```swift\nlet navigationController = UINavigationController(rootViewController: ViewController())\nnavigationController.router = AppRouter()\n```\n\nFinally, without any further modification to any of the child view controllers, they can start a transition by simply calling `show()` with the desired destination:\n\n```swift\nclass ViewController: UIViewController {\n    func moveToNewViewController() {\n        show(AppRoute.viewController(number: 2))\n    } \n} \n```\n\nAnd that's the entire library! 🎉\n\n# Requirements\n* Swift 5\n* UIKit-compatible platforms (iOS, tvOS, Mac Catalyst)\n\n# Installation\n\nBeeline is a very small framework, with all of its code contained in `Router.swift`. You can install it in the following ways:\n\n## Manual Installation\n\nDrag the `Beeline/Router.swift` file into your Xcode project.\n\n### CocoaPods\n\n```\npod 'Beeline'\n```\n\n### SPM\n\nYou can add Beeline to an Xcode project by adding it as a package dependency.\n\nhttps://github.com/TimOliver/Beeline\n\nor, add the following to the dependencies in package.swift.\n\n```swift\ndependencies: [\n  .package(url: \"https://github.com/TimOliver/Beeline\", from: \"1.0.2\")\n]\n```\n\n### Carthage\n\nNo plans to support Carthage at the moment, but please consider filing a PR if you would like it!\n\n# Credits\n\nBeeline was built as a component of iComics 2 by [Tim Oliver](https://twitter.com/TimOliverAU)\n\n# License\n\nBeeline is available under the MIT License. Please check the [LICENSE](LICENSE) file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimoliver%2Fbeeline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimoliver%2Fbeeline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimoliver%2Fbeeline/lists"}