SwiftGen+Assets.swift 4.38 KB
Newer Older
1
// swiftlint:disable all
Jose Blaya's avatar
Jose Blaya committed
2
// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
Davide De Rosa's avatar
Davide De Rosa committed
3

Jose Blaya's avatar
Jose Blaya committed
4 5 6 7 8 9
#if os(macOS)
  import AppKit
#elseif os(iOS)
  import UIKit
#elseif os(tvOS) || os(watchOS)
  import UIKit
Davide De Rosa's avatar
Davide De Rosa committed
10 11
#endif

Jose Blaya's avatar
Jose Blaya committed
12 13 14 15 16
// Deprecated typealiases
@available(*, deprecated, renamed: "ImageAsset.Image", message: "This typealias will be removed in SwiftGen 7.0")
internal typealias AssetImageTypeAlias = ImageAsset.Image

// swiftlint:disable superfluous_disable_command file_length implicit_return
Davide De Rosa's avatar
Davide De Rosa committed
17

18
// MARK: - Asset Catalogs
Davide De Rosa's avatar
Davide De Rosa committed
19 20

// swiftlint:disable identifier_name line_length nesting type_body_length type_name
ueshiba's avatar
ueshiba committed
21
internal enum Asset {
Jose Blaya's avatar
Jose Blaya committed
22 23
  internal static let centeredDarkMap = ImageAsset(name: "centered-dark-map")
  internal static let centeredLightMap = ImageAsset(name: "centered-light-map")
Jose Blaya's avatar
WIP  
Jose Blaya committed
24 25
  internal static let computerIcon = ImageAsset(name: "computer-icon")
  internal static let globeIcon = ImageAsset(name: "globe-icon")
Jose Blaya's avatar
wip  
Jose Blaya committed
26
  internal static let iconBack = ImageAsset(name: "icon-back")
Jose Blaya's avatar
Jose Blaya committed
27
  internal static let iconCamera = ImageAsset(name: "icon-camera")
28
  internal static let iconClose = ImageAsset(name: "icon-close")
Jose Blaya's avatar
Jose Blaya committed
29
  internal static let iconWarning = ImageAsset(name: "icon-warning")
Jose Blaya's avatar
Jose Blaya committed
30 31
  internal static let logoDark = ImageAsset(name: "logo-dark")
  internal static let logoLight = ImageAsset(name: "logo-light")
Jose Blaya's avatar
Jose Blaya committed
32 33
  internal static let pagecontrolSelectedDot = ImageAsset(name: "pagecontrol-selected-dot")
  internal static let pagecontrolUnselectedDot = ImageAsset(name: "pagecontrol-unselected-dot")
Jose Blaya's avatar
Jose Blaya committed
34 35
  internal static let planSelected = ImageAsset(name: "plan-selected")
  internal static let planUnselected = ImageAsset(name: "plan-unselected")
Jose Blaya's avatar
Jose Blaya committed
36 37
  internal static let scrollableMapDark = ImageAsset(name: "scrollableMap-dark")
  internal static let scrollableMapLight = ImageAsset(name: "scrollableMap-light")
Jose Blaya's avatar
WIP  
Jose Blaya committed
38
  internal static let shieldIcon = ImageAsset(name: "shield-icon")
ueshiba's avatar
ueshiba committed
39 40 41 42 43 44 45 46
  internal static let closeIcon = ImageAsset(name: "close-icon")
  internal static let imageAccountFailed = ImageAsset(name: "image-account-failed")
  internal static let imageNoInternet = ImageAsset(name: "image-no-internet")
  internal static let imagePurchaseSuccess = ImageAsset(name: "image-purchase-success")
  internal static let imageReceiptBackground = ImageAsset(name: "image-receipt-background")
  internal static let imageRedeemClaimed = ImageAsset(name: "image-redeem-claimed")
  internal static let imageRedeemInvalid = ImageAsset(name: "image-redeem-invalid")
  internal static let imageRedeemSuccess = ImageAsset(name: "image-redeem-success")
Jose Blaya's avatar
Jose Blaya committed
47 48 49
  internal static let imageWalkthrough1 = ImageAsset(name: "image-walkthrough-1")
  internal static let imageWalkthrough2 = ImageAsset(name: "image-walkthrough-2")
  internal static let imageWalkthrough3 = ImageAsset(name: "image-walkthrough-3")
ueshiba's avatar
ueshiba committed
50 51
  internal static let navLogo = ImageAsset(name: "nav-logo")
  internal static let qrCode = ImageAsset(name: "qr-code")
Davide De Rosa's avatar
Davide De Rosa committed
52 53 54
}
// swiftlint:enable identifier_name line_length nesting type_body_length type_name

55 56
// MARK: - Implementation Details

Jose Blaya's avatar
Jose Blaya committed
57
internal struct ImageAsset {
58 59
  internal fileprivate(set) var name: String

Jose Blaya's avatar
Jose Blaya committed
60 61 62 63
  #if os(macOS)
  internal typealias Image = NSImage
  #elseif os(iOS) || os(tvOS) || os(watchOS)
  internal typealias Image = UIImage
64 65
  #endif

Jose Blaya's avatar
Jose Blaya committed
66 67
  internal var image: Image {
    let bundle = BundleToken.bundle
68
    #if os(iOS) || os(tvOS)
Jose Blaya's avatar
Jose Blaya committed
69 70
    let image = Image(named: name, in: bundle, compatibleWith: nil)
    #elseif os(macOS)
Thomas Markiewicz's avatar
Thomas Markiewicz committed
71 72
    let name = NSImage.Name(self.name)
    let image = (bundle == .main) ? NSImage(named: name) : bundle.image(forResource: name)
73
    #elseif os(watchOS)
Jose Blaya's avatar
Jose Blaya committed
74
    let image = Image(named: name)
75
    #endif
Jose Blaya's avatar
Jose Blaya committed
76 77 78
    guard let result = image else {
      fatalError("Unable to load image named \(name).")
    }
79 80 81 82
    return result
  }
}

Jose Blaya's avatar
Jose Blaya committed
83 84
internal extension ImageAsset.Image {
  @available(macOS, deprecated,
85 86 87
    message: "This initializer is unsafe on macOS, please use the ImageAsset.image property")
  convenience init!(asset: ImageAsset) {
    #if os(iOS) || os(tvOS)
Jose Blaya's avatar
Jose Blaya committed
88
    let bundle = BundleToken.bundle
Davide De Rosa's avatar
Davide De Rosa committed
89
    self.init(named: asset.name, in: bundle, compatibleWith: nil)
Jose Blaya's avatar
Jose Blaya committed
90
    #elseif os(macOS)
91
    self.init(named: NSImage.Name(asset.name))
Davide De Rosa's avatar
Davide De Rosa committed
92 93 94 95 96 97
    #elseif os(watchOS)
    self.init(named: asset.name)
    #endif
  }
}

Jose Blaya's avatar
Jose Blaya committed
98 99 100
// swiftlint:disable convenience_type
private final class BundleToken {
  static let bundle: Bundle = {
Thomas Markiewicz's avatar
Thomas Markiewicz committed
101 102 103 104 105
    #if SWIFT_PACKAGE
    return Bundle.module
    #else
    return Bundle(for: BundleToken.self)
    #endif
Jose Blaya's avatar
Jose Blaya committed
106 107 108
  }()
}
// swiftlint:enable convenience_type