Handle bundle for Image and Color
Some checks reported warnings
gitea-openium/resgen.swift/pipeline/head This commit is unstable
Some checks reported warnings
gitea-openium/resgen.swift/pipeline/head This commit is unstable
This commit is contained in:
@@ -63,7 +63,8 @@ struct Colors: ParsableCommand {
|
|||||||
extensionName: extensionName,
|
extensionName: extensionName,
|
||||||
extensionFilePath: extensionFilePath,
|
extensionFilePath: extensionFilePath,
|
||||||
isSwiftUI: true,
|
isSwiftUI: true,
|
||||||
visibility: options.extensionVisibility
|
visibility: options.extensionVisibility,
|
||||||
|
assetBundle: options.assetBundle
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +77,8 @@ struct Colors: ParsableCommand {
|
|||||||
extensionName: extensionNameUIKit,
|
extensionName: extensionNameUIKit,
|
||||||
extensionFilePath: extensionFilePathUIKit,
|
extensionFilePath: extensionFilePathUIKit,
|
||||||
isSwiftUI: false,
|
isSwiftUI: false,
|
||||||
visibility: options.extensionVisibility
|
visibility: options.extensionVisibility,
|
||||||
|
assetBundle: options.assetBundle
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -44,6 +44,11 @@ struct ColorsToolOptions: ParsableArguments {
|
|||||||
)
|
)
|
||||||
var extensionVisibility: ExtensionVisibility = .internal
|
var extensionVisibility: ExtensionVisibility = .internal
|
||||||
|
|
||||||
|
@Option(
|
||||||
|
help: "Bundle where the asset are generated"
|
||||||
|
)
|
||||||
|
var assetBundle: AssetBundle = .main
|
||||||
|
|
||||||
@Option(
|
@Option(
|
||||||
help: "Path where to generate the extension.",
|
help: "Path where to generate the extension.",
|
||||||
transform: { $0.replaceTiltWithHomeDirectoryPath() }
|
transform: { $0.replaceTiltWithHomeDirectoryPath() }
|
||||||
|
@@ -21,7 +21,8 @@ struct ColorExtensionGenerator {
|
|||||||
extensionName: String,
|
extensionName: String,
|
||||||
extensionFilePath: String,
|
extensionFilePath: String,
|
||||||
isSwiftUI: Bool,
|
isSwiftUI: Bool,
|
||||||
visibility: ExtensionVisibility
|
visibility: ExtensionVisibility,
|
||||||
|
assetBundle: AssetBundle
|
||||||
) {
|
) {
|
||||||
// Create extension content
|
// Create extension content
|
||||||
let extensionContent = Self.getExtensionContent(
|
let extensionContent = Self.getExtensionContent(
|
||||||
@@ -29,7 +30,8 @@ struct ColorExtensionGenerator {
|
|||||||
staticVar: staticVar,
|
staticVar: staticVar,
|
||||||
extensionName: extensionName,
|
extensionName: extensionName,
|
||||||
isSwiftUI: isSwiftUI,
|
isSwiftUI: isSwiftUI,
|
||||||
visibility: visibility
|
visibility: visibility,
|
||||||
|
assetBundle: assetBundle
|
||||||
)
|
)
|
||||||
|
|
||||||
// Write content
|
// Write content
|
||||||
@@ -48,7 +50,8 @@ struct ColorExtensionGenerator {
|
|||||||
staticVar: Bool,
|
staticVar: Bool,
|
||||||
extensionName: String,
|
extensionName: String,
|
||||||
isSwiftUI: Bool,
|
isSwiftUI: Bool,
|
||||||
visibility: ExtensionVisibility
|
visibility: ExtensionVisibility,
|
||||||
|
assetBundle: AssetBundle
|
||||||
) -> String {
|
) -> String {
|
||||||
[
|
[
|
||||||
Self.getHeader(
|
Self.getHeader(
|
||||||
@@ -59,7 +62,8 @@ struct ColorExtensionGenerator {
|
|||||||
for: colors,
|
for: colors,
|
||||||
withStaticVar: staticVar,
|
withStaticVar: staticVar,
|
||||||
isSwiftUI: isSwiftUI,
|
isSwiftUI: isSwiftUI,
|
||||||
visibility: visibility
|
visibility: visibility,
|
||||||
|
assetBundle: assetBundle
|
||||||
),
|
),
|
||||||
Self.getFooter()
|
Self.getFooter()
|
||||||
]
|
]
|
||||||
@@ -87,13 +91,15 @@ struct ColorExtensionGenerator {
|
|||||||
for colors: [ParsedColor],
|
for colors: [ParsedColor],
|
||||||
withStaticVar staticVar: Bool,
|
withStaticVar staticVar: Bool,
|
||||||
isSwiftUI: Bool,
|
isSwiftUI: Bool,
|
||||||
visibility: ExtensionVisibility
|
visibility: ExtensionVisibility,
|
||||||
|
assetBundle: AssetBundle
|
||||||
) -> String {
|
) -> String {
|
||||||
colors.map {
|
colors.map {
|
||||||
$0.getColorProperty(
|
$0.getColorProperty(
|
||||||
isStatic: staticVar,
|
isStatic: staticVar,
|
||||||
isSwiftUI: isSwiftUI,
|
isSwiftUI: isSwiftUI,
|
||||||
visibility: visibility
|
visibility: visibility,
|
||||||
|
assetBundle: assetBundle
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.joined(separator: "\n\n")
|
.joined(separator: "\n\n")
|
||||||
|
@@ -83,20 +83,21 @@ struct ParsedColor {
|
|||||||
func getColorProperty(
|
func getColorProperty(
|
||||||
isStatic: Bool,
|
isStatic: Bool,
|
||||||
isSwiftUI: Bool,
|
isSwiftUI: Bool,
|
||||||
visibility: ExtensionVisibility
|
visibility: ExtensionVisibility,
|
||||||
|
assetBundle: AssetBundle
|
||||||
) -> String {
|
) -> String {
|
||||||
if isSwiftUI {
|
if isSwiftUI {
|
||||||
return """
|
return """
|
||||||
/// Color \(name) is \(light) (light) or \(dark) (dark)"
|
/// Color \(name) is \(light) (light) or \(dark) (dark)"
|
||||||
\(visibility) \(isStatic ? "static " : "")var \(name): Color {
|
\(visibility) \(isStatic ? "static " : "")var \(name): Color {
|
||||||
Color("\(name)")
|
Color("\(name)", bundle: Bundle.\(assetBundle))
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
return """
|
return """
|
||||||
/// Color \(name) is \(light) (light) or \(dark) (dark)"
|
/// Color \(name) is \(light) (light) or \(dark) (dark)"
|
||||||
\(isStatic ? "" : "@objc ")\(visibility) \(isStatic ? "static " : "")var \(name): UIColor {
|
\(isStatic ? "" : "@objc ")\(visibility) \(isStatic ? "static " : "")var \(name): UIColor {
|
||||||
UIColor(named: "\(name)")!
|
UIColor(named: "\(name)", in: Bundle.\(assetBundle), compatibleWith: nil)!
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,8 @@ enum ImageExtensionGenerator {
|
|||||||
extensionName: String,
|
extensionName: String,
|
||||||
extensionFilePath: String,
|
extensionFilePath: String,
|
||||||
isSwiftUI: Bool,
|
isSwiftUI: Bool,
|
||||||
visibility: ExtensionVisibility
|
visibility: ExtensionVisibility,
|
||||||
|
assetBundle: AssetBundle
|
||||||
) {
|
) {
|
||||||
// Create extension conten1t
|
// Create extension conten1t
|
||||||
let extensionContent = Self.getExtensionContent(
|
let extensionContent = Self.getExtensionContent(
|
||||||
@@ -28,7 +29,8 @@ enum ImageExtensionGenerator {
|
|||||||
extensionName: extensionName,
|
extensionName: extensionName,
|
||||||
inputFilename: inputFilename,
|
inputFilename: inputFilename,
|
||||||
isSwiftUI: isSwiftUI,
|
isSwiftUI: isSwiftUI,
|
||||||
visibility: visibility
|
visibility: visibility,
|
||||||
|
assetBundle: assetBundle
|
||||||
)
|
)
|
||||||
|
|
||||||
// Write content
|
// Write content
|
||||||
@@ -48,7 +50,8 @@ enum ImageExtensionGenerator {
|
|||||||
extensionName: String,
|
extensionName: String,
|
||||||
inputFilename: String,
|
inputFilename: String,
|
||||||
isSwiftUI: Bool,
|
isSwiftUI: Bool,
|
||||||
visibility: ExtensionVisibility
|
visibility: ExtensionVisibility,
|
||||||
|
assetBundle: AssetBundle
|
||||||
) -> String {
|
) -> String {
|
||||||
[
|
[
|
||||||
Self.getHeader(
|
Self.getHeader(
|
||||||
@@ -60,7 +63,8 @@ enum ImageExtensionGenerator {
|
|||||||
images: images,
|
images: images,
|
||||||
staticVar: staticVar,
|
staticVar: staticVar,
|
||||||
isSwiftUI: isSwiftUI,
|
isSwiftUI: isSwiftUI,
|
||||||
visibility: visibility
|
visibility: visibility,
|
||||||
|
assetBundle: assetBundle
|
||||||
),
|
),
|
||||||
Self.getFooter()
|
Self.getFooter()
|
||||||
]
|
]
|
||||||
@@ -86,11 +90,18 @@ enum ImageExtensionGenerator {
|
|||||||
images: [ParsedImage],
|
images: [ParsedImage],
|
||||||
staticVar: Bool,
|
staticVar: Bool,
|
||||||
isSwiftUI: Bool,
|
isSwiftUI: Bool,
|
||||||
visibility: ExtensionVisibility
|
visibility: ExtensionVisibility,
|
||||||
|
assetBundle: AssetBundle
|
||||||
) -> String {
|
) -> String {
|
||||||
images
|
images
|
||||||
.map {
|
.map { parsedImage in
|
||||||
"\n\($0.getImageProperty(isStatic: staticVar, isSwiftUI: isSwiftUI, visibility: visibility))"
|
let property = parsedImage.getImageProperty(
|
||||||
|
isStatic: staticVar,
|
||||||
|
isSwiftUI: isSwiftUI,
|
||||||
|
visibility: visibility,
|
||||||
|
assetBundle: assetBundle
|
||||||
|
)
|
||||||
|
return "\n\(property)"
|
||||||
}
|
}
|
||||||
.joined(separator: "\n")
|
.joined(separator: "\n")
|
||||||
}
|
}
|
||||||
|
@@ -62,7 +62,8 @@ struct Images: ParsableCommand {
|
|||||||
extensionName: extensionName,
|
extensionName: extensionName,
|
||||||
extensionFilePath: extensionFilePath,
|
extensionFilePath: extensionFilePath,
|
||||||
isSwiftUI: true,
|
isSwiftUI: true,
|
||||||
visibility: options.extensionVisibility
|
visibility: options.extensionVisibility,
|
||||||
|
assetBundle: options.assetBundle
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +76,8 @@ struct Images: ParsableCommand {
|
|||||||
extensionName: extensionNameUIKit,
|
extensionName: extensionNameUIKit,
|
||||||
extensionFilePath: extensionFilePathUIKit,
|
extensionFilePath: extensionFilePathUIKit,
|
||||||
isSwiftUI: false,
|
isSwiftUI: false,
|
||||||
visibility: options.extensionVisibility
|
visibility: options.extensionVisibility,
|
||||||
|
assetBundle: options.assetBundle
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -51,6 +51,11 @@ struct ImagesOptions: ParsableArguments {
|
|||||||
)
|
)
|
||||||
var extensionVisibility: ExtensionVisibility = .internal
|
var extensionVisibility: ExtensionVisibility = .internal
|
||||||
|
|
||||||
|
@Option(
|
||||||
|
help: "Bundle where the asset are generated"
|
||||||
|
)
|
||||||
|
var assetBundle: AssetBundle = .main
|
||||||
|
|
||||||
@Option(
|
@Option(
|
||||||
help: "Path where to generate the extension.",
|
help: "Path where to generate the extension.",
|
||||||
transform: { $0.replaceTiltWithHomeDirectoryPath() }
|
transform: { $0.replaceTiltWithHomeDirectoryPath() }
|
||||||
|
@@ -130,17 +130,22 @@ struct ParsedImage {
|
|||||||
|
|
||||||
// MARK: - Extension property
|
// MARK: - Extension property
|
||||||
|
|
||||||
func getImageProperty(isStatic: Bool, isSwiftUI: Bool, visibility: ExtensionVisibility) -> String {
|
func getImageProperty(
|
||||||
|
isStatic: Bool,
|
||||||
|
isSwiftUI: Bool,
|
||||||
|
visibility: ExtensionVisibility,
|
||||||
|
assetBundle: AssetBundle
|
||||||
|
) -> String {
|
||||||
if isSwiftUI {
|
if isSwiftUI {
|
||||||
return """
|
return """
|
||||||
\(visibility) \(isStatic ? "static " : "")var \(name): Image {
|
\(visibility) \(isStatic ? "static " : "")var \(name): Image {
|
||||||
Image("\(name)")
|
Image("\(name)", bundle: Bundle.\(assetBundle))
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
return """
|
return """
|
||||||
\(visibility) \(isStatic ? "static " : "")var \(name): UIImage {
|
\(visibility) \(isStatic ? "static " : "")var \(name): UIImage {
|
||||||
UIImage(named: "\(name)")!
|
UIImage(named: "\(name)", in: Bundle.\(assetBundle), with: nil)!
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,8 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
|||||||
staticVar: false,
|
staticVar: false,
|
||||||
extensionName: "GenColors",
|
extensionName: "GenColors",
|
||||||
isSwiftUI: false,
|
isSwiftUI: false,
|
||||||
visibility: .public
|
visibility: .public,
|
||||||
|
assetBundle: .main
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
@@ -39,12 +40,12 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
|||||||
|
|
||||||
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
|
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
|
||||||
@objc public var colorOne: UIColor {
|
@objc public var colorOne: UIColor {
|
||||||
UIColor(named: "colorOne")!
|
UIColor(named: "colorOne", in: Bundle.main, compatibleWith: nil)!
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
||||||
@objc public var colorTwo: UIColor {
|
@objc public var colorTwo: UIColor {
|
||||||
UIColor(named: "colorTwo")!
|
UIColor(named: "colorTwo", in: Bundle.main, compatibleWith: nil)!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -65,7 +66,8 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
|||||||
staticVar: true,
|
staticVar: true,
|
||||||
extensionName: "GenColor",
|
extensionName: "GenColor",
|
||||||
isSwiftUI: false,
|
isSwiftUI: false,
|
||||||
visibility: .public
|
visibility: .public,
|
||||||
|
assetBundle: .module
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
@@ -78,12 +80,12 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
|||||||
|
|
||||||
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
|
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
|
||||||
public static var colorOne: UIColor {
|
public static var colorOne: UIColor {
|
||||||
UIColor(named: "colorOne")!
|
UIColor(named: "colorOne", in: Bundle.module, compatibleWith: nil)!
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
||||||
public static var colorTwo: UIColor {
|
public static var colorTwo: UIColor {
|
||||||
UIColor(named: "colorTwo")!
|
UIColor(named: "colorTwo", in: Bundle.module, compatibleWith: nil)!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -104,7 +106,8 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
|||||||
staticVar: false,
|
staticVar: false,
|
||||||
extensionName: "GenColors",
|
extensionName: "GenColors",
|
||||||
isSwiftUI: true,
|
isSwiftUI: true,
|
||||||
visibility: .package
|
visibility: .package,
|
||||||
|
assetBundle: .main
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
@@ -117,12 +120,12 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
|||||||
|
|
||||||
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
|
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
|
||||||
package var colorOne: Color {
|
package var colorOne: Color {
|
||||||
Color("colorOne")
|
Color("colorOne", bundle: Bundle.main)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
||||||
package var colorTwo: Color {
|
package var colorTwo: Color {
|
||||||
Color("colorTwo")
|
Color("colorTwo", bundle: Bundle.main)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -143,7 +146,8 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
|||||||
staticVar: true,
|
staticVar: true,
|
||||||
extensionName: "GenColor",
|
extensionName: "GenColor",
|
||||||
isSwiftUI: true,
|
isSwiftUI: true,
|
||||||
visibility: .internal
|
visibility: .internal,
|
||||||
|
assetBundle: .module
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
@@ -156,12 +160,12 @@ final class ColorExtensionGeneratorTests: XCTestCase {
|
|||||||
|
|
||||||
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
|
/// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
|
||||||
internal static var colorOne: Color {
|
internal static var colorOne: Color {
|
||||||
Color("colorOne")
|
Color("colorOne", bundle: Bundle.module)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
/// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
|
||||||
internal static var colorTwo: Color {
|
internal static var colorTwo: Color {
|
||||||
Color("colorTwo")
|
Color("colorTwo", bundle: Bundle.module)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
@@ -20,14 +20,15 @@ final class ParsedColorTests: XCTestCase {
|
|||||||
let property = color.getColorProperty(
|
let property = color.getColorProperty(
|
||||||
isStatic: false,
|
isStatic: false,
|
||||||
isSwiftUI: false,
|
isSwiftUI: false,
|
||||||
visibility: .public
|
visibility: .public,
|
||||||
|
assetBundle: .main
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
||||||
@objc public var red: UIColor {
|
@objc public var red: UIColor {
|
||||||
UIColor(named: "red")!
|
UIColor(named: "red", in: Bundle.main, compatibleWith: nil)!
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -42,14 +43,15 @@ final class ParsedColorTests: XCTestCase {
|
|||||||
let property = color.getColorProperty(
|
let property = color.getColorProperty(
|
||||||
isStatic: true,
|
isStatic: true,
|
||||||
isSwiftUI: false,
|
isSwiftUI: false,
|
||||||
visibility: .private
|
visibility: .private,
|
||||||
|
assetBundle: .module
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
||||||
private static var red: UIColor {
|
private static var red: UIColor {
|
||||||
UIColor(named: "red")!
|
UIColor(named: "red", in: Bundle.module, compatibleWith: nil)!
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -64,14 +66,15 @@ final class ParsedColorTests: XCTestCase {
|
|||||||
let property = color.getColorProperty(
|
let property = color.getColorProperty(
|
||||||
isStatic: false,
|
isStatic: false,
|
||||||
isSwiftUI: true,
|
isSwiftUI: true,
|
||||||
visibility: .package
|
visibility: .package,
|
||||||
|
assetBundle: .main
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
||||||
package var red: Color {
|
package var red: Color {
|
||||||
Color("red")
|
Color("red", bundle: Bundle.main)
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -86,14 +89,15 @@ final class ParsedColorTests: XCTestCase {
|
|||||||
let property = color.getColorProperty(
|
let property = color.getColorProperty(
|
||||||
isStatic: true,
|
isStatic: true,
|
||||||
isSwiftUI: true,
|
isSwiftUI: true,
|
||||||
visibility: .internal
|
visibility: .internal,
|
||||||
|
assetBundle: .module
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
/// Color red is #FF0000 (light) or #0000FF (dark)"
|
||||||
internal static var red: Color {
|
internal static var red: Color {
|
||||||
Color("red")
|
Color("red", bundle: Bundle.module)
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@@ -27,7 +27,8 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
extensionName: "GenImages",
|
extensionName: "GenImages",
|
||||||
inputFilename: "myInputFilename",
|
inputFilename: "myInputFilename",
|
||||||
isSwiftUI: false,
|
isSwiftUI: false,
|
||||||
visibility: .public
|
visibility: .public,
|
||||||
|
assetBundle: .main
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
@@ -40,11 +41,11 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
extension GenImages {
|
extension GenImages {
|
||||||
|
|
||||||
public var image_one: UIImage {
|
public var image_one: UIImage {
|
||||||
UIImage(named: "image_one")!
|
UIImage(named: "image_one", in: Bundle.main, with: nil)!
|
||||||
}
|
}
|
||||||
|
|
||||||
public var image_two: UIImage {
|
public var image_two: UIImage {
|
||||||
UIImage(named: "image_two")!
|
UIImage(named: "image_two", in: Bundle.main, with: nil)!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -66,7 +67,8 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
extensionName: "GenImages",
|
extensionName: "GenImages",
|
||||||
inputFilename: "myInputFilename",
|
inputFilename: "myInputFilename",
|
||||||
isSwiftUI: false,
|
isSwiftUI: false,
|
||||||
visibility: .internal
|
visibility: .internal,
|
||||||
|
assetBundle: .module
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
@@ -79,11 +81,11 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
extension GenImages {
|
extension GenImages {
|
||||||
|
|
||||||
internal static var image_one: UIImage {
|
internal static var image_one: UIImage {
|
||||||
UIImage(named: "image_one")!
|
UIImage(named: "image_one", in: Bundle.module, with: nil)!
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static var image_two: UIImage {
|
internal static var image_two: UIImage {
|
||||||
UIImage(named: "image_two")!
|
UIImage(named: "image_two", in: Bundle.module, with: nil)!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -105,7 +107,8 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
extensionName: "GenImages",
|
extensionName: "GenImages",
|
||||||
inputFilename: "myInputFilename",
|
inputFilename: "myInputFilename",
|
||||||
isSwiftUI: true,
|
isSwiftUI: true,
|
||||||
visibility: .public
|
visibility: .public,
|
||||||
|
assetBundle: .main
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
@@ -118,11 +121,11 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
extension GenImages {
|
extension GenImages {
|
||||||
|
|
||||||
public var image_one: Image {
|
public var image_one: Image {
|
||||||
Image("image_one")
|
Image("image_one", bundle: Bundle.main)
|
||||||
}
|
}
|
||||||
|
|
||||||
public var image_two: Image {
|
public var image_two: Image {
|
||||||
Image("image_two")
|
Image("image_two", bundle: Bundle.main)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@@ -144,7 +147,8 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
extensionName: "GenImages",
|
extensionName: "GenImages",
|
||||||
inputFilename: "myInputFilename",
|
inputFilename: "myInputFilename",
|
||||||
isSwiftUI: true,
|
isSwiftUI: true,
|
||||||
visibility: .package
|
visibility: .package,
|
||||||
|
assetBundle: .module
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
@@ -157,11 +161,11 @@ final class ImageExtensionGeneratorTests: XCTestCase {
|
|||||||
extension GenImages {
|
extension GenImages {
|
||||||
|
|
||||||
package static var image_one: Image {
|
package static var image_one: Image {
|
||||||
Image("image_one")
|
Image("image_one", bundle: Bundle.module)
|
||||||
}
|
}
|
||||||
|
|
||||||
package static var image_two: Image {
|
package static var image_two: Image {
|
||||||
Image("image_two")
|
Image("image_two", bundle: Bundle.module)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
@@ -48,13 +48,14 @@ final class ParsedImageTests: XCTestCase {
|
|||||||
let property = parsedImage.getImageProperty(
|
let property = parsedImage.getImageProperty(
|
||||||
isStatic: false,
|
isStatic: false,
|
||||||
isSwiftUI: false,
|
isSwiftUI: false,
|
||||||
visibility: .public
|
visibility: .public,
|
||||||
|
assetBundle: .main
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
public var \(imageName): UIImage {
|
public var \(imageName): UIImage {
|
||||||
UIImage(named: "\(imageName)")!
|
UIImage(named: "\(imageName)", in: Bundle.main, with: nil)!
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -75,13 +76,14 @@ final class ParsedImageTests: XCTestCase {
|
|||||||
let property = parsedImage.getImageProperty(
|
let property = parsedImage.getImageProperty(
|
||||||
isStatic: true,
|
isStatic: true,
|
||||||
isSwiftUI: false,
|
isSwiftUI: false,
|
||||||
visibility: .internal
|
visibility: .internal,
|
||||||
|
assetBundle: .module
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
internal static var \(imageName): UIImage {
|
internal static var \(imageName): UIImage {
|
||||||
UIImage(named: "\(imageName)")!
|
UIImage(named: "\(imageName)", in: Bundle.module, with: nil)!
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -102,13 +104,14 @@ final class ParsedImageTests: XCTestCase {
|
|||||||
let property = parsedImage.getImageProperty(
|
let property = parsedImage.getImageProperty(
|
||||||
isStatic: false,
|
isStatic: false,
|
||||||
isSwiftUI: true,
|
isSwiftUI: true,
|
||||||
visibility: .private
|
visibility: .private,
|
||||||
|
assetBundle: .main
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
private var \(imageName): Image {
|
private var \(imageName): Image {
|
||||||
Image("\(imageName)")
|
Image("\(imageName)", bundle: Bundle.main)
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -129,13 +132,14 @@ final class ParsedImageTests: XCTestCase {
|
|||||||
let property = parsedImage.getImageProperty(
|
let property = parsedImage.getImageProperty(
|
||||||
isStatic: true,
|
isStatic: true,
|
||||||
isSwiftUI: true,
|
isSwiftUI: true,
|
||||||
visibility: .package
|
visibility: .package,
|
||||||
|
assetBundle: .module
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = """
|
let expect = """
|
||||||
package static var \(imageName): Image {
|
package static var \(imageName): Image {
|
||||||
Image("\(imageName)")
|
Image("\(imageName)", bundle: Bundle.module)
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user