Converted MFLabel (objc) to Label (Swift). Pulled LabelWithoutAccessibilityTraits from Mobilefirst module and converted it. Altered imports where needed.

This commit is contained in:
Christiano, Kevin 2019-04-15 16:50:35 -04:00
parent 71f1f499e0
commit da1f5a5703
19 changed files with 125 additions and 436 deletions

View File

@ -96,8 +96,6 @@
D29DF28021E7AA51003B2FB9 /* MVMCoreUIDetailViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF27F21E7AA50003B2FB9 /* MVMCoreUIDetailViewProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28121E7AB23003B2FB9 /* MVMCoreUICommonViewsUtility.m */; };
D29DF28421E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF28221E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h */; settings = {ATTRIBUTES = (Public, ); }; };
D29DF28921E7AC2B003B2FB9 /* MFLabel.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF28521E7AC2B003B2FB9 /* MFLabel.h */; settings = {ATTRIBUTES = (Public, ); }; };
D29DF28A21E7AC2B003B2FB9 /* MFLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28621E7AC2B003B2FB9 /* MFLabel.m */; };
D29DF28B21E7AC2B003B2FB9 /* ViewConstrainingView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */; settings = {ATTRIBUTES = (Public, ); }; };
D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */; };
D29DF29521E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28D21E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m */; };
@ -161,6 +159,7 @@
DBC4391922442197001AB423 /* DashLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391722442197001AB423 /* DashLine.swift */; };
DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391A224421A0001AB423 /* CaretButton.swift */; };
DBC4392122491730001AB423 /* LabelWithInternalButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */; };
DBE3596E22651FCB00AB87F5 /* LabelWithoutAccessibilityTraits.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBE3596D22651FCB00AB87F5 /* LabelWithoutAccessibilityTraits.swift */; };
DBEFFA04225A829700230692 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB891E822253FA8500022516 /* Label.swift */; };
/* End PBXBuildFile section */
@ -263,8 +262,6 @@
D29DF27F21E7AA50003B2FB9 /* MVMCoreUIDetailViewProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIDetailViewProtocol.h; sourceTree = "<group>"; };
D29DF28121E7AB23003B2FB9 /* MVMCoreUICommonViewsUtility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUICommonViewsUtility.m; sourceTree = "<group>"; };
D29DF28221E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUICommonViewsUtility.h; sourceTree = "<group>"; };
D29DF28521E7AC2B003B2FB9 /* MFLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFLabel.h; sourceTree = "<group>"; };
D29DF28621E7AC2B003B2FB9 /* MFLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFLabel.m; sourceTree = "<group>"; };
D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewConstrainingView.h; sourceTree = "<group>"; };
D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewConstrainingView.m; sourceTree = "<group>"; };
D29DF28D21E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProgrammaticScrollViewController.m; sourceTree = "<group>"; };
@ -318,13 +315,12 @@
D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerViewController.swift; sourceTree = "<group>"; };
D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewControllerMappingObject.h; sourceTree = "<group>"; };
D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIViewControllerMappingObject.m; sourceTree = "<group>"; };
D2C5001B21F8EE66001DA659 /* LabelWithInternalButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LabelWithInternalButton.h; sourceTree = "<group>"; };
D2C5001C21F8EE66001DA659 /* LabelWithInternalButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LabelWithInternalButton.m; sourceTree = "<group>"; };
DB891E822253FA8500022516 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = "<group>"; };
DBC4391622442196001AB423 /* CaretView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretView.swift; sourceTree = "<group>"; };
DBC4391722442197001AB423 /* DashLine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DashLine.swift; sourceTree = "<group>"; };
DBC4391A224421A0001AB423 /* CaretButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretButton.swift; sourceTree = "<group>"; };
DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelWithInternalButton.swift; sourceTree = "<group>"; };
DBE3596D22651FCB00AB87F5 /* LabelWithoutAccessibilityTraits.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelWithoutAccessibilityTraits.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -566,8 +562,6 @@
DBC4391722442197001AB423 /* DashLine.swift */,
D29DF17E21E69E2E003B2FB9 /* MFView.h */,
D29DF17F21E69E2E003B2FB9 /* MFView.m */,
D29DF28521E7AC2B003B2FB9 /* MFLabel.h */,
D29DF28621E7AC2B003B2FB9 /* MFLabel.m */,
D29DF31E21ED0CBA003B2FB9 /* LabelView.h */,
D29DF31F21ED0CBA003B2FB9 /* LabelView.m */,
D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */,
@ -595,6 +589,7 @@
DB891E822253FA8500022516 /* Label.swift */,
0198F7A02256A80A0066C936 /* MFRadioButton.h */,
0198F7A22256A80A0066C936 /* MFRadioButton.m */,
DBE3596D22651FCB00AB87F5 /* LabelWithoutAccessibilityTraits.swift */,
);
path = Views;
sourceTree = "<group>";
@ -747,7 +742,6 @@
D29DF27521E79E81003B2FB9 /* MVMCoreUILoggingHandler.h in Headers */,
D29DF28B21E7AC2B003B2FB9 /* ViewConstrainingView.h in Headers */,
D29DF2B321E7B76D003B2FB9 /* MFLoadingSpinner.h in Headers */,
D29DF28921E7AC2B003B2FB9 /* MFLabel.h in Headers */,
D29DF32521ED0DA2003B2FB9 /* TextButtonView.h in Headers */,
D29DF25021E6A177003B2FB9 /* MFDigitTextBox.h in Headers */,
D29DF2C621E7BF57003B2FB9 /* MFTabBarInteractor.h in Headers */,
@ -906,7 +900,6 @@
D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */,
D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */,
D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */,
D29DF28A21E7AC2B003B2FB9 /* MFLabel.m in Sources */,
D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */,
D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */,
01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */,
@ -919,6 +912,7 @@
D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */,
D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */,
D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */,
DBE3596E22651FCB00AB87F5 /* LabelWithoutAccessibilityTraits.swift in Sources */,
0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */,
D29DF29821E7ADB8003B2FB9 /* MFScrollingViewController.m in Sources */,
D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */,

