### Basic Factory Implementation Example Source: https://github.com/ekazaev/route-composer/blob/master/docs/readme.html An example of implementing the `Factory` protocol for a `ProductViewController`. It shows how to initialize the view controller with a `productID` from the context. ```swift class ProductViewControllerFactory: Factory { func build(with productID: UUID) throws -> ProductViewController { let productViewController = ProductViewController(nibName: "ProductViewController", bundle: nil) productViewController.productID = productID // Parameter initialisation can be handled by a ContextAction, see below: return productViewController } } ``` -------------------------------- ### setup(with:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/Extensions/UIHostingController.html Sets up the hosted SwiftUI view with the provided context. This is an instance method. ```APIDOC ## setup(with:) ### Description Sets up the hosted SwiftUI view with the provided context. ### Method `func setup(with context: Content.Context) throws` ### Parameters #### Path Parameters - **context** (Content.Context) - The context to set up the view with. ``` -------------------------------- ### Install SwiftFormat via Mint Source: https://github.com/ekazaev/route-composer/blob/master/Example/Pods/SwiftFormat/README.md Installs the SwiftFormat command-line tool using Mint. This is an alternative installation method for macOS or Linux. ```bash $ mint install nicklockwood/SwiftFormat ``` -------------------------------- ### prepare(with:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Structs/CompleteFactory.html Prepares the factory with the given context, potentially performing setup or validation. ```APIDOC ## prepare(with:) ### Description Prepares the factory with the given context. ### Declaration ```swift @MainActor public mutating func prepare(with context: FC.Context) throws ``` ### Parameters - **context** (FC.Context) - The context to prepare with. ``` -------------------------------- ### setup(with:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/Protocols/ContextAcceptingView.html Sets up the view with the provided context instance. This method is called by the `ContextSettingTask` during the view's lifecycle. ```APIDOC ## setup(with:) ### Description `ContextSettingTask` will call this method to provide the `Context` instance to the `View` that has just been built or found. ### Method `mutating func setup(with context: Context) throws` ### Parameters - **context** (`Context`) - Required - The `Context` instance to set up the view with. ### Throws `Error` if the `Context` instance is not supported. `Router` will stop building the rest of the stack in this case. ``` -------------------------------- ### Install SwiftFormat Prerelease Build with Homebrew Source: https://github.com/ekazaev/route-composer/blob/master/Example/Pods/SwiftFormat/README.md Install the latest prerelease version of SwiftFormat using Homebrew. The --HEAD option fetches and builds the most recent changes from the develop branch. ```bash brew install swiftformat --HEAD ``` -------------------------------- ### Install SwiftFormat via Homebrew Source: https://github.com/ekazaev/route-composer/blob/master/Example/Pods/SwiftFormat/README.md Installs the SwiftFormat command-line tool using Homebrew on macOS or Linux. Use this command to get the latest version. ```bash $ brew install swiftformat ``` ```bash $ brew upgrade swiftformat ``` -------------------------------- ### Setup with Context Source: https://github.com/ekazaev/route-composer/blob/master/docs/Extensions/UIHostingController.html Use this instance method to set up the `UIHostingController` with a specific context. This method is also marked with `@MainActor` for main thread execution. ```Swift @MainActor public func setup(with context: Content.Context) throws ``` -------------------------------- ### Initializer with Options and Providers Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Structs/UIHostingControllerWithContextFinder.html Initializes the finder with search options, starting point, window provider, and container adapter locator. ```APIDOC ## init(options:startingPoint:windowProvider:containerAdapterLocator:) ### Description Initializes the finder with search options, starting point, window provider, and container adapter locator. ### Parameters - `options` (SearchOptions) - A combination of `SearchOptions`. - `startingPoint` (DefaultStackIterator.StartingPoint) - The starting point for the search. - `windowProvider` (WindowProvider) - The `WindowProvider` instance. - `containerAdapterLocator` (ContainerAdapterLocator) - The `ContainerAdapterLocator` instance. ``` -------------------------------- ### SwiftFormat Configuration File Example Source: https://github.com/ekazaev/route-composer/blob/master/Example/Pods/SwiftFormat/README.md A sample `.swiftformat` configuration file demonstrating common options like indentation style and rule disabling. ```ini --allman true --indent tab --disable elseOnSameLine,semicolons ``` -------------------------------- ### Install SwiftFormat using Homebrew Source: https://github.com/ekazaev/route-composer/blob/master/Example/Pods/SwiftFormat/README.md Use this command to install SwiftFormat for Xcode via Homebrew. This installs the application to your Applications folder. ```bash $ brew install --cask swiftformat-for-xcode ``` -------------------------------- ### Custom Header Template Example Source: https://github.com/ekazaev/route-composer/blob/master/Example/Pods/SwiftFormat/README.md Example of a command-line argument to set a custom file header template using placeholders for file name, year, creation date, and author. ```bash --header "{file}\nCopyright (c) {year} Foobar Industries\nCreated by John Smith on {created}." ``` -------------------------------- ### StartingPoint.custom(_:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/DefaultStackIterator/StartingPoint.html Represents starting the iteration from a custom UIViewController, provided as an autoclosure. ```APIDOC ## Case: custom(_:) Start from the custom `UIViewController` ### Declaration ```swift case custom(@autoclosure () throws -> UIViewController?) ``` ``` -------------------------------- ### StepAssembly Usage Example Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Classes/StepAssembly.html Demonstrates how to initialize StepAssembly and chain navigation steps, including adding interceptors, tasks, and specifying navigation actions. ```APIDOC ## StepAssembly Usage This example shows how to create a `StepAssembly` and configure a navigation flow. ### Code Example ```swift let productScreen = StepAssembly(finder: ProductViewControllerFinder(), factory: ProductViewControllerFactory()) .adding(LoginInterceptor()) .adding(ProductViewControllerContextTask()) .adding(ProductViewControllerPostTask(analyticsManager: AnalyticsManager.sharedInstance)) .using(.push) .from(.navigationController) .using(.present) .from(.current) .assemble() ``` ### Explanation - `StepAssembly` is initialized with a `Finder` and `Factory`. - Interceptors and tasks can be added using `.adding()`. - Navigation actions like `.push` and `.present` are chained using `.using()` and specified with a source using `.from()`. ``` -------------------------------- ### StartingPoint.root Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/DefaultStackIterator/StartingPoint.html Represents starting the iteration from the root UIViewController of the UIWindow. ```APIDOC ## Case: root Start from the `UIWindow`s root `UIViewController` ### Declaration ```swift case root ``` ``` -------------------------------- ### Default Initializer Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Structs/UIHostingControllerWithContextFinder.html Initializes a new instance of `UIHostingControllerWithContextFinder` with optional starting point, window provider, and container adapter locator. ```APIDOC init(startingPoint: DefaultStackIterator.StartingPoint = .topmost, windowProvider: WindowProvider = RouteComposerDefaults.shared.windowProvider, containerAdapterLocator: ContainerAdapterLocator = RouteComposerDefaults.shared.containerAdapterLocator) ``` -------------------------------- ### Formatted File Header Example Source: https://github.com/ekazaev/route-composer/blob/master/Example/Pods/SwiftFormat/README.md Illustrates how the custom header template with placeholders is rendered in a Swift file. ```swift // SomeFile.swift // Copyright (c) 2019 Foobar Industries // Created by John Smith on 01/02/2016. ``` -------------------------------- ### Example Usage of CompleteFactoryAssembly Source: https://github.com/ekazaev/route-composer/blob/master/docs/tests/CompleteFactoryAssembly.swift.html Demonstrates how to initialize and configure a CompleteFactoryAssembly to build a tab bar controller with child view controllers. The order of adding factories is important. ```swift let rootFactory = CompleteFactoryAssembly(factory: TabBarFactory()) .with(XibFactory(.), using: UITabBarController.add()) .with(XibFactory(.), using: UITabBarController.add()) .assemble() ``` -------------------------------- ### Get Starting ViewController Source: https://github.com/ekazaev/route-composer/blob/master/docs/tests/DefaultStackIterator.swift.html Determines and returns the starting UIViewController for the iteration based on the 'startingPoint' property. This can be the topmost, root, or a custom view controller. ```swift func getStartingViewController() throws -> UIViewController? { switch startingPoint { case .topmost: return windowProvider.window?.topmostViewController case .root: return windowProvider.window?.rootViewController case let .custom(viewControllerClosure): return try viewControllerClosure() } } ``` -------------------------------- ### StartingPoint.topmost - RouteComposer Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Structs/PresentingFinder/StartingPoint.html Represents starting the search from the topmost UIViewController in the stack. No additional setup is required. ```swift case topmost ``` -------------------------------- ### setup(with:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Protocols/ContextAcceptingView.html Sets up the view with a provided context instance. This method is called by `ContextSettingTask` when a view is built or found. It throws an error if the context is not supported, which will stop the router from building the rest of the stack. ```APIDOC ## setup(with:) ### Description `ContextSettingTask` will call this method to provide the `Context` instance to the `View` that has just been build or found. ### Declaration ```swift @MainActor mutating func setup(with context: Context) throws ``` ### Parameters - `context` (`Context`) - `Context` instance. ``` -------------------------------- ### ClassFinder Initializers Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/ClassFinder.html Initializes a ClassFinder instance. The first initializer allows providing a custom StackIterator, while the second offers a more comprehensive setup with options, starting point, window provider, and container adapter locator. ```APIDOC ## Initializers ### `init(iterator:)` Constructor #### Declaration ```swift @MainActor public init(iterator: StackIterator = RouteComposerDefaults.shared.stackIterator) ``` #### Parameters * `iterator` (StackIterator) - A `StackIterator` is to be used by `ClassFinder` ### `init(options:startingPoint:windowProvider:containerAdapterLocator:)` Constructor #### Declaration ```swift @MainActor init(options: SearchOptions, startingPoint: DefaultStackIterator.StartingPoint = .topmost, windowProvider: WindowProvider = RouteComposerDefaults.shared.windowProvider, containerAdapterLocator: ContainerAdapterLocator = RouteComposerDefaults.shared.containerAdapterLocator) ``` #### Parameters * `options` (SearchOptions) - A combination of the `SearchOptions` * `startingPoint` (DefaultStackIterator.StartingPoint) - `DefaultStackIterator.StartingPoint` value * `windowProvider` (WindowProvider) - `WindowProvider` instance. * `containerAdapterLocator` (ContainerAdapterLocator) - A `ContainerAdapterLocator` instance. ``` -------------------------------- ### Install RouteComposer with CocoaPods Source: https://github.com/ekazaev/route-composer/blob/master/README.md Add this line to your Podfile to install RouteComposer using CocoaPods. Run 'pod install' afterwards. ```ruby pod 'RouteComposer' ``` -------------------------------- ### init(options:startingPoint:windowProvider:containerAdapterLocator:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/ClassWithContextFinder.html Initializes a new instance of ClassWithContextFinder with detailed configuration options. ```APIDOC ## init(options:startingPoint:windowProvider:containerAdapterLocator:) ### Description Initializes a new instance of ClassWithContextFinder with detailed configuration options. ### Parameters - **options** (SearchOptions) - A combination of the `SearchOptions`. - **startingPoint** (DefaultStackIterator.StartingPoint) - `DefaultStackIterator.StartingPoint` value. Defaults to `.topmost`. - **windowProvider** (WindowProvider) - `WindowProvider` instance. Defaults to `RouteComposerDefaults.shared.windowProvider`. - **containerAdapterLocator** (ContainerAdapterLocator) - A `ContainerAdapterLocator` instance. Defaults to `RouteComposerDefaults.shared.containerAdapterLocator`. ``` -------------------------------- ### setup(with:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/Protocols/ContextAccepting.html Sets up the UIViewController with the provided context instance. This method is called by the `ContextSettingTask` to inject the context into a newly built or found UIViewController. If the context is not supported, an error is thrown, and the Router will halt the building of the rest of the navigation stack. ```APIDOC ## setup(with:) ### Description `[ContextSettingTask](../Structs/ContextSettingTask.html)` will call this method to provide the `[Context](../Protocols/ContextAccepting.html#/s:13RouteComposer16ContextAcceptingP0C0Qa)` instance to the `UIViewController` that has just been build or found. ### Method `func setup(with context: Context) throws` ### Parameters - **context** (`Context`) - Description: `[Context](../Protocols/ContextAccepting.html#/s:13RouteComposer16ContextAcceptingP0C0Qa)` instance. ### Throws Throws `Error` if `[Context](../Protocols/ContextAccepting.html#/s:13RouteComposer16ContextAcceptingP0C0Qa)` instance is not supported. `[Router](../Protocols/Router.html)` will stop building the rest of the stack in this case. ``` -------------------------------- ### Method: setup Source: https://github.com/ekazaev/route-composer/blob/master/docs/Protocols/ContextAcceptingView.html This method is called by ContextSettingTask to provide the Context instance to a newly built or found View. It throws an error if the context is not supported, which will stop the Router from building the rest of the stack. ```swift @MainActor mutating func setup(with context: Context) throws ``` -------------------------------- ### Configuring a StepAssembler with InlineFactory Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Structs/InlineFactory.html This example demonstrates how to use InlineFactory to configure a StepAssembler for creating a ProductViewController. It shows the typical chain of configuration methods. ```swift let productScreen = StepAssembler() .finder(.classWithContextFinder) .factory(.build { ProductViewController(context: $0) }) .adding(ContextSettingTask()) .using(.push) .from(.navigationController) .using(.present) .from(.current) .assemble() ``` -------------------------------- ### Swift CustomContainerViewController Extension Example Source: https://github.com/ekazaev/route-composer/blob/master/docs/Other Protocols.html Example of extending UINavigationController to conform to CustomContainerViewController. This allows the library to provide a custom ContainerAdapter for UINavigationController instances. ```swift public extension UINavigationController: CustomContainerViewController { var adapter: ContainerAdapter { return CustomNavigationAdapter(with: self) } } ``` -------------------------------- ### Create Symbolic Link for SwiftFormat Source: https://github.com/ekazaev/route-composer/blob/master/Example/Pods/SwiftFormat/README.md Alternatively, create a symbolic link in /usr/local/bin to point to the SwiftFormat binary installed by Homebrew on Apple Silicon. ```bash ln -s /opt/homebrew/bin/swiftformat /usr/local/bin/swiftformat ``` -------------------------------- ### init() Source: https://github.com/ekazaev/route-composer/blob/master/docs/Classes/SwitchAssembly.html Initializes a new instance of SwitchAssembly. ```APIDOC ## init() ### Description Constructor for SwitchAssembly. ### Declaration Swift ```swift @MainActor public init() ``` ``` -------------------------------- ### StartingPoint.custom(_:) - RouteComposer Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Structs/PresentingFinder/StartingPoint.html Represents starting the search from a custom UIViewController. This case accepts an autoclosure that returns an optional UIViewController, allowing for dynamic determination of the starting point. ```swift case custom(@autoclosure () throws -> UIViewController?) ``` -------------------------------- ### StartingPoint Enum Cases Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/PresentingFinder/StartingPoint.html Defines the possible starting points for a UIViewController stack. Use 'topmost' to start from the current top view controller, or 'custom' to provide a specific view controller. ```swift case topmost ``` ```swift case custom(@autoclosure () throws -> UIViewController?) ``` -------------------------------- ### init() Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/ContextSettingTask.html Initializes a new instance of ContextSettingTask. ```APIDOC ## init() ### Description Constructor for ContextSettingTask. ### Declaration ```swift @MainActor public init() ``` ``` -------------------------------- ### addCase with Finder Only Source: https://github.com/ekazaev/route-composer/blob/master/docs/tests/SwitchAssembly.swift.html Adds a navigation case that uses a Finder to locate a ViewController. If found, navigation starts from that ViewController. This overload does not specify a subsequent step, implying it's for finding a starting point. ```APIDOC ## addCase(from finder: F) -> Self where F.ViewController == ViewController, F.Context == Context ### Description Adds a navigation case that uses a Finder to locate a ViewController. The found ViewController will be the starting point for navigation. ### Method public final func addCase(from finder: F) -> Self where F.ViewController == ViewController, F.Context == Context ### Parameters - **finder**: An instance conforming to the `Finder` protocol used to locate the ViewController. ``` -------------------------------- ### init(options:startingPoint:windowProvider:containerAdapterLocator:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Structs/DefaultStackIterator.html Initializes a new instance of DefaultStackIterator with specified search options, starting point, window provider, and container adapter locator. ```APIDOC ## init(options:startingPoint:windowProvider:containerAdapterLocator:) ### Description Constructor for DefaultStackIterator. ### Parameters - **options** (`SearchOptions`) - Default value: `.fullStack` - `SearchOptions` to be used by `StackIteratingFinder`. - **startingPoint** (`StartingPoint`) - Default value: `.topmost` - A starting point in the `UIViewController`s stack. - **windowProvider** (`WindowProvider`) - `WindowProvider` to get proper `UIWindow`. - **containerAdapterLocator** (`ContainerAdapterLocator`) - `ContainerAdapter` instance. ``` -------------------------------- ### Implement ProductViewController Factory Source: https://github.com/ekazaev/route-composer/blob/master/README.md Example implementation of a Factory for a custom `ProductViewController`. Note the manual setting of associated types due to a known Xcode bug. ```swift class ProductViewControllerFactory: Factory { func build(with productID: UUID) throws -> ProductViewController { let productViewController = ProductViewController(nibName: "ProductViewController", bundle: nil) productViewController.productID = productID // Parameter initialisation can be handled by a ContextAction, see below: return productViewController } } ``` -------------------------------- ### Initialize UIHostingControllerWithContextFinder with Options Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/UIHostingControllerWithContextFinder.html Initializes the finder with search options, starting point, window provider, and container adapter locator. Default values are used for startingPoint, windowProvider, and containerAdapterLocator if not specified. ```swift @MainActor init(options: SearchOptions, startingPoint: DefaultStackIterator.StartingPoint = .topmost, windowProvider: WindowProvider = RouteComposerDefaults.shared.windowProvider, containerAdapterLocator: ContainerAdapterLocator = RouteComposerDefaults.shared.containerAdapterLocator) ``` -------------------------------- ### Custom Starting Point for Navigation Source: https://github.com/ekazaev/route-composer/blob/master/EXAMPLES.md Use DefaultStackIterator.StartingPoint.custom with ClassFinder to specify the correct starting point for navigation. This prevents unintended tab switching when presenting a view controller that already exists in another tab. ```swift let screenConfig: DestinationStep = StepAssembly( finder: ClassFinder(options: .currentVisibleOnly, startingPoint: .custom(ClassFinder(options: .currentVisibleOnly, startingPoint: .root).findViewController())), factory: StoryboardFactory(storyboardName: "TabBar", viewControllerID: "Square")) .adding(ExampleGenericContextTask()) .using(UINavigationController.push()) .from(GeneralStep.custom(using: ClassFinder(options: .currentVisibleOnly, startingPoint: .root))) .assemble() ``` -------------------------------- ### StepAssembly Initialization and Chaining Source: https://github.com/ekazaev/route-composer/blob/master/docs/Classes/StepAssembly.html Demonstrates how to initialize StepAssembly with Finder and Factory, and chain methods like adding interceptors/tasks, and specifying navigation actions. ```APIDOC ## StepAssembly Usage ### Description Initializes a `StepAssembly` with `Finder` and `Factory` instances, then allows chaining of operations to build a navigation flow. ### Initialization ```swift let productScreen = StepAssembly(finder: ProductViewControllerFinder(), factory: ProductViewControllerFactory()) ``` ### Chaining Operations - `.adding(Interceptor)`: Adds an interceptor to the assembly. - `.adding(Task)`: Adds a task to the assembly. - `.using(.push)`: Specifies the presentation action as push. - `.from(.navigationController)`: Specifies the origin as a navigation controller. - `.using(.present)`: Specifies the presentation action as present. - `.from(.current)`: Specifies the origin as the current view controller. - `.assemble()`: Finalizes the assembly and returns the configured navigation chain. ### Example ```swift let productScreen = StepAssembly(finder: ProductViewControllerFinder(), factory: ProductViewControllerFactory()) .adding(LoginInterceptor()) .adding(ProductViewControllerContextTask()) .adding(ProductViewControllerPostTask(analyticsManager: AnalyticsManager.sharedInstance)) .using(.push) .from(.navigationController) .using(.present) .from(.current) .assemble() ``` ``` -------------------------------- ### Custom Starting Point for Navigation Stack Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/examples.html Configure the router to start building the navigation stack from a specific point within a navigation controller. This is useful when the desired view controller is nested within a tab bar or other container. ```swift let screenConfig: DestinationStep = StepAssembly( finder: ClassFinder(options: .currentVisibleOnly, startingPoint: .custom(ClassFinder(options: .currentVisibleOnly, startingPoint: .root).findViewController())), factory: StoryboardFactory(storyboardName: "TabBar", viewControllerID: "Square")) .adding(ExampleGenericContextTask()) .using(UINavigationController.push()) .from(GeneralStep.custom(using: ClassFinder(options: .currentVisibleOnly, startingPoint: .root))) .assemble() ``` -------------------------------- ### KeyWindowProvider Initializer Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/KeyWindowProvider.html Initializes a new instance of KeyWindowProvider. ```APIDOC ## Method: init() ### Description Initializes a new instance of the `KeyWindowProvider`. ### Declaration ```swift public nonisolated init() ``` ``` -------------------------------- ### InlineStackIteratingFinder Initializer with Options and Predicate Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/InlineStackIteratingFinder.html Initializes InlineStackIteratingFinder with various search options, starting point, window provider, container adapter locator, and a predicate block. The starting point defaults to .topmost, and providers/locators use shared defaults. ```swift init(options: SearchOptions, startingPoint: DefaultStackIterator.StartingPoint = .topmost, windowProvider: WindowProvider = RouteComposerDefaults.shared.windowProvider, containerAdapterLocator: ContainerAdapterLocator = RouteComposerDefaults.shared.containerAdapterLocator, predicate inlineBock: @escaping (VC, C) -> Bool) ``` -------------------------------- ### StartingPoint Enum Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Structs/DefaultStackIterator/StartingPoint.html Defines the possible starting points for DefaultStackIterator. ```APIDOC ## StartingPoint Enum A starting point in the `UIViewController`s stack. ### Cases * `topmost`: Start from the topmost `UIViewController`. * `root`: Start from the `UIWindow`s root `UIViewController`. * `custom(_:)`: Start from a custom `UIViewController`. ### Declaration ```swift public enum StartingPoint ``` ### Case Details #### topmost Start from the topmost `UIViewController` ```swift case topmost ``` #### root Start from the `UIWindow`s root `UIViewController` ```swift case root ``` #### custom(_:) Start from the custom `UIViewController` ```swift case custom(@autoclosure () throws -> UIViewController?) ``` ``` -------------------------------- ### Initialization Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Structs/UIHostingControllerWithContextFactory.html Initializes a new instance of UIHostingControllerWithContextFactory. ```APIDOC ## init() ### Description Constructor for `UIHostingControllerWithContextFactory`. ### Declaration ```swift @MainActor public init() ``` ``` -------------------------------- ### Associated Types Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Structs/CATransactionWrappedContainerAction.html Defines the `ViewController` type that the `Action` can start from. ```APIDOC ### Associated types * `ViewController` Type of the `UIViewController` that `Action` can start from. #### Declaration ```swift public typealias ViewController = A.ViewController ``` ``` -------------------------------- ### Initializer: init(with:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Protocols/ConcreteContainerAdapter.html Initializes a new instance of the adapter with a specific container view controller. ```APIDOC ## Initializer: init(with:) ### Description Constructor ### Declaration ```swift @MainActor init(with viewController: Container) ``` ``` -------------------------------- ### StartingPoint.topmost Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/DefaultStackIterator/StartingPoint.html Represents starting the iteration from the topmost UIViewController in the stack. ```APIDOC ## Case: topmost Start from the topmost `UIViewController` ### Declaration ```swift case topmost ``` ``` -------------------------------- ### CompleteFactoryAssembly Initialization and Assembly Source: https://github.com/ekazaev/route-composer/blob/master/docs/Classes/CompleteFactoryAssembly.html Demonstrates how to initialize CompleteFactoryAssembly with a root factory and add child factories using the `with` method, followed by assembling the final factory. ```APIDOC ## CompleteFactoryAssembly ### Description Builds a `ContainerFactory` fulfilled with the children `UIViewController` factories. ### Usage Example ```swift let rootFactory = CompleteFactoryAssembly(factory: TabBarFactory()) .with(XibFactory, using: UITabBarController.add()) .with(XibFactory, using: UITabBarController.add()) .assemble() ``` _NB: Order matters here_ ``` -------------------------------- ### ModalPresentationStartingPoint Source: https://github.com/ekazaev/route-composer/blob/master/docs/Enums/ViewControllerActions/PresentModallyAction/ModalPresentationStartingPoint.html An enum that defines the starting point for modal presentations. ```APIDOC ## Enum: ModalPresentationStartingPoint ### Description A starting point in the modal presentation. ### Cases - **current** Present from the `UIViewController` from the previous step (Default behaviour). - **topmostParent** Present from the topmost parent `UIViewController` of the `UIViewController` from the previous step. - **custom(_:)** Present from the custom `UIViewController`. #### Parameters - `() -> UIViewController?` - An autoclosure that provides the custom `UIViewController` to present from. ``` -------------------------------- ### Method: setup Source: https://github.com/ekazaev/route-composer/blob/master/docs/Protocols/ContextAccepting.html Called by ContextSettingTask to provide the Context instance to a newly built or found UIViewController. Throws an error if the context is not supported, which stops the router's stack building. ```swift @MainActor func setup(with context: Context) throws ``` -------------------------------- ### init() Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Structs/NilFactory.html Initializes a new instance of NilFactory. ```APIDOC ## init() ### Description Initializes a new instance of NilFactory. ### Declaration ```swift @MainActor public init() ``` ``` -------------------------------- ### Associated Type: ViewController Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/CATransactionWrappedContainerAction.html Defines the type of UIViewController that an Action can start from. ```APIDOC ### Associated Types * `ViewController` Type of the `UIViewController` that `Action` can start from. #### Declaration ```swift public typealias ViewController = A.ViewController ``` ``` -------------------------------- ### init(finder:factory:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/Classes/SingleContainerStep.html Creates an instance of the ActionToStepIntegrator describing a container view controller. ```APIDOC ## init(finder:factory:) ### Description Creates an instance of the `ActionToStepIntegrator` describing a container view controller. ### Parameters - `finder` (F) - The `UIViewController` `Finder`. - `factory` (FC) - The `UIViewController` `ContainerFactory`. ``` -------------------------------- ### CompleteFactoryAssembly Initialization and Chaining Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Classes/CompleteFactoryAssembly.html Demonstrates how to initialize CompleteFactoryAssembly and chain `with` calls to add child factories. ```APIDOC ## CompleteFactoryAssembly ### Description Builds a `ContainerFactory` fulfilled with the children `UIViewController` factories. ### Usage ```swift let rootFactory = CompleteFactoryAssembly(factory: TabBarFactory()) .with(XibFactory, using: UITabBarController.add()) .with(XibFactory, using: UITabBarController.add()) .assemble() ``` _NB: Order matters here_ ``` -------------------------------- ### StartingPoint Property Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Structs/PresentingFinder.html Represents the starting point for searching within the UIViewController stack. ```swift @MainActor public let startingPoint: StartingPoint ``` -------------------------------- ### StartingPoint Enum Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/DefaultStackIterator/StartingPoint.html Defines the possible starting points for iterating through a UIViewController stack. ```APIDOC ## Enum: StartingPoint A starting point in the `UIViewController`s stack. ### Cases - **topmost**: Start from the topmost `UIViewController`. - **root**: Start from the `UIWindow`s root `UIViewController`. - **custom(_:)**: Start from the custom `UIViewController`. ``` -------------------------------- ### init(factory:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Classes/CompleteFactoryAssembly.html Initializes the assembly with a root factory. ```APIDOC ## init(factory:) ### Description Initializes the `CompleteFactoryAssembly` with a root factory. ### Parameters - **factory** (`FC`) - Required - The `ContainerFactory` instance that serves as the root of the assembly. ``` -------------------------------- ### init(finder:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Structs/StepAssemblerWithFinder.html Initializes a new instance of StepAssemblerWithFinder with a given Finder. ```APIDOC ## init(finder:) ### Description Constructor for StepAssemblerWithFinder. ### Parameters - **finder** (F) - The `UIViewController` `Finder` instance. ``` -------------------------------- ### addCase(from:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/Classes/SwitchAssembly.html Adds a case that starts navigation from a found view controller in the stack. ```APIDOC ## addCase(from:) ### Description Adds a case when a view controller exists - navigation will start from the resulting view controller. ### Declaration Swift ```swift @MainActor public final func addCase(from finder: F) -> Self where ViewController == F.ViewController, Context == F.Context, F : Finder ``` ### Parameters #### Finder Parameter - `_finder_` (F) - Required - The Finder instance is to find a UIViewController in the stack. A UIViewController found by the Finder will be considered as a view controller to start the navigation process from. ``` -------------------------------- ### prepare(with:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Protocols/ContainerFactory.html Default implementation for preparing the factory with a context. This method is part of the extension and typically does nothing by default. ```APIDOC ## prepare(with:) ### Description Default implementation does nothing. ### Parameters - **context**: The context to prepare the factory with. ### Throws An error if preparation fails. ### Declaration ```swift @MainActor mutating func prepare(with context: Context) throws ``` ``` -------------------------------- ### assemble(from:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/ContainerStepChainAssembly.html Assembles all the provided settings into a DestinationStep. ```APIDOC ## assemble(from:) ### Description Assembles all the provided settings. ### Method func assemble(from step: DestinationStep) -> DestinationStep ### Parameters - **step** (DestinationStep) - An instance of `[DestinationStep](../Structs/DestinationStep.html)` to build a current stack from. ### Return Value An instance of `[DestinationStep](../Structs/DestinationStep.html)` with all the provided settings inside. ``` -------------------------------- ### Header Comment Definition Source: https://github.com/ekazaev/route-composer/blob/master/Example/Pods/SwiftFormat/README.md Example of a single-line comment block that qualifies as a header comment. ```swift // This is a header comment ``` -------------------------------- ### Associated Type: ViewController Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Structs/CATransactionWrappedAction.html Defines the type of UIViewController that an Action can start from when wrapped by CATransactionWrappedAction. ```APIDOC ## Associated Types ### ViewController Type of the `UIViewController` that `[Action](../Core%20Entities.html#/s:13RouteComposer6ActionP)` can start from. #### Declaration ```swift public typealias ViewController = A.ViewController ``` ``` -------------------------------- ### Initialize and Configure StepAssembly Source: https://github.com/ekazaev/route-composer/blob/master/docs/tests/StepAssembly.swift.html Example of initializing StepAssembly with a finder and factory, then chaining interceptors, tasks, and actions to define a routing step. Use this to build complex navigation flows. ```swift let productScreen = StepAssembly(finder: ProductViewControllerFinder(), factory: ProductViewControllerFactory()) .adding(LoginInterceptor()) .adding(ProductViewControllerContextTask()) .adding(ProductViewControllerPostTask(analyticsManager: AnalyticsManager.sharedInstance)) .using(UINavigationController.push()) .from(NavigationControllerStep()) .using(GeneralAction.presentModally()) .from(GeneralStep.current()) .assemble() ``` -------------------------------- ### Configure Product View Controller Step Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/index.html Configure a `DestinationStep` for `ProductViewController` using `StepAssembler`. This example defines how the view controller should be found, created, presented, and what tasks should run before and after routing. ```swift let productScreen = StepAssembler() .finder(ProductViewControllerFinder()) .factory(ProductViewControllerFactory()) .add(LoginInterceptor()) .add(ProductViewControllerContextTask()) .add(ProductViewControllerPostTask(analyticsManager: AnalyticsManager.sharedInstance)) .using(.push) .from(.navigationController) .using(.present) .from(.current) .assemble() ``` -------------------------------- ### CompleteFactoryAssembly Initialization Source: https://github.com/ekazaev/route-composer/blob/master/docs/tests/CompleteFactoryAssembly.swift.html Initializes the CompleteFactoryAssembly with a root ContainerFactory. This is the starting point for building a chain of factories. ```swift public final class CompleteFactoryAssembly { // MARK: Properties private final var factory: FC // MARK: Methods /// Constructor /// /// - Parameters: /// - factory: The `ContainerFactory` instance. public init(factory: FC) { self.factory = factory } } ``` -------------------------------- ### StepAssembler Initialization Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Structs/StepAssembler.html Initializes a new StepAssembler instance. This is the starting point for configuring a navigation step. ```APIDOC ## init() ### Description Constructor for StepAssembler. ### Declaration ```swift @MainActor public init() ``` ``` -------------------------------- ### init() Source: https://github.com/ekazaev/route-composer/blob/master/docs/Classes/NavigationControllerStep.html Initializes a new instance of NavigationControllerStep. ```APIDOC ## init() ### Description Constructor for NavigationControllerStep. ### Declaration Swift ```swift @MainActor public init() ``` ``` -------------------------------- ### StepAssembler Initialization Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/StepAssembler.html Initializes a new instance of StepAssembler. This is the starting point for building a navigation step. ```APIDOC ## init() ### Description Constructor for StepAssembler. ### Declaration Swift ```swift @MainActor public init() ``` ``` -------------------------------- ### DetailsNavigationFinder Initialization with Options Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/DetailsNavigationFinder.html Initializes a new instance of DetailsNavigationFinder with various configuration options including search options, starting point, window provider, and container adapter locator. ```APIDOC ## DetailsNavigationFinder.init(options:startingPoint:windowProvider:containerAdapterLocator:) ### Description Constructor for DetailsNavigationFinder. ### Parameters - **options** (`SearchOptions`) - Required - A combination of the `SearchOptions`. - **startingPoint** (`DefaultStackIterator.StartingPoint`) - Optional - `DefaultStackIterator.StartingPoint` value. Defaults to `.topmost`. - **windowProvider** (`WindowProvider`) - Optional - `WindowProvider` instance. Defaults to `RouteComposerDefaults.shared.windowProvider`. - **containerAdapterLocator** (`ContainerAdapterLocator`) - Optional - A `ContainerAdapterLocator` instance. Defaults to `RouteComposerDefaults.shared.containerAdapterLocator`. ``` -------------------------------- ### Associated Type: ViewController Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/DispatchQueueWrappedContainerAction.html Defines the type of UIViewController that an Action can start from within the DispatchQueueWrappedContainerAction context. ```APIDOC ## Associated Type: ViewController Type of the `UIViewController` that `[Action](../Core%20Entities.html#/s:13RouteComposer6ActionP)` can start from. ### Declaration ```swift public typealias ViewController = A.ViewController ``` ``` -------------------------------- ### Associated Type ViewController Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/CATransactionWrappedContainerAction.html Defines the type of UIViewController that an Action can start from. This is a type alias for A.ViewController. ```swift public typealias ViewController = A.ViewController ``` -------------------------------- ### execute(with:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/Protocols/Factory.html Prepares the Factory and builds its ViewController. This is a helper method that combines preparation and building steps. ```APIDOC ## execute(with:) ### Description Prepares the `Factory` and builds its `UIViewController`. ### Method `execute(with context: Context) throws -> ViewController` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **ViewController** (ViewController) - The built `UIViewController` instance. #### Response Example None ### Error Handling None explicitly mentioned, but may throw `RoutingError` due to underlying `build` method. ``` -------------------------------- ### SingleNavigationLock Implementation Source: https://github.com/ekazaev/route-composer/blob/master/docs/tests/SingleNavigationRouter.swift.html Manages the state of navigation in progress. Use this to prevent multiple navigations from starting concurrently. ```swift public final class SingleNavigationLock { private final var isNavigationInProgressFlag = false /// `SingleNavigationLock` state public final var isNavigationInProgress: Bool { isNavigationInProgressFlag } /// Constructor public init() {} final func startNavigation() { isNavigationInProgressFlag = true } final func stopNavigation() { isNavigationInProgressFlag = false } } ``` -------------------------------- ### Configure ProductViewController Step Source: https://github.com/ekazaev/route-composer/blob/master/README.md Use StepAssembler to configure a ProductViewController step. This example shows how to define finder, factory, interceptors, tasks, and presentation logic for a view controller. ```swift let productScreen = StepAssembler() .finder(ProductViewControllerFinder()) .factory(ProductViewControllerFactory()) .add(LoginInterceptor()) // Have to specify the context type till https://bugs.swift.org/browse/SR-8719, https://bugs.swift.org/browse/SR-8705 are fixed .add(ProductViewControllerContextTask()) .add(ProductViewControllerPostTask(analyticsManager: AnalyticsManager.sharedInstance)) .using(.push) .from(.navigationController) .using(.present) .from(.current) .assemble() ``` -------------------------------- ### ModalPresentationStartingPoint Enum Cases Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Enums/ViewControllerActions/PresentModallyAction/ModalPresentationStartingPoint.html This enum provides different options for specifying the starting point of a modal presentation. ```APIDOC ## Enum: ModalPresentationStartingPoint A starting point in the modal presentation. ### Cases - **`current`** Present from the `UIViewController` from the previous step (Default behaviour). - **`topmostParent`** Present from the topmost parent `UIViewController` of the `UIViewController` from the previous step. - **`custom(_:)`** Present from the custom `UIViewController`. ``` -------------------------------- ### Initializer with Finder and Factory Source: https://github.com/ekazaev/route-composer/blob/master/docs/Classes/StepAssembly.html Initializes StepAssembly with a Finder and a Factory. ```APIDOC ## init(finder:factory:) ### Description Initializes StepAssembly with a Finder and a Factory. ### Parameters - **finder** (F) - The UIViewController Finder instance. - **factory** (FC) - The UIViewController Factory instance. ``` -------------------------------- ### init(factory:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/Classes/CompleteFactoryAssembly.html Initializes the CompleteFactoryAssembly with a given factory. ```APIDOC ## init(factory:) ### Description Constructor for CompleteFactoryAssembly. ### Parameters - **factory** (FC) - The `[ContainerFactory](../Protocols/ContainerFactory.html)` instance. ``` -------------------------------- ### Import RouteComposer in Swift Source: https://github.com/ekazaev/route-composer/blob/master/README.md Once integrated, import the RouteComposer library into your Swift files to start using its features. ```swift import RouteComposer ``` -------------------------------- ### Initialize ClassFactory Source: https://github.com/ekazaev/route-composer/blob/master/docs/tests/ClassFactory.swift.html Initializes a ClassFactory with an optional nib name, bundle, and a configuration closure for extended setup. ```swift public init(nibName nibNameOrNil: String? = nil, bundle nibBundleOrNil: Bundle? = nil, configuration: ((_: VC) -> Void)? = nil) ``` -------------------------------- ### assemble(default step:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/tests/SwitchAssembly.swift.html Assembles all cases and adds a default `DestinationStep` instance to handle navigation when no other cases match. ```APIDOC ## assemble(default step: DestinationStep) -> DestinationStep ### Description Assembles the navigation cases and provides a default `DestinationStep` instance to be used if no other cases are met. ### Method public final func assemble(default step: DestinationStep) -> DestinationStep ### Parameters - **step**: A `DestinationStep` instance to be used as the default navigation action. ``` -------------------------------- ### prepare(with:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/CompleteFactory.html Prepares the factory with the given context. This method is marked with `@MainActor` ensuring it runs on the main thread. ```APIDOC ## prepare(with:) ### Description Prepares the factory with the given context. This method is marked with `@MainActor` ensuring it runs on the main thread. ### Method `mutating func prepare(with context: FC.Context) throws` ### Parameters #### Path Parameters * `context` (FC.Context) - Description of the context parameter. ``` -------------------------------- ### prepare(with:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/ContextSettingTask.html Prepares the task with the given context. ```APIDOC ## prepare(with:) ### Description Prepares the task with the provided context. ### Declaration ```swift @MainActor public func prepare(with context: VC.Context) throws ``` ``` -------------------------------- ### addCase with Finder Source: https://github.com/ekazaev/route-composer/blob/master/docs/tests/SwitchAssembly.swift.html Adds a navigation case that uses a Finder to locate a ViewController. If found, navigation starts from that ViewController. ```APIDOC ## addCase(when finder: F, from step: DestinationStep) -> Self where F.Context == Context ### Description Adds a navigation case using a Finder to determine the starting ViewController for navigation. ### Method public final func addCase(when finder: F, from step: DestinationStep) -> Self where F.Context == Context ### Parameters - **finder**: An instance conforming to the `Finder` protocol. - **step**: The `DestinationStep` to be used if the finder locates a ViewController. ``` -------------------------------- ### PresentingFinder Initializer Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Structs/PresentingFinder.html Initializes a PresentingFinder instance with optional WindowProvider and StartingPoint. Defaults to RouteComposerDefaults.shared.windowProvider and .topmost starting point. ```swift public init(windowProvider: WindowProvider = RouteComposerDefaults.shared.windowProvider, startingPoint: StartingPoint = .topmost) ``` -------------------------------- ### prepare(with:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Structs/ContextSettingTask.html Prepares the context for a view controller. ```APIDOC ## prepare(with:) ### Description Prepares the context for a view controller. ### Declaration ```swift @MainActor public func prepare(with context: VC.Context) throws ``` ``` -------------------------------- ### RoutingInterceptor perform Method Source: https://github.com/ekazaev/route-composer/blob/master/docs/Protocols/RoutingInterceptor.html Called by the Router to start the interceptor. The completion block MUST be called to continue navigation. ```swift @MainActor func perform(with context: Context, completion: @escaping (RoutingResult) -> Void) ``` -------------------------------- ### ModalPresentationStartingPoint Enum Cases Source: https://github.com/ekazaev/route-composer/blob/master/docs/Enums/ViewControllerActions/PresentModallyAction/ModalPresentationStartingPoint.html Use these cases to define the starting point for modal presentations. `current` is the default behavior. ```swift case current ``` ```swift case topmostParent ``` ```swift case custom(@autoclosure () throws -> UIViewController?) ``` -------------------------------- ### Initialize UIHostingControllerWithContextFinder Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/UIHostingControllerWithContextFinder.html Initializes the finder with a custom StackIterator. Defaults to RouteComposerDefaults.shared.stackIterator if not provided. ```swift @MainActor public init(iterator: StackIterator = RouteComposerDefaults.shared.stackIterator) ``` -------------------------------- ### Initialization Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Structs/ContextSettingTask.html Initializes a new instance of ContextSettingTask. ```APIDOC ## init() ### Description Initializes a new instance of `ContextSettingTask`. ### Declaration ```swift @MainActor public init() ``` ``` -------------------------------- ### Get Previous Step Source: https://github.com/ekazaev/route-composer/blob/master/docs/tests/BaseStep.swift.html Returns the previous routing step in the chain. Used to maintain the sequence of routing operations. ```swift func getPreviousStep(with context: AnyContext) -> RoutingStep? { previousStep } ``` -------------------------------- ### prepare() Source: https://github.com/ekazaev/route-composer/blob/master/docs/Protocols/RoutingInterceptor.html The Router calls this method before the navigation process begins. If the RoutingInterceptor cannot permit navigation, it can halt the Router by throwing an exception. ```APIDOC ## prepare() ### Description The `Router` will call this method before the navigation process. If `RoutingInterceptor` is not able to allow the navigation process to start it can stop `Router` by throwing an exception. ### Method `prepare()` ### Throws The `RoutingError` if the `RoutingInterceptor` cannot prepare itself or if the navigation process cannot start with the `Context` instance provided. ### Declaration ```swift @MainActor mutating func prepare() throws ``` ``` -------------------------------- ### Upgrade SwiftFormat using Homebrew Source: https://github.com/ekazaev/route-composer/blob/master/Example/Pods/SwiftFormat/README.md Run this command to update SwiftFormat for Xcode to the latest version when installed via Homebrew. ```bash $ brew upgrade --cask swiftformat-for-xcode ``` -------------------------------- ### prepare(with:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/docsets/RouteComposer.docset/Contents/Resources/Documents/Protocols/RoutingInterceptor.html The Router calls this method before the navigation process. If the interceptor cannot allow navigation, it can stop the Router by throwing an exception. ```APIDOC ## prepare(with:) ### Description The `Router` will call this method before the navigation process. If `RoutingInterceptor` is not able to allow the navigation process to start it can stop `Router` by throwing an exception. ### Throws The `RoutingError` if the `RoutingInterceptor` cannot prepare itself or if the navigation process cannot start with the `Context` instance provided. ### Declaration ```swift @MainActor mutating func prepare(with context: Context) throws ``` ### Parameters - `_context_` (Context) - The `Context` instance that is provided to the `Router`. ``` -------------------------------- ### addCase Source: https://github.com/ekazaev/route-composer/blob/master/docs/tests/SwitchAssembly.swift.html Adds a case to the SwitchAssembly, expecting a Finder to locate a UIViewController. The found UIViewController will be used as the starting point for navigation. ```APIDOC ## addCase(expecting finder: F) -> Self where F.Context == Context ### Description Adds a case to the SwitchAssembly, expecting a `Finder` to locate a `UIViewController`. A `UIViewController` found by the `Finder` will be considered as a view controller to start the navigation process from. ### Method Signature ```swift func addCase(expecting finder: F) -> Self where F.Context == Context ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```swift // Example usage (assuming SwitchAssembly and Finder are properly initialized) let assembly = SwitchAssembly() let viewControllerFinder = MyViewControllerFinder() assembly.addCase(expecting: viewControllerFinder) ``` ### Response #### Success Response - `Self`: Returns the modified `SwitchAssembly` instance for chaining. ``` -------------------------------- ### assemble() Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/LastStepInChainAssembly.html Assembles all the provided settings into a DestinationStep. ```APIDOC ## assemble() ### Description Assembles all the provided settings. ### Method `assemble()` ### Return Value The instance of `DestinationStep` with all the settings provided inside. ``` -------------------------------- ### Initialize DefaultStackIterator Source: https://github.com/ekazaev/route-composer/blob/master/docs/tests/DefaultStackIterator.swift.html Initializes DefaultStackIterator with custom search options, starting point, window provider, and container adapter locator. ```swift public init(options: SearchOptions = .fullStack, startingPoint: StartingPoint = .topmost, windowProvider: WindowProvider, containerAdapterLocator: ContainerAdapterLocator) { self.startingPoint = startingPoint self.options = options self.windowProvider = windowProvider self.containerAdapterLocator = containerAdapterLocator } ``` -------------------------------- ### execute(completion:) Source: https://github.com/ekazaev/route-composer/blob/master/docs/Protocols/RoutingInterceptor.html Prepares the RoutingInterceptor and executes it. ```APIDOC ## execute(completion:) ### Description Prepares the `RoutingInterceptor` and executes it. ### Method `execute(completion:) ### Parameters #### completion Completion block with a result. - **completion** (@escaping (RoutingResult) -> Void) - Description ### Declaration ```swift @MainActor func execute(completion: @escaping (RoutingResult) -> Void) throws ``` ``` -------------------------------- ### Initialize View Controller Stack Building Source: https://github.com/ekazaev/route-composer/blob/master/docs/tests/DefaultRouter.swift.html Initiates the process of building the view controller stack. Logs whether any view controllers are needed or if the process is starting. ```swift logger?.log(.info(factories.isEmpty ? "No view controllers needed to be integrated into the stack." : "Started to build the view controllers stack.")) buildViewController(from: rootViewController) ``` -------------------------------- ### StartingPoint Enum Cases Source: https://github.com/ekazaev/route-composer/blob/master/docs/Structs/DefaultStackIterator/StartingPoint.html Defines the possible starting points for stack iteration: topmost, root, or a custom view controller. ```swift case topmost ``` ```swift case root ``` ```swift case custom(@autoclosure () throws -> UIViewController?) ```