Changes made to satisfy update to MFLabel.
This commit is contained in:
parent
ac0e200321
commit
edde99cc23
@ -157,10 +157,10 @@
|
||||
D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */; };
|
||||
D2C5001D21F8EE67001DA659 /* LabelWithInternalButton.h in Headers */ = {isa = PBXBuildFile; fileRef = D2C5001B21F8EE66001DA659 /* LabelWithInternalButton.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D2C5001E21F8EE67001DA659 /* LabelWithInternalButton.m in Sources */ = {isa = PBXBuildFile; fileRef = D2C5001C21F8EE66001DA659 /* LabelWithInternalButton.m */; };
|
||||
DB891E832253FA8500022516 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB891E822253FA8500022516 /* Label.swift */; };
|
||||
DBC4391822442197001AB423 /* CaretView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391622442196001AB423 /* CaretView.swift */; };
|
||||
DBC4391922442197001AB423 /* DashLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391722442197001AB423 /* DashLine.swift */; };
|
||||
DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391A224421A0001AB423 /* CaretButton.swift */; };
|
||||
DBEFFA04225A829700230692 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB891E822253FA8500022516 /* Label.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@ -886,6 +886,7 @@
|
||||
D29DF25421E6A177003B2FB9 /* MFMdnTextField.m in Sources */,
|
||||
D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */,
|
||||
D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */,
|
||||
DBEFFA04225A829700230692 /* Label.swift in Sources */,
|
||||
D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */,
|
||||
D28B4F8B21FF967C00712C7A /* MVMCoreUIObject.m in Sources */,
|
||||
D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */,
|
||||
@ -893,7 +894,6 @@
|
||||
D282AACB2243C61700C46919 /* ButtonView.swift in Sources */,
|
||||
0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */,
|
||||
D29DF2AE21E7B3A4003B2FB9 /* MFTextView.m in Sources */,
|
||||
DB891E832253FA8500022516 /* Label.swift in Sources */,
|
||||
D29DF18121E69E50003B2FB9 /* MFView.m in Sources */,
|
||||
D29DF18321E69E54003B2FB9 /* SeparatorView.m in Sources */,
|
||||
D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */,
|
||||
|
||||
@ -54,6 +54,7 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
// MARK: - Initialization
|
||||
//------------------------------------------------------
|
||||
@ -87,79 +88,18 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol {
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// MARK: - Functions
|
||||
// MARK: - Enum
|
||||
//------------------------------------------------------
|
||||
|
||||
func updateView(_ size: CGFloat) {
|
||||
|
||||
scaleSize = NSNumber(value: Float(size))
|
||||
|
||||
if let originalAttributedString = originalAttributedString {
|
||||
let attributedString = NSMutableAttributedString(attributedString: originalAttributedString)
|
||||
attributedString.removeAttribute(.font, range: NSRange(location: 0, length: attributedString.length))
|
||||
|
||||
originalAttributedString.enumerateAttribute(.font, in: NSRange(location: 0, length: originalAttributedString.length), options: [], using: { value, range, stop in
|
||||
// Loop the original attributed string, resize the fonts.
|
||||
let font: UIFont? = (value as? UIFont)?.withSize((MFStyler.sizeObjectGeneric(forCurrentDevice: ((value as? UIFont)?.pointSize)!)?.getValueBased(onSize: size))!)
|
||||
attributedString.addAttribute(.font, value: font as Any, range: range)
|
||||
})
|
||||
attributedText = attributedString
|
||||
|
||||
} else if !MVMCoreGetterUtility.fequal(a: Float(standardFontSize), b: 0.0) {
|
||||
var sizeObject: MFSizeObject? = self.sizeObject
|
||||
|
||||
if sizeObject == nil {
|
||||
sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: standardFontSize)
|
||||
}
|
||||
|
||||
self.font = self.font.withSize(sizeObject?.getValueBased(onSize: size) ?? 0.0)
|
||||
}
|
||||
}
|
||||
|
||||
func setFont(_ font: UIFont, scale: Bool) {
|
||||
self.font = font
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func setScale(_ scale: Bool) {
|
||||
if scale {
|
||||
standardFontSize = font.pointSize
|
||||
if let scaleSize = scaleSize {
|
||||
updateView(CGFloat(scaleSize.floatValue))
|
||||
} else {
|
||||
updateView(MVMCoreUISplitViewController.getApplicationViewWidth())
|
||||
}
|
||||
} else {
|
||||
standardFontSize = 0
|
||||
}
|
||||
}
|
||||
|
||||
class func label() -> Label {
|
||||
return Label(frame: CGRect.zero)
|
||||
}
|
||||
|
||||
enum Style {
|
||||
case commonLabelB2(scale: Bool)
|
||||
case commonLabelBody(size: CGFloat, scale: Bool)
|
||||
case commonLabelBodyBold(scale: Bool)
|
||||
case commonLabelBodyLighter(scale: Bool)
|
||||
case commonLabelBodyLarge(scale: Bool)
|
||||
case commonLabelH1(scale: Bool)
|
||||
case commonLabelH2(scale: Bool)
|
||||
case commonLabelHeadlineSmall(scale: Bool)
|
||||
case commonLabelHeadline(size: CGFloat, scale: Bool)
|
||||
case commonLabelHeadlineBlack(size: CGFloat, scale: Bool)
|
||||
case commonLabelH32(scale: Bool)
|
||||
case commonLabelH3(scale: Bool)
|
||||
case commonLabelSubheadBold(scale: Bool)
|
||||
case commonLabelSubheadBoldLarge(scale: Bool)
|
||||
case commonLabelB3(scale: Bool)
|
||||
case commonLabelFeedMessage(scale: Bool)
|
||||
case commonLabelFeedSubMessage(scale: Bool)
|
||||
case commonLabelFeedHeadline(scale: Bool)
|
||||
case commonLabelFeedTitle(scale: Bool)
|
||||
case commonLabelPlanCardTitle(scale: Bool)
|
||||
case commonLabelB20(scale: Bool)
|
||||
case commonLabelB1(scale: Bool)
|
||||
case commonLabelTopAlert(scale: Bool)
|
||||
|
||||
func createLabel() -> Label {
|
||||
|
||||
@ -169,65 +109,26 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol {
|
||||
case .commonLabelB2(let scale):
|
||||
label.styleB2(scale)
|
||||
|
||||
case .commonLabelBody(let size, let scale):
|
||||
label.styleBody(withSize: size, scale: scale)
|
||||
|
||||
case .commonLabelBodyBold(let scale):
|
||||
label.styleBodyBold(scale)
|
||||
|
||||
case .commonLabelBodyLighter(let scale):
|
||||
label.styleBodyLighter(scale)
|
||||
|
||||
case .commonLabelBodyLarge(let scale):
|
||||
label.styleBodyLarge(scale)
|
||||
|
||||
case .commonLabelH1(let scale):
|
||||
label.styleH1(scale)
|
||||
|
||||
case .commonLabelH2(let scale):
|
||||
label.styleH2(scale)
|
||||
|
||||
case .commonLabelHeadlineSmall(let scale):
|
||||
label.styleHeadlineSmall(scale)
|
||||
|
||||
case .commonLabelHeadline(let size, let scale):
|
||||
label.styleHeadline(withSize: size, scale: scale)
|
||||
|
||||
case .commonLabelHeadlineBlack(let size, let scale):
|
||||
label.styleHeadlineBlack(withSize: size, scale: scale)
|
||||
case .commonLabelH32(let scale):
|
||||
label.styleH32(scale)
|
||||
|
||||
case .commonLabelH3(let scale):
|
||||
label.styleH3(scale)
|
||||
|
||||
case .commonLabelSubheadBold(let scale):
|
||||
label.styleSubheadBold(scale)
|
||||
|
||||
case .commonLabelSubheadBoldLarge(let scale):
|
||||
label.styleSubheadBoldLarge(scale)
|
||||
|
||||
case .commonLabelB3(let scale):
|
||||
label.styleB3(scale)
|
||||
|
||||
case .commonLabelFeedMessage(let scale):
|
||||
label.styleFeedMessage(scale)
|
||||
|
||||
case .commonLabelFeedSubMessage(let scale):
|
||||
label.styleFeedSubMessage(scale)
|
||||
|
||||
case .commonLabelFeedHeadline(let scale):
|
||||
label.styleFeedHeadline(scale)
|
||||
|
||||
case .commonLabelFeedTitle(let scale):
|
||||
label.styleFeedTitle(scale)
|
||||
|
||||
case .commonLabelPlanCardTitle(let scale):
|
||||
label.stylePlanCardTitle(scale)
|
||||
case .commonLabelB20(let scale):
|
||||
label.styleB20(scale)
|
||||
|
||||
case .commonLabelB1(let scale):
|
||||
label.styleB1(scale)
|
||||
|
||||
case .commonLabelTopAlert(let scale):
|
||||
label.styleTopAlert(scale)
|
||||
}
|
||||
|
||||
return label
|
||||
@ -235,130 +136,14 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol {
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// MARK: - Methods
|
||||
// MARK: - Functions
|
||||
//------------------------------------------------------
|
||||
|
||||
func styleB2(_ scale: Bool) {
|
||||
MFStyler.styleLabelB2(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
static func label() -> Label {
|
||||
return Label(frame: CGRect.zero)
|
||||
}
|
||||
|
||||
func styleBody(withSize size: CGFloat, scale: Bool) {
|
||||
MFStyler.styleLabelB2(self, size: size, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleBodyBold(_ scale: Bool) {
|
||||
MFStyler.styleLabelBodyBold(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleBodyLighter(_ scale: Bool) {
|
||||
MFStyler.styleLabelBodyLighter(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleBodyLarge(_ scale: Bool) {
|
||||
MFStyler.styleLabelBodyLarge(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleH1(_ scale: Bool) {
|
||||
MFStyler.styleLabelH1(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleH2(_ scale: Bool) {
|
||||
MFStyler.styleLabelH2(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleHeadlineLarge(_ scale: Bool) {
|
||||
MFStyler.styleLabelHeadlineLarge(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleHeadlineSmall(_ scale: Bool) {
|
||||
MFStyler.styleLabelHeadlineSmall(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleHeadline(withSize size: CGFloat, scale: Bool) {
|
||||
MFStyler.styleLabelH2(self, size: size, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleHeadlineBlack(withSize size: CGFloat, scale: Bool) {
|
||||
MFStyler.styleLabelHeadlineBlack(self, size: size, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleH3(_ scale: Bool) {
|
||||
MFStyler.styleLabelH3(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleSubheadBold(_ scale: Bool) {
|
||||
MFStyler.styleLabelSubheadBold(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleSubheadBoldLarge(_ scale: Bool) {
|
||||
MFStyler.styleLabelSubheadBoldLarge(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleB3(_ scale: Bool) {
|
||||
MFStyler.styleLabelB3(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleFeedMessage(_ scale: Bool) {
|
||||
MFStyler.styleLabelFeedMessage(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleFeedSubMessage(_ scale: Bool) {
|
||||
MFStyler.styleLabelFeedSubMessage(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleFeedHeadline(_ scale: Bool) {
|
||||
MFStyler.styleLabelHeadlineFeed(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleFeedTitle(_ scale: Bool) {
|
||||
MFStyler.styleFeedCardTitleLabel(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func stylePlanCardTitle(_ scale: Bool) {
|
||||
font = MFStyler.font(forPlanCardTitle: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleB1(_ scale: Bool) {
|
||||
MFStyler.styleLabelB1(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleTableRow(_ scale: Bool) {
|
||||
MFStyler.styleLabelB1(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleTopAlert(_ scale: Bool) {
|
||||
font = MFStyler.fontB1(false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func setFontH1(_ scale: Bool) {
|
||||
font = MFStyler.fontH1(false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
class func setLabel(_ label: UILabel?, withHTML html: String?) {
|
||||
static func setLabel(_ label: UILabel?, withHTML html: String?) {
|
||||
let data: Data? = html?.data(using: .utf8)
|
||||
if data != nil {
|
||||
let error: Error? = nil
|
||||
@ -366,6 +151,10 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol {
|
||||
label?.attributedText = try? NSAttributedString(data: data,
|
||||
options: [NSAttributedString.DocumentReadingOptionKey.documentType:NSAttributedString.DocumentType.html, NSAttributedString.DocumentReadingOptionKey.characterEncoding: String.Encoding.utf8.rawValue],
|
||||
documentAttributes: nil)
|
||||
|
||||
// label?.attributedText = try? NSAttributedString(data: data, options: [
|
||||
// NSAttributedString.DocumentAttributeKey.documentType: NSAttributedString.DocumentType.html.rawValue
|
||||
// ], documentAttributes: nil)
|
||||
}
|
||||
if let labelError = error {
|
||||
try? MVMCoreUILoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject.createErrorObject(for: labelError, location: "LabelHTMLParse")!)
|
||||
@ -373,7 +162,7 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
class func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) {
|
||||
static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) {
|
||||
|
||||
if let label = label {
|
||||
label.text = json?.optionalStringForKey(KeyText)
|
||||
@ -441,6 +230,94 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// MARK: - Methods
|
||||
//------------------------------------------------------
|
||||
|
||||
func styleH1(_ scale: Bool) {
|
||||
MFStyler.styleLabelH1(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleH2(_ scale: Bool) {
|
||||
MFStyler.styleLabelH2(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleH3(_ scale: Bool) {
|
||||
MFStyler.styleLabelH3(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleH32(_ scale: Bool) {
|
||||
MFStyler.styleLabelH32(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleB1(_ scale: Bool) {
|
||||
MFStyler.styleLabelB1(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleB2(_ scale: Bool) {
|
||||
MFStyler.styleLabelB2(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleB3(_ scale: Bool) {
|
||||
MFStyler.styleLabelB3(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func styleB20(_ scale: Bool) {
|
||||
MFStyler.styleLabelB20(self, genericScaling: false)
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func updateView(_ size: CGFloat) {
|
||||
|
||||
scaleSize = NSNumber(value: Float(size))
|
||||
|
||||
if let originalAttributedString = originalAttributedString {
|
||||
let attributedString = NSMutableAttributedString(attributedString: originalAttributedString)
|
||||
attributedString.removeAttribute(.font, range: NSRange(location: 0, length: attributedString.length))
|
||||
|
||||
originalAttributedString.enumerateAttribute(.font, in: NSRange(location: 0, length: originalAttributedString.length), options: [], using: { value, range, stop in
|
||||
// Loop the original attributed string, resize the fonts.
|
||||
let font: UIFont? = (value as? UIFont)?.withSize((MFStyler.sizeObjectGeneric(forCurrentDevice: ((value as? UIFont)?.pointSize)!)?.getValueBased(onSize: size))!)
|
||||
attributedString.addAttribute(.font, value: font as Any, range: range)
|
||||
})
|
||||
attributedText = attributedString
|
||||
|
||||
} else if !MVMCoreGetterUtility.fequal(a: Float(standardFontSize), b: 0.0) {
|
||||
var sizeObject: MFSizeObject? = self.sizeObject
|
||||
|
||||
if sizeObject == nil {
|
||||
sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: standardFontSize)
|
||||
}
|
||||
|
||||
self.font = self.font.withSize(sizeObject?.getValueBased(onSize: size) ?? 0.0)
|
||||
}
|
||||
}
|
||||
|
||||
func setFont(_ font: UIFont, scale: Bool) {
|
||||
self.font = font
|
||||
setScale(scale)
|
||||
}
|
||||
|
||||
func setScale(_ scale: Bool) {
|
||||
if scale {
|
||||
standardFontSize = font.pointSize
|
||||
if let scaleSize = scaleSize {
|
||||
updateView(CGFloat(scaleSize.floatValue))
|
||||
} else {
|
||||
updateView(MVMCoreUISplitViewController.getApplicationViewWidth())
|
||||
}
|
||||
} else {
|
||||
standardFontSize = 0
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// MARK: - Atomization
|
||||
//------------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user