Merge branch 'feature/VDS_TextLink' into 'feature/develop_mvp_3'
made changes to textlink as per core specs. See merge request BPHV_MIPS/mvm_core_ui!836
This commit is contained in:
commit
b997dbdb7a
@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
import VDSColorTokens
|
||||
|
||||
@objcMembers open class Link: Button {
|
||||
//--------------------------------------------------
|
||||
@ -28,8 +28,8 @@ import UIKit
|
||||
// x should be according to the text, not the button
|
||||
let x = textRect.origin.x
|
||||
|
||||
// Line is 1 point below the text
|
||||
let y = textRect.origin.y + textRect.size.height + 1
|
||||
// Line is 0 point below the text
|
||||
let y = textRect.origin.y + textRect.size.height
|
||||
|
||||
context.move(to: CGPoint(x: x, y: y))
|
||||
context.addLine(to: CGPoint(x: x + textRect.size.width, y: y))
|
||||
@ -38,7 +38,7 @@ import UIKit
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -56,7 +56,9 @@ import UIKit
|
||||
}
|
||||
setTitleColor((model.inverted ? model.enabledColor_inverted : model.enabledColor).uiColor, for: .normal)
|
||||
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)
|
||||
}
|
||||
|
||||
@ -68,21 +70,15 @@ 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() {
|
||||
super.setupView()
|
||||
backgroundColor = .clear
|
||||
contentMode = .redraw
|
||||
setTitleColor(.mvmBlack, for: .normal)
|
||||
setTitleColor(.mvmCoolGray6, for: .disabled)
|
||||
setTitleColor(VDSColor.elementsPrimaryOnlight, for: .normal)
|
||||
setTitleColor(VDSColor.interactiveDisabledOnlight, for: .disabled)
|
||||
setTitleColor(VDSColor.interactiveActiveOnlight, for: .highlighted)
|
||||
titleLabel?.numberOfLines = 1
|
||||
titleLabel?.lineBreakMode = .byTruncatingTail
|
||||
titleLabel?.textAlignment = .left
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
import VDSColorTokens
|
||||
|
||||
open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableModelProtocol {
|
||||
//--------------------------------------------------
|
||||
@ -22,11 +22,15 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode
|
||||
public var accessibilityText: String?
|
||||
public var action: ActionModelProtocol
|
||||
public var enabled = true
|
||||
public var enabledColor = Color(uiColor: .mvmBlack)
|
||||
public var enabledColor_inverted = Color(uiColor: .mvmWhite)
|
||||
public var disabledColor = Color(uiColor: .mvmCoolGray6)
|
||||
public var disabledColor_inverted = Color(uiColor: .mvmCoolGray10)
|
||||
public var enabledColor = Color(uiColor: VDSColor.elementsPrimaryOnlight)
|
||||
public var enabledColor_inverted = Color(uiColor: VDSColor.elementsPrimaryOndark)
|
||||
public var disabledColor = Color(uiColor: VDSColor.interactiveDisabledOnlight)
|
||||
public var disabledColor_inverted = Color(uiColor: VDSColor.interactiveDisabledOndark)
|
||||
public var activeColor = Color(uiColor: VDSColor.interactiveActiveOnlight)
|
||||
public var activeColor_inverted = Color(uiColor: VDSColor.interactiveActiveOndark)
|
||||
|
||||
public var inverted = false
|
||||
public var size:linkFontSize = linkFontSize.small
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializer
|
||||
@ -53,9 +57,30 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode
|
||||
case enabledColor_inverted
|
||||
case disabledColor
|
||||
case disabledColor_inverted
|
||||
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
|
||||
//--------------------------------------------------
|
||||
@ -92,6 +117,17 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode
|
||||
if let disabledColor_inverted = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledColor_inverted) {
|
||||
self.disabledColor_inverted = disabledColor_inverted
|
||||
}
|
||||
|
||||
if let activeColor = try typeContainer.decodeIfPresent(Color.self, forKey: .activeColor) {
|
||||
self.activeColor = activeColor
|
||||
}
|
||||
|
||||
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 {
|
||||
@ -107,5 +143,8 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode
|
||||
try container.encode(enabledColor_inverted, forKey: .enabledColor_inverted)
|
||||
try container.encode(disabledColor, forKey: .disabledColor)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user