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