Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
157 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// swiftlint:disable all | ||
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen | ||
|
||
// swiftlint:disable sorted_imports | ||
import Foundation | ||
import UIKit | ||
|
||
// swiftlint:disable superfluous_disable_command | ||
// swiftlint:disable file_length | ||
|
||
// MARK: - Storyboard Scenes | ||
|
||
// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name | ||
internal enum StoryboardScene { | ||
internal enum Main: StoryboardType { | ||
internal static let storyboardName = "Main" | ||
|
||
internal static let initialScene = InitialSceneType<UIKit.UISplitViewController>(storyboard: Main.self) | ||
|
||
internal static let accountIdentifier = SceneType<AccountViewController>(storyboard: Main.self, identifier: "AccountIdentifier") | ||
|
||
internal static let configurationIdentifier = SceneType<ConfigurationViewController>(storyboard: Main.self, identifier: "ConfigurationIdentifier") | ||
|
||
internal static let serviceIdentifier = SceneType<UIKit.UINavigationController>(storyboard: Main.self, identifier: "ServiceIdentifier") | ||
} | ||
internal enum Organizer: StoryboardType { | ||
internal static let storyboardName = "Organizer" | ||
|
||
internal static let initialScene = InitialSceneType<UIKit.UINavigationController>(storyboard: Organizer.self) | ||
|
||
internal static let provider = SceneType<UIKit.UINavigationController>(storyboard: Organizer.self, identifier: "Provider") | ||
|
||
internal static let wizardHostIdentifier = SceneType<UIKit.UINavigationController>(storyboard: Organizer.self, identifier: "WizardHostIdentifier") | ||
} | ||
} | ||
// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name | ||
|
||
// MARK: - Implementation Details | ||
|
||
internal protocol StoryboardType { | ||
static var storyboardName: String { get } | ||
} | ||
|
||
internal extension StoryboardType { | ||
static var storyboard: UIStoryboard { | ||
let name = self.storyboardName | ||
return UIStoryboard(name: name, bundle: Bundle(for: BundleToken.self)) | ||
} | ||
} | ||
|
||
internal struct SceneType<T: UIViewController> { | ||
internal let storyboard: StoryboardType.Type | ||
internal let identifier: String | ||
|
||
internal func instantiate() -> T { | ||
let identifier = self.identifier | ||
guard let controller = storyboard.storyboard.instantiateViewController(withIdentifier: identifier) as? T else { | ||
fatalError("ViewController '\(identifier)' is not of the expected class \(T.self).") | ||
} | ||
return controller | ||
} | ||
} | ||
|
||
internal struct InitialSceneType<T: UIViewController> { | ||
internal let storyboard: StoryboardType.Type | ||
|
||
internal func instantiate() -> T { | ||
guard let controller = storyboard.storyboard.instantiateInitialViewController() as? T else { | ||
fatalError("ViewController is not of the expected class \(T.self).") | ||
} | ||
return controller | ||
} | ||
} | ||
|
||
private final class BundleToken {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// swiftlint:disable all | ||
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen | ||
|
||
// swiftlint:disable sorted_imports | ||
import Foundation | ||
import UIKit | ||
|
||
// swiftlint:disable superfluous_disable_command | ||
// swiftlint:disable file_length | ||
|
||
// MARK: - Storyboard Segues | ||
|
||
// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name | ||
internal enum StoryboardSegue { | ||
internal enum Main: String, SegueType { | ||
case accountSegueIdentifier = "AccountSegueIdentifier" | ||
case debugLogSegueIdentifier = "DebugLogSegueIdentifier" | ||
case endpointSegueIdentifier = "EndpointSegueIdentifier" | ||
case hostParametersSegueIdentifier = "HostParametersSegueIdentifier" | ||
case providerPoolSegueIdentifier = "ProviderPoolSegueIdentifier" | ||
case providerPresetSegueIdentifier = "ProviderPresetSegueIdentifier" | ||
} | ||
internal enum Organizer: String, SegueType { | ||
case aboutSegueIdentifier = "AboutSegueIdentifier" | ||
case addProviderSegueIdentifier = "AddProviderSegueIdentifier" | ||
case creditsSegueIdentifier = "CreditsSegueIdentifier" | ||
case disclaimerSegueIdentifier = "DisclaimerSegueIdentifier" | ||
case importHostSegueIdentifier = "ImportHostSegueIdentifier" | ||
case selectProfileSegueIdentifier = "SelectProfileSegueIdentifier" | ||
case showImportedHostsSegueIdentifier = "ShowImportedHostsSegueIdentifier" | ||
case versionSegueIdentifier = "VersionSegueIdentifier" | ||
} | ||
} | ||
// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name | ||
|
||
// MARK: - Implementation Details | ||
|
||
internal protocol SegueType: RawRepresentable {} | ||
|
||
internal extension UIViewController { | ||
func perform<S: SegueType>(segue: S, sender: Any? = nil) where S.RawValue == String { | ||
let identifier = segue.rawValue | ||
performSegue(withIdentifier: identifier, sender: sender) | ||
} | ||
} | ||
|
||
internal extension SegueType where RawValue == String { | ||
init?(_ segue: UIStoryboardSegue) { | ||
guard let identifier = segue.identifier else { return nil } | ||
self.init(rawValue: identifier) | ||
} | ||
} | ||
|
||
private final class BundleToken {} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.