Merge branch 'feature/global_font_3_0' of https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui into feature/titlelockup_clean
This commit is contained in:
commit
572583bf00
@ -295,8 +295,8 @@ public typealias ActionBlock = () -> ()
|
||||
accessibilityLabel = accessibilityText
|
||||
}
|
||||
|
||||
if let fontStyle = labelModel.fontStyle?.rawValue {
|
||||
MFStyler.styleLabel(self, withStyle: fontStyle, genericScaling: false)
|
||||
if let fontStyle = labelModel.fontStyle {
|
||||
fontStyle.styleLabel(self, genericScaling: false)
|
||||
standardFontSize = font.pointSize
|
||||
} else {
|
||||
let fontSize = labelModel.fontSize
|
||||
@ -428,7 +428,7 @@ public typealias ActionBlock = () -> ()
|
||||
label.accessibilityLabel = json?.optionalStringForKey("accessibilityText")
|
||||
|
||||
if let fontStyle = json?.optionalStringForKey("fontStyle") {
|
||||
MFStyler.styleLabel(label, withStyle: fontStyle, genericScaling: mvmLabel == nil)
|
||||
MFStyler.style(label: label, styleString: fontStyle, genericScaling: mvmLabel == nil)
|
||||
mvmLabel?.standardFontSize = label.font.pointSize
|
||||
} else {
|
||||
let fontSize = json?["fontSize"] as? CGFloat
|
||||
@ -490,7 +490,7 @@ public typealias ActionBlock = () -> ()
|
||||
|
||||
case "font":
|
||||
if let fontStyle = attribute.optionalStringForKey("style") {
|
||||
let styles = MFStyler.styleGetAttributedString("0", withStyle: fontStyle, genericScaling: mvmLabel == nil)
|
||||
let styles = MFStyler.getAttributedString(for: "0", styleString: fontStyle, genericScaling: mvmLabel == nil)
|
||||
attributedString.removeAttribute(.font, range: range)
|
||||
attributedString.removeAttribute(.foregroundColor, range: range)
|
||||
attributedString.addAttributes(styles.attributes(at: 0, effectiveRange: nil), range: range)
|
||||
@ -531,8 +531,7 @@ public typealias ActionBlock = () -> ()
|
||||
//------------------------------------------------------
|
||||
|
||||
public func setFontStyle(_ fontStyle: Styler.Font, _ scale: Bool = true) {
|
||||
font = fontStyle.getFont(false)
|
||||
textColor = .mvmBlack
|
||||
fontStyle.styleLabel(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ open class HeaderView: Container {
|
||||
|
||||
public override func setupView() {
|
||||
super.setupView()
|
||||
line.setStyle(.heavy)
|
||||
line.setStyle(.none)
|
||||
addSubview(line)
|
||||
NSLayoutConstraint.pinViewBottom(toSuperview: line, useMargins: false, constant: 0).isActive = true
|
||||
NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true
|
||||
@ -43,7 +43,7 @@ open class HeaderView: Container {
|
||||
// MARK: - MoleculeViewProtocol
|
||||
open override func reset() {
|
||||
super.reset()
|
||||
line.setStyle(.heavy)
|
||||
line.setStyle(.none)
|
||||
molecule?.reset()
|
||||
}
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ public class MoleculeHeaderView: MoleculeContainer {
|
||||
|
||||
public override func setupView() {
|
||||
super.setupView()
|
||||
line.setStyle(.heavy)
|
||||
line.setStyle(.none)
|
||||
addSubview(line)
|
||||
NSLayoutConstraint.pinViewBottom(toSuperview: line, useMargins: false, constant: 0).isActive = true
|
||||
NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true
|
||||
@ -40,7 +40,7 @@ public class MoleculeHeaderView: MoleculeContainer {
|
||||
|
||||
open override func reset() {
|
||||
super.reset()
|
||||
line.setStyle(.heavy)
|
||||
line.setStyle(.none)
|
||||
}
|
||||
|
||||
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||
|
||||
@ -54,27 +54,27 @@ open class HeadlineBody: View {
|
||||
}
|
||||
|
||||
public func styleLandingPageHeader() {
|
||||
headlineLabel.setFontStyle(.Title2XLarge)
|
||||
messageLabel.setFontStyle(.RegularBodySmall)
|
||||
spaceBetweenLabelsConstant = Padding.Two
|
||||
headlineLabel.setFontStyle(.RegularTitle2XLarge)
|
||||
messageLabel.setFontStyle(.RegularTitleMedium)
|
||||
spaceBetweenLabelsConstant = Padding.Four
|
||||
}
|
||||
|
||||
public func stylePageHeader() {
|
||||
headlineLabel.setFontStyle(.BoldTitleLarge)
|
||||
headlineLabel.setFontStyle(.RegularTitleLarge)
|
||||
messageLabel.setFontStyle(.RegularBodyLarge)
|
||||
spaceBetweenLabelsConstant = Padding.Two
|
||||
}
|
||||
|
||||
public func styleListItem() {
|
||||
headlineLabel.setFontStyle(.RegularTitleSmall)
|
||||
messageLabel.setFontStyle(.RegularBodySmall)
|
||||
spaceBetweenLabelsConstant = Padding.One
|
||||
}
|
||||
|
||||
public func styleListItem() {
|
||||
headlineLabel.setFontStyle(.BoldBodySmall)
|
||||
messageLabel.setFontStyle(.RegularBodySmall)
|
||||
spaceBetweenLabelsConstant = 0
|
||||
}
|
||||
|
||||
public func styleListItemDivider() {
|
||||
headlineLabel.setFontStyle(.BoldTitleMedium)
|
||||
headlineLabel.setFontStyle(.BoldTitleSmall)
|
||||
messageLabel.setFontStyle(.RegularBodySmall)
|
||||
spaceBetweenLabelsConstant = 0
|
||||
spaceBetweenLabelsConstant = Padding.Two
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -45,10 +45,10 @@ import UIKit
|
||||
bottomSeparatorView?.setStyle(.secondary)
|
||||
case .shortDivider?:
|
||||
topSeparatorView?.setStyle(.none)
|
||||
bottomSeparatorView?.setStyle(.primary)
|
||||
bottomSeparatorView?.setStyle(.none)
|
||||
case .tallDivider?:
|
||||
topSeparatorView?.setStyle(.none)
|
||||
bottomSeparatorView?.setStyle(.primary)
|
||||
bottomSeparatorView?.setStyle(.none)
|
||||
case .sectionFooter?:
|
||||
topSeparatorView?.setStyle(.none)
|
||||
bottomSeparatorView?.setStyle(.none)
|
||||
|
||||
@ -217,7 +217,6 @@ B3 -> Legal
|
||||
+ (nullable UIFont *)fontForHeadlineSmall:(BOOL)genericScaling;
|
||||
+ (nullable UIFont *)fontForHeadlineSmall2;
|
||||
+ (nullable UIFont *)fontForHeadlineSmall2:(BOOL)genericScaling;
|
||||
+ (nullable UIFont *)fontForHeadlineSmall2ForWidth:(CGFloat)size;
|
||||
+ (nullable UIFont *)fontB1ForWidth:(CGFloat)size;
|
||||
+ (nullable UIFont *)fontForBodyWithSize:(CGFloat)size genericScaling:(BOOL)genericScaling;
|
||||
+ (nullable UIFont *)fontB2ForWidth:(CGFloat)size;
|
||||
@ -287,15 +286,8 @@ B3 -> Legal
|
||||
+ (void)styleLabelRegularMicro:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling;
|
||||
+ (void)styleLabelRegularMicro:(nonnull UILabel *)label;
|
||||
|
||||
/// Will style the label with mva 3.0 fonts based on the string.
|
||||
+ (BOOL)styleMVA3Label:(nonnull UILabel *)label withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling;
|
||||
|
||||
#pragma mark - 2.0 styles
|
||||
|
||||
/// 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)styleLabelH1:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling;
|
||||
+ (void)styleLabelH1:(nonnull UILabel *)label;
|
||||
|
||||
@ -377,11 +369,6 @@ B3 -> Legal
|
||||
+ (nonnull NSAttributedString *)styleGetRegularMicroAttributedString:(nullable NSString *)string;
|
||||
+ (nonnull NSAttributedString *)styleGetRegularMicroAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling;
|
||||
|
||||
|
||||
/// Will style the string based on the string. Accepted values, H1, H2, H3, H32, B1, B2, B3, B20
|
||||
+ (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style;
|
||||
+ (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling;
|
||||
|
||||
+ (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string font:(nonnull UIFont *)font color:(nonnull UIColor *)color;
|
||||
+ (nonnull NSAttributedString *)styleGetH1AttributedString:(nullable NSString *)string;
|
||||
+ (nonnull NSAttributedString *)styleGetH2AttributedString:(nullable NSString *)string;
|
||||
|
||||
@ -113,27 +113,11 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
#pragma mark - 3.0 fonts
|
||||
|
||||
+ (nonnull UIFont *)getMVA3FontSize:(CGFloat)size bold:(BOOL)isBold {
|
||||
if (isBold) {
|
||||
if (size >= 15) {
|
||||
return [MFFonts mfFontDSBold:size];
|
||||
} else {
|
||||
return [MFFonts mfFontTXBold:size];
|
||||
}
|
||||
} else {
|
||||
if (size >= 15) {
|
||||
return [MFFonts mfFontDSRegular:size];
|
||||
} else {
|
||||
return [MFFonts mfFontTXRegular:size];
|
||||
}
|
||||
}
|
||||
return [self getFontForSize:size isBold:isBold];
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontTitle2XLarge:(BOOL)genericScaling {
|
||||
CGFloat size = 36;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [self getMVA3FontSize:size bold:YES];
|
||||
return [self getFontForStyleString:@"Title2XLarge" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontTitle2XLarge {
|
||||
@ -141,22 +125,15 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontTitleXLarge:(BOOL)genericScaling {
|
||||
CGFloat size = 32;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [self getMVA3FontSize:size bold:YES];
|
||||
return [self getFontForStyleString:@"TitleXLarge" genericScaling:genericScaling];
|
||||
}
|
||||
+ (nonnull UIFont *)fontTitleXLarge{
|
||||
|
||||
+ (nonnull UIFont *)fontTitleXLarge {
|
||||
return [self fontTitleXLarge:YES];
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontBoldTitleLarge:(BOOL)genericScaling {
|
||||
CGFloat size = 24;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [self getMVA3FontSize:size bold:YES];
|
||||
return [self getFontForStyleString:@"BoldTitleLarge" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontBoldTitleLarge {
|
||||
@ -164,11 +141,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontRegularTitleLarge:(BOOL)genericScaling {
|
||||
CGFloat size = 24;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [self getMVA3FontSize:size bold:NO];
|
||||
return [self getFontForStyleString:@"RegularTitleLarge" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontRegularTitleLarge {
|
||||
@ -176,11 +149,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontBoldTitleMedium:(BOOL)genericScaling {
|
||||
CGFloat size = 20;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [self getMVA3FontSize:size bold:YES];
|
||||
return [self getFontForStyleString:@"BoldTitleMedium" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontBoldTitleMedium {
|
||||
@ -188,11 +157,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontRegularTitleMedium:(BOOL)genericScaling {
|
||||
CGFloat size = 20;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [self getMVA3FontSize:size bold:NO];
|
||||
return [self getFontForStyleString:@"RegularTitleMedium" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontRegularTitleMedium {
|
||||
@ -200,11 +165,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontBoldBodyLarge:(BOOL)genericScaling {
|
||||
CGFloat size = 16;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [self getMVA3FontSize:size bold:YES];
|
||||
return [self getFontForStyleString:@"BoldBodyLarge" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontBoldBodyLarge {
|
||||
@ -212,11 +173,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontRegularBodyLarge:(BOOL)genericScaling {
|
||||
CGFloat size = 16;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [self getMVA3FontSize:size bold:NO];
|
||||
return [self getFontForStyleString:@"RegularBodyLarge" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontRegularBodyLarge {
|
||||
@ -224,11 +181,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontBoldBodySmall:(BOOL)genericScaling {
|
||||
CGFloat size = 13;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [self getMVA3FontSize:size bold:YES];
|
||||
return [self getFontForStyleString:@"BoldBodySmall" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontBoldBodySmall {
|
||||
@ -236,11 +189,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontRegularBodySmall:(BOOL)genericScaling {
|
||||
CGFloat size = 13;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [self getMVA3FontSize:size bold:NO];
|
||||
return [self getFontForStyleString:@"RegularBodySmall" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontRegularBodySmall {
|
||||
@ -248,11 +197,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontBoldMicro:(BOOL)genericScaling {
|
||||
CGFloat size = 11;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [self getMVA3FontSize:size bold:YES];
|
||||
return [self getFontForStyleString:@"BoldMicro" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontBoldMicro {
|
||||
@ -260,11 +205,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontRegularMicro:(BOOL)genericScaling {
|
||||
CGFloat size = 11;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [self getMVA3FontSize:size bold:NO];
|
||||
return [self getFontForStyleString:@"RegularMicro" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nonnull UIFont *)fontRegularMicro {
|
||||
@ -275,11 +216,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
#pragma mark - 2.0 fonts
|
||||
|
||||
+ (nullable UIFont *)fontH1:(BOOL)genericScaling {
|
||||
CGFloat size = 40;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [MFFonts mfFont75Bd:size];
|
||||
return [self getFontForStyleString:@"H1" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontH1 {
|
||||
@ -287,11 +224,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontH2:(BOOL)genericScaling {
|
||||
CGFloat size = 25;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [MFFonts mfFont75Bd:size];
|
||||
return [self getFontForStyleString:@"H2" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontH2 {
|
||||
@ -299,11 +232,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontH3:(BOOL)genericScaling {
|
||||
CGFloat size = 18;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [MFFonts mfFont75Bd:size];
|
||||
return [self getFontForStyleString:@"H3" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontH3 {
|
||||
@ -311,11 +240,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontH32:(BOOL)genericScaling {
|
||||
CGFloat size = 32;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [MFFonts mfFont75Bd:size];
|
||||
return [self getFontForStyleString:@"H32" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontH32 {
|
||||
@ -323,11 +248,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontB1:(BOOL)genericScaling {
|
||||
CGFloat size = 13;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [MFFonts mfFont75Bd:size];
|
||||
return [self getFontForStyleString:@"B1" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontB1 {
|
||||
@ -335,11 +256,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontB2:(BOOL)genericScaling {
|
||||
CGFloat size = 13;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [MFFonts mfFont55Rg:size];
|
||||
return [self getFontForStyleString:@"B2" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontB2 {
|
||||
@ -347,11 +264,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontB3:(BOOL)genericScaling {
|
||||
CGFloat size = 11;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [MFFonts mfFont55Rg:size];
|
||||
return [self getFontForStyleString:@"B3" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontB3 {
|
||||
@ -359,11 +272,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontB20:(BOOL)genericScaling {
|
||||
CGFloat size = 20;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [MFFonts mfFont55Rg:size];
|
||||
return [self getFontForStyleString:@"B20" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontB20 {
|
||||
@ -412,16 +321,8 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
return [MFFonts mfFont75Bd:size];
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontForHeadlineSmall2ForWidth:(CGFloat)size {
|
||||
CGFloat pointSize = 16;
|
||||
pointSize = [[MFStyler sizeObjectGenericForCurrentDevice:pointSize] getValueBasedOnSize:size];
|
||||
return [MFFonts mfFont75Bd:pointSize];
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontB1ForWidth:(CGFloat)size {
|
||||
CGFloat pointSize = 13;
|
||||
pointSize = [[MFStyler sizeObjectGenericForCurrentDevice:pointSize] getValueBasedOnSize:size];
|
||||
return [MFFonts mfFont75Bd:pointSize];
|
||||
return [self getFontForStyleString:@"B1" scaleValue:size];
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontForBodyWithSize:(CGFloat)size genericScaling:(BOOL)genericScaling {
|
||||
@ -432,9 +333,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontB2ForWidth:(CGFloat)size {
|
||||
CGFloat pointSize = 13;
|
||||
pointSize = [[MFStyler sizeObjectGenericForCurrentDevice:pointSize] getValueBasedOnSize:size];
|
||||
return [MFFonts mfFont55Rg:pointSize];
|
||||
return [self getFontForStyleString:@"B2" scaleValue:size];
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontForBodyWithSize:(CGFloat)size forWidth:(CGFloat)width {
|
||||
@ -467,47 +366,27 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontForPrimaryButton:(BOOL)genericScaling {
|
||||
CGFloat size = 13;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [MFFonts mfFontTXBold:size];
|
||||
return [self getFontForStyleString:@"BoldBodyLarge" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontForPrimaryButtonForWidth:(CGFloat)size {
|
||||
CGFloat pointSize = 13;
|
||||
pointSize = [[MFStyler sizeObjectGenericForCurrentDevice:pointSize] getValueBasedOnSize:size];
|
||||
return [MFFonts mfFontTXBold:pointSize];
|
||||
return [self getFontForStyleString:@"BoldBodyLarge" scaleValue:size];
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontForSmallButton:(BOOL)genericScaling {
|
||||
CGFloat size = 11;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [MFFonts mfFontTXBold:size];
|
||||
return [self getFontForStyleString:@"BoldBodySmall" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontForSmallButtonForWidth:(CGFloat)size {
|
||||
CGFloat pointSize = 11;
|
||||
pointSize = [[MFStyler sizeObjectGenericForCurrentDevice:pointSize] getValueBasedOnSize:size];
|
||||
return [MFFonts mfFontTXBold:pointSize];
|
||||
return [self getFontForStyleString:@"BoldBodySmall" scaleValue:size];
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontForTextField:(BOOL)genericScaling {
|
||||
CGFloat size = 16;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [MFFonts mfFont55Rg:size];
|
||||
return [self getFontForStyleString:@"RegularBodyLarge" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontForTextFieldUnderLabel:(BOOL)genericScaling {
|
||||
CGFloat size = 12;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [MFFonts mfFont55Rg:size];
|
||||
return [self getFontForStyleString:@"RegularBodySmall" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontForUnreadMessageOnSupport:(BOOL)genericScaling {
|
||||
@ -554,11 +433,7 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontForFeedCardTitle:(BOOL)genericScaling {
|
||||
CGFloat size = 16;
|
||||
if (genericScaling) {
|
||||
size = [self sizeFontGenericForCurrentDevice:size];
|
||||
}
|
||||
return [MFFonts mfFont75Bd:size];
|
||||
return [self getFontForStyleString:@"BoldTitleXLarge" genericScaling:genericScaling];
|
||||
}
|
||||
|
||||
+ (nullable UIFont *)fontForLargeLoyaltyHeaderTitle:(BOOL)genericScaling {
|
||||
@ -785,77 +660,8 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
[self styleLabelRegularMicro:label genericScaling:YES];
|
||||
}
|
||||
|
||||
+ (BOOL)styleMVA3Label:(nonnull UILabel *)label withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling {
|
||||
if ([style isEqualToString:@"Title2XLarge"]) {
|
||||
[self styleLabelTitle2XLarge:label genericScaling:genericScaling];
|
||||
return YES;
|
||||
} else if ([style isEqualToString:@"TitleXLarge"]) {
|
||||
[self styleLabelTitleXLarge:label genericScaling:genericScaling];
|
||||
return YES;
|
||||
} else if ([style isEqualToString:@"BoldTitleLarge"]) {
|
||||
[self styleLabelBoldTitleLarge:label genericScaling:genericScaling];
|
||||
return YES;
|
||||
} else if ([style isEqualToString:@"RegularTitleLarge"]) {
|
||||
[self styleLabelRegularTitleLarge:label genericScaling:genericScaling];
|
||||
return YES;
|
||||
} else if ([style isEqualToString:@"BoldTitleMedium"]) {
|
||||
[self styleLabelBoldTitleMedium:label genericScaling:genericScaling];
|
||||
return YES;
|
||||
} else if ([style isEqualToString:@"RegularTitleMedium"]) {
|
||||
[self styleLabelRegularTitleMedium:label genericScaling:genericScaling];
|
||||
return YES;
|
||||
} else if ([style isEqualToString:@"BoldBodyLarge"]) {
|
||||
[self styleLabelBoldBodyLarge:label genericScaling:genericScaling];
|
||||
return YES;
|
||||
} else if ([style isEqualToString:@"RegularBodyLarge"]) {
|
||||
[self styleLabelRegularBodyLarge:label genericScaling:genericScaling];
|
||||
return YES;
|
||||
} else if ([style isEqualToString:@"BoldBodySmall"]) {
|
||||
[self styleLabelBoldBodySmall:label genericScaling:genericScaling];
|
||||
return YES;
|
||||
} else if ([style isEqualToString:@"RegularBodySmall"]) {
|
||||
[self styleLabelRegularBodySmall:label genericScaling:genericScaling];
|
||||
return YES;
|
||||
} else if ([style isEqualToString:@"BoldMicro"]) {
|
||||
[self styleLabelBoldMicro:label genericScaling:genericScaling];
|
||||
return YES;
|
||||
} else if ([style isEqualToString:@"RegularMicro"]) {
|
||||
[self styleLabelRegularMicro:label genericScaling:genericScaling];
|
||||
return YES;
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - 2.0 Styles
|
||||
|
||||
+ (void)styleLabel:(nonnull UILabel *)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];
|
||||
}
|
||||
|
||||
+ (void)styleLabelH1:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling {
|
||||
label.font = [MFStyler fontH1:genericScaling];
|
||||
label.textColor = [UIColor blackColor];
|
||||
@ -975,30 +781,6 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
|
||||
|
||||
#pragma mark - Attributed Strings
|
||||
|
||||
+ (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style {
|
||||
return [self styleGetAttributedString:string withStyle:style genericScaling:YES];
|
||||
}
|
||||
|
||||
+ (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling {
|
||||
if ([style isEqualToString:@"H1"]) {
|
||||
return [self styleGetH1AttributedString:string genericScaling:genericScaling];
|
||||
} else if ([style isEqualToString:@"H2"]) {
|
||||
return [self styleGetH2AttributedString:string genericScaling:genericScaling];
|
||||
} else if ([style isEqualToString:@"H3"]) {
|
||||
return [self styleGetH3AttributedString:string genericScaling:genericScaling];
|
||||
} else if ([style isEqualToString:@"H32"]) {
|
||||
return [self styleGetH32AttributedString:string genericScaling:genericScaling];
|
||||
} else if ([style isEqualToString:@"B1"]) {
|
||||
return [self styleGetB1AttributedString:string genericScaling:genericScaling];
|
||||
} else if ([style isEqualToString:@"B3"]) {
|
||||
return [self styleGetB3AttributedString:string genericScaling:genericScaling];
|
||||
} else if ([style isEqualToString:@"B20"]) {
|
||||
return [self styleGetB20AttributedString:string genericScaling:genericScaling];
|
||||
} else {
|
||||
return [self styleGetB2AttributedString:string genericScaling:genericScaling];
|
||||
}
|
||||
}
|
||||
|
||||
+ (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string font:(nonnull UIFont *)font color:(nonnull UIColor *)color {
|
||||
NSAttributedString *attributedString = nil;
|
||||
if (![string isEqual:[NSNull null]] && string.length > 0) {
|
||||
|
||||
@ -7,69 +7,103 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
|
||||
open class Styler {
|
||||
|
||||
// MARK:- Font Enum
|
||||
public enum Font: String, Codable {
|
||||
case Title2XLarge
|
||||
case TitleXLarge
|
||||
case BoldTitleLarge
|
||||
case RegularFeatureXLarge
|
||||
case BoldFeatureXLarge
|
||||
case RegularFeatureLarge
|
||||
case BoldFeatureLarge
|
||||
case RegularFeatureMedium
|
||||
case BoldFeatureMedium
|
||||
case RegularFeatureSmall
|
||||
case BoldFeatureSmall
|
||||
case RegularFeatureXSmall
|
||||
case BoldFeatureXSmall
|
||||
|
||||
case RegularTitle2XLarge
|
||||
case BoldTitle2XLarge
|
||||
case RegularTitleXLarge
|
||||
case BoldTitleXLarge
|
||||
case RegularTitleLarge
|
||||
case BoldTitleMedium
|
||||
case BoldTitleLarge
|
||||
case RegularTitleMedium
|
||||
case BoldBodyLarge
|
||||
case BoldTitleMedium
|
||||
case RegularTitleSmall
|
||||
case BoldTitleSmall
|
||||
|
||||
case RegularBodyLarge
|
||||
case BoldBodySmall
|
||||
case BoldBodyLarge
|
||||
case RegularBodyMedium
|
||||
case BoldBodyMedium
|
||||
case RegularBodySmall
|
||||
case BoldMicro
|
||||
case BoldBodySmall
|
||||
case RegularMicro
|
||||
case BoldMicro
|
||||
|
||||
// Legacy Fonts
|
||||
case H1
|
||||
case H32
|
||||
case H2
|
||||
case B20
|
||||
case H3
|
||||
case B1
|
||||
case B2
|
||||
case B3
|
||||
case Title2XLarge // Maps to RegularTitle2XLarge
|
||||
case TitleXLarge // Maps to RegularTitleXLarge
|
||||
case H1 // Maps to RegularTitle2XLarge
|
||||
case H32 // Maps to RegularTitleXLarge
|
||||
case H2 // Maps to RegularTitleLarge
|
||||
case B20 // Maps to RegularBodyLarge
|
||||
case H3 // Maps to BoldTitleMedium
|
||||
case B1 // Maps to BoldBodySmall
|
||||
case B2 // Maps to RegularBodySmall
|
||||
case B3 // Maps to RegularMicro
|
||||
|
||||
/// Returns the font size of the current enum case.
|
||||
public func pointSize() -> CGFloat {
|
||||
switch self {
|
||||
case .H1:
|
||||
case .RegularFeatureXLarge,
|
||||
.BoldFeatureXLarge:
|
||||
return 96
|
||||
case .RegularFeatureLarge,
|
||||
.BoldFeatureLarge:
|
||||
return 80
|
||||
case .RegularFeatureMedium,
|
||||
.BoldFeatureMedium:
|
||||
return 64
|
||||
case .RegularFeatureSmall,
|
||||
.BoldFeatureSmall:
|
||||
return 48
|
||||
case .RegularFeatureXSmall,
|
||||
.BoldFeatureXSmall,
|
||||
.RegularTitle2XLarge,
|
||||
.BoldTitle2XLarge,
|
||||
.Title2XLarge,
|
||||
.H1:
|
||||
return 40
|
||||
|
||||
case .Title2XLarge:
|
||||
return 36
|
||||
|
||||
case .TitleXLarge, .H32:
|
||||
case .RegularTitleXLarge,
|
||||
.BoldTitleXLarge,
|
||||
.TitleXLarge,
|
||||
.H32:
|
||||
return 32
|
||||
|
||||
case .H2:
|
||||
return 25
|
||||
|
||||
case .BoldTitleLarge,
|
||||
.RegularTitleLarge:
|
||||
.RegularTitleLarge,
|
||||
.H2:
|
||||
return 24
|
||||
|
||||
case .BoldTitleMedium,
|
||||
.RegularTitleMedium, .B20:
|
||||
.RegularTitleMedium,
|
||||
.H3:
|
||||
return 20
|
||||
|
||||
case .H3:
|
||||
return 18
|
||||
|
||||
case .BoldBodyLarge,
|
||||
.RegularBodyLarge:
|
||||
case .RegularTitleSmall,
|
||||
.BoldTitleSmall,
|
||||
.BoldBodyLarge,
|
||||
.RegularBodyLarge,
|
||||
.B20:
|
||||
return 16
|
||||
|
||||
case .RegularBodyMedium,
|
||||
.BoldBodyMedium:
|
||||
return 14
|
||||
case .BoldBodySmall, .B1,
|
||||
.RegularBodySmall, .B2:
|
||||
return 13
|
||||
|
||||
return 12
|
||||
case .BoldMicro,
|
||||
.RegularMicro, .B3:
|
||||
return 11
|
||||
@ -90,85 +124,38 @@ open class Styler {
|
||||
public func isBold() -> Bool {
|
||||
|
||||
switch self {
|
||||
case .RegularTitleLarge,
|
||||
.RegularTitleMedium, .B20,
|
||||
.RegularBodyLarge,
|
||||
.RegularBodySmall, .B2,
|
||||
.RegularMicro, .B3:
|
||||
return false
|
||||
|
||||
case .H1,
|
||||
.Title2XLarge,
|
||||
.TitleXLarge, .H32,
|
||||
.H2,
|
||||
.BoldTitleLarge,
|
||||
.BoldTitleMedium,
|
||||
.H3,
|
||||
.BoldBodyLarge,
|
||||
.BoldBodySmall, .B1,
|
||||
.BoldMicro:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
/// Determines if the current enum is a legacy or modern font.
|
||||
public func isLegacyFont() -> Bool {
|
||||
|
||||
switch self {
|
||||
case .Title2XLarge,
|
||||
.TitleXLarge,
|
||||
.RegularTitleLarge,
|
||||
.RegularTitleMedium,
|
||||
.RegularBodyLarge,
|
||||
.RegularBodySmall,
|
||||
.RegularMicro,
|
||||
case .BoldFeatureXLarge,
|
||||
.BoldFeatureLarge,
|
||||
.BoldFeatureMedium,
|
||||
.BoldFeatureSmall,
|
||||
.BoldFeatureXSmall,
|
||||
.BoldTitle2XLarge,
|
||||
.BoldTitleXLarge,
|
||||
.BoldTitleLarge,
|
||||
.BoldTitleMedium,
|
||||
.BoldTitleSmall,
|
||||
.BoldBodyLarge,
|
||||
.BoldBodyMedium,
|
||||
.BoldBodySmall,
|
||||
.BoldMicro:
|
||||
return false
|
||||
|
||||
case .H1,
|
||||
.H32,
|
||||
.H2,
|
||||
.H3,
|
||||
.B1,
|
||||
.B2,
|
||||
.B3,
|
||||
.B20:
|
||||
.BoldMicro:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Returns the font based on the declared enum case.
|
||||
public func getFont(_ genericScaling: Bool = true) -> UIFont {
|
||||
|
||||
let size = genericScaling ? sizeFontGeneric(forCurrentDevice: pointSize()) : pointSize()
|
||||
|
||||
if isLegacyFont() {
|
||||
switch self {
|
||||
case .B2, .B3, .B20:
|
||||
return MFFonts.mfFont55Rg(size)
|
||||
|
||||
default:
|
||||
return MFFonts.mfFont75Bd(size)
|
||||
}
|
||||
} else {
|
||||
if isBold() {
|
||||
return size >= 13 ? MFFonts.mfFontDSBold(size) : MFFonts.mfFontTXBold(size)
|
||||
|
||||
} else {
|
||||
return size >= 13 ? MFFonts.mfFontDSRegular(size) : MFFonts.mfFontTXRegular(size)
|
||||
}
|
||||
}
|
||||
return MFStyler.getFontFor(size: size, isBold: isBold())
|
||||
}
|
||||
|
||||
/// Styles the provided label to the declared enum Font case.
|
||||
public func styleLabel(_ label: UILabel, textColor: UIColor = .mvmBlack, genericScaling: Bool = true) {
|
||||
|
||||
public func styleLabel(_ label: UILabel, genericScaling: Bool = true) {
|
||||
label.font = getFont(genericScaling)
|
||||
label.textColor = textColor
|
||||
label.textColor = color()
|
||||
}
|
||||
}
|
||||
|
||||
@ -267,3 +254,38 @@ open class Styler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc public extension MFStyler {
|
||||
/// Creates the appropriate VZW font for a given size and weight.
|
||||
@objc static func getFontFor(size: CGFloat, isBold: Bool) -> UIFont {
|
||||
if isBold {
|
||||
return size >= 13 ? MFFonts.mfFontDSBold(size) : MFFonts.mfFontTXBold(size)
|
||||
} else {
|
||||
return size >= 13 ? MFFonts.mfFontDSRegular(size) : MFFonts.mfFontTXRegular(size)
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates the appropriate VZW font for a VDS style.
|
||||
@objc static func getFontFor(styleString: String, genericScaling: Bool = true) -> UIFont? {
|
||||
return Styler.Font(rawValue: styleString)?.getFont(genericScaling)
|
||||
}
|
||||
|
||||
/// Creates the appropriate VZW font for a VDS style, scaling based on the scaleValue threshold passed in.
|
||||
@objc static func getFontFor(styleString: String, scaleValue: CGFloat) -> UIFont? {
|
||||
guard let font = Styler.Font(rawValue: styleString),
|
||||
let size = Styler.Font(rawValue: styleString)?.pointSize(),
|
||||
let newSize = Styler.sizeObjectGeneric(forCurrentDevice: size)?.getValueBased(onSize: scaleValue) else { return nil }
|
||||
return getFontFor(size: newSize, isBold: font.isBold())
|
||||
}
|
||||
|
||||
/// Styles the label accordingly to Styler.Font
|
||||
@objc static func style(label: UILabel, styleString: String, genericScaling: Bool = true) {
|
||||
Styler.Font(rawValue: styleString)?.styleLabel(label, genericScaling: genericScaling)
|
||||
}
|
||||
|
||||
/// Returns an attributed string with the passed in VDS Style.
|
||||
@objc static func getAttributedString(for string: String, styleString: String, genericScaling: Bool = true) -> NSAttributedString {
|
||||
let font = Styler.Font(rawValue: styleString)!
|
||||
return styleGetAttributedString(string, font: font.getFont(genericScaling), color: font.color())
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user