{"id":769,"url":"https://github.com/SpectralDragon/LiteRoute","last_synced_at":"2025-08-06T13:31:45.255Z","repository":{"id":56919883,"uuid":"87865893","full_name":"SpectralDragon/LiteRoute","owner":"SpectralDragon","description":"LiteRoute is easy transition for your app. Written on Swift 4","archived":false,"fork":false,"pushed_at":"2020-04-08T19:43:13.000Z","size":679,"stargazers_count":92,"open_issues_count":8,"forks_count":24,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-05-23T02:36:00.379Z","etag":null,"topics":["easy-to-use","framework","ios","router","routing","routing-protocols","swift","swift-framework","viper-architecture"],"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/SpectralDragon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-10T23:10:39.000Z","updated_at":"2023-03-17T15:03:42.000Z","dependencies_parsed_at":"2022-08-20T21:50:17.221Z","dependency_job_id":null,"html_url":"https://github.com/SpectralDragon/LiteRoute","commit_stats":null,"previous_names":["spectraldragon/lightroute"],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpectralDragon%2FLiteRoute","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpectralDragon%2FLiteRoute/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpectralDragon%2FLiteRoute/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpectralDragon%2FLiteRoute/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SpectralDragon","download_url":"https://codeload.github.com/SpectralDragon/LiteRoute/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228686176,"owners_count":17957032,"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":["easy-to-use","framework","ios","router","routing","routing-protocols","swift","swift-framework","viper-architecture"],"created_at":"2024-01-05T20:15:30.932Z","updated_at":"2024-12-09T14:30:38.348Z","avatar_url":"https://github.com/SpectralDragon.png","language":"Swift","funding_links":[],"categories":["App Routing","Libs","Architecture and State","App Routing [🔝](#readme)"],"sub_categories":["App Routing","Getting Started"],"readme":"# LiteRoute\n[![Build Status](https://travis-ci.org/SpectralDragon/LiteRoute.svg?branch=master)](https://travis-ci.org/SpectralDragon/LiteRoute)\n[![Pod version](https://img.shields.io/cocoapods/v/LiteRoute.svg)](https://img.shields.io/cocoapods/v/LiteRoute.svg)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n![Platform](https://img.shields.io/badge/platform-iOS-lightgrey.svg)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/SpectralDragon/LiteRoute/blob/master/LICENSE.txt)\n[![Twitter](https://img.shields.io/badge/twitter-@SpectralDragon_-blue.svg?style=flat)](http://twitter.com/spectraldragon_)\n![Swift](https://img.shields.io/badge/Swift-4.2-green.svg)\n\n## Description\nLiteRoute is easy transition between VIPER modules, who implemented on pure Swift.\nWe can transition between your modules very easy from couple lines of codes.\n\n### What's happend with LightRoute?\n\nBecause CocoaPods Dev Team doesn't respond me about return right to my lib, I will move `LightRoute` to other name `LiteRoute`.\nCode and all rights saved.\n\n## Installation\n### CocoaPods\n\nAdd to your podfile:\n\n```ruby\npod \"LiteRoute\"\n```\n\n### Carthage\n\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.\n\nYou can install Carthage with [Homebrew](http://brew.sh/) using the following command:\n\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate LiteRoute into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"SpectralDragon/LiteRoute\" ~\u003e 2.1\n```\n\nRun `carthage update` to build the framework and drag the built `LiteRoute.framework` into your Xcode project.\n\n### Swift Package Manager\n\nOnce you have your Swift package set up, adding LiteRoute as a dependency is as easy as adding it to the dependencies value of your `Package.swift`.\n\n**Swift 4**\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/SpectralDragon/LiteRoute.git\", from: \"2.1\")\n]\n```\n\n## Example\n\n- **New Demo project:** [iOS Example](https://github.com/SpectralDragon/LiteRoute/tree/master/Example)\n- Old Demo project: [Viper-LightRoute-Swinject](https://github.com/SpectralDragon/Viper-LightRoute-Swinject)\n\n## About LiteRoute\n\nLiteRoute can work with `Segue`, `UINavigationController` and default view controller presenting.\n\nFor all transition, returns  `TransitionNode` instance, who managed current transition. You can change transition flow, how you want.\n\n\n## How to use\n\nFor example, we will make the transition between the two VIPER modules:\n\n```swift\nimport LiteRoute\n\n// MARK: - The module initiating the transition.\n\nprotocol FirstViperRouterInput: class {\n  func openModule(userIdentifier: String)\n}\n\nfinal class FirstViperRouter: FirstViperRouterInput {\n\n  // This property contain protocol protected view controller for transition.\n  weak var transitionHandler: TransitionHandler!\n\n  // View controller identifier for current storyboard.\n  let viewControllerIdentifier = \"SecondViperViewController\"\n\n\n  func openModule(userIdentifier: String) {\n\n      try? transitionHandler\n\t\t\t\t\n      // Initiates the opening of a new view controller.\n      .forCurrentStoryboard(resterationId: viewControllerIdentifier, to: SecondViperViewControllerModuleInput.self)\n\t\t\t\t\n      // Set animate for transition.\n      .transition(animate: false)\n\n      // Set transition case.\n      .to(preffered: TransitionStyle.navigation(style: .push))\n\n      // View controller init block. \n      .then { moduleInput in \n        moduleInput.configure(with: userIdentifier)\n      }\n  }\n} \n\n// MARK: - The module at which the jump occurs.\n\n// Module input protocol for initialize\nprotocol SecondViperViewControllerModuleInput: class {\n  func configure(with userIdentifier: String)\n}\n\n\nfinal class SecondViperPresenter: SecondViperViewControllerModuleInput, ... {\n\t\n  // Implementation protocol\n  func configure(with userIdentifier: String) {\n\t\tprint(\"User identifier\", userIdentifier) // Print it!\n    // Initialize code..\n  }\n\n}\n```\nIn this case, you make default transition between viewControllers and configure moduleInput how you want.\nBut also, you can use just viewController, example:\n\n```swift\n.forCurrentStoryboard(resterationId: viewControllerIdentifier, to: SecondViperPresenter.self)\n/// and etc..\n```\n\n**Note❗️**\n`moduleInput` - by default that property contain your `output` property in destination view controller. You can change that use methods `selector:`.\nYou can use next for get custom moduleInput:\n- by string: `selector(_ selector: String)`\n- by selector: `selector(_ selector: Selector)`\n- by keyPath:  `selector(_ selector: KeyPath)`\n\n## Transition case \nFor example we analyze this code, then contain two case for work with transition:\n\n\n**First case:**\n\nThis default case, with default LiteRoute implementation. If you want just present new module, then use that:\n\n```swift\n\ntry? transitionHandler\n\n// Initiates the opening of a new view controller.\n.forCurrentStoryboard(resterationId: viewControllerIdentifier, to: SecondViperViewControllerModuleInput.self)\n\n// Setup module input.\n.then { moduleInput in \n  moduleInput.configure(with: \"Hello!\")\n}\n\n```\n\n\n**Second case:**\n\nBut first way can't be flexible, for that has `customTransition()` method. This method returns `CustomTransitionNode`. This node not support default `TransitionNode` methods.\n`CustomTransitionNode` is class, who return method flexible settings your transition, but for this transition flow, you should be implement your transition logic, and call `them(_:)` or `perform()` method for activate transition.\n\nExample:\n\n```swift\n\ntry? transitionHandler\n\n// Initiates the opening of a new view controller.\n.forCurrentStoryboard(resterationId: viewControllerIdentifier, to: SecondViperViewControllerModuleInput.self)\n\n// Activate custom transition.\n.customTransition()\n\n// Custom transition case.\n.transition { source, destination in \n  // Implement here your transition logic, like that:\n  // source.present(destination, animated: true, completion: nil)\n}\n\n// Setup module input.\n.then { moduleInput in \n  moduleInput.configure(with: \"Hello custom transition!\")\n}\n\n```\n\n## Customize transition\n\nFor customize your transition you can change transition presentation and set animation.\n\n**Animate transition**\n\nThis methods can animate your current transition.\n\n```swift\n.transition(animate: false)\n```\n\n**Change presentation**\n\nMethod `to(preffered:)`, have responsobility for change presentation style. He work with UINavigationController, UISplitViewController, ModalPresentation and default presentation.\n\n```swift\n.to(preferred: TransitionStyle)\n```\n**📌Supported styles:**\n- ***Navigation style*** (`push`, `pop`, `present`)\n  ```swift\n  .to(preferred: .navigation(style: NavigationStyle))\n   ```\n - ***Split style*** (`detail`, `default`)\n    ```swift\n    .to(preferred: .split(style: SplitStyle))\n   ```\n - ***Modal style*** (`UIModalTransitionStyle`, `UIModalPresentationStyle` - standart UIKit's presentations styles.)\n    ```swift\n    .to(preferred: .modal(style: style: (transition: UIModalTransitionStyle, presentation: UIModalPresentationStyle)))\n   ```\n\n**Configure you destination controller**\n\nSometimes you need add additional dependency in your controller. For this case, will be add method `apply(to:)`. That method return destination controller and you can configurate him.\n\n````swift\n\ntry? transitionHandler\n  .forSegue(identifier: \"LiteRouteSegue\", to: SecondViperViewControllerModuleInput.self)\n  .apply(to: { controller in\n    // configure your controller.\n  })\n  .then { moduleInput in\n    // configure your module\n  }\n  \n````\n\n## Transition on new storyboard\n\nAlso LiteRoute can transition on new storyboard instance like this:\n\n```swift\n\n// We remeber this class :)\nfunc openModule(userIdentifier: String) {\n\n  let storyboard = UIStoryboard(name: \"NewStoryboard\", bundle: Bundle.main)\n  let factory = StoryboardFactory(storyboard: storyboard)\n\n  try? transitionHandler\n\n  // Initiates the opening of a new view controller from custom `UIStoryboard`.\n  .forStoryboard(factory: factory, to: SecondViperViewControllerModuleInput.self)\n\n\t// Set animate for transition.\n  .transition(animate: false)\n\n  // View controller init block. \n  .then { moduleInput in \n    moduleInput.configure(with: userIdentifier)\n  } // If you don't want initialize view controller, we should be use `.perform()`\n}\n\n```\n\n## Transition for Segue\n\nYou can initiate transition from `UIStoryboardSegue` like this:\n\n```swift\n\nfunc openModule(userIdentifier: String) {\n  try? transitionHandler\n       // Performs transition from segue and cast to need type\n       .forSegue(identifier: \"LiteRouteSegue\", to: SecondViperViewControllerModuleInput.self)\n       .then { moduleInput in\n        moduleInput.setup(text: \"Segue transition!\")\n      }\n}\n\n```\n\nIf you want to use `EmbedSegue`, need to add segue in storyboard, set class `EmbedSegue` and source view controller must conform protocol `ViewContainerForEmbedSegue` like this:\n\n```swift\n\nextension SourceViewController: ViewContainerForEmbedSegue {\n    func containerViewForSegue(_ identifier: String) -\u003e UIView {\n        return embedView\n    }\n}\n\n```\n\nAnd you can initiate `EmbedSegue` transition like this:\n\n```swift\n\nfunc addEmbedModule() {\n  try? transitionHandler\n       .forSegue(identifier: \"LiteRouteEmbedSegue\", to: EmbedModuleInput.self)\n       .perform()\n}\n\n```\n\n## Close current module\n\nIf you want initiate close current module, you should be use:\n\n```swift\n.closeCurrentModule()\n```\n\nAnd after this you can use `perform()` method for initiate close method.\n\n**Animate close transition**\n\nThis methods can animate your current transition.\n\n```swift\n.transition(animate: false)\n```\n\nNote: Default `true`\n\n**Custom close style**\n\nIf you wanna close pop controller or use popToRoot controller, you must perform method `preferred(style:)`.\nThat method have different styles for your close transition.\n\nIf you need call `popToViewController(:animated)` for your custom controller, you must perform method `find(pop:)`.\n\n````swift\ntry? transitionHandler\n  .closeCurrentModule()\n  .find(pop: { controller -\u003e Bool\n    return controller is MyCustomController\n  })\n  .preferred(style: .navigation(style: .findedPop))\n  .perform()\n````\n\n## Support UIViewControllerTransitioningDelegate\n\nLiteRoute 2.0 start support UIViewControllerTransitioningDelegate for your transition. We can work with that use next methods:\n\n```swift\n.add(transitioningDelegate: UIViewControllerTransitioningDelegate)\n```\n\n\n## Note\n\n- Mastermind: [ViperMcFlurry](https://github.com/rambler-digital-solutions/ViperMcFlurry)\n- License: `MIT`\n- Author: Vladislav Prusakov / spectraldragonchannel@gmail.com\n\nThanks for watching.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSpectralDragon%2FLiteRoute","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSpectralDragon%2FLiteRoute","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSpectralDragon%2FLiteRoute/lists"}