Add swiftgen build script for generating image and color assets.

This commit is contained in:
Stefan Ceriu
2022-04-14 09:22:55 +03:00
parent 3c0ca95e8f
commit 6c7dd6f6b0
15 changed files with 212 additions and 45 deletions
-37
View File
@@ -1,37 +0,0 @@
//
// Colors.swift
// ElementX
//
// Created by Stefan Ceriu on 29/03/2022.
// Copyright © 2022 Element. All rights reserved.
//
import Foundation
import UIKit
import SwiftUI
// TODO: Switch this to SwiftGen
extension Color {
static let elementGreen = Color(ColorNames.elementGreen.rawValue)
static let codeBlockBackgroundColor = Color(ColorNames.codeBlockBackgroundColor.rawValue)
}
extension UIColor {
static let elementGreen = UIColor(named: ColorNames.elementGreen.rawValue)
static let codeBlockBackgroundColor = UIColor(named: ColorNames.codeBlockBackgroundColor.rawValue)
}
private enum ColorNames: String {
case elementGreen
case codeBlockBackgroundColor
var rawValue: String {
switch self {
case .elementGreen:
return "ElementGreen"
case .codeBlockBackgroundColor:
return "CodeBlockBackgroundColor"
}
}
}
@@ -140,7 +140,7 @@ struct AttributedStringBuilder: AttributedStringBuilderProtocol {
attributedString.enumerateAttribute(.backgroundColor, in: .init(location: 0, length: attributedString.length), options: []) { value, range, _ in
if let value = value as? UIColor,
value == temporaryCodeBlockMarkingColor {
attributedString.addAttribute(.backgroundColor, value: UIColor.codeBlockBackgroundColor as Any, range: range)
attributedString.addAttribute(.backgroundColor, value: Asset.Colors.codeBlockBackground.color as Any, range: range)
}
}
}