temporary dropdown molecule

label reuse font fixes
This commit is contained in:
Pfeil, Scott Robert 2019-11-27 13:49:01 -05:00
parent 1ec603e969
commit 63556707bc
11 changed files with 234 additions and 49 deletions

View File

@ -50,6 +50,8 @@
D260D7B122D65BDD007E7233 /* MVMCoreUIPageControl.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */; settings = {ATTRIBUTES = (Public, ); }; };
D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */; };
D260D7B622D68514007E7233 /* MVMCoreUIPagingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */; };
D268C712238D6699007F2C1C /* DropDown.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C711238D6699007F2C1C /* DropDown.swift */; };
D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D274CA322236A78900B01B62 /* StandardFooterView.swift */; };
D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2755D7A23689C7500485468 /* TableViewCell.swift */; };
D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */; };
@ -246,6 +248,8 @@
D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPageControl.h; sourceTree = "<group>"; };
D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIPageControl.m; sourceTree = "<group>"; };
D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPagingProtocol.h; sourceTree = "<group>"; };
D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DropDownFilterTableViewCell.swift; sourceTree = "<group>"; };
D268C711238D6699007F2C1C /* DropDown.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropDown.swift; sourceTree = "<group>"; };
D274CA322236A78900B01B62 /* StandardFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandardFooterView.swift; sourceTree = "<group>"; };
D2755D7A23689C7500485468 /* TableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableViewCell.swift; sourceTree = "<group>"; };
D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsTableViewCell.swift; sourceTree = "<group>"; };
@ -509,6 +513,7 @@
D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */,
D224799A231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift */,
D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */,
D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */,
);
path = Items;
sourceTree = "<group>";
@ -752,6 +757,7 @@
D29DF2AD21E7B3A4003B2FB9 /* MFTextView.h */,
D29DF2AB21E7B3A4003B2FB9 /* MFTextView.m */,
D29DF2AC21E7B3A4003B2FB9 /* MFTextView.xib */,
D268C711238D6699007F2C1C /* DropDown.swift */,
D29DF2B121E7B76C003B2FB9 /* MFLoadingSpinner.h */,
D29DF2B221E7B76D003B2FB9 /* MFLoadingSpinner.m */,
D29DF32321ED0DA2003B2FB9 /* TextButtonView.h */,
@ -1071,6 +1077,7 @@
D224799B231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift in Sources */,
D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */,
01004F3022721C3800991ECC /* RadioButton.swift in Sources */,
D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */,
D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */,
D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */,
D29DF25321E6A177003B2FB9 /* MFDigitTextField.m in Sources */,
@ -1154,6 +1161,7 @@
D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */,
DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */,
0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */,
D268C712238D6699007F2C1C /* DropDown.swift in Sources */,
0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */,
D29DF13221E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m in Sources */,
D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */,

View File

@ -74,6 +74,7 @@
//default error message
@property (nullable, strong, nonatomic) NSString *errMessage;
@property (nullable, strong, nonatomic) IBOutlet NSLayoutConstraint *errorHeightConstraint;
@property (nullable, copy, nonatomic) void (^editCompleteAction)(NSString * _Nullable text);

View File

@ -558,6 +558,7 @@
#pragma mark - MVMCoreUIMoleculeViewProtocol
- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
[super setWithJSON:json delegateObject:delegateObject additionalData:additionalData];
if ([delegateObject isKindOfClass:[MVMCoreUIDelegateObject class]]) {
[FormValidator setupValidationWithMolecule:self delegate:delegateObject.formValidationProtocol];
FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:delegateObject.formValidationProtocol];

View File

@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15510"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@ -15,6 +13,7 @@
<outlet property="dashLine" destination="hw1-Eo-Szn" id="WCs-FF-LCg"/>
<outlet property="dropDownCarrotLabel" destination="XuL-hz-X9C" id="Kv1-Pd-Kra"/>
<outlet property="dropDownCarrotWidth" destination="DJA-00-1ne" id="SHb-1H-EZD"/>
<outlet property="errorHeightConstraint" destination="r34-xP-jcf" id="jno-7u-oKU"/>
<outlet property="errorLableLeftPin" destination="8pf-sH-2Ct" id="nhS-H8-RKZ"/>
<outlet property="errorLableRightPin" destination="I5y-Go-vVq" id="TN8-Bi-GEP"/>
<outlet property="formLabel" destination="8zH-YN-qag" id="him-Et-eoN"/>

View File

