Files
resgen.swift/Sources/ResgenSwift/Fonts/Model/FontName.swift
Thibaut Schmitt 4f7d7e18b1
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
Génération de composant SwiftUI: Color et Image
2022-10-31 16:21:32 +01:00

49 lines
1.2 KiB
Swift

//
// FontName.swift
//
//
// Created by Thibaut Schmitt on 29/08/2022.
//
import Foundation
typealias FontName = String
extension FontName {
var fontNameSanitize: String {
self.removeCharacters(from: "[]+-_")
}
var method: String {
"""
func \(fontNameSanitize)(withSize size: CGFloat) -> UIFont {
UIFont(name: FontName.\(fontNameSanitize).rawValue, size: size)!
}
"""
}
var staticProperty: String {
"""
static let \(fontNameSanitize): ((_ size: CGFloat) -> UIFont) = { size in
UIFont(name: FontName.\(fontNameSanitize).rawValue, size: size)!
}
"""
}
var suiMethod: String {
"""
func \(fontNameSanitize)(withSize size: CGFloat) -> Font {
Font.custom(FontName.\(fontNameSanitize).rawValue, size: size)
}
"""
}
var suiStaticProperty: String {
"""
static let \(fontNameSanitize): ((_ size: CGFloat) -> Font) = { size in
Font.custom(FontName.\(fontNameSanitize).rawValue, size: size)
}
"""
}
}