Skip to content

Commit 05ca91b

Browse files
authored
feat: add resources (#54)
1 parent 8da18fb commit 05ca91b

25 files changed

+1571
-0
lines changed
+150
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
// swiftlint:disable all
2+
// swift-format-ignore-file
3+
// swiftformat:disable all
4+
// Generated using tuist — https://github.com/tuist/tuist
5+
6+
#if os(macOS)
7+
import AppKit
8+
#elseif os(iOS)
9+
import UIKit
10+
#elseif os(tvOS) || os(watchOS)
11+
import UIKit
12+
#endif
13+
#if canImport(SwiftUI)
14+
import SwiftUI
15+
#endif
16+
17+
// swiftlint:disable superfluous_disable_command file_length implicit_return
18+
19+
// MARK: - Asset Catalogs
20+
21+
// swiftlint:disable identifier_name line_length nesting type_body_length type_name
22+
public enum AuthAsset {
23+
public enum Assets {
24+
public static let accentColor = AuthColors(name: "AccentColor")
25+
public static let splash = AuthImages(name: "Splash")
26+
}
27+
public enum PreviewAssets {
28+
}
29+
}
30+
// swiftlint:enable identifier_name line_length nesting type_body_length type_name
31+
32+
// MARK: - Implementation Details
33+
34+
public final class AuthColors {
35+
public fileprivate(set) var name: String
36+
37+
#if os(macOS)
38+
public typealias Color = NSColor
39+
#elseif os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)
40+
public typealias Color = UIColor
41+
#endif
42+
43+
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, macOS 10.13, visionOS 1.0, *)
44+
public private(set) lazy var color: Color = {
45+
guard let color = Color(asset: self) else {
46+
fatalError("Unable to load color asset named \(name).")
47+
}
48+
return color
49+
}()
50+
51+
#if canImport(SwiftUI)
52+
private var _swiftUIColor: Any? = nil
53+
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, visionOS 1.0, *)
54+
public private(set) var swiftUIColor: SwiftUI.Color {
55+
get {
56+
if self._swiftUIColor == nil {
57+
self._swiftUIColor = SwiftUI.Color(asset: self)
58+
}
59+
60+
return self._swiftUIColor as! SwiftUI.Color
61+
}
62+
set {
63+
self._swiftUIColor = newValue
64+
}
65+
}
66+
#endif
67+
68+
fileprivate init(name: String) {
69+
self.name = name
70+
}
71+
}
72+
73+
public extension AuthColors.Color {
74+
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, macOS 10.13, visionOS 1.0, *)
75+
convenience init?(asset: AuthColors) {
76+
let bundle = Bundle.module
77+
#if os(iOS) || os(tvOS) || os(visionOS)
78+
self.init(named: asset.name, in: bundle, compatibleWith: nil)
79+
#elseif os(macOS)
80+
self.init(named: NSColor.Name(asset.name), bundle: bundle)
81+
#elseif os(watchOS)
82+
self.init(named: asset.name)
83+
#endif
84+
}
85+
}
86+
87+
#if canImport(SwiftUI)
88+
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, visionOS 1.0, *)
89+
public extension SwiftUI.Color {
90+
init(asset: AuthColors) {
91+
let bundle = Bundle.module
92+
self.init(asset.name, bundle: bundle)
93+
}
94+
}
95+
#endif
96+
97+
public struct AuthImages {
98+
public fileprivate(set) var name: String
99+
100+
#if os(macOS)
101+
public typealias Image = NSImage
102+
#elseif os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)
103+
public typealias Image = UIImage
104+
#endif
105+
106+
public var image: Image {
107+
let bundle = Bundle.module
108+
#if os(iOS) || os(tvOS) || os(visionOS)
109+
let image = Image(named: name, in: bundle, compatibleWith: nil)
110+
#elseif os(macOS)
111+
let image = bundle.image(forResource: NSImage.Name(name))
112+
#elseif os(watchOS)
113+
let image = Image(named: name)
114+
#endif
115+
guard let result = image else {
116+
fatalError("Unable to load image asset named \(name).")
117+
}
118+
return result
119+
}
120+
121+
#if canImport(SwiftUI)
122+
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, visionOS 1.0, *)
123+
public var swiftUIImage: SwiftUI.Image {
124+
SwiftUI.Image(asset: self)
125+
}
126+
#endif
127+
}
128+
129+
#if canImport(SwiftUI)
130+
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, visionOS 1.0, *)
131+
public extension SwiftUI.Image {
132+
init(asset: AuthImages) {
133+
let bundle = Bundle.module
134+
self.init(asset.name, bundle: bundle)
135+
}
136+
137+
init(asset: AuthImages, label: Text) {
138+
let bundle = Bundle.module
139+
self.init(asset.name, bundle: bundle, label: label)
140+
}
141+
142+
init(decorative asset: AuthImages) {
143+
let bundle = Bundle.module
144+
self.init(decorative: asset.name, bundle: bundle)
145+
}
146+
}
147+
#endif
148+
149+
// swiftlint:enable all
150+
// swiftformat:enable all
+150
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
// swiftlint:disable all
2+
// swift-format-ignore-file
3+
// swiftformat:disable all
4+
// Generated using tuist — https://github.com/tuist/tuist
5+
6+
#if os(macOS)
7+
import AppKit
8+
#elseif os(iOS)
9+
import UIKit
10+
#elseif os(tvOS) || os(watchOS)
11+
import UIKit
12+
#endif
13+
#if canImport(SwiftUI)
14+
import SwiftUI
15+
#endif
16+
17+
// swiftlint:disable superfluous_disable_command file_length implicit_return
18+
19+
// MARK: - Asset Catalogs
20+
21+
// swiftlint:disable identifier_name line_length nesting type_body_length type_name
22+
public enum CommonAsset {
23+
public enum Assets {
24+
public static let accentColor = CommonColors(name: "AccentColor")
25+
public static let splash = CommonImages(name: "Splash")
26+
}
27+
public enum PreviewAssets {
28+
}
29+
}
30+
// swiftlint:enable identifier_name line_length nesting type_body_length type_name
31+
32+
// MARK: - Implementation Details
33+
34+
public final class CommonColors {
35+
public fileprivate(set) var name: String
36+
37+
#if os(macOS)
38+
public typealias Color = NSColor
39+
#elseif os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)
40+
public typealias Color = UIColor
41+
#endif
42+
43+
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, macOS 10.13, visionOS 1.0, *)
44+
public private(set) lazy var color: Color = {
45+
guard let color = Color(asset: self) else {
46+
fatalError("Unable to load color asset named \(name).")
47+
}
48+
return color
49+
}()
50+
51+
#if canImport(SwiftUI)
52+
private var _swiftUIColor: Any? = nil
53+
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, visionOS 1.0, *)
54+
public private(set) var swiftUIColor: SwiftUI.Color {
55+
get {
56+
if self._swiftUIColor == nil {
57+
self._swiftUIColor = SwiftUI.Color(asset: self)
58+
}
59+
60+
return self._swiftUIColor as! SwiftUI.Color
61+
}
62+
set {
63+
self._swiftUIColor = newValue
64+
}
65+
}
66+
#endif
67+
68+
fileprivate init(name: String) {
69+
self.name = name
70+
}
71+
}
72+
73+
public extension CommonColors.Color {
74+
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, macOS 10.13, visionOS 1.0, *)
75+
convenience init?(asset: CommonColors) {
76+
let bundle = Bundle.module
77+
#if os(iOS) || os(tvOS) || os(visionOS)
78+
self.init(named: asset.name, in: bundle, compatibleWith: nil)
79+
#elseif os(macOS)
80+
self.init(named: NSColor.Name(asset.name), bundle: bundle)
81+
#elseif os(watchOS)
82+
self.init(named: asset.name)
83+
#endif
84+
}
85+
}
86+
87+
#if canImport(SwiftUI)
88+
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, visionOS 1.0, *)
89+
public extension SwiftUI.Color {
90+
init(asset: CommonColors) {
91+
let bundle = Bundle.module
92+
self.init(asset.name, bundle: bundle)
93+
}
94+
}
95+
#endif
96+
97+
public struct CommonImages {
98+
public fileprivate(set) var name: String
99+
100+
#if os(macOS)
101+
public typealias Image = NSImage
102+
#elseif os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)
103+
public typealias Image = UIImage
104+
#endif
105+
106+
public var image: Image {
107+
let bundle = Bundle.module
108+
#if os(iOS) || os(tvOS) || os(visionOS)
109+
let image = Image(named: name, in: bundle, compatibleWith: nil)
110+
#elseif os(macOS)
111+
let image = bundle.image(forResource: NSImage.Name(name))
112+
#elseif os(watchOS)
113+
let image = Image(named: name)
114+
#endif
115+
guard let result = image else {
116+
fatalError("Unable to load image asset named \(name).")
117+
}
118+
return result
119+
}
120+
121+
#if canImport(SwiftUI)
122+
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, visionOS 1.0, *)
123+
public var swiftUIImage: SwiftUI.Image {
124+
SwiftUI.Image(asset: self)
125+
}
126+
#endif
127+
}
128+
129+
#if canImport(SwiftUI)
130+
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, visionOS 1.0, *)
131+
public extension SwiftUI.Image {
132+
init(asset: CommonImages) {
133+
let bundle = Bundle.module
134+
self.init(asset.name, bundle: bundle)
135+
}
136+
137+
init(asset: CommonImages, label: Text) {
138+
let bundle = Bundle.module
139+
self.init(asset.name, bundle: bundle, label: label)
140+
}
141+
142+
init(decorative asset: CommonImages) {
143+
let bundle = Bundle.module
144+
self.init(decorative: asset.name, bundle: bundle)
145+
}
146+
}
147+
#endif
148+
149+
// swiftlint:enable all
150+
// swiftformat:enable all

0 commit comments

Comments
 (0)