Add visibility parameters to control scope of generated extension
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit

This commit is contained in:
2025-07-18 11:53:46 +02:00
parent beca2c6b2b
commit 7162f13166
61 changed files with 1511 additions and 791 deletions

View File

@ -6,14 +6,19 @@
//
import Foundation
import ToolCore
struct ParsedColor {
// MARK: - Properties
let name: String
let light: String
let dark: String
// Generate Contents.json content
// MARK: - Contents.json
/// Generate Contents.json content
func contentsJSON() -> String {
let lightARGB = light.colorComponent()
let darkARGB = dark.colorComponent()
@ -73,20 +78,24 @@ struct ParsedColor {
"""
}
// MARK: - UIKit
// MARK: - Property
func getColorProperty(isStatic: Bool, isSwiftUI: Bool) -> String {
func getColorProperty(
isStatic: Bool,
isSwiftUI: Bool,
visibility: ExtensionVisibility
) -> String {
if isSwiftUI {
return """
/// Color \(name) is \(light) (light) or \(dark) (dark)"
\(isStatic ? "static " : "")var \(name): Color {
\(visibility) \(isStatic ? "static " : "")var \(name): Color {
Color("\(name)")
}
"""
}
return """
/// Color \(name) is \(light) (light) or \(dark) (dark)"
\(isStatic ? "static " : "@objc ")var \(name): UIColor {
\(isStatic ? "" : "@objc ")\(visibility) \(isStatic ? "static " : "")var \(name): UIColor {
UIColor(named: "\(name)")!
}
"""