View File

@ -11,7 +11,7 @@
@class PrimaryButton;
@class MFTextField;
@class MFLabel;
@class Label;
@protocol MFTextFieldDelegate <NSObject>
@ -34,7 +34,7 @@
@property (nullable, weak, nonatomic) IBOutlet UIView *textFieldContainerView;
@property (nullable, weak, nonatomic) IBOutlet UITextField *textField;
@property (nullable, weak, nonatomic) IBOutlet MFLabel *formLabel;
@property (nullable, weak, nonatomic) IBOutlet Label *formLabel;
@property (nullable, weak, nonatomic) IBOutlet UIView *separatorView;//make it public so outsider class can know the posistion of it.
@property (nullable, weak, nonatomic) IBOutlet NSLayoutConstraint *heightConstraint;

View File

@ -7,12 +7,10 @@
//
#import "MFTextField.h"
#import <MVMCoreUI/MVMCoreUI-Swift.h>
#import "MFTextFieldSubclassExtension.h"
#import "MFStyler.h"
#import "UIColor+MFConvenience.h"
#import "MVMCoreUICommonViewsUtility.h"
#import "MFLabel.h"
#import "MVMCoreUIUtility.h"
#import "MVMCoreUIConstants.h"
#import <MVMCoreUI/MVMCoreUI-Swift.h>

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<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>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@ -98,7 +98,7 @@
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8zH-YN-qag" customClass="MFLabel">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8zH-YN-qag" customClass="Label" customModule="MVMCoreUI" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="320" height="36"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>

View File