@ -0,0 +1,55 @@
//
// DropDown.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 11/26/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import UIKit
@objcMembers public class DropDown: MFTextField {
let picker = MVMCoreUICommonViewsUtility.commonPickerView()!
public override func getNib() -> UINib? {
return UINib(nibName: String(describing: MFTextField.self), bundle: MVMCoreUIUtility.bundleForMVMCoreUI())
}
public override func setupView() {
super.setupView()
dropDownCarrotWidth?.isActive = false
errorHeightConstraint?.constant = 0
}
override public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
guard let textField = textField, textField.inputView == nil else { return }
picker.delegate = self
picker.dataSource = self
picker.tag = textField.tag
textField.inputView = picker
picker.reloadAllComponents()
MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: delegateObject?.uiTextFieldDelegate)
textField.text = json?.stringWithChainOfKeysOrIndexes([KeyValue,picker.selectedRow(inComponent: 0)])
}
}
extension DropDown: UIPickerViewDelegate {
public func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return json?.stringWithChainOfKeysOrIndexes([KeyValue,row])
}
public func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
textField?.text = json?.stringWithChainOfKeysOrIndexes([KeyValue,row])
}
}
extension DropDown: UIPickerViewDataSource {
public func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
public func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return json?.optionalArrayForKey(KeyValue)?.count ?? 0
}
}

View File

