{"id":25195944,"url":"https://github.com/simplisticated/direct","last_synced_at":"2025-04-04T15:44:02.944Z","repository":{"id":56908595,"uuid":"116421154","full_name":"simplisticated/Direct","owner":"simplisticated","description":"Library for transition between screens in iOS app","archived":false,"fork":false,"pushed_at":"2018-06-09T14:21:33.000Z","size":858,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T08:38:12.495Z","etag":null,"topics":["screen","swift","transition","uiwindow"],"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/simplisticated.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}},"created_at":"2018-01-05T19:49:24.000Z","updated_at":"2021-12-23T11:04:58.000Z","dependencies_parsed_at":"2022-08-21T01:50:59.200Z","dependency_job_id":null,"html_url":"https://github.com/simplisticated/Direct","commit_stats":null,"previous_names":["igormatyushkin014/direct"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplisticated%2FDirect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplisticated%2FDirect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplisticated%2FDirect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplisticated%2FDirect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simplisticated","download_url":"https://codeload.github.com/simplisticated/Direct/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247208022,"owners_count":20901568,"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":["screen","swift","transition","uiwindow"],"created_at":"2025-02-10T01:39:11.164Z","updated_at":"2025-04-04T15:44:02.916Z","avatar_url":"https://github.com/simplisticated.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\" \u003e\n\t\u003cimg src=\"/Images/logo_2048_2048.png\" alt=\"Direct\" title=\"Direct\" width=\"300px\" height=\"300px\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\t\u003ca href=\"https://swift.org\"\u003e\n\t\t\u003cimg src=\"https://img.shields.io/badge/Swift-4.0-orange.svg?style=flat\"\u003e\n\t\u003c/a\u003e\n\t\u003ca href=\"https://cocoapods.org\"\u003e\n\t\t\u003cimg src=\"https://img.shields.io/cocoapods/v/Direct.svg\"\u003e\n\t\u003c/a\u003e\n\t\u003ca href=\"https://cocoapods.org\"\u003e\n\t\t\u003cimg src=\"https://img.shields.io/cocoapods/dt/Direct.svg\"\u003e\n\t\u003c/a\u003e\n\t\u003ca href=\"https://tldrlegal.com/license/mit-license\"\u003e\n\t\t\u003cimg src=\"https://img.shields.io/badge/License-MIT-blue.svg?style=flat\"\u003e\n\t\u003c/a\u003e\n\u003c/p\u003e\n\n## At a Glance\n\n`Direct` simplifies transitions between screens in iOS app.\n\n## How To Get Started\n\n- Copy content of `Source` folder to your project.\n\nor\n\n- Use `Direct` cocoapod\n\n## Requirements\n\n* iOS 9 and later\n* Xcode 9 and later\n* Swift 4\n\n## Usage\n\n### Preparations\n\nCreate extension for `Scene` class:\n\n```swift\nextension Scene {\n    \n    static var main: Scene {\n        let navigationController = UINavigationController()\n        navigationController.viewControllers = [\n            MainViewController(nibName: \"MainViewController\", bundle: nil)\n        ]\n        return Scene(rootController: navigationController)\n    }\n    \n}\n```\n\nChange `AppDelegate.swift`:\n\n```swift\nfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -\u003e Bool {\n    Navigator.shared\n        .createWindow()\n        .setScene(.main)\n    \n    return true\n}\n```\n\nAlso, remove reference to window (`var window: UIWindow?`) from `AppDelegate` class.\n\n### Window\n\nWith `Navigator` class you can create window in one line of code:\n\n```swift\nNavigator.shared.createWindow()\n```\n\nIf you have a custom window class, it's possible to use it too:\n\n```swift\nNavigator.shared.createWindow(ofType: MyWindow.self)\n```\n\nIt's recommended to use `createWindow()` method in `AppDelegate` (see example in [Preparations](#preparations) section).\n\nUsually, Xcode creates `AppDelegate` class with a reference to `UIWindow` inside:\n\n```swift\n@UIApplicationMain\nclass AppDelegate: UIResponder, UIApplicationDelegate {\n    var window: UIWindow?\n}\n```\n\nWith `Navigator` you don't need to keep this reference, so you can remove it from `AppDelegate` class. Use `Navigator.window` instead.\n\n### Scenes\n\nScene describes navigation stack including root controller. Here's an example:\n\n```swift\nlet navigationController = UINavigationController()\n\nnavigationController.viewControllers = [\n    MyViewController(nibName: \"MyViewController\", bundle: nil)\n]\n\nlet scene = Scene(rootController: navigationController)\n```\n\nIt's highly recommended to create extension for `Scene` class and provide static variables describing new scenes like it's done in [Preparations](#preparations) section.\n\nSwitching between scenes is simple:\n\n```swift\nNavigator.shared.setScene(newScene)\n```\n\n### Transitions\n\nTransition is an action that is performed with stack of navigation controller, for example: pushing, presenting, dismissing view controllers, etc. Below you can find list of examples how to manage navigation stack with `Direct` library.\n\nPush view controller:\n\n```swift\nlet someViewController = SomeViewController(nibName: \"SomeViewController\", bundle: nil)\nNavigator.shared.performTransition(.push(viewController: someViewController, animated: true))\n```\n\nPop:\n\n```swift\nNavigator.shared.performTransition(.pop(animated: true))\n```\n\nPop to root view controller:\n\n```swift\nNavigator.shared.performTransition(.popToRootViewController(animated: true))\n```\n\nPresent:\n\n```swift\nNavigator.shared.performTransition(.present(viewController: someViewController, animated: true, completion: {\n}))\n```\n\nDismiss:\n\n```swift\nNavigator.shared.performTransition(.dismiss(animated: true, completion: {\n}))\n```\n\nAccess to current navigation controller:\n\n```swift\nif let currentNavigationController = Navigator.shared.scene?.rootNavigationController {\n    // Do something with current navigation controller\n}\n```\n\n### Syntax\n\n`Navigator` supports call chains so you can write long expressions:\n\n```swift\nNavigator.shared\n    .createWindow()\n    .setScene(.main)\n    .performTransition(.push(viewController: someViewController, animated: false))\n    .performTransition(.present(viewController: popupViewController, animated: true, completion: {\n    }))\n```\n\n## License\n\n`Direct` is available under the MIT license. See the [LICENSE](./LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplisticated%2Fdirect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimplisticated%2Fdirect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplisticated%2Fdirect/lists"}