DEVTOOLS-192 Resgen iOS vector
Some checks failed
gitea-openium/resgen.swift/pipeline/pr-master There was a failure building this commit
Some checks failed
gitea-openium/resgen.swift/pipeline/pr-master There was a failure building this commit
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
import Foundation
|
||||
|
||||
enum ImageExtension: String {
|
||||
case vector
|
||||
case png
|
||||
}
|
||||
|
||||
struct ParsedImage {
|
||||
@ -61,10 +61,12 @@ struct ParsedImage {
|
||||
|
||||
// MARK: - Assets
|
||||
|
||||
var contentJson: String? {
|
||||
func generateContentJson(isVector: Bool) -> String? {
|
||||
let encoder = JSONEncoder()
|
||||
encoder.outputFormatting = .prettyPrinted
|
||||
|
||||
|
||||
let imageContent = generateImageContent(isVector: isVector)
|
||||
|
||||
guard let data = try? encoder.encode(imageContent) else {
|
||||
let error = ImagesError.writeFile("Contents.json", "Error encoding json file")
|
||||
print(error.description)
|
||||
@ -74,8 +76,10 @@ struct ParsedImage {
|
||||
return String(data: data, encoding: .utf8)
|
||||
}
|
||||
|
||||
var imageContent: AssetContent {
|
||||
if imageExtensions.contains(.vector) {
|
||||
func generateImageContent(isVector: Bool) -> AssetContent {
|
||||
|
||||
if !imageExtensions.contains(.png) && isVector {
|
||||
//Generate svg
|
||||
return AssetContent(
|
||||
images: [
|
||||
AssetImageDescription(
|
||||
@ -93,7 +97,7 @@ struct ParsedImage {
|
||||
)
|
||||
)
|
||||
} else {
|
||||
|
||||
//Generate png
|
||||
return AssetContent(
|
||||
images: [
|
||||
AssetImageDescription(
|
||||
|
Reference in New Issue
Block a user