@ -212,9 +212,12 @@ public typealias ActionBlock = () -> ()
}
@objc public static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: DelegateObject?, additionalData: [AnyHashable: Any]?) {
guard let label = label else { return }
label.attributedText = nil
// Some properties can only be set on Label.
// Label fonts should not be scaled because it will be scaled in updateView.
let mvmLabel = label as? Label
label.text = json?.optionalStringForKey(KeyText)
setLabel(label, withHTML: json?.optionalStringForKey("html"))
@ -230,9 +233,7 @@ public typealias ActionBlock = () -> ()
}
}
if let wholeViewIsClickable = json?.boolForKey("makeWholeViewClickable") {
(label as? Label)?.makeWholeViewClickable = wholeViewIsClickable
}
mvmLabel?.makeWholeViewClickable = json?.boolForKey("makeWholeViewClickable") ?? false
if let backgroundColorHex = json?.optionalStringForKey(KeyBackgroundColor), !backgroundColorHex.isEmpty {
label.backgroundColor = UIColor.mfGet(forHex: backgroundColorHex)
@ -241,12 +242,12 @@ public typealias ActionBlock = () -> ()
label.accessibilityLabel = json?.optionalStringForKey("accessibilityText")
if let fontStyle = json?.optionalStringForKey("fontStyle") {
MFStyler.styleLabel(label, withStyle: fontStyle)
MFStyler.styleLabel(label, withStyle: fontStyle, genericScaling: mvmLabel == nil)
} else {
let fontSize = json?["fontSize"] as? CGFloat
if let fontName = json?.optionalStringForKey("fontName") {
label.font = MFFonts.mfFont(withName: fontName, size: fontSize ?? label.font.pointSize)
label.font = MFFonts.mfFont(withName: fontName, size: fontSize ?? mvmLabel?.standardFontSize ?? label.font.pointSize)
} else if let fontSize = fontSize {
label.font = label.font.withSize(fontSize)
}
@ -256,8 +257,8 @@ public typealias ActionBlock = () -> ()
label.textColor = UIColor.mfGet(forHex: textColorHex)
}
if let attributes = json?.arrayForKey("attributes"), let labelText = label.text {
let attributedString = NSMutableAttributedString(string: labelText, attributes: [NSAttributedString.Key.font: label.font as UIFont,
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,
NSAttributedString.Key.foregroundColor: label.textColor as UIColor])
for case let attribute as [String: Any] in attributes {
guard let attributeType = attribute.optionalStringForKey(KeyType),
@ -298,7 +299,7 @@ public typealias ActionBlock = () -> ()
case "font":
if let fontStyle = attribute.optionalStringForKey("style") {
let styles = MFStyler.styleGetAttributedString("0", withStyle: fontStyle)
let styles = MFStyler.styleGetAttributedString("0", withStyle: fontStyle, genericScaling: mvmLabel == nil)
attributedString.removeAttribute(.font, range: range)
attributedString.removeAttribute(.foregroundColor, range: range)
attributedString.addAttributes(styles.attributes(at: 0, effectiveRange: nil), range: range)
@ -307,7 +308,7 @@ public typealias ActionBlock = () -> ()
var font: UIFont?
if let fontName = attribute.optionalStringForKey("name") {
font = MFFonts.mfFont(withName: fontName, size: fontSize ?? label.font.pointSize)
font = MFFonts.mfFont(withName: fontName, size: fontSize ?? mvmLabel?.standardFontSize ?? label.font.pointSize)
} else if let fontSize = fontSize {
font = label.font.withSize(fontSize)
}
@ -330,6 +331,7 @@ public typealias ActionBlock = () -> ()
}
}
label.attributedText = attributedString
mvmLabel?.originalAttributedString = attributedString
}
}
@ -419,7 +421,7 @@ public typealias ActionBlock = () -> ()
if let floatScale = scaleSize?.floatValue {
updateView(CGFloat(floatScale))
} else {
updateView(MVMCoreUISplitViewController.getApplicationViewWidth())
updateView(MVMCoreUIUtility.getWidth())
}
} else {
standardFontSize = 0
@ -581,8 +583,6 @@ extension Label {
@objc public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
clauses = []
Label.setUILabel(self, withJSON: json, delegate: delegateObject, additionalData: additionalData)
originalAttributedString = attributedText
hero = json?["hero"] as? Int
}

View File

@ -357,7 +357,6 @@
if (!self.constrainedView) {
[super setWithJSON:json delegateObject:delegateObject additionalData:additionalData];
}
[self.molecule setWithJSON:json delegateObject:delegateObject additionalData:additionalData];
if (self.shouldSetupMoleculeFromJSON) {
NSDictionary *moleculeJSON = [json dict:KeyMolecule];
if (self.molecule) {

View File

@ -0,0 +1,70 @@
//
// DropDownFilterTableViewCell.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 9/6/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import UIKit
@objcMembers public class DropDownFilterTableViewCell: TableViewCell {
let dropDown = DropDown(forDropDownWithBothDelegates: nil)
var delegateObject: MVMCoreUIDelegateObject?
var previousIndex = NSNotFound
var dropDownSelectionObservation: NSKeyValueObservation?
// MARK: - MFViewProtocol
override public func setupView() {
super.setupView()
guard let dropDown = dropDown, dropDown.superview == nil else {
return
}
bottomMarginPadding = 0
dropDown.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(dropDown)
NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: dropDown, useMargins: true).values))
#warning("Once we have the state manager, we will need to change this logic to only add or remove on user selection...Want to avoid re-use crashes from array size differences")
dropDownSelectionObservation = observe(
\.dropDown?.textField?.text,
options: [.old, .new]
) { [weak self] object, change in
guard change.newValue != change.oldValue, let self = self,
let options = self.dropDown?.json?.optionalArrayForKey(KeyValue) as? [NSString],
let index = options.firstIndex(of: change.newValue!! as NSString),
let moleculesArrays = self.json?.arrayForKey(KeyMolecules) as? [[[AnyHashable: Any]]] else { return }
if self.previousIndex != NSNotFound {
let previousMolecules = moleculesArrays[self.previousIndex]
self.delegateObject?.moleculeDelegate?.removeMolecules?(previousMolecules, sender: self, animation: .fade)
}
let molecules = moleculesArrays[index]
self.delegateObject?.moleculeDelegate?.addMolecules?(molecules, sender: self, animation: .fade)
self.previousIndex = index
}
}
public override func updateView(_ size: CGFloat) {
super.updateView(size)
dropDown?.updateView(size)
}
// MARK: - MoleculeDelegateProtocol
public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
bottomSeparatorView?.style = .none
self.delegateObject = delegateObject
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
dropDown?.mfTextFieldDelegate = delegateObject?.uiTextFieldDelegate as? MFTextFieldDelegate
dropDown?.uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate
dropDown?.setWithJSON(json?.optionalDictionaryForKey("dropDown"), delegateObject: delegateObject, additionalData: additionalData)
}
public override func reset() {
super.reset()
bottomMarginPadding = 0
bottomSeparatorView?.style = .none
}
}

View File

