added back setFont/setScale

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-02-13 10:26:18 -06:00
parent 9e6b2a2bd6
commit f577f1a419

View File

@ -70,12 +70,12 @@ public typealias ActionBlock = () -> ()
public init(fontStyle: Styler.Font, _ scale: Bool = true) {
super.init(frame: .zero)
guard let style = fontStyle.vdsTextStyle() else { return }
textStyle = style
setFontStyle(fontStyle, scale)
}
@objc convenience public init(standardFontSize size: CGFloat) {
self.init()
standardFontSize = size
}
/// Convenience to init Label with a link comprised of range, actionMap and delegateObject
@ -280,6 +280,24 @@ public typealias ActionBlock = () -> ()
public func updateView(_ size: CGFloat) { }
@objc public func setFont(_ font: UIFont, scale: Bool) {
self.font = font
setScale(scale)
}
@objc public func setScale(_ scale: Bool) {
if scale {
standardFontSize = font.pointSize
if let floatScale = scaleSize?.floatValue {
updateView(CGFloat(floatScale))
} else {
updateView(MVMCoreUIUtility.getWidth())
}
} else {
standardFontSize = 0
}
}
@objc public static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: DelegateObject?, additionalData: [AnyHashable: Any]?) {
guard let label = label as? Label,
let json = json as? [String: Any],
@ -292,47 +310,44 @@ public typealias ActionBlock = () -> ()
//------------------------------------------------------
public func setFontStyle(_ fontStyle: Styler.Font, _ scale: Bool = true) {
style(for: fontStyle)
guard let style = fontStyle.vdsTextStyle() else { return }
textStyle = style
setScale(scale)
}
//------------------------------------------------------
// MARK: - 2.0 Styling Methods
//------------------------------------------------------
private func style(for legacy: Styler.Font) {
guard let style = legacy.vdsTextStyle() else { return }
textStyle = style
}
@objc public func styleH1(_ scale: Bool) {
style(for: .H1)
setFontStyle(.H1, scale)
}
@objc public func styleH2(_ scale: Bool) {
style(for: .H2)
setFontStyle(.H2, scale)
}
@objc public func styleH3(_ scale: Bool) {
style(for: .H3)
setFontStyle(.H3, scale)
}
@objc public func styleH32(_ scale: Bool) {
style(for: .H32)
setFontStyle(.H32, scale)
}
@objc public func styleB1(_ scale: Bool) {
style(for: .B1)
setFontStyle(.B1, scale)
}
@objc public func styleB2(_ scale: Bool) {
style(for: .B2)
setFontStyle(.B2, scale)
}
@objc public func styleB3(_ scale: Bool) {
style(for: .B3)
setFontStyle(.B3, scale)
}
@objc public func styleB20(_ scale: Bool) {
style(for: .B20)
setFontStyle(.B20, scale)
}
}