@ -8,26 +8,25 @@
//
import MVMCore
import MVMCoreUI
class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol {
@objc open class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol {
//------------------------------------------------------
// MARK: - Properties
//------------------------------------------------------
// Set this property if you want updateView to update the font based on this standard and the size passed in.
var standardFontSize: CGFloat = 0.0
@objc public var standardFontSize: CGFloat = 0.0
// Set this to use a custom sizing object during updateView instead of the standard.
var sizeObject: MFSizeObject?
@objc public var sizeObject: MFSizeObject?
private var scaleSize: CGFloat?
@objc public var scaleSize: NSNumber?
// Used for scaling the font in updateView.
private var originalAttributedString: NSAttributedString?
override var accessibilityTraits: UIAccessibilityTraits {
override open var accessibilityTraits: UIAccessibilityTraits {
get {
return super.accessibilityTraits
}
@ -41,7 +40,7 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol {
}
}
var hasText: Bool {
@objc public var hasText: Bool {
guard let text = text, let attributedText = attributedText else { return false }
return !text.isEmpty || !attributedText.string.isEmpty
}
@ -50,29 +49,29 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol {
// MARK: - Initialization
//------------------------------------------------------
func setupView() {
@objc public func setupView() {
backgroundColor = .clear
numberOfLines = 0
lineBreakMode = .byWordWrapping
translatesAutoresizingMaskIntoConstraints = false
}
init() {
@objc public init() {
super.init(frame: .zero)
setupView()
}
required init?(coder: NSCoder) {
@objc required public init?(coder: NSCoder) {
super.init(coder: coder)
setupView()
}
override init(frame: CGRect) {
@objc override public init(frame: CGRect) {
super.init(frame: frame)
setupView()
}
convenience init(standardFontSize size: CGFloat) {
@objc convenience public init(standardFontSize size: CGFloat) {
self.init()
standardFontSize = size
}
@ -81,55 +80,55 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol {
// MARK: - Functions
//------------------------------------------------------
static func commonLabelH1(_ scale: Bool) -> Label {
@objc public static func commonLabelH1(_ scale: Bool) -> Label {
let label = Label.label()
label.styleH1(scale)
return label
}
static func commonLabelH2(_ scale: Bool) -> Label {
@objc public static func commonLabelH2(_ scale: Bool) -> Label {
let label = Label.label()
label.styleH2(scale)
return label
}
static func commonLabelH3(_ scale: Bool) -> Label {
@objc public static func commonLabelH3(_ scale: Bool) -> Label {
let label = Label.label()
label.styleH3(scale)
return label
}
static func commonLabelH32(_ scale: Bool) -> Label {
@objc public static func commonLabelH32(_ scale: Bool) -> Label {
let label = Label.label()
label.styleH32(scale)
return label
}
static func commonLabelB1(_ scale: Bool) -> Label {
@objc public static func commonLabelB1(_ scale: Bool) -> Label {
let label = Label.label()
label.styleB1(scale)
return label
}
static func commonLabelB2(_ scale: Bool) -> Label {
@objc public static func commonLabelB2(_ scale: Bool) -> Label {
let label = Label.label()
label.styleB2(scale)
return label
}
static func commonLabelB3(_ scale: Bool) -> Label {
@objc public static func commonLabelB3(_ scale: Bool) -> Label {
let label = Label.label()
label.styleB3(scale)
return label
}
static func commonLabelB20(_ scale: Bool) -> Label {
@objc public static func commonLabelB20(_ scale: Bool) -> Label {
let label = Label.label()
label.styleB20(scale)
return label
}
static func label() -> Label {
@objc open class func label() -> Label {
return Label(frame: CGRect.zero)
}
@ -137,13 +136,13 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol {
// MARK: - Functions
//------------------------------------------------------
static func setLabel(_ label: UILabel?, withHTML html: String?) {
@objc public static func setLabel(_ label: UILabel?, withHTML html: String?) {
guard let data = html?.data(using: .utf8) else { return }
do {
label?.attributedText = try NSAttributedString(data: data,
options: [NSAttributedString.DocumentReadingOptionKey.documentType:NSAttributedString.DocumentType.html, NSAttributedString.DocumentReadingOptionKey.characterEncoding: String.Encoding.utf8.rawValue],
options: [NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.html, NSAttributedString.DocumentReadingOptionKey.characterEncoding: String.Encoding.utf8.rawValue],
documentAttributes: nil)
} catch {
if let coreErrorObject = MVMCoreErrorObject.createErrorObject(for: error, location: "LabelHTMLParse") {
@ -152,7 +151,7 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol {
}
}
static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) {
@objc public static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) {
guard let label = label else { return }
@ -221,48 +220,48 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol {
// MARK: - Methods
//------------------------------------------------------
func styleH1(_ scale: Bool) {
@objc public func styleH1(_ scale: Bool) {
MFStyler.styleLabelH1(self, genericScaling: false)
setScale(scale)
}
func styleH2(_ scale: Bool) {
@objc public func styleH2(_ scale: Bool) {
MFStyler.styleLabelH2(self, genericScaling: false)
setScale(scale)
}
func styleH3(_ scale: Bool) {
@objc public func styleH3(_ scale: Bool) {
MFStyler.styleLabelH3(self, genericScaling: false)
setScale(scale)
}
func styleH32(_ scale: Bool) {
@objc public func styleH32(_ scale: Bool) {
MFStyler.styleLabelH32(self, genericScaling: false)
setScale(scale)
}
func styleB1(_ scale: Bool) {
@objc public func styleB1(_ scale: Bool) {
MFStyler.styleLabelB1(self, genericScaling: false)
setScale(scale)
}
func styleB2(_ scale: Bool) {
@objc public func styleB2(_ scale: Bool) {
MFStyler.styleLabelB2(self, genericScaling: false)
setScale(scale)
}
func styleB3(_ scale: Bool) {
@objc public func styleB3(_ scale: Bool) {
MFStyler.styleLabelB3(self, genericScaling: false)
setScale(scale)
}
func styleB20(_ scale: Bool) {
@objc public func styleB20(_ scale: Bool) {
MFStyler.styleLabelB20(self, genericScaling: false)
setScale(scale)
}
func updateView(_ size: CGFloat) {
scaleSize = size
@objc public func updateView(_ size: CGFloat) {
scaleSize = size as NSNumber
if let originalAttributedString = originalAttributedString {
let attributedString = NSMutableAttributedString(attributedString: originalAttributedString)
@ -280,15 +279,19 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol {
}
}
func setFont(_ font: UIFont, scale: Bool) {
@objc public func setFont(_ font: UIFont, scale: Bool) {
self.font = font
setScale(scale)
}
func setScale(_ scale: Bool) {
@objc public func setScale(_ scale: Bool) {
if scale {
standardFontSize = font.pointSize
updateView(scaleSize ?? MVMCoreUISplitViewController.getApplicationViewWidth())
if let floatScale = scaleSize?.floatValue {
updateView(CGFloat(floatScale))
} else {
updateView(MVMCoreUISplitViewController.getApplicationViewWidth())
}
} else {
standardFontSize = 0
}
@ -298,18 +301,32 @@ class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol {
// MARK: - Atomization
//------------------------------------------------------
func setAsMolecule() {
@objc public func setAsMolecule() {
originalAttributedString = attributedText
setupView()
}
func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) {
@objc public func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) {
Label.setUILabel(self, withJSON: json, delegate: delegate, additionalData: additionalData)
originalAttributedString = attributedText
guard let dictionary = json else { return }
// if let actionText = dictionary["actionText"] as? String {
// self.actionText = actionText
// }
/*
if let numberOfLinesCount = dictionary["numberOfLines"] as? Int {
numberOfLines = numberOfLinesCount
}
if let lineBreakModeValue = dictionary["lineBreakMode"] as? Int, let brakMode = NSLineBreakMode(rawValue: lineBreakModeValue) {
lineBreakMode = brakMode
}
0 byWordWrapping // Wrap at word boundaries, default
1 byCharWrapping // Wrap at character boundaries
2 byClipping // Simply clip
3 byTruncatingHead // Truncate at head of line: "...wxyz"
4 byTruncatingTail // Truncate at tail of line: "abcd..."
5 byTruncatingMiddle // Truncate middle of line: "ab...yz"
*/
}
}

View File

@ -8,12 +8,12 @@
#import <UIKit/UIKit.h>
#import <MVMCoreUI/ViewConstrainingView.h>
#import <MVMCoreUI/MFLabel.h>
@class Label;
@interface LabelView : ViewConstrainingView
// Customize the label.
@property (nullable, weak, nonatomic) MFLabel *label;
@property (nullable, weak, nonatomic) Label *label;
// Change the alignment of the label
- (void)alignLeft;

View File

@ -8,6 +8,7 @@
#import <MVMCoreUI/LabelView.h>
#import "MFStyler.h"
#import <MVMCoreUI/MVMCoreUI-Swift.h>
@interface LabelView ()
// Change to customize.
@ -32,7 +33,7 @@
if (!self.label) {
self.backgroundColor = [UIColor clearColor];
MFLabel *label = [MFLabel commonLabelB2:YES];
Label *label = [Label commonLabelB2:YES];
[self addSubview:label];
self.label = label;

View File

@ -22,7 +22,7 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt
//------------------------------------------------------
public var actionBlock: ActionBlock?
public weak var label: MFLabel?
public weak var label: Label?
public var attributedText: NSAttributedString? {
willSet(newAttributedText) {
@ -167,7 +167,7 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt
private func setup() {
if self.label == nil {
let label = MFLabel(frame: CGRect.zero)
let label = Label(frame: CGRect.zero)
backgroundColor = .clear
label.isUserInteractionEnabled = false

View File

@ -0,0 +1,35 @@
//
// MFLabelWithoutAccessibilityTraits.swift
// MobileFirstFramework
//
// Created by Gujuluva Santharam, Ajai Prabhu on 06/01/17.
// Converted by Christiano, Kevin on 4/15/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import MVMCoreUI
@objc open class LabelWithoutAccessibilityTraits: Label {
// Overriding accessibility traits setter to set none for this label
@objc override open var accessibilityTraits: UIAccessibilityTraits {
get {
return super.accessibilityTraits
}
set(accessibilityTraits) {
super.accessibilityTraits = .staticText
}
}
@objc override open class func label() -> LabelWithoutAccessibilityTraits {
let label = LabelWithoutAccessibilityTraits(frame: CGRect.zero)
label.translatesAutoresizingMaskIntoConstraints = false
label.backgroundColor = .clear
label.numberOfLines = 0
label.lineBreakMode = .byWordWrapping
return label
}
}

View File

@ -1,63 +0,0 @@
//
// MFLabel.h
// mobilefirst
//
// Created by Scott Pfeil on 3/22/17.
// Copyright © 2017 Verizon Wireless. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <MVMCoreUI/MFView.h>
@class MFSizeObject;
@interface MFLabel : UILabel <MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol>
- (nullable instancetype)initWithStandardFontSize:(CGFloat)size;
// Set this property if you want updateView to update the font based on this standard and the size passed in.
@property (nonatomic) CGFloat standardFontSize;
// Set this to use a custom sizing object during updateView instead of the standard.
@property (nonatomic, strong, nullable) MFSizeObject *sizeObject;
// Set the font and set to scale
- (void)setFont:(nonnull UIFont *)font scale:(BOOL)scale;
// Convenience checker for text or attributed text.
- (BOOL)hasText;
#pragma mark - 2.0
//75Bd 40pt
+ (nonnull MFLabel *)commonLabelH1:(BOOL)scale;
//75Bd 25pt
+ (nonnull MFLabel *)commonLabelH2:(BOOL)scale;
//75Bd 18pt
+ (nonnull MFLabel *)commonLabelH3:(BOOL)scale;
//75Bd 32pt
+ (nonnull MFLabel *)commonLabelH32:(BOOL)scale;
//75Bd 13pt
+ (nonnull MFLabel *)commonLabelB1:(BOOL)scale;
//55Rg 13pt
+ (nonnull MFLabel *)commonLabelB2:(BOOL)scale;
//55Rg 11pt gray
+ (nonnull MFLabel *)commonLabelB3:(BOOL)scale;
//55Rg 20pt
+ (nonnull MFLabel *)commonLabelB20:(BOOL)scale;
// Getters
+ (nonnull MFLabel *)label NS_SWIFT_NAME(commonLabel());
// Setters
+ (void)setLabel:(nullable UILabel *)label withHTML:(nullable NSString *)html;
+ (void)setUILabel:(nullable UILabel *)label withJSON:(nullable NSDictionary *)json delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData;
- (void)styleH1:(BOOL)scale;
- (void)styleH2:(BOOL)scale;
- (void)styleH3:(BOOL)scale;
- (void)styleH32:(BOOL)scale;
- (void)styleB1:(BOOL)scale;
- (void)styleB2:(BOOL)scale;
- (void)styleB3:(BOOL)scale;
- (void)styleB20:(BOOL)scale;
@end

View File

@ -1,291 +0,0 @@
//
// MFLabel.m
// mobilefirst
//
// Created by Scott Pfeil on 3/22/17.
// Copyright © 2017 Verizon Wireless. All rights reserved.
//
#import "MFLabel.h"
#import <MVMCoreUI/MFStyler.h>
#import <MVMCoreUI/MFSizeObject.h>
#import <MVMCoreUI/MVMCoreUIConstants.h>
#import "UIColor+MFConvenience.h"
#import "MFFonts.h"
#import "MVMCoreUISplitViewController.h"
#import "MVMCoreUILoggingHandler.h"
@import MVMCore.MVMCoreGetterUtility;
@import MVMCore.NSDictionary_MFConvenience;
@import MVMCore.MVMCoreJSONConstants;
@interface MFLabel ()
@property (strong, nonatomic) NSNumber *scaleSize;
// Used for scaling the font in updateView.
@property (strong, nonatomic) NSAttributedString *originalAttributedString;
@end
@implementation MFLabel
- (void)setupView {
self.backgroundColor = [UIColor clearColor];
self.numberOfLines = 0;
self.lineBreakMode = NSLineBreakByWordWrapping;
self.translatesAutoresizingMaskIntoConstraints = NO;
}
- (instancetype)init {
if (self = [super init]) {
[self setupView];
}
return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
self = [super initWithCoder:coder];
if (self) {
[self setupView];
}
return self;
}
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self setupView];
}
return self;
}
- (instancetype)initWithStandardFontSize:(CGFloat)size {
if ([self init]) {
self.standardFontSize = size;
}
return self;
}
- (void)updateView:(CGFloat)size {
self.scaleSize = @(size);
if (self.originalAttributedString) {
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithAttributedString:self.originalAttributedString];
[attributedString removeAttribute:NSFontAttributeName range:NSMakeRange(0, attributedString.length)];
[self.originalAttributedString enumerateAttribute:NSFontAttributeName inRange:NSMakeRange(0, self.originalAttributedString.length) options:0 usingBlock:^(UIFont *value, NSRange range, BOOL * _Nonnull stop) {
// Loop the original attributed string, resize the fonts.
UIFont *font = [value fontWithSize:[[MFStyler sizeObjectGenericForCurrentDevice:value.pointSize] getValueBasedOnSize:size]];
[attributedString addAttribute:NSFontAttributeName value:font range:range];
}];
self.attributedText = attributedString;
} else if (!fequal(self.standardFontSize, 0)) {
MFSizeObject *sizeObject = self.sizeObject;
if (!sizeObject) {
sizeObject = [MFStyler sizeObjectGenericForCurrentDevice:self.standardFontSize];
}
self.font = [self.font fontWithSize:[sizeObject getValueBasedOnSize:size]];
}
}
- (void)setFont:(nonnull UIFont *)font scale:(BOOL)scale {
self.font = font;
[self setScale:scale];
}
- (void)setScale:(BOOL)scale {
if (scale) {
self.standardFontSize = self.font.pointSize;
[self updateView:(self.scaleSize ? self.scaleSize.floatValue : [MVMCoreUISplitViewController getApplicationViewWidth])];
} else {
self.standardFontSize = 0;
}
}
- (BOOL)hasText {
return self.text.length > 0 || self.attributedText.length > 0;
}
#pragma mark - 2.0
+ (nonnull MFLabel *)commonLabelH1:(BOOL)scale {
MFLabel *label = [MFLabel label];
[label styleH1:scale];
return label;
}
+ (nonnull MFLabel *)commonLabelH2:(BOOL)scale {
MFLabel *label = [MFLabel label];
[label styleH2:scale];
return label;
}
+ (nonnull MFLabel *)commonLabelH3:(BOOL)scale {
MFLabel *label = [MFLabel label];
[label styleH3:scale];
return label;
}
+ (nonnull MFLabel *)commonLabelH32:(BOOL)scale {
MFLabel *label = [MFLabel label];
[label styleH32:scale];
return label;
}
+ (nonnull MFLabel *)commonLabelB1:(BOOL)scale {
MFLabel *label = [MFLabel label];
[label styleB1:scale];
return label;
}
+ (nonnull MFLabel *)commonLabelB2:(BOOL)scale {
MFLabel *label = [MFLabel label];
[label styleB2:scale];
return label;
}
+ (nonnull MFLabel *)commonLabelB3:(BOOL)scale {
MFLabel *label = [MFLabel label];
[label styleB3:scale];
return label;
}
+ (nonnull MFLabel *)commonLabelB20:(BOOL)scale {
MFLabel *label = [MFLabel label];
[label styleB20:scale];
return label;
}
+ (nonnull MFLabel *)label {
return [[MFLabel alloc] initWithFrame:CGRectZero];
}
#pragma mark - Setters
+ (void)setLabel:(nullable UILabel *)label withHTML:(nullable NSString *)html {
NSData *data = [html dataUsingEncoding:kCFStringEncodingUTF8];
if (data) {
NSError *error = nil;
label.attributedText = [[NSAttributedString alloc] initWithData:data options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType} documentAttributes:nil error:&error];
if (error) {
[[MVMCoreUILoggingHandler sharedLoggingHandler] addErrorToLog:[MVMCoreErrorObject createErrorObjectForNSError:error location:@"LabelHTMLParse"]];
}
}
}
+ (void)setUILabel:(nullable UILabel *)label withJSON:(nullable NSDictionary *)json delegate:(nullable NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData {
if (label) {
label.text = [json string:KeyText];
[self setLabel:label withHTML:[json string:@"html"]];
NSString *textColor = [json string:KeyTextColor];
if (textColor) {
label.textColor = [UIColor mfGetColorForHex:textColor];
}
NSString *backgroundColor = [json string:KeyBackgroundColor];
if (backgroundColor) {
label.backgroundColor = [UIColor mfGetColorForHex:backgroundColor];
}
NSString *accessibilityText = [json string:@"accessibilityText"];
if (accessibilityText) {
label.accessibilityLabel = accessibilityText;
}
NSString *fontName = [json string:@"fontName"];
NSNumber *fontSize = [json optionalNumberForKey:@"fontSize"];
if (fontName) {
label.font = [MFFonts mfFontWithName:fontName size:fontSize ? fontSize.doubleValue : label.font.pointSize];
} else if (fontSize) {
label.font = [label.font fontWithSize:fontSize.doubleValue];
}
NSArray *attributes = [json array:@"attributes"];
if (attributes) {
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:label.text attributes:@{NSFontAttributeName:label.font,NSForegroundColorAttributeName:label.textColor}];
for (NSDictionary *attribute in attributes) {
NSNumber *location = [attribute optionalNumberForKey:@"location"];
NSNumber *length = [attribute optionalNumberForKey:@"length"];
if (location && length) {
NSRange range = NSMakeRange(location.unsignedIntegerValue, length.unsignedIntegerValue);
NSString *type = [attribute string:KeyType];
if ([type isEqualToString:@"underline"]) {
[attributedString addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:range];
} else if ([type isEqualToString:@"strikethrough"]) {
[attributedString addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlineStyleThick) range:range];
} else if ([type isEqualToString:@"color"]) {
NSString *color = [attribute string:KeyTextColor];
if (color) {
[attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor mfGetColorForHex:color] range:range];
}
} else if ([type isEqualToString:@"font"]) {
NSString *fontName = [attribute string:@"name"];
NSNumber *fontSize = [attribute optionalNumberForKey:@"size"];
UIFont *font = nil;
if (fontName) {
font = [MFFonts mfFontWithName:fontName size:fontSize ? fontSize.doubleValue : label.font.pointSize];
} else if (fontSize) {
font = [label.font fontWithSize:fontSize.doubleValue];
}
if (font) {
[attributedString addAttribute:NSFontAttributeName value:font range:range];
}
}
}
}
label.attributedText = attributedString;
}
}
}
- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(NSDictionary *)additionalData {
[MFLabel setUILabel:self withJSON:json delegate:delegate additionalData:additionalData];
self.originalAttributedString = self.attributedText;
}
- (void)styleH1:(BOOL)scale {
[MFStyler styleLabelH1:self genericScaling:NO];
[self setScale:scale];
}
- (void)styleH2:(BOOL)scale {
[MFStyler styleLabelH2:self genericScaling:NO];
[self setScale:scale];
}
- (void)styleH3:(BOOL)scale {
[MFStyler styleLabelH3:self genericScaling:NO];
[self setScale:scale];
}
- (void)styleH32:(BOOL)scale {
[MFStyler styleLabelH32:self genericScaling:NO];
[self setScale:scale];
}
- (void)styleB1:(BOOL)scale {
[MFStyler styleLabelB1:self genericScaling:NO];
[self setScale:scale];
}
- (void)styleB2:(BOOL)scale {
[MFStyler styleLabelB2:self genericScaling:NO];
[self setScale:scale];
}
- (void)styleB3:(BOOL)scale {
[MFStyler styleLabelB3:self genericScaling:NO];
[self setScale:scale];
}
- (void)styleB20:(BOOL)scale {
[MFStyler styleLabelB20:self genericScaling:NO];
[self setScale:scale];
}
- (void)setAccessibilityTraits:(UIAccessibilityTraits)accessibilityTraits {
if (accessibilityTraits& UIAccessibilityTraitHeader) {
UIAccessibilityTraits noHeaderTraits = accessibilityTraits - UIAccessibilityTraitHeader;
[super setAccessibilityTraits:noHeaderTraits];
} else {
[super setAccessibilityTraits:accessibilityTraits];
}
}
@end

View File

@ -9,7 +9,7 @@
#import <UIKit/UIKit.h>
#import <MVMCoreUI/MFView.h>
#import <MVMCoreUI/MVMCoreUICheckMarkView.h>
#import <MVMCoreUI/MFLabel.h>
@class Label;
@class MFSizeObject;
@interface MVMCoreUICheckBox : UIControl <MVMCoreViewProtocol>
@ -23,7 +23,7 @@
@property (nullable, strong, nonatomic) UIColor *unCheckedColor;
// Label to the right of the check box.
@property (nullable, weak, nonatomic) MFLabel *descriptionLabel;
@property (nullable, weak, nonatomic) Label *descriptionLabel;
// Setter for the descriptionLabel.text. Also sets the accessibility text.
@property (nullable, strong, nonatomic) NSString *descriptionText;

View File

@ -16,6 +16,7 @@
#import "UIColor+MFConvenience.h"
#import "MVMCoreUIUtility.h"
#import "MFStyler.h"
#import <MVMCoreUI/MVMCoreUI-Swift.h>
static const CGFloat FaultTolerance = 20.f;
static const CGFloat CheckBoxHeightWidth = 18.0;
@ -186,7 +187,7 @@ static const CGFloat CheckBoxHeightWidth = 18.0;
//label
if (!self.descriptionLabel) {
MFLabel *descriptionLabel = [MFLabel commonLabelB2:YES];
Label *descriptionLabel = [Label commonLabelB2:YES];
[containterView addSubview:descriptionLabel];
[NSLayoutConstraint constraintPinSubview:descriptionLabel pinCenterX:NO pinCenterY:YES];
[NSLayoutConstraint constraintPinSubview:descriptionLabel pinTop:NO pinBottom:NO pinLeft:NO pinRight:YES];

View File

@ -10,7 +10,6 @@
#import <MVMCoreUI/StackableViewController.h>
#import <MVMCoreUI/ViewConstrainingView.h>
#import <MVMCoreUI/TopLabelsView.h>
@class LabelView;
@class PrimaryButton;

View File

@ -72,8 +72,6 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[];
#pragma mark - Atoms
#pragma mark Views
#import <MVMCoreUI/MFView.h>
#import <MVMCoreUI/MFLabel.h>
#import <MVMCoreUI/ViewConstrainingView.h>
#import <MVMCoreUI/MFLoadingSpinner.h>
#import <MVMCoreUI/MFTextView.h>

View File

@ -9,8 +9,8 @@
import UIKit
public class StandardHeaderView: ViewConstrainingView {
let headlineLabel = MFLabel.commonLabelH2(true)
let messageLabel = MFLabel.commonLabelB2(true)
let headlineLabel = Label.commonLabelH2(true)
let messageLabel = Label.commonLabelB2(true)
var separatorView: SeparatorView?
var spaceBetweenLabels: NSLayoutConstraint?
var leftConstraintTitle: NSLayoutConstraint?
@ -75,10 +75,10 @@ public class StandardHeaderView: ViewConstrainingView {
}
public func setSpacing() {
if headlineLabel.hasText() && messageLabel.hasText() {
if headlineLabel.hasText && messageLabel.hasText {
spaceBetweenLabels?.constant = PaddingTwo
show()
} else if headlineLabel.hasText() || messageLabel.hasText() {
} else if headlineLabel.hasText || messageLabel.hasText {
spaceBetweenLabels?.constant = 0
show()
} else {

View File

@ -7,17 +7,16 @@
//
#import <UIKit/UIKit.h>
#import <MVMCoreUI/MFView.h>
#import <MVMCoreUI/MFLabel.h>
@class Label;
#import <MVMCoreUI/SeparatorView.h>
@class TopLabelsAndBottomButtonsTableViewController;
@interface TopLabelsView : MFView
@property (nullable, weak, nonatomic) MFLabel *headlineLabel;
@property (nullable, weak, nonatomic) MFLabel *messageLabel;
@property (nullable, weak, nonatomic) Label *headlineLabel;
@property (nullable, weak, nonatomic) Label *messageLabel;
@property (nullable, strong, nonatomic) NSLayoutConstraint *topLabelConstraint;
@property (nullable, weak, nonatomic) NSLayoutConstraint *spaceBetweenLabels;

View File

@ -14,6 +14,7 @@
#import <MVMCoreUI/MFStyler.h>
#import <MVMCore/MVMCoreConstants.h>
#import <MVMCoreUI/NSLayoutConstraint+MFConvenience.h>
#import <MVMCoreUI/MVMCoreUI-Swift.h>
@interface TopLabelsView ()
@ -54,12 +55,12 @@
self.clipsToBounds = YES;
[self.headlineLabel removeFromSuperview];
MFLabel *headlineLabel = [MFLabel commonLabelH2:YES];
Label *headlineLabel = [Label commonLabelH2:YES];
[self addSubview:headlineLabel];
self.headlineLabel = headlineLabel;
[self.messageLabel removeFromSuperview];
MFLabel *messageLabel = [MFLabel commonLabelB2:YES];
Label *messageLabel = [Label commonLabelB2:YES];
[self addSubview:messageLabel];
self.messageLabel = messageLabel;

View File

@ -22,7 +22,7 @@
static NSMutableDictionary <NSString *, Class>*mapping;
dispatch_once(&onceToken, ^{
mapping = [@{
@"label": LabelView.class,
@"label": Label.class,
@"separator": SeparatorView.class,
@"button": ButtonView.class,
@"textButton": MFTextButton.class,