// // Route.swift // Privado // // Created by Jura on 10/9/19. // Copyright © 2019 Omicronmedia. All rights reserved. // import Foundation enum Route: CustomStringConvertible { case hive(type: Hive) case killSwitch indirect case initialize(next: Route?) indirect case launchScreen(next: Route?) case login(type: Login) case purchase(type: Purchase) case servers case connect case notifications case disconnect case preference(tab: Preference?) case update case hide case quit case navigate(url: URL) case modal(settings: ModalSettings) case tutorial(type: Tutorial) /// just pop top Coordinator case back enum Hive: CustomStringConvertible { case check case install var description: String { switch self { case .check: return "check" case .install: return "install" } } } enum Login: CustomStringConvertible, Equatable { case signup case resend(String) case clear case refresh case authorize case restore case create case confirm case signout(isPassreset: Bool) case authenticate(String, String) // MARK: - CustomStringConvertible var description: String { switch self { case .signup: return "signup" case .resend: return "resend" case .clear: return "clear" case .refresh: return "refresh" case .authorize: return "authorize" case .restore: return "restore" case .create: return "create" case .confirm: return "confirm" case .signout: return "signout" case .authenticate: return "authenticate" } } // MARK: - Equatable static func == (lhs: Self, rhs: Self) -> Bool { switch (lhs, rhs) { case (.signup, .signup), (.resend, .resend), (.clear, .clear), (.refresh, .refresh), (.authorize, .authorize), (.restore, .restore), (.create, .create), (.confirm, .confirm), (.signout, .signout): return true case let (.authenticate(llogin, lpass), .authenticate(rlogin, rpass)): return llogin == rlogin && lpass == rpass default: return false } } } enum Preference: CustomStringConvertible { case account case options case `protocol` case logs case upgrade var description: String { switch self { case .account: return "account" case .options: return "options" case .`protocol`: return "protocol" case .logs: return "logs" case .upgrade: return "upgrade" } } } enum Purchase: CustomStringConvertible { case verify var description: String { switch self { case .verify: return "verify" } } } struct ModalSettings { enum `Type` { case closable case modal } let type: Type let title: String let description: String let buttonTitle: String let action: URL? } enum Tutorial: CustomStringConvertible { case credentials case exit case finish case welcome case keyhole case serverList case country case menu case customize case thatsIt var description: String { switch self { case .exit: return "exit" case .credentials: return "credentials" case .finish: return "finish" case .welcome: return "welcome" case .keyhole: return "keyhole" case .serverList: return "serverList" case .country: return "country" case .menu: return "menu" case .customize: return "customise" case .thatsIt: return "thatsIt" } } } var description: String { switch self { case let .hive(type: type): return "hive(\(type)" case .killSwitch: return "killSwitch" case let .initialize(next: route): return "initialize(next: \(route?.description ?? ""))" case let .launchScreen(next: route): return "launchScreen(next: \(route?.description ?? "")" case let .login(type: type): return "login(\(type))" case let .purchase(type: type): return "purchase(\(type))" case .servers: return "servers" case .notifications: return "notifications" case .connect: return "connect" case .disconnect: return "disconnect" case let .preference(tab: tab): return "preference(\(String(describing: tab)))" case .update: return "update" case .hide: return "hide" case .quit: return "quit" case let .navigate(url: url): return "navigate: \(url)" case let .modal(settings: settings): return "modal: \(settings)" case let .tutorial(type: type): return "tutorial: \(type)" case .back: return "back" } } }