61 lines
2.4 KiB
Plaintext
61 lines
2.4 KiB
Plaintext
|
// swiftlint:disable all
|
||
|
// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
|
||
|
|
||
|
{% if platform and storyboards %}
|
||
|
{% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
|
||
|
{% set isAppKit %}{% if platform == "macOS" %}true{% endif %}{% endset %}
|
||
|
// swiftlint:disable sorted_imports
|
||
|
import Foundation
|
||
|
{% for module in modules where module != env.PRODUCT_MODULE_NAME and module != param.module %}
|
||
|
import {{module}}
|
||
|
{% endfor %}
|
||
|
|
||
|
// 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
|
||
|
{{accessModifier}} enum {{param.enumName|default:"StoryboardSegue"}} {
|
||
|
{% for storyboard in storyboards where storyboard.segues %}
|
||
|
{{accessModifier}} enum {{storyboard.name|swiftIdentifier:"pretty"|escapeReservedKeywords}}: String, SegueType {
|
||
|
{% for segue in storyboard.segues %}
|
||
|
{% set segueID %}{{segue.identifier|swiftIdentifier:"pretty"|lowerFirstWord}}{% endset %}
|
||
|
case {{segueID|escapeReservedKeywords}}{% if segueID != segue.identifier %} = "{{segue.identifier}}"{% endif %}
|
||
|
{% endfor %}
|
||
|
}
|
||
|
{% endfor %}
|
||
|
}
|
||
|
// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name
|
||
|
|
||
|
// MARK: - Implementation Details
|
||
|
|
||
|
{{accessModifier}} protocol SegueType: RawRepresentable {}
|
||
|
|
||
|
{{accessModifier}} extension {% if isAppKit %}NSSeguePerforming{% else %}UIViewController{% endif %} {
|
||
|
func perform<S: SegueType>(segue: S, sender: Any? = nil) where S.RawValue == String {
|
||
|
let identifier = {% if isAppKit %}NSStoryboardSegue.Identifier({% endif %}segue.rawValue{% if isAppKit %}){% endif %}
|
||
|
performSegue{% if isAppKit %}?{% endif %}(withIdentifier: identifier, sender: sender)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
{{accessModifier}} extension SegueType where RawValue == String {
|
||
|
init?(_ segue: {% if isAppKit %}NS{% else %}UI{% endif %}StoryboardSegue) {
|
||
|
{% if isAppKit %}
|
||
|
#if swift(>=4.2)
|
||
|
guard let identifier = segue.identifier else { return nil }
|
||
|
#else
|
||
|
guard let identifier = segue.identifier?.rawValue else { return nil }
|
||
|
#endif
|
||
|
{% else %}
|
||
|
guard let identifier = segue.identifier else { return nil }
|
||
|
{% endif %}
|
||
|
self.init(rawValue: identifier)
|
||
|
}
|
||
|
}
|
||
|
{% elif storyboards %}
|
||
|
// Mixed AppKit and UIKit storyboard files found, please invoke swiftgen with these separately
|
||
|
{% else %}
|
||
|
// No storyboard found
|
||
|
{% endif %}
|