diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 95bd45b6..7e47c840 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -113,6 +113,8 @@ 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589202385D6E900DE9FD4 /* DashLineModel.swift */; }; 944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 944589222385DA9500DE9FD4 /* ImageViewModel.swift */; }; 9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; }; + 9458C3172406C8FD00930963 /* UIFont+FontWrapping.h in Headers */ = {isa = PBXBuildFile; fileRef = 9458C3152406C8FD00930963 /* UIFont+FontWrapping.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9458C3182406C8FD00930963 /* UIFont+FontWrapping.m in Sources */ = {isa = PBXBuildFile; fileRef = 9458C3162406C8FD00930963 /* UIFont+FontWrapping.m */; }; 946EE1BA237B66D80036751F /* MoleculeModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* MoleculeModelHelper.swift */; }; 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; }; 94AF4A3E23E9D13900676048 /* MFCaretButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 94AF4A3C23E9D13900676048 /* MFCaretButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -128,6 +130,10 @@ 94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */; }; 94C661D923CCF4B400D9FE5B /* LeftRightLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */; }; 94C661DA23CCF4FB00D9FE5B /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */; }; + 94CA227C24058534002D6750 /* VerizonNHGeTX-Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = 94CA227824058533002D6750 /* VerizonNHGeTX-Bold.otf */; }; + 94CA227D24058534002D6750 /* VerizonNHGeDS-Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = 94CA227924058533002D6750 /* VerizonNHGeDS-Regular.otf */; }; + 94CA227E24058534002D6750 /* VerizonNHGeDS-Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = 94CA227A24058533002D6750 /* VerizonNHGeDS-Bold.otf */; }; + 94CA227F24058534002D6750 /* VerizonNHGeTX-Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = 94CA227B24058533002D6750 /* VerizonNHGeTX-Regular.otf */; }; 94F217B623E0BF6100A47C06 /* PrimaryButtonView.h in Headers */ = {isa = PBXBuildFile; fileRef = 94F217B423E0BF6100A47C06 /* PrimaryButtonView.h */; settings = {ATTRIBUTES = (Public, ); }; }; 94F217B723E0BF6100A47C06 /* PrimaryButtonView.m in Sources */ = {isa = PBXBuildFile; fileRef = 94F217B523E0BF6100A47C06 /* PrimaryButtonView.m */; }; 94FB966223D797DA003D482B /* MFTextButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 94FB966023D797DA003D482B /* MFTextButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -290,10 +296,7 @@ D29DF2E121E9240B003B2FB9 /* MVMCoreUIPanelProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF2E021E9240B003B2FB9 /* MVMCoreUIPanelProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF2EE21ECEADF003B2FB9 /* MFFonts.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF14D21E693AD003B2FB9 /* MFFonts.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF14C21E693AD003B2FB9 /* MFFonts.m */; }; - D29DF31A21ECECC0003B2FB9 /* NHaasGroteskDSStd-45Lt.otf in Resources */ = {isa = PBXBuildFile; fileRef = D29DF31621ECECC0003B2FB9 /* NHaasGroteskDSStd-45Lt.otf */; }; D29DF31B21ECECC0003B2FB9 /* OCRAExtended.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D29DF31721ECECC0003B2FB9 /* OCRAExtended.ttf */; }; - D29DF31C21ECECC0003B2FB9 /* NHaasGroteskDSStd-75Bd.otf in Resources */ = {isa = PBXBuildFile; fileRef = D29DF31821ECECC0003B2FB9 /* NHaasGroteskDSStd-75Bd.otf */; }; - D29DF31D21ECECC0003B2FB9 /* NHaasGroteskDSStd-55Rg.otf in Resources */ = {isa = PBXBuildFile; fileRef = D29DF31921ECECC0003B2FB9 /* NHaasGroteskDSStd-55Rg.otf */; }; D29DF32021ED0CBA003B2FB9 /* LabelView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF31E21ED0CBA003B2FB9 /* LabelView.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF31F21ED0CBA003B2FB9 /* LabelView.m */; }; D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF32221ED0DA2003B2FB9 /* TextButtonView.m */; }; @@ -448,6 +451,8 @@ 944589202385D6E900DE9FD4 /* DashLineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashLineModel.swift; sourceTree = ""; }; 944589222385DA9500DE9FD4 /* ImageViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageViewModel.swift; sourceTree = ""; }; 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = ""; }; + 9458C3152406C8FD00930963 /* UIFont+FontWrapping.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIFont+FontWrapping.h"; sourceTree = ""; }; + 9458C3162406C8FD00930963 /* UIFont+FontWrapping.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIFont+FontWrapping.m"; sourceTree = ""; }; 946EE1B9237B66D80036751F /* MoleculeModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeModelHelper.swift; sourceTree = ""; }; 948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = ""; }; 94AF4A3C23E9D13900676048 /* MFCaretButton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MFCaretButton.h; sourceTree = ""; }; @@ -461,6 +466,10 @@ 94C2D9A623872DA90006CF46 /* LabelAttributeColorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeColorModel.swift; sourceTree = ""; }; 94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeImageModel.swift; sourceTree = ""; }; 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeActionModel.swift; sourceTree = ""; }; + 94CA227824058533002D6750 /* VerizonNHGeTX-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "VerizonNHGeTX-Bold.otf"; sourceTree = ""; }; + 94CA227924058533002D6750 /* VerizonNHGeDS-Regular.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "VerizonNHGeDS-Regular.otf"; sourceTree = ""; }; + 94CA227A24058533002D6750 /* VerizonNHGeDS-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "VerizonNHGeDS-Bold.otf"; sourceTree = ""; }; + 94CA227B24058533002D6750 /* VerizonNHGeTX-Regular.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "VerizonNHGeTX-Regular.otf"; sourceTree = ""; }; 94F217B423E0BF6100A47C06 /* PrimaryButtonView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PrimaryButtonView.h; sourceTree = ""; }; 94F217B523E0BF6100A47C06 /* PrimaryButtonView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PrimaryButtonView.m; sourceTree = ""; }; 94FB966023D797DA003D482B /* MFTextButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFTextButton.h; sourceTree = ""; }; @@ -635,10 +644,7 @@ D29DF2CC21E7C104003B2FB9 /* MFLoadingViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFLoadingViewController.h; sourceTree = ""; }; D29DF2CD21E7C104003B2FB9 /* MFLoadingViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFLoadingViewController.m; sourceTree = ""; }; D29DF2E021E9240B003B2FB9 /* MVMCoreUIPanelProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPanelProtocol.h; sourceTree = ""; }; - D29DF31621ECECC0003B2FB9 /* NHaasGroteskDSStd-45Lt.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NHaasGroteskDSStd-45Lt.otf"; sourceTree = ""; }; D29DF31721ECECC0003B2FB9 /* OCRAExtended.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = OCRAExtended.ttf; sourceTree = ""; }; - D29DF31821ECECC0003B2FB9 /* NHaasGroteskDSStd-75Bd.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NHaasGroteskDSStd-75Bd.otf"; sourceTree = ""; }; - D29DF31921ECECC0003B2FB9 /* NHaasGroteskDSStd-55Rg.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NHaasGroteskDSStd-55Rg.otf"; sourceTree = ""; }; D29DF31E21ED0CBA003B2FB9 /* LabelView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LabelView.h; sourceTree = ""; }; D29DF31F21ED0CBA003B2FB9 /* LabelView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LabelView.m; sourceTree = ""; }; D29DF32221ED0DA2003B2FB9 /* TextButtonView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TextButtonView.m; sourceTree = ""; }; @@ -1246,6 +1252,8 @@ D29DF28121E7AB23003B2FB9 /* MVMCoreUICommonViewsUtility.m */, D29DF14D21E693AD003B2FB9 /* MFFonts.h */, D29DF14C21E693AD003B2FB9 /* MFFonts.m */, + 9458C3152406C8FD00930963 /* UIFont+FontWrapping.h */, + 9458C3162406C8FD00930963 /* UIFont+FontWrapping.m */, D29DF29F21E7AF4E003B2FB9 /* MVMCoreUIUtility.h */, D29DF2A021E7AF4E003B2FB9 /* MVMCoreUIUtility.m */, D29DF2A721E7B2F9003B2FB9 /* MVMCoreUIConstants.h */, @@ -1424,10 +1432,11 @@ D29DF31521ECECC0003B2FB9 /* Fonts */ = { isa = PBXGroup; children = ( - D29DF31621ECECC0003B2FB9 /* NHaasGroteskDSStd-45Lt.otf */, + 94CA227A24058533002D6750 /* VerizonNHGeDS-Bold.otf */, + 94CA227924058533002D6750 /* VerizonNHGeDS-Regular.otf */, + 94CA227824058533002D6750 /* VerizonNHGeTX-Bold.otf */, + 94CA227B24058533002D6750 /* VerizonNHGeTX-Regular.otf */, D29DF31721ECECC0003B2FB9 /* OCRAExtended.ttf */, - D29DF31821ECECC0003B2FB9 /* NHaasGroteskDSStd-75Bd.otf */, - D29DF31921ECECC0003B2FB9 /* NHaasGroteskDSStd-55Rg.otf */, ); path = Fonts; sourceTree = ""; @@ -1508,6 +1517,7 @@ D29770F421F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.h in Headers */, D29DF15421E69760003B2FB9 /* MVMCoreUIPanelButtonProtocol.h in Headers */, D2A514582211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h in Headers */, + 9458C3172406C8FD00930963 /* UIFont+FontWrapping.h in Headers */, D29DF0D121E404D4003B2FB9 /* MVMCoreUI.h in Headers */, D29DF29A21E7ADB8003B2FB9 /* MFProgrammaticTableViewController.h in Headers */, D29DF11521E6805F003B2FB9 /* UIColor+MFConvenience.h in Headers */, @@ -1627,14 +1637,15 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 94CA227F24058534002D6750 /* VerizonNHGeTX-Regular.otf in Resources */, D29DF2AF21E7B3A4003B2FB9 /* MFTextView.xib in Resources */, - D29DF31C21ECECC0003B2FB9 /* NHaasGroteskDSStd-75Bd.otf in Resources */, - D29DF31D21ECECC0003B2FB9 /* NHaasGroteskDSStd-55Rg.otf in Resources */, 0A21DB8E235E06EF00C160A2 /* MFDigitTextField.xib in Resources */, + 94CA227C24058534002D6750 /* VerizonNHGeTX-Bold.otf in Resources */, D29DF32C21EE8736003B2FB9 /* Localizable.strings in Resources */, 0A21DB86235E06EF00C160A2 /* MFTextField.xib in Resources */, - D29DF31A21ECECC0003B2FB9 /* NHaasGroteskDSStd-45Lt.otf in Resources */, + 94CA227D24058534002D6750 /* VerizonNHGeDS-Regular.otf in Resources */, D29DF32E21EE8C3D003B2FB9 /* Media.xcassets in Resources */, + 94CA227E24058534002D6750 /* VerizonNHGeDS-Bold.otf in Resources */, D29DF31B21ECECC0003B2FB9 /* OCRAExtended.ttf in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1684,6 +1695,7 @@ DBC4392122491730001AB423 /* LabelWithInternalButton.swift in Sources */, D224798C231450C8003FCCF9 /* HeadlineBodyToggle.swift in Sources */, 017BEB442362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift in Sources */, + 9458C3182406C8FD00930963 /* UIFont+FontWrapping.m in Sources */, 522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */, 9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */, 9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atoms/Views/Label/Label.swift index f08d532d..6550d307 100644 --- a/MVMCoreUI/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label/Label.swift @@ -132,6 +132,89 @@ public typealias ActionBlock = () -> () // MARK: - Factory Functions //------------------------------------------------------ + /// Title 2XLarge + @objc public static func createLabelTitle2XLarge(_ scale: Bool) -> Label { + let label = Label.label() + label.styleTitle2XLarge(scale) + return label + } + + /// TitleXLarge + @objc public static func createLabelTitleXLarge(_ scale: Bool) -> Label { + let label = Label.label() + label.styleTitleXLarge(scale) + return label + } + + /// BoldTitleLarge + @objc public static func createLabelBoldTitleLarge(_ scale: Bool) -> Label { + let label = Label.label() + label.styleBoldTitleLarge(scale) + return label + } + + /// RegularTitleLarge + @objc public static func createLabelRegularTitleLarge(_ scale: Bool) -> Label { + let label = Label.label() + label.styleRegularTitleLarge(scale) + return label + } + + /// BoldTitleMedium + @objc public static func createLabelBoldTitleMedium(_ scale: Bool) -> Label { + let label = Label.label() + label.styleBoldTitleMedium(scale) + return label + } + + /// RegularTitleMedium + @objc public static func createLabelRegularTitleMedium(_ scale: Bool) -> Label { + let label = Label.label() + label.styleRegularTitleMedium(scale) + return label + } + + /// BoldBodyLarge + @objc public static func createLabelBoldBodyLarge(_ scale: Bool) -> Label { + let label = Label.label() + label.styleBoldBodyLarge(scale) + return label + } + + /// RegularBodyLarge + @objc public static func createLabelRegularBodyLarge(_ scale: Bool) -> Label { + let label = Label.label() + label.styleRegularBodyLarge(scale) + return label + } + + /// BoldBodySmall + @objc public static func createLabelBoldBodySmall(_ scale: Bool) -> Label { + let label = Label.label() + label.styleBoldBodySmall(scale) + return label + } + + /// RegularBodySmall + @objc public static func createLabelRegularBodySmall(_ scale: Bool) -> Label { + let label = Label.label() + label.styleRegularBodySmall(scale) + return label + } + /// BoldMicro + @objc public static func createLabelBoldMicro(_ scale: Bool) -> Label { + let label = Label.label() + label.styleBoldMicro(scale) + return label + } + /// RegularMicro + @objc public static func createLabelRegularMicro(_ scale: Bool) -> Label { + let label = Label.label() + label.styleRegularMicro(scale) + return label + } + + //2.0 fonts init methods /// H1 -> HeadlineLarge @objc public static func commonLabelH1(_ scale: Bool) -> Label { let label = Label.label() @@ -267,7 +350,7 @@ public typealias ActionBlock = () -> () if let fontName = labelModel.fontName { font = MFFonts.mfFont(withName: fontName, size: fontSize ?? standardFontSize) } else if let fontSize = fontSize { - font = font.withSize(fontSize) + font = font.updateSize(fontSize) } } @@ -276,7 +359,7 @@ public typealias ActionBlock = () -> () } if let attributes = labelModel.attributes, let labelText = text { - let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: font.withSize(standardFontSize), NSAttributedString.Key.foregroundColor: textColor as UIColor]) + let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: font.updateSize(standardFontSize), NSAttributedString.Key.foregroundColor: textColor as UIColor]) for attribute in attributes { let range = NSRange(location: attribute.location, length: attribute.length) @@ -324,7 +407,7 @@ public typealias ActionBlock = () -> () if let fontName = fontAtt.name { font = MFFonts.mfFont(withName: fontName, size: fontSize ?? self.font.pointSize) } else if let fontSize = fontSize { - font = self.font.withSize(fontSize) + font = self.font.updateSize(fontSize) } if let font = font { attributedString.removeAttribute(.font, range: range) @@ -390,7 +473,7 @@ public typealias ActionBlock = () -> () if let fontName = json?.optionalStringForKey("fontName") { label.font = MFFonts.mfFont(withName: fontName, size: fontSize ?? mvmLabel?.standardFontSize ?? label.font.pointSize) } else if let fontSize = fontSize { - label.font = label.font.withSize(fontSize) + label.font = label.font.updateSize(fontSize) } } @@ -400,7 +483,7 @@ public typealias ActionBlock = () -> () if let attributes = json?.optionalArrayForKey("attributes"), let labelText = label.text { let attributedString = NSMutableAttributedString(string: labelText, - attributes: [NSAttributedString.Key.font: mvmLabel?.font.withSize(mvmLabel!.standardFontSize) ?? label.font as UIFont, + attributes: [NSAttributedString.Key.font: mvmLabel?.font.updateSize(mvmLabel!.standardFontSize) ?? label.font as UIFont, NSAttributedString.Key.foregroundColor: label.textColor as UIColor]) for case let attribute as [String: Any] in attributes { guard let attributeType = attribute.optionalStringForKey(KeyType), @@ -452,7 +535,7 @@ public typealias ActionBlock = () -> () if let fontName = attribute.optionalStringForKey("name") { font = MFFonts.mfFont(withName: fontName, size: fontSize ?? mvmLabel?.standardFontSize ?? label.font.pointSize) } else if let fontSize = fontSize { - font = label.font.withSize(fontSize) + font = label.font.updateSize(fontSize) } if let font = font { @@ -481,6 +564,68 @@ public typealias ActionBlock = () -> () // MARK: - Methods //------------------------------------------------------ + //mva 3.0 font + @objc public func styleTitle2XLarge(_ scale: Bool) { + MFStyler.styleLabelTitle2XLarge(self, genericScaling: false) + setScale(scale) + } + + @objc public func styleTitleXLarge(_ scale: Bool) { + MFStyler.styleLabelTitleXLarge(self, genericScaling: false) + setScale(scale) + } + + @objc public func styleBoldTitleLarge(_ scale: Bool) { + MFStyler.styleLabelBoldTitleLarge(self, genericScaling: false) + setScale(scale) + } + + @objc public func styleRegularTitleLarge(_ scale: Bool) { + MFStyler.styleLabelRegularTitleLarge(self, genericScaling: false) + setScale(scale) + } + + @objc public func styleBoldTitleMedium(_ scale: Bool) { + MFStyler.styleLabelBoldTitleMedium(self, genericScaling: false) + setScale(scale) + } + + @objc public func styleRegularTitleMedium(_ scale: Bool) { + MFStyler.styleLabelRegularTitleMedium(self, genericScaling: false) + setScale(scale) + } + + @objc public func styleBoldBodyLarge(_ scale: Bool) { + MFStyler.styleLabelBoldBodyLarge(self, genericScaling: false) + setScale(scale) + } + + @objc public func styleRegularBodyLarge(_ scale: Bool) { + MFStyler.styleLabelRegularBodyLarge(self, genericScaling: false) + setScale(scale) + } + + @objc public func styleBoldBodySmall(_ scale: Bool) { + MFStyler.styleLabelBoldBodySmall(self, genericScaling: false) + setScale(scale) + } + + @objc public func styleRegularBodySmall(_ scale: Bool) { + MFStyler.styleLabelRegularBodySmall(self, genericScaling: false) + setScale(scale) + } + + @objc public func styleBoldMicro(_ scale: Bool) { + MFStyler.styleLabelBoldMicro(self, genericScaling: false) + setScale(scale) + } + + @objc public func styleRegularMicro(_ scale: Bool) { + MFStyler.styleLabelRegularMicro(self, genericScaling: false) + setScale(scale) + } + + //2.0 fonts @objc public func styleH1(_ scale: Bool) { MFStyler.styleLabelH1(self, genericScaling: false) setScale(scale) @@ -532,7 +677,7 @@ public typealias ActionBlock = () -> () originalAttributedString.enumerateAttribute(.font, in: NSRange(location: 0, length: originalAttributedString.length), options: []) { value, range, stop in if let fontObj = value as? UIFont, let stylerSize = MFStyler.sizeObjectGeneric(forCurrentDevice: fontObj.pointSize)?.getValueBased(onSize: size) { - attributedString.addAttribute(.font, value: fontObj.withSize(stylerSize) as Any, range: range) + attributedString.addAttribute(.font, value: fontObj.updateSize(stylerSize) as Any, range: range) } } @@ -548,7 +693,7 @@ public typealias ActionBlock = () -> () attributedText = attributedString } else if !MVMCoreGetterUtility.fequal(a: Float(standardFontSize), b: 0.0), let sizeObject = sizeObject ?? MFStyler.sizeObjectGeneric(forCurrentDevice: standardFontSize) { - font = font.withSize(sizeObject.getValueBased(onSize: size)) + font = font.updateSize(sizeObject.getValueBased(onSize: size)) } } diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index 623b2f47..6e18e427 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -20,9 +20,7 @@ import UIKit navigationBar.shadowImage = UIImage() navigationBar.isOpaque = true navigationBar.tintColor = .black - if let font = MFFonts.mfFont75Bd(MFSizeObject(standardSize: 14, standardiPadPortraitSize: 16, iPadProLandscapeSize: 18)?.getValueBasedOnScreenSize() ?? 14) { - navigationBar.titleTextAttributes = [NSAttributedString.Key.font: font]; - } + navigationBar.titleTextAttributes = [NSAttributedString.Key.font: MFStyler.fontBoldBodySmall(false)]; } public static func setupNavigationController() -> Self? { diff --git a/MVMCoreUI/Containers/TabBarController/TopTabbar.m b/MVMCoreUI/Containers/TabBarController/TopTabbar.m index e9d77c77..4b89903f 100644 --- a/MVMCoreUI/Containers/TabBarController/TopTabbar.m +++ b/MVMCoreUI/Containers/TabBarController/TopTabbar.m @@ -338,7 +338,7 @@ static NSString * const COLLECTION_CELL_ID = @"cell"; #pragma mark - helper -- (void)pinHeight:(CGFloat)height; { +- (void)pinHeight:(CGFloat)height { self.heightConstraint.constant = height; [self setNeedsLayout]; [self layoutIfNeeded]; diff --git a/MVMCoreUI/MVMCoreUI.h b/MVMCoreUI/MVMCoreUI.h index 1b2183aa..5e8c92cc 100644 --- a/MVMCoreUI/MVMCoreUI.h +++ b/MVMCoreUI/MVMCoreUI.h @@ -32,6 +32,7 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[]; #pragma mark - Categories #import #import +#import #pragma mark - Styles #import diff --git a/MVMCoreUI/Styles/MFStyler.h b/MVMCoreUI/Styles/MFStyler.h index bdef57ba..6accea28 100644 --- a/MVMCoreUI/Styles/MFStyler.h +++ b/MVMCoreUI/Styles/MFStyler.h @@ -98,6 +98,48 @@ B3 -> Legal //------------------------------------------------- // Returns the fonts for these styles. Scales them as needed by default + +#pragma mark - 3.0 fonts +///auto select corresponding font based on font size, DS for font bigger than 15 pt, TX for font smaller than 15 pt ++ (nonnull UIFont *)getMVA3FontSize:(CGFloat)size bold:(BOOL)isBold; +///Bold 36pt ++ (nonnull UIFont *)fontTitle2XLarge:(BOOL)genericScaling; ++ (nonnull UIFont *)fontTitle2XLarge; +///Bold 32pt ++ (nonnull UIFont *)fontTitleXLarge:(BOOL)genericScaling; ++ (nonnull UIFont *)fontTitleXLarge; +///Bold 24pt ++ (nonnull UIFont *)fontBoldTitleLarge:(BOOL)genericScaling; ++ (nonnull UIFont *)fontBoldTitleLarge; +///Regular 24pt ++ (nonnull UIFont *)fontRegularTitleLarge:(BOOL)genericScaling; ++ (nonnull UIFont *)fontRegularTitleLarge; +///Bold 20pt ++ (nonnull UIFont *)fontBoldTitleMedium:(BOOL)genericScaling; ++ (nonnull UIFont *)fontBoldTitleMedium; +///Regular 20pt ++ (nonnull UIFont *)fontRegularTitleMedium:(BOOL)genericScaling; ++ (nonnull UIFont *)fontRegularTitleMedium; +///Bold 16pt ++ (nonnull UIFont *)fontBoldBodyLarge:(BOOL)genericScaling; ++ (nonnull UIFont *)fontBoldBodyLarge; +///Regular 16pt ++ (nonnull UIFont *)fontRegularBodyLarge:(BOOL)genericScaling; ++ (nonnull UIFont *)fontRegularBodyLarge; +///Bold 13pt ++ (nonnull UIFont *)fontBoldBodySmall:(BOOL)genericScaling; ++ (nonnull UIFont *)fontBoldBodySmall; +///Regular 13pt ++ (nonnull UIFont *)fontRegularBodySmall:(BOOL)genericScaling; ++ (nonnull UIFont *)fontRegularBodySmall; +///Bold 11pt ++ (nonnull UIFont *)fontBoldMicro:(BOOL)genericScaling; ++ (nonnull UIFont *)fontBoldMicro; +///Regular 11pt ++ (nonnull UIFont *)fontRegularMicro:(BOOL)genericScaling; ++ (nonnull UIFont *)fontRegularMicro; + + #pragma mark - 2.0 fonts //75Bd 40pt @@ -206,9 +248,50 @@ B3 -> Legal //------------------------------------------------- // Applies the styles to the passed in objects. +#pragma mark - 3.0 Styles + ++ (void)styleLabelTitle2XLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; ++ (void)styleLabelTitle2XLarge:(nonnull UILabel *)label; + ++ (void)styleLabelTitleXLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; ++ (void)styleLabelTitleXLarge:(nonnull UILabel *)label; + ++ (void)styleLabelBoldTitleLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; ++ (void)styleLabelBoldTitleLarge:(nonnull UILabel *)label; + ++ (void)styleLabelRegularTitleLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; ++ (void)styleLabelRegularTitleLarge:(nonnull UILabel *)label; + ++ (void)styleLabelBoldTitleMedium:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; ++ (void)styleLabelBoldTitleMedium:(nonnull UILabel *)label; + ++ (void)styleLabelRegularTitleMedium:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; ++ (void)styleLabelRegularTitleMedium:(nonnull UILabel *)label; + ++ (void)styleLabelBoldBodyLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; ++ (void)styleLabelBoldBodyLarge:(nonnull UILabel *)label; + ++ (void)styleLabelRegularBodyLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; ++ (void)styleLabelRegularBodyLarge:(nonnull UILabel *)label; + ++ (void)styleLabelBoldBodySmall:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; ++ (void)styleLabelBoldBodySmall:(nonnull UILabel *)label; + ++ (void)styleLabelRegularBodySmall:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; ++ (void)styleLabelRegularBodySmall:(nonnull UILabel *)label; + ++ (void)styleLabelBoldMicro:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling; ++ (void)styleLabelBoldMicro:(nonnull UILabel *)label; + ++ (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, 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 genericScaling:(BOOL)genericScaling; @@ -257,6 +340,43 @@ B3 -> Legal #pragma mark - Attributed Strings ++ (nonnull NSAttributedString *)styleGetTitle2XLargeAttributedString:(nullable NSString *)string; ++ (nonnull NSAttributedString *)styleGetTitle2XLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; + ++ (nonnull NSAttributedString *)styleGetTitleXLargeAttributedString:(nullable NSString *)string; ++ (nonnull NSAttributedString *)styleGetTitleXLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; + ++ (nonnull NSAttributedString *)styleGetBoldTitleLargeAttributedString:(nullable NSString *)string; ++ (nonnull NSAttributedString *)styleGetBoldTitleLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; + ++ (nonnull NSAttributedString *)styleGetRegularTitleLargeAttributedString:(nullable NSString *)string; ++ (nonnull NSAttributedString *)styleGetRegularTitleLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; + ++ (nonnull NSAttributedString *)styleGetBoldTitleMediumAttributedString:(nullable NSString *)string; ++ (nonnull NSAttributedString *)styleGetBoldTitleMediumAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; + ++ (nonnull NSAttributedString *)styleGetRegularTitleMediumAttributedString:(nullable NSString *)string; ++ (nonnull NSAttributedString *)styleGetRegularTitleMediumAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; + ++ (nonnull NSAttributedString *)styleGetBoldBodyLargeAttributedString:(nullable NSString *)string; ++ (nonnull NSAttributedString *)styleGetBoldBodyLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; + ++ (nonnull NSAttributedString *)styleGetRegularBodyLargeAttributedString:(nullable NSString *)string; ++ (nonnull NSAttributedString *)styleGetRegularBodyLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; + ++ (nonnull NSAttributedString *)styleGetBoldBodySmallAttributedString:(nullable NSString *)string; ++ (nonnull NSAttributedString *)styleGetBoldBodySmallAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; + ++ (nonnull NSAttributedString *)styleGetRegularBodySmallAttributedString:(nullable NSString *)string; ++ (nonnull NSAttributedString *)styleGetRegularBodySmallAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; + ++ (nonnull NSAttributedString *)styleGetBoldMicroAttributedString:(nullable NSString *)string; ++ (nonnull NSAttributedString *)styleGetBoldMicroAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling; + ++ (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; diff --git a/MVMCoreUI/Styles/MFStyler.m b/MVMCoreUI/Styles/MFStyler.m index c3dc8946..213c205e 100644 --- a/MVMCoreUI/Styles/MFStyler.m +++ b/MVMCoreUI/Styles/MFStyler.m @@ -111,6 +111,168 @@ 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]; + } + } +} + ++ (nonnull UIFont *)fontTitle2XLarge:(BOOL)genericScaling { + CGFloat size = 36; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [self getMVA3FontSize:size bold:YES]; +} + ++ (nonnull UIFont *)fontTitle2XLarge { + return [self fontTitle2XLarge:YES]; +} + ++ (nonnull UIFont *)fontTitleXLarge:(BOOL)genericScaling { + CGFloat size = 32; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [self getMVA3FontSize:size bold:YES]; +} ++ (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]; +} + ++ (nonnull UIFont *)fontBoldTitleLarge { + return [self fontBoldTitleLarge:YES]; +} + ++ (nonnull UIFont *)fontRegularTitleLarge:(BOOL)genericScaling { + CGFloat size = 24; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [self getMVA3FontSize:size bold:NO]; +} + ++ (nonnull UIFont *)fontRegularTitleLarge { + return [self fontRegularTitleLarge:YES]; +} + ++ (nonnull UIFont *)fontBoldTitleMedium:(BOOL)genericScaling { + CGFloat size = 20; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [self getMVA3FontSize:size bold:YES]; +} + ++ (nonnull UIFont *)fontBoldTitleMedium { + return [self fontBoldTitleMedium:YES]; +} + ++ (nonnull UIFont *)fontRegularTitleMedium:(BOOL)genericScaling { + CGFloat size = 20; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [self getMVA3FontSize:size bold:NO]; +} + ++ (nonnull UIFont *)fontRegularTitleMedium { + return [self fontRegularTitleMedium:YES]; +} + ++ (nonnull UIFont *)fontBoldBodyLarge:(BOOL)genericScaling { + CGFloat size = 16; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [self getMVA3FontSize:size bold:YES]; +} + ++ (nonnull UIFont *)fontBoldBodyLarge { + return [self fontBoldBodyLarge:YES]; +} + ++ (nonnull UIFont *)fontRegularBodyLarge:(BOOL)genericScaling { + CGFloat size = 16; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [self getMVA3FontSize:size bold:NO]; +} + ++ (nonnull UIFont *)fontRegularBodyLarge { + return [self fontRegularBodyLarge:YES]; +} + ++ (nonnull UIFont *)fontBoldBodySmall:(BOOL)genericScaling { + CGFloat size = 13; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [self getMVA3FontSize:size bold:YES]; +} + ++ (nonnull UIFont *)fontBoldBodySmall { + return [self fontBoldBodySmall:YES]; +} + ++ (nonnull UIFont *)fontRegularBodySmall:(BOOL)genericScaling { + CGFloat size = 13; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [self getMVA3FontSize:size bold:NO]; +} + ++ (nonnull UIFont *)fontRegularBodySmall { + return [self fontRegularBodySmall:YES]; +} + ++ (nonnull UIFont *)fontBoldMicro:(BOOL)genericScaling { + CGFloat size = 11; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [self getMVA3FontSize:size bold:YES]; +} + ++ (nonnull UIFont *)fontBoldMicro { + return [self fontBoldMicro:YES]; +} + ++ (nonnull UIFont *)fontRegularMicro:(BOOL)genericScaling { + CGFloat size = 11; + if (genericScaling) { + size = [self sizeFontGenericForCurrentDevice:size]; + } + return [self getMVA3FontSize:size bold:NO]; +} + ++ (nonnull UIFont *)fontRegularMicro { + return [self fontRegularMicro:YES]; +} + + #pragma mark - 2.0 fonts + (nullable UIFont *)fontH1:(BOOL)genericScaling { @@ -514,10 +676,165 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return [MFFonts mfFont55Rg:[self sizeFontGenericForCurrentDevice:size]]; } +#pragma mark - 3.0 Styles + ++ (void)styleLabelTitle2XLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { + label.font = [MFStyler fontTitle2XLarge:genericScaling]; + label.textColor = [UIColor blackColor]; +} + ++ (void)styleLabelTitle2XLarge:(nonnull UILabel *)label { + [self styleLabelTitle2XLarge:label genericScaling:YES]; +} + ++ (void)styleLabelTitleXLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { + label.font = [MFStyler fontTitleXLarge:genericScaling]; + label.textColor = [UIColor blackColor]; +} + ++ (void)styleLabelTitleXLarge:(nonnull UILabel *)label { + [self styleLabelTitleXLarge:label genericScaling:YES]; +} + ++ (void)styleLabelBoldTitleLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { + label.font = [MFStyler fontBoldTitleLarge:genericScaling]; + label.textColor = [UIColor blackColor]; +} + ++ (void)styleLabelBoldTitleLarge:(nonnull UILabel *)label { + [self styleLabelBoldTitleLarge:label genericScaling:YES]; +} + ++ (void)styleLabelRegularTitleLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { + label.font = [MFStyler fontRegularTitleLarge:genericScaling]; + label.textColor = [UIColor blackColor]; +} + ++ (void)styleLabelRegularTitleLarge:(nonnull UILabel *)label { + [self styleLabelBoldTitleLarge:label genericScaling:YES]; +} + ++ (void)styleLabelBoldTitleMedium:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { + label.font = [MFStyler fontBoldTitleMedium:genericScaling]; + label.textColor = [UIColor blackColor]; +} + ++ (void)styleLabelBoldTitleMedium:(nonnull UILabel *)label { + [self styleLabelBoldTitleMedium:label genericScaling:YES]; +} + ++ (void)styleLabelRegularTitleMedium:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { + label.font = [MFStyler fontRegularTitleMedium:genericScaling]; + label.textColor = [UIColor blackColor]; +} + ++ (void)styleLabelRegularTitleMedium:(nonnull UILabel *)label { + [self styleLabelRegularTitleMedium:label genericScaling:YES]; +} + ++ (void)styleLabelBoldBodyLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { + label.font = [MFStyler fontBoldBodyLarge:genericScaling]; + label.textColor = [UIColor blackColor]; +} + ++ (void)styleLabelBoldBodyLarge:(nonnull UILabel *)label { + [self styleLabelBoldBodyLarge:label genericScaling:YES]; +} + ++ (void)styleLabelRegularBodyLarge:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { + label.font = [MFStyler fontRegularBodyLarge:genericScaling]; + label.textColor = [UIColor blackColor]; +} + ++ (void)styleLabelRegularBodyLarge:(nonnull UILabel *)label { + [self styleLabelRegularBodyLarge:label genericScaling:YES]; +} + ++ (void)styleLabelBoldBodySmall:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { + label.font = [MFStyler fontBoldBodySmall:genericScaling]; + label.textColor = [UIColor blackColor]; +} + ++ (void)styleLabelBoldBodySmall:(nonnull UILabel *)label { + [self styleLabelBoldBodySmall:label genericScaling:YES]; +} + ++ (void)styleLabelRegularBodySmall:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { + label.font = [MFStyler fontRegularBodySmall:genericScaling]; + label.textColor = [UIColor blackColor]; +} + ++ (void)styleLabelRegularBodySmall:(nonnull UILabel *)label { + [self styleLabelRegularBodySmall:label genericScaling:YES]; +} + ++ (void)styleLabelBoldMicro:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { + label.font = [MFStyler fontBoldMicro:genericScaling]; + label.textColor = [UIColor blackColor]; +} + ++ (void)styleLabelBoldMicro:(nonnull UILabel *)label { + [self styleLabelBoldMicro:label genericScaling:YES]; +} + ++ (void)styleLabelRegularMicro:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling { + label.font = [MFStyler fontRegularMicro:genericScaling]; + label.textColor = [UIColor blackColor]; +} + ++ (void)styleLabelRegularMicro:(nonnull UILabel *)label { + [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 ([style isEqualToString:@"H1"]) { + 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]; @@ -697,6 +1014,105 @@ CGFloat const LabelWithInternalButtonLineSpace = 2; return attributedString; } + ++ (nonnull NSAttributedString *)styleGetTitle2XLargeAttributedString:(nullable NSString *)string { + return [MFStyler styleGetTitle2XLargeAttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetTitle2XLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontTitle2XLarge:genericScaling] color:[UIColor blackColor]]; +} + ++ (nonnull NSAttributedString *)styleGetTitleXLargeAttributedString:(nullable NSString *)string { + return [MFStyler styleGetTitleXLargeAttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetTitleXLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontTitleXLarge:genericScaling] color:[UIColor blackColor]]; +} + ++ (nonnull NSAttributedString *)styleGetBoldTitleLargeAttributedString:(nullable NSString *)string { + return [MFStyler styleGetBoldTitleLargeAttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetBoldTitleLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontBoldTitleLarge:genericScaling] color:[UIColor blackColor]]; +} + ++ (nonnull NSAttributedString *)styleGetRegularTitleLargeAttributedString:(nullable NSString *)string { + return [MFStyler styleGetRegularTitleLargeAttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetRegularTitleLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontRegularTitleLarge:genericScaling] color:[UIColor blackColor]]; +} + ++ (nonnull NSAttributedString *)styleGetBoldTitleMediumAttributedString:(nullable NSString *)string { + return [MFStyler styleGetBoldTitleMediumAttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetBoldTitleMediumAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontBoldTitleMedium:genericScaling] color:[UIColor blackColor]]; +} + ++ (nonnull NSAttributedString *)styleGetRegularTitleMediumAttributedString:(nullable NSString *)string { + return [MFStyler styleGetRegularTitleMediumAttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetRegularTitleMediumAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontRegularTitleMedium:genericScaling] color:[UIColor blackColor]]; +} + ++ (nonnull NSAttributedString *)styleGetBoldBodyLargeAttributedString:(nullable NSString *)string { + return [MFStyler styleGetBoldBodyLargeAttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetBoldBodyLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontBoldBodyLarge:genericScaling] color:[UIColor blackColor]]; +} + ++ (nonnull NSAttributedString *)styleGetRegularBodyLargeAttributedString:(nullable NSString *)string { + return [MFStyler styleGetRegularBodyLargeAttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetRegularBodyLargeAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontRegularBodyLarge:genericScaling] color:[UIColor blackColor]]; +} + ++ (nonnull NSAttributedString *)styleGetBoldBodySmallAttributedString:(nullable NSString *)string { + return [MFStyler styleGetBoldBodySmallAttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetBoldBodySmallAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontBoldBodySmall:genericScaling] color:[UIColor blackColor]]; +} + ++ (nonnull NSAttributedString *)styleGetRegularBodySmallAttributedString:(nullable NSString *)string { + return [MFStyler styleGetRegularBodySmallAttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetRegularBodySmallAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontRegularBodySmall:genericScaling] color:[UIColor blackColor]]; +} + ++ (nonnull NSAttributedString *)styleGetBoldMicroAttributedString:(nullable NSString *)string { + return [MFStyler styleGetBoldMicroAttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetBoldMicroAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontBoldMicro:genericScaling] color:[UIColor blackColor]]; +} + ++ (nonnull NSAttributedString *)styleGetRegularMicroAttributedString:(nullable NSString *)string { + return [MFStyler styleGetRegularBodySmallAttributedString:string genericScaling:YES]; +} + ++ (nonnull NSAttributedString *)styleGetRegularMicroAttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling { + return [MFStyler styleGetAttributedString:string font:[MFStyler fontRegularMicro:genericScaling] color:[UIColor blackColor]]; +} + + +//2.0 font get attributedString + (nonnull NSAttributedString *)styleGetH1AttributedString:(nullable NSString *)string { return [MFStyler styleGetH1AttributedString:string genericScaling:YES]; } diff --git a/MVMCoreUI/SupportingFiles/Fonts/NHaasGroteskDSStd-45Lt.otf b/MVMCoreUI/SupportingFiles/Fonts/NHaasGroteskDSStd-45Lt.otf deleted file mode 100644 index bddef9eb..00000000 Binary files a/MVMCoreUI/SupportingFiles/Fonts/NHaasGroteskDSStd-45Lt.otf and /dev/null differ diff --git a/MVMCoreUI/SupportingFiles/Fonts/NHaasGroteskDSStd-55Rg.otf b/MVMCoreUI/SupportingFiles/Fonts/NHaasGroteskDSStd-55Rg.otf deleted file mode 100644 index f56ed7aa..00000000 Binary files a/MVMCoreUI/SupportingFiles/Fonts/NHaasGroteskDSStd-55Rg.otf and /dev/null differ diff --git a/MVMCoreUI/SupportingFiles/Fonts/NHaasGroteskDSStd-75Bd.otf b/MVMCoreUI/SupportingFiles/Fonts/NHaasGroteskDSStd-75Bd.otf deleted file mode 100644 index fbcba354..00000000 Binary files a/MVMCoreUI/SupportingFiles/Fonts/NHaasGroteskDSStd-75Bd.otf and /dev/null differ diff --git a/MVMCoreUI/SupportingFiles/Fonts/VerizonNHGeDS-Bold.otf b/MVMCoreUI/SupportingFiles/Fonts/VerizonNHGeDS-Bold.otf new file mode 100755 index 00000000..dd3476af Binary files /dev/null and b/MVMCoreUI/SupportingFiles/Fonts/VerizonNHGeDS-Bold.otf differ diff --git a/MVMCoreUI/SupportingFiles/Fonts/VerizonNHGeDS-Regular.otf b/MVMCoreUI/SupportingFiles/Fonts/VerizonNHGeDS-Regular.otf new file mode 100755 index 00000000..ce34c596 Binary files /dev/null and b/MVMCoreUI/SupportingFiles/Fonts/VerizonNHGeDS-Regular.otf differ diff --git a/MVMCoreUI/SupportingFiles/Fonts/VerizonNHGeTX-Bold.otf b/MVMCoreUI/SupportingFiles/Fonts/VerizonNHGeTX-Bold.otf new file mode 100755 index 00000000..59b1f438 Binary files /dev/null and b/MVMCoreUI/SupportingFiles/Fonts/VerizonNHGeTX-Bold.otf differ diff --git a/MVMCoreUI/SupportingFiles/Fonts/VerizonNHGeTX-Regular.otf b/MVMCoreUI/SupportingFiles/Fonts/VerizonNHGeTX-Regular.otf new file mode 100755 index 00000000..13d202d1 Binary files /dev/null and b/MVMCoreUI/SupportingFiles/Fonts/VerizonNHGeTX-Regular.otf differ diff --git a/MVMCoreUI/Utility/MFFonts.h b/MVMCoreUI/Utility/MFFonts.h index 484e2c82..46947581 100644 --- a/MVMCoreUI/Utility/MFFonts.h +++ b/MVMCoreUI/Utility/MFFonts.h @@ -10,11 +10,24 @@ #import #import +extern NSString * _Nonnull const DSBold; +extern NSString * _Nonnull const DSRegular; +extern NSString * _Nonnull const TXBold; +extern NSString * _Nonnull const TXRegular; + @interface MFFonts : NSObject -+ (nullable UIFont *)mfFont75Bd:(CGFloat)size; -+ (nullable UIFont *)mfFont55Rg:(CGFloat)size; +//mva 3.0 font, should use MFStyler.getMVA3FontSize:bold: instead, in most case. ++ (nonnull UIFont *)mfFontDSBold:(CGFloat)size; ++ (nonnull UIFont *)mfFontDSRegular:(CGFloat)size; ++ (nonnull UIFont *)mfFontTXBold:(CGFloat)size; ++ (nonnull UIFont *)mfFontTXRegular:(CGFloat)size; + +///return mfFontTXBold when size smaller than 15, otherwise, return mfFontDSBold ++ (nonnull UIFont *)mfFont75Bd:(CGFloat)size; +///return mfFontTXRegular when size smaller than 15, otherwise, return mfFontDSRegular ++ (nonnull UIFont *)mfFont55Rg:(CGFloat)size; + (nullable UIFont *)mfFontOcratxt:(CGFloat)size; -+ (nullable UIFont *)mfFontWithName:(nonnull NSString *)name size:(CGFloat)size; ++ (nonnull UIFont *)mfFontWithName:(nonnull NSString *)name size:(CGFloat)size; @end diff --git a/MVMCoreUI/Utility/MFFonts.m b/MVMCoreUI/Utility/MFFonts.m index 65326e6c..0a73fb36 100644 --- a/MVMCoreUI/Utility/MFFonts.m +++ b/MVMCoreUI/Utility/MFFonts.m @@ -10,14 +10,23 @@ #import #import "MVMCoreUIUtility.h" @import MVMCore.MVMCoreLoggingHandler; +@import MVMCore.MVMCoreErrorConstants; + +NSString * const DSBold = @"VerizonNHGeDS-Bold"; +NSString * const DSRegular = @"VerizonNHGeDS-Regular"; +NSString * const TXBold = @"VerizonNHGeTX-Bold"; +NSString * const TXRegular = @"VerizonNHGeTX-Regular"; + @implementation MFFonts + (void)loadMVMFonts { static dispatch_once_t once; dispatch_once(&once, ^{ - [MFFonts loadFont:@"NHaasGroteskDSStd-75Bd" type:@"otf"]; - [MFFonts loadFont:@"NHaasGroteskDSStd-55Rg" type:@"otf"]; + [MFFonts loadFont:DSBold type:@"otf"]; + [MFFonts loadFont:DSRegular type:@"otf"]; + [MFFonts loadFont:TXBold type:@"otf"]; + [MFFonts loadFont:TXRegular type:@"otf"]; [MFFonts loadFont:@"OCRAExtended" type:@"ttf"]; }); } @@ -39,23 +48,70 @@ CFRelease(provider); } -+ (nullable UIFont *)mfFont75Bd:(CGFloat)size { - [self loadMVMFonts]; - return [UIFont fontWithName:@"NHaasGroteskDSStd-75Bd" size:size]; ++ (nonnull UIFont *)mfFontDSBold:(CGFloat)size { + UIFont *font = [UIFont fontWithName:DSBold size:size]; + [self validFont:font fontName:DSBold]; + return font ?: [UIFont boldSystemFontOfSize:size]; } -+ (nullable UIFont *)mfFont55Rg:(CGFloat)size { ++ (nonnull UIFont *)mfFontDSRegular:(CGFloat)size { + UIFont *font = [UIFont fontWithName:DSRegular size:size]; + [self validFont:font fontName:DSRegular]; + return font ?: [UIFont systemFontOfSize:size]; +} + ++ (nonnull UIFont *)mfFontTXBold:(CGFloat)size { + UIFont *font = [UIFont fontWithName:TXBold size:size]; + [self validFont:font fontName:TXBold]; + return font ?: [UIFont boldSystemFontOfSize:size]; +} + ++ (nonnull UIFont *)mfFontTXRegular:(CGFloat)size { + UIFont *font = [UIFont fontWithName:TXRegular size:size]; + [self validFont:font fontName:TXRegular]; + return font ?: [UIFont systemFontOfSize:size]; +} + + ++ (UIFont *)mfFont75Bd:(CGFloat)size { [self loadMVMFonts]; - return [UIFont fontWithName:@"NHaasGroteskDSStd-55Rg" size:size]; + UIFont *font; + if (size >= 15) { + font = [self mfFontDSBold:size]; + } else { + font = [self mfFontTXBold:size]; + } + return font; +} + ++ (UIFont *)mfFont55Rg:(CGFloat)size { + [self loadMVMFonts]; + UIFont *font; + if (size >= 15) { + font = [self mfFontDSRegular:size]; + } else { + font = [self mfFontTXRegular:size]; + } + return font; } + (nullable UIFont *)mfFontOcratxt:(CGFloat)size { [self loadMVMFonts]; - return [UIFont fontWithName:@"OCRAExtended" size:size]; + UIFont *font = [UIFont fontWithName:@"OCRAExtended" size:size]; + [self validFont:font fontName:@"OCRAExtended"]; + return font; } -+ (nullable UIFont *)mfFontWithName:(nonnull NSString *)name size:(CGFloat)size { - return [UIFont fontWithName:name size:size] ?: [self mfFont55Rg:size]; ++ (UIFont *)mfFontWithName:(nonnull NSString *)name size:(CGFloat)size { + UIFont *font = [UIFont fontWithName:name size:size]; + [self validFont:font fontName:name]; + return font ?: [self mfFont55Rg:size]; } ++ (void)validFont:(UIFont *)font fontName:(NSString *)fontName { + if (font == nil) { + MVMCoreErrorObject *errorObject = [[MVMCoreErrorObject alloc] initWithTitle:@"font can not load" message:[NSString stringWithFormat:@"missing font name is %@", fontName] code:ErrorCodeFontNotFound domain:ErrorDomainNative location:@"MFStyler"]; + [MVMCoreLoggingHandler addErrorToLog:errorObject]; + } +} @end diff --git a/MVMCoreUI/Utility/UIFont+FontWrapping.h b/MVMCoreUI/Utility/UIFont+FontWrapping.h new file mode 100644 index 00000000..0302e25e --- /dev/null +++ b/MVMCoreUI/Utility/UIFont+FontWrapping.h @@ -0,0 +1,20 @@ +// +// UIFont+FontWrapping.h +// MVMCoreUI +// +// Created by Ryan on 2/26/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface UIFont (FontWrapping) + +///if using mva3.0 font, should call this method to update font size. When size is bigger than 15 pt, using DS font family. Otherwise using TX font family +- (UIFont *)updateFontSize:(CGFloat)size; + +@end + +NS_ASSUME_NONNULL_END diff --git a/MVMCoreUI/Utility/UIFont+FontWrapping.m b/MVMCoreUI/Utility/UIFont+FontWrapping.m new file mode 100644 index 00000000..8eedbb01 --- /dev/null +++ b/MVMCoreUI/Utility/UIFont+FontWrapping.m @@ -0,0 +1,26 @@ +// +// UIFont+FontWrapping.m +// MVMCoreUI +// +// Created by Ryan on 2/26/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +#import "UIFont+FontWrapping.h" +#import "MFFonts.h" +#import "MFStyler.h" +#import + +@implementation UIFont (FontWrapping) + +- (UIFont *)updateFontSize:(CGFloat)size { + if ([self.familyName isEqualToString:@"Verizon NHG eDS"]) { + return [MFStyler getMVA3FontSize:size bold:[self.fontName isEqualToString:DSBold]]; + } else if ([self.familyName isEqualToString:@"Verizon NHG eTX"]) { + return [MFStyler getMVA3FontSize:size bold:[self.fontName isEqualToString:TXBold]]; + } else { + return [self fontWithSize:size]; + } +} + +@end