@ -35,10 +35,11 @@
@"footer": StandardFooterView.class,
@"caretView": CaretView.class,
@"caretButton": CaretButton.class,
@"textField" : MFTextField.class,
@"digitTextField" : MFDigitTextField.class,
@"checkbox" : Checkbox.class,
@"checkboxWithLabel" : CheckboxWithLabelView.class,
@"textField": MFTextField.class,
@"dropDown": DropDown.class,
@"digitTextField": MFDigitTextField.class,
@"checkbox": Checkbox.class,
@"checkboxWithLabel": CheckboxWithLabelView.class,
@"cornerLabels" : CornerLabels.class,
@"progressbar": ProgressBar.class,
@"circleProgress": GraphView.class,
@ -63,6 +64,7 @@
@"headlineBodyTextButton": HeadlineBodyTextButton.class,
@"headlineBodyTextButtonSwitch": HeadlineBodyTextButtonSwitch.class,
@"tabsListItem": TabsTableViewCell.class,
@"dropDownListItem": DropDownFilterTableViewCell.class,
@"headlineBodyButton": HeadlineBodyButton.class,
@"eyebrowHeadlineBodyLink": EyebrowHeadlineBodyLink.class
} mutableCopy];

View File

@ -210,6 +210,7 @@ B3 -> Legal
/// Will style the label based on the string. Accepted values, 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;
@ -258,6 +259,7 @@ B3 -> Legal
/// Will style the string based on the string. Accepted values, H1, H2, H3, H32, B1, B2, B3, B20
+ (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style;
+ (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling;
+ (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string font:(nonnull UIFont *)font color:(nonnull UIColor *)color;
+ (nonnull NSAttributedString *)styleGetH1AttributedString:(nullable NSString *)string;
@ -266,6 +268,14 @@ B3 -> Legal
+ (nonnull NSAttributedString *)styleGetB1AttributedString:(nullable NSString *)string;
+ (nonnull NSAttributedString *)styleGetB2AttributedString:(nullable NSString *)string;
+ (nonnull NSAttributedString *)styleGetB3AttributedString:(nullable NSString *)string;
+ (nonnull NSAttributedString *)styleGetH1AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling;
+ (nonnull NSAttributedString *)styleGetH2AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling;
+ (nonnull NSAttributedString *)styleGetH3AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling;
+ (nonnull NSAttributedString *)styleGetH32AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling;
+ (nonnull NSAttributedString *)styleGetB1AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling;
+ (nonnull NSAttributedString *)styleGetB2AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling;
+ (nonnull NSAttributedString *)styleGetB3AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling;
+ (nonnull NSAttributedString *)styleGetB20AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling;
+ (nonnull NSAttributedString *)styleGetDisabledB2AttributedString:(nullable NSString *)string;
+ (nonnull NSAttributedString *)styleGetDisabledB1AttributedString:(nullable NSString *)string;

View File

@ -516,26 +516,30 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
#pragma mark - 2.0 Styles
+ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style {
+ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling {
if ([style isEqualToString:@"H1"]) {
[self styleLabelH1:label];
[self styleLabelH1:label genericScaling:genericScaling];
} else if ([style isEqualToString:@"H2"]) {
[self styleLabelH2:label];
[self styleLabelH2:label genericScaling:genericScaling];
} else if ([style isEqualToString:@"H3"]) {
[self styleLabelH3:label];
[self styleLabelH3:label genericScaling:genericScaling];
} else if ([style isEqualToString:@"H32"]) {
[self styleLabelH32:label];
[self styleLabelH32:label genericScaling:genericScaling];
} else if ([style isEqualToString:@"B1"]) {
[self styleLabelB1:label];
[self styleLabelB1:label genericScaling:genericScaling];
} else if ([style isEqualToString:@"B3"]) {
[self styleLabelB3:label];
[self styleLabelB3:label genericScaling:genericScaling];
} else if ([style isEqualToString:@"B20"]) {
[self styleLabelB20:label];
[self styleLabelB20:label genericScaling:genericScaling];
} else {
[self styleLabelB2:label];
[self styleLabelB2:label genericScaling:genericScaling];
}
}
+ (void)styleLabel:(nonnull UILabel *)label withStyle:(nullable NSString *)style {
[self styleLabel:label withStyle:style genericScaling:YES];
}
+ (void)styleLabelH1:(nonnull UILabel *)label genericScaling:(BOOL)genericScaling {
label.font = [MFStyler fontH1:genericScaling];
label.textColor = [UIColor blackColor];
@ -656,22 +660,26 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
#pragma mark - Attributed Strings
+ (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style {
return [self styleGetAttributedString:string withStyle:style genericScaling:YES];
}
+ (nonnull NSAttributedString *)styleGetAttributedString:(nullable NSString *)string withStyle:(nullable NSString *)style genericScaling:(BOOL)genericScaling {
if ([style isEqualToString:@"H1"]) {
return [self styleGetH1AttributedString:string];
return [self styleGetH1AttributedString:string genericScaling:genericScaling];
} else if ([style isEqualToString:@"H2"]) {
return [self styleGetH2AttributedString:string];
return [self styleGetH2AttributedString:string genericScaling:genericScaling];
} else if ([style isEqualToString:@"H3"]) {
return [self styleGetH3AttributedString:string];
return [self styleGetH3AttributedString:string genericScaling:genericScaling];
} else if ([style isEqualToString:@"H32"]) {
return [self styleGetH32AttributedString:string];
return [self styleGetH32AttributedString:string genericScaling:genericScaling];
} else if ([style isEqualToString:@"B1"]) {
return [self styleGetB1AttributedString:string];
return [self styleGetB1AttributedString:string genericScaling:genericScaling];
} else if ([style isEqualToString:@"B3"]) {
return [self styleGetB3AttributedString:string];
return [self styleGetB3AttributedString:string genericScaling:genericScaling];
} else if ([style isEqualToString:@"B20"]) {
return [self styleGetB20AttributedString:string];
return [self styleGetB20AttributedString:string genericScaling:genericScaling];
} else {
return [self styleGetB2AttributedString:string];
return [self styleGetB2AttributedString:string genericScaling:genericScaling];
}
}
@ -690,35 +698,67 @@ CGFloat const LabelWithInternalButtonLineSpace = 2;
}
+ (nonnull NSAttributedString *)styleGetH1AttributedString:(nullable NSString *)string {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontH1] color:[UIColor blackColor]];
return [MFStyler styleGetH1AttributedString:string genericScaling:YES];
}
+ (nonnull NSAttributedString *)styleGetH1AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontH1:genericScaling] color:[UIColor blackColor]];
}
+ (nonnull NSAttributedString *)styleGetH2AttributedString:(nullable NSString *)string {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontH2] color:[UIColor blackColor]];
return [MFStyler styleGetH2AttributedString:string genericScaling:YES];
}
+ (nonnull NSAttributedString *)styleGetH2AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontH2:genericScaling] color:[UIColor blackColor]];
}
+ (nonnull NSAttributedString *)styleGetH3AttributedString:(nullable NSString *)string {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontH3] color:[UIColor blackColor]];
return [MFStyler styleGetH3AttributedString:string genericScaling:YES];
}
+ (nonnull NSAttributedString *)styleGetH3AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontH3:genericScaling] color:[UIColor blackColor]];
}
+ (nonnull NSAttributedString *)styleGetH32AttributedString:(nullable NSString *)string {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontH32] color:[UIColor blackColor]];
return [MFStyler styleGetH32AttributedString:string genericScaling:YES];
}
+ (nonnull NSAttributedString *)styleGetH32AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontH32:genericScaling] color:[UIColor blackColor]];
}
+ (nonnull NSAttributedString *)styleGetB1AttributedString:(nullable NSString *)string {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontB1] color:[UIColor blackColor]];
return [MFStyler styleGetB1AttributedString:string genericScaling:YES];
}
+ (nonnull NSAttributedString *)styleGetB1AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontB1:genericScaling] color:[UIColor blackColor]];
}
+ (nonnull NSAttributedString *)styleGetB2AttributedString:(nullable NSString *)string {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontB2] color:[UIColor blackColor]];
return [MFStyler styleGetB2AttributedString:string genericScaling:YES];
}
+ (nonnull NSAttributedString *)styleGetB2AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontB2:genericScaling] color:[UIColor blackColor]];
}
+ (nonnull NSAttributedString *)styleGetB3AttributedString:(nullable NSString *)string {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontB3] color:[UIColor mfBattleshipGrey]];
return [MFStyler styleGetB3AttributedString:string genericScaling:YES];
}
+ (nonnull NSAttributedString *)styleGetB3AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontB3:genericScaling] color:[UIColor mfBattleshipGrey]];
}
+ (nonnull NSAttributedString *)styleGetB20AttributedString:(nullable NSString *)string {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontB20] color:[UIColor blackColor]];
return [MFStyler styleGetB20AttributedString:string genericScaling:YES];
}
+ (nonnull NSAttributedString *)styleGetB20AttributedString:(nullable NSString *)string genericScaling:(BOOL)genericScaling {
return [MFStyler styleGetAttributedString:string font:[MFStyler fontB20:genericScaling] color:[UIColor blackColor]];
}
+ (nonnull NSAttributedString *)styleGetDisabledB1AttributedString:(nullable NSString *)string {