Merge branch 'release/11_4_0' of https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui into feature/vds_header_mapping
This commit is contained in:
commit
6e2d1d7132
@ -182,29 +182,7 @@ public typealias ActionBlock = () -> ()
|
||||
}
|
||||
|
||||
@objc public func resetAttributeStyle() {
|
||||
/*
|
||||
* This is to address a reuse issue with iOS 13 and up.
|
||||
* Even if you set text & attributedText to nil, the moment you set text with a value,
|
||||
* attributedText will hold a dirty value from a previously reused cell even if reset() is
|
||||
* appropriately called.
|
||||
* Only other reference found of issue: https://www.thetopsites.net/article/58142205.shtml
|
||||
*/
|
||||
if let text = text, !text.isEmpty {
|
||||
|
||||
//create the primary string
|
||||
let mutableText = NSMutableAttributedString.mutableText(for: text,
|
||||
textStyle: textStyle,
|
||||
useScaledFont: useScaledFont,
|
||||
textColor: textColorConfiguration.getColor(self),
|
||||
alignment: textAlignment,
|
||||
lineBreakMode: lineBreakMode)
|
||||
|
||||
if let attributes = attributes {
|
||||
mutableText.apply(attributes: attributes)
|
||||
}
|
||||
|
||||
self.attributedText = mutableText
|
||||
}
|
||||
setNeedsUpdate()
|
||||
}
|
||||
|
||||
public func viewModelDidUpdate() {
|
||||
@ -221,7 +199,6 @@ public typealias ActionBlock = () -> ()
|
||||
}
|
||||
|
||||
if let style = viewModel.fontStyle?.vdsTextStyle() {
|
||||
font = style.font
|
||||
textStyle = style
|
||||
} else if let fontName = viewModel.fontName {
|
||||
// there is a TextStyle.defaultStyle
|
||||
@ -229,9 +206,8 @@ public typealias ActionBlock = () -> ()
|
||||
if let fontSize {
|
||||
standardFontSize = fontSize
|
||||
}
|
||||
if let customStyle = style(for: fontName, pointSize: fontSize ?? standardFontSize), customStyle != textStyle {
|
||||
font = customStyle.font
|
||||
textStyle = customStyle
|
||||
if let newFont = UIFont(name: fontName, size: fontSize ?? standardFontSize) {
|
||||
font = newFont
|
||||
}
|
||||
}
|
||||
|
||||
@ -248,26 +224,6 @@ public typealias ActionBlock = () -> ()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// See if the font that is currently set matches a VDS Font and if so grab the matching TextStyle or create custom TextStyle that
|
||||
/// that the Label will use moving forward.
|
||||
private func checkforFontChange() {
|
||||
guard let customStyle = style(for: font.fontName, pointSize: font.pointSize), customStyle != textStyle
|
||||
else { return }
|
||||
textStyle = customStyle
|
||||
}
|
||||
|
||||
private func style(for fontName: String, pointSize: CGFloat) -> TextStyle? {
|
||||
guard let vdsFont = Font.from(fontName: fontName),
|
||||
let customStyle = TextStyle.style(from: vdsFont, pointSize: pointSize)
|
||||
else { return nil }
|
||||
return customStyle
|
||||
}
|
||||
|
||||
open override func updateView() {
|
||||
checkforFontChange()
|
||||
super.updateView()
|
||||
}
|
||||
|
||||
open override func updateAccessibility() {
|
||||
super.updateAccessibility()
|
||||
|
||||
@ -54,12 +54,3 @@ extension VDS.Font {
|
||||
Self.allCases.filter({$0.fontName == fontName }).first
|
||||
}
|
||||
}
|
||||
|
||||
extension VDS.TextStyle {
|
||||
internal static func style(from font: VDS.Font, pointSize: CGFloat) -> TextStyle? {
|
||||
guard let first = allCases.filter({$0.fontFace == font && $0.pointSize == pointSize}).first else {
|
||||
return TextStyle(rawValue: "Custom-TextStyle", fontFace: font, pointSize: pointSize)
|
||||
}
|
||||
return first
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@ public class TwoButtonViewModel: ParentMoleculeModelProtocol {
|
||||
case backgroundColor
|
||||
case primaryButton
|
||||
case secondaryButton
|
||||
case fillContainer
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -69,6 +70,7 @@ public class TwoButtonViewModel: ParentMoleculeModelProtocol {
|
||||
try decoder.setContext(value: Use.secondary, for: "style") {
|
||||
self.secondaryButton = try typeContainer.decodeMoleculeIfPresent(codingKey: .secondaryButton)
|
||||
}
|
||||
fillContainer = try typeContainer.decodeIfPresent(Bool.self, forKey: .fillContainer) ?? false
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@ -78,5 +80,6 @@ public class TwoButtonViewModel: ParentMoleculeModelProtocol {
|
||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||
try container.encodeIfPresent(primaryButton, forKey: .primaryButton)
|
||||
try container.encodeIfPresent(secondaryButton, forKey: .secondaryButton)
|
||||
try container.encodeIfPresent(fillContainer, forKey: .fillContainer)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user