latest
This commit is contained in:
parent
4747c11a90
commit
76fe9749ad
@ -18,6 +18,9 @@ import UIKit
|
|||||||
|
|
||||||
private var initialSetupPerformed = false
|
private var initialSetupPerformed = false
|
||||||
|
|
||||||
|
/// Set this property if you want updateView to update the font based on this standard and the size passed in.
|
||||||
|
public var standardFontSize: CGFloat = 0.0
|
||||||
|
|
||||||
public var isShowingPlaceholder = true
|
public var isShowingPlaceholder = true
|
||||||
|
|
||||||
/// Set to true to hide the blinking textField cursor.
|
/// Set to true to hide the blinking textField cursor.
|
||||||
@ -198,18 +201,34 @@ extension TextView: MoleculeViewProtocol {
|
|||||||
textColor = model.textColor.uiColor
|
textColor = model.textColor.uiColor
|
||||||
layer.borderColor = model.borderColor?.cgColor
|
layer.borderColor = model.borderColor?.cgColor
|
||||||
layer.borderWidth = model.borderWidth
|
layer.borderWidth = model.borderWidth
|
||||||
// font = model.fontStyle
|
// placeholderFont = model.placeholderFont
|
||||||
// placeholderFont = model.placeholderFont
|
|
||||||
text = model.text
|
text = model.text
|
||||||
isShowingPlaceholder = model.text.isEmpty
|
isShowingPlaceholder = model.text.isEmpty
|
||||||
placeholderTraits.text = model.placeholder
|
placeholderTraits.text = model.placeholder
|
||||||
|
|
||||||
uiTextViewDelegate = delegateObject?.uiTextViewDelegate
|
uiTextViewDelegate = delegateObject?.uiTextViewDelegate
|
||||||
|
|
||||||
if let accessibilityText = model.accessibilityText {
|
if let accessibilityText = model.accessibilityText {
|
||||||
accessibilityLabel = accessibilityText
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if isEditable {
|
if isEditable {
|
||||||
MVMCoreUICommonViewsUtility.addDismissToolbar(to: self, delegate: delegateObject?.uiTextViewDelegate)
|
MVMCoreUICommonViewsUtility.addDismissToolbar(to: self, delegate: delegateObject?.uiTextViewDelegate)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -100,8 +100,8 @@ open class TextViewModel: MoleculeModelProtocol {
|
|||||||
borderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .borderColor)
|
borderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .borderColor)
|
||||||
accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText)
|
accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText)
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .accessibilityText)
|
fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .fontSize)
|
||||||
fontName = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText)
|
fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName)
|
||||||
fontStyle = try typeContainer.decodeIfPresent(LabelModel.FontStyle.self, forKey: .fontStyle)
|
fontStyle = try typeContainer.decodeIfPresent(LabelModel.FontStyle.self, forKey: .fontStyle)
|
||||||
height = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .height)
|
height = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .height)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -294,6 +294,7 @@ 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
|
/// 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;
|
||||||
+ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling;
|
+ (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 genericScaling:(BOOL)genericScaling;
|
||||||
+ (void)styleLabelH1:(nonnull UILabel *)label;
|
+ (void)styleLabelH1:(nonnull UILabel *)label;
|
||||||
|
|||||||
@ -853,6 +853,28 @@ 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 {
|
+ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style {
|
||||||
[self styleLabel:label withStyle:style genericScaling:YES];
|
[self styleLabel:label withStyle:style genericScaling:YES];
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user