From d3cac3f36db4171e69bce96e954379f81ff2a628 Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Mon, 9 May 2022 14:29:59 +0530 Subject: [PATCH] set font size as per spec --- .../Atomic/Atoms/Buttons/Link/Link.swift | 10 ++------ .../Atomic/Atoms/Buttons/Link/LinkModel.swift | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift index b180d50f..4f4a8b34 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift @@ -38,7 +38,7 @@ import VDSColorTokens open override var intrinsicContentSize: CGSize { guard let size = titleLabel?.intrinsicContentSize else { return super.intrinsicContentSize } - return CGSize(width: size.width, height: size.height + 2) + return CGSize(width: size.width, height: size.height + 1) } //-------------------------------------------------- @@ -58,6 +58,7 @@ import VDSColorTokens setTitleColor((model.inverted ? model.disabledColor_inverted : model.disabledColor).uiColor, for: .disabled) setTitleColor((model.inverted ? model.activeColor_inverted : model.activeColor).uiColor, for: .highlighted) isEnabled = model.enabled + titleLabel?.font = model.getFont(model.size) set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) } @@ -69,13 +70,6 @@ extension Link { open override func updateView(_ size: CGFloat) { super.updateView(size) - - var width = size - if MVMCoreGetterUtility.fequal(a: Float.leastNormalMagnitude, b: Float(size)) { - width = MVMCoreUIUtility.getWidth() - } - - titleLabel?.font = MFStyler.fontB2(forWidth: width) } open override func setupView() { diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift index 83b1fc7c..af507860 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/LinkModel.swift @@ -30,6 +30,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode public var activeColor_inverted = Color(uiColor: VDSColor.interactiveActiveOndark) public var inverted = false + public var size:linkFontSize = linkFontSize.small //-------------------------------------------------- // MARK: - Initializer @@ -59,8 +60,27 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode case activeColor case activeColor_inverted case inverted + case size } + public enum linkFontSize: String, Codable { + case small + case large + } + + //-------------------------------------------------- + // MARK: - Method + //-------------------------------------------------- + + func getFont(_ type: linkFontSize) -> UIFont { + switch type { + case .small: + return MFStyler.fontRegularBodySmall() + case .large: + return MFStyler.fontRegularBodyLarge() + } + } + //-------------------------------------------------- // MARK: - Codec //-------------------------------------------------- @@ -105,6 +125,9 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode if let activeColor_inverted = try typeContainer.decodeIfPresent(Color.self, forKey: .activeColor_inverted) { self.activeColor_inverted = activeColor_inverted } + if let size = try typeContainer.decodeIfPresent(linkFontSize.self, forKey: .size) { + self.size = size + } } public func encode(to encoder: Encoder) throws { @@ -122,5 +145,6 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode try container.encode(disabledColor_inverted, forKey: .disabledColor_inverted) try container.encode(activeColor, forKey: .activeColor) try container.encode(activeColor_inverted, forKey: .activeColor_inverted) + try container.encodeIfPresent(size, forKey: .size) } }