set font size as per spec
This commit is contained in:
parent
31827b0816
commit
d3cac3f36d
@ -38,7 +38,7 @@ import VDSColorTokens
|
|||||||
|
|
||||||
open override var intrinsicContentSize: CGSize {
|
open override var intrinsicContentSize: CGSize {
|
||||||
guard let size = titleLabel?.intrinsicContentSize else { return super.intrinsicContentSize }
|
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.disabledColor_inverted : model.disabledColor).uiColor, for: .disabled)
|
||||||
setTitleColor((model.inverted ? model.activeColor_inverted : model.activeColor).uiColor, for: .highlighted)
|
setTitleColor((model.inverted ? model.activeColor_inverted : model.activeColor).uiColor, for: .highlighted)
|
||||||
isEnabled = model.enabled
|
isEnabled = model.enabled
|
||||||
|
titleLabel?.font = model.getFont(model.size)
|
||||||
set(with: model.action, delegateObject: delegateObject, additionalData: additionalData)
|
set(with: model.action, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,13 +70,6 @@ extension Link {
|
|||||||
|
|
||||||
open override func updateView(_ size: CGFloat) {
|
open override func updateView(_ size: CGFloat) {
|
||||||
super.updateView(size)
|
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() {
|
open override func setupView() {
|
||||||
|
|||||||
@ -30,6 +30,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode
|
|||||||
public var activeColor_inverted = Color(uiColor: VDSColor.interactiveActiveOndark)
|
public var activeColor_inverted = Color(uiColor: VDSColor.interactiveActiveOndark)
|
||||||
|
|
||||||
public var inverted = false
|
public var inverted = false
|
||||||
|
public var size:linkFontSize = linkFontSize.small
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializer
|
// MARK: - Initializer
|
||||||
@ -59,8 +60,27 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode
|
|||||||
case activeColor
|
case activeColor
|
||||||
case activeColor_inverted
|
case activeColor_inverted
|
||||||
case 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
|
// MARK: - Codec
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -105,6 +125,9 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode
|
|||||||
if let activeColor_inverted = try typeContainer.decodeIfPresent(Color.self, forKey: .activeColor_inverted) {
|
if let activeColor_inverted = try typeContainer.decodeIfPresent(Color.self, forKey: .activeColor_inverted) {
|
||||||
self.activeColor_inverted = 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 {
|
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(disabledColor_inverted, forKey: .disabledColor_inverted)
|
||||||
try container.encode(activeColor, forKey: .activeColor)
|
try container.encode(activeColor, forKey: .activeColor)
|
||||||
try container.encode(activeColor_inverted, forKey: .activeColor_inverted)
|
try container.encode(activeColor_inverted, forKey: .activeColor_inverted)
|
||||||
|
try container.encodeIfPresent(size, forKey: .size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user