now
This commit is contained in:
parent
5c80bb9c90
commit
4fb8e05498
@ -26,8 +26,10 @@ import UIKit
|
||||
/// Set to true to hide the blinking textField cursor.
|
||||
public var hideBlinkingCaret = false
|
||||
|
||||
private var textTraits: (color: UIColor, font: UIFont) = (color: .mvmBlack, font: MFStyler.fontRegularBodySmall())
|
||||
private var placeholderTraits: (text: String, color: UIColor, font: UIFont) = (text: "", color: .mvmCoolGray3, font: MFStyler.fontRegularMicro() )
|
||||
private var textTraits: (color: UIColor, font: UIFont) = (color: .mvmBlack,
|
||||
font: Styler.Font.RegularBodySmall.getFont())
|
||||
private var placeholderTraits: (text: String, color: UIColor, font: UIFont) = (text: "",
|
||||
color: .mvmCoolGray3, font: Styler.Font.RegularMicro.getFont())
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Delegate
|
||||
@ -201,9 +203,9 @@ extension TextView: MoleculeViewProtocol {
|
||||
textColor = model.textColor.uiColor
|
||||
layer.borderColor = model.borderColor?.cgColor
|
||||
layer.borderWidth = model.borderWidth
|
||||
// placeholderFont = model.placeholderFont
|
||||
text = model.text
|
||||
isShowingPlaceholder = model.text.isEmpty
|
||||
placeholderTraits.font = model.placeholderFont.getFont()
|
||||
placeholderTraits.text = model.placeholder
|
||||
uiTextViewDelegate = delegateObject?.uiTextViewDelegate
|
||||
|
||||
@ -211,22 +213,22 @@ extension TextView: MoleculeViewProtocol {
|
||||
accessibilityLabel = accessibilityText
|
||||
}
|
||||
|
||||
if let fontStyle = model.fontStyle?.rawValue {
|
||||
MFStyler.styleTextView(self, withStyle: fontStyle, genericScaling: false)
|
||||
standardFontSize = font?.pointSize ?? 0
|
||||
if let font = font {
|
||||
textTraits.font = font
|
||||
}
|
||||
} else {
|
||||
let fontSize = model.fontSize
|
||||
if let fontSize = fontSize {
|
||||
standardFontSize = fontSize
|
||||
}
|
||||
if let fontName = model.fontName {
|
||||
font = MFFonts.mfFont(withName: fontName, size: fontSize ?? standardFontSize)
|
||||
} else if let fontSize = fontSize {
|
||||
font = font?.updateSize(fontSize)
|
||||
}
|
||||
font = model.fontStyle.getFont()
|
||||
standardFontSize = model.fontStyle.pointSize()
|
||||
if let font = font {
|
||||
textTraits.font = font
|
||||
}
|
||||
|
||||
let fontSize = model.fontSize
|
||||
if let fontSize = fontSize {
|
||||
standardFontSize = fontSize
|
||||
}
|
||||
if let fontName = model.fontName {
|
||||
font = Styler.Font(rawValue: fontName)?.getFont()
|
||||
textTraits.font = font!
|
||||
} else if let fontSize = fontSize {
|
||||
font = font?.updateSize(fontSize)
|
||||
textTraits.font = font!
|
||||
}
|
||||
|
||||
if isEditable {
|
||||
|
||||
@ -21,11 +21,11 @@ open class TextViewModel: MoleculeModelProtocol {
|
||||
public var textColor: Color = Color(uiColor: .mvmBlack)
|
||||
public var fontSize: CGFloat?
|
||||
public var fontName: String?
|
||||
public var fontStyle: LabelModel.FontStyle?
|
||||
public var fontStyle: Styler.Font = Styler.Font.RegularBodySmall
|
||||
public var textAlignment: NSTextAlignment = .left
|
||||
public var height: CGFloat?
|
||||
public var placeholder: String = ""
|
||||
public var placeholderFont: LabelModel.FontStyle = LabelModel.FontStyle.RegularMicro
|
||||
public var placeholderFont: Styler.Font = Styler.Font.RegularMicro
|
||||
public var isEditable: Bool = true
|
||||
public var borderColor: Color?
|
||||
public var borderWidth: CGFloat = 0
|
||||
@ -77,7 +77,7 @@ open class TextViewModel: MoleculeModelProtocol {
|
||||
self.placeholder = placeholder
|
||||
}
|
||||
|
||||
if let placeholderFont = try typeContainer.decodeIfPresent(LabelModel.FontStyle.self, forKey: .placeholderFont) {
|
||||
if let placeholderFont = try typeContainer.decodeIfPresent(Styler.Font.self, forKey: .placeholderFont) {
|
||||
self.placeholderFont = placeholderFont
|
||||
}
|
||||
|
||||
@ -97,12 +97,15 @@ open class TextViewModel: MoleculeModelProtocol {
|
||||
self.borderWidth = borderWidth
|
||||
}
|
||||
|
||||
if let fontStyle = try typeContainer.decodeIfPresent(Styler.Font.self, forKey: .fontStyle) {
|
||||
self.fontStyle = fontStyle
|
||||
}
|
||||
|
||||
borderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .borderColor)
|
||||
accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText)
|
||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||
fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .fontSize)
|
||||
fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName)
|
||||
fontStyle = try typeContainer.decodeIfPresent(LabelModel.FontStyle.self, forKey: .fontStyle)
|
||||
height = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .height)
|
||||
}
|
||||
|
||||
|
||||
@ -294,7 +294,6 @@ B3 -> Legal
|
||||
/// Will style the label based on the string. Accepted values, including mva3.0 fonts and 2.0 fonts H1, H2, H3, H32, B1, B2, B3, B20
|
||||
+ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style;
|
||||
+ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling;
|
||||
+ (void)styleTextView:(nonnull UITextView *)label withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling;
|
||||
|
||||
+ (void)styleLabelH1:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling;
|
||||
+ (void)styleLabelH1:(nonnull UILabel *)label;
|
||||
|
||||
@ -853,28 +853,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)styleTextView:(nonnull UITextView *)label withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling {
|
||||
if ([self styleMVA3Label:label withStyle:style genericScaling:genericScaling]) {
|
||||
//try mva 3.0 font first
|
||||
} else if ([style isEqualToString:@"H1"]) {
|
||||
[self styleLabelH1:label genericScaling:genericScaling];
|
||||
} else if ([style isEqualToString:@"H2"]) {
|
||||
[self styleLabelH2:label genericScaling:genericScaling];
|
||||
} else if ([style isEqualToString:@"H3"]) {
|
||||
[self styleLabelH3:label genericScaling:genericScaling];
|
||||
} else if ([style isEqualToString:@"H32"]) {
|
||||
[self styleLabelH32:label genericScaling:genericScaling];
|
||||
} else if ([style isEqualToString:@"B1"]) {
|
||||
[self styleLabelB1:label genericScaling:genericScaling];
|
||||
} else if ([style isEqualToString:@"B3"]) {
|
||||
[self styleLabelB3:label genericScaling:genericScaling];
|
||||
} else if ([style isEqualToString:@"B20"]) {
|
||||
[self styleLabelB20:label genericScaling:genericScaling];
|
||||
} else {
|
||||
[self styleLabelB2:label genericScaling:genericScaling];
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style {
|
||||
[self styleLabel:label withStyle:style genericScaling:YES];
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ open class Styler {
|
||||
}
|
||||
|
||||
/// Returns the font based on the declared enum case.
|
||||
public func getFont(_ genericScaling: Bool = true) -> UIFont? {
|
||||
public func getFont(_ genericScaling: Bool = true) -> UIFont {
|
||||
|
||||
let size = genericScaling ? sizeFontGeneric(forCurrentDevice: pointSize()) : pointSize()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user