From a9248a528b3b127899c9699c88757427947022d7 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sun, 16 Apr 2023 14:41:14 +0200 Subject: [PATCH] Implemented the WindowRouter router for iOS platform. --- .../Platform/iOS/Routers/WindowRouter.swift | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Sources/Coordinator/Platform/iOS/Routers/WindowRouter.swift diff --git a/Sources/Coordinator/Platform/iOS/Routers/WindowRouter.swift b/Sources/Coordinator/Platform/iOS/Routers/WindowRouter.swift new file mode 100644 index 0000000..92a2dd3 --- /dev/null +++ b/Sources/Coordinator/Platform/iOS/Routers/WindowRouter.swift @@ -0,0 +1,43 @@ +// +// WindowRouter.swift +// Coordinator +// +// Created by Javier Cicchelli on 11/04/2023. +// Copyright © 2023 Röck+Cöde. All rights reserved. +// + +import UIKit + +/// This class is responsible for populating the window of an application. +public class WindowRouter: Router { + + // MARK: Properties + + /// The window to set manually with a `UIViewController` view controller instance. + private let window: UIWindow? + + // MARK: Initialisers + + /// Initialise this router. + /// - Parameter window: A `UIWindow` window instance to be set manually. + public init(window: UIWindow?) { + self.window = window + } + + // MARK: Functions + + public func present( + _ viewController: UIViewController, + animated: Bool, + onDismiss: OnDismissedClosure? + ) { + window?.rootViewController = viewController + + window?.makeKeyAndVisible() + } + + public func dismiss(animated: Bool) { + // Nothing to do here... + } + +}