This PR contains the work done to implement the necessary protocols and router to implement the Coordinators pattern in the app. Reviewed-on: #15 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
47 lines
972 B
Swift
47 lines
972 B
Swift
//
|
|
// SpyRouter.swift
|
|
// ReviewsCoordinationTest
|
|
//
|
|
// Created by Javier Cicchelli on 21/03/2024.
|
|
// Copyright © 2024 Röck+Cöde. All rights reserved.
|
|
//
|
|
|
|
import ReviewsCoordinationKit
|
|
import UIKit
|
|
|
|
final class SpyRouter: Router {
|
|
|
|
// MARK: Properties
|
|
var animated: Bool?
|
|
var onDismiss: OnDismissClosure?
|
|
var state: State = .initialised
|
|
var viewController: UIViewController?
|
|
|
|
// MARK: Functions
|
|
func present(
|
|
_ viewController: UIViewController,
|
|
animated: Bool,
|
|
onDismiss: OnDismissClosure?
|
|
) {
|
|
self.viewController = viewController
|
|
self.animated = animated
|
|
self.onDismiss = onDismiss
|
|
self.state = .presented
|
|
}
|
|
|
|
func dismiss(animated: Bool) {
|
|
self.animated = animated
|
|
self.state = .dismissed
|
|
}
|
|
|
|
}
|
|
|
|
// MARK: - Enumerations
|
|
extension SpyRouter {
|
|
enum State {
|
|
case initialised
|
|
case presented
|
|
case dismissed
|
|
}
|
|
}
|