merging develop
This commit is contained in:
commit
5c80bb9c90
@ -89,10 +89,14 @@
|
|||||||
0A6682A42434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682A32434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift */; };
|
0A6682A42434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682A32434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift */; };
|
||||||
0A6682B5243769C700AD3CA1 /* TextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682B3243769C700AD3CA1 /* TextView.swift */; };
|
0A6682B5243769C700AD3CA1 /* TextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682B3243769C700AD3CA1 /* TextView.swift */; };
|
||||||
0A6682B6243769C700AD3CA1 /* TextViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682B4243769C700AD3CA1 /* TextViewModel.swift */; };
|
0A6682B6243769C700AD3CA1 /* TextViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682B4243769C700AD3CA1 /* TextViewModel.swift */; };
|
||||||
|
0A6682AA2435125F00AD3CA1 /* Styler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682A92435125F00AD3CA1 /* Styler.swift */; };
|
||||||
|
0A6682AC243531C300AD3CA1 /* Padding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6682AB243531C300AD3CA1 /* Padding.swift */; };
|
||||||
0A69F611241BDEA700F7231B /* RuleAnyRequiredModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */; };
|
0A69F611241BDEA700F7231B /* RuleAnyRequiredModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */; };
|
||||||
0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */; };
|
0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */; };
|
||||||
0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; };
|
0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; };
|
||||||
0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */; };
|
0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */; };
|
||||||
|
0A7ECC5D243CE85300C828E8 /* DoughnutChartItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7ECC5C243CE85300C828E8 /* DoughnutChartItemModel.swift */; };
|
||||||
|
0A7ECC5F243CEB1200C828E8 /* ColorViewWithLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7ECC5E243CEB1200C828E8 /* ColorViewWithLabel.swift */; };
|
||||||
0A7EF85B23D8A52800B2AAD1 /* EntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EF85A23D8A52800B2AAD1 /* EntryFieldModel.swift */; };
|
0A7EF85B23D8A52800B2AAD1 /* EntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EF85A23D8A52800B2AAD1 /* EntryFieldModel.swift */; };
|
||||||
0A7EF85D23D8A95600B2AAD1 /* TextEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EF85C23D8A95600B2AAD1 /* TextEntryFieldModel.swift */; };
|
0A7EF85D23D8A95600B2AAD1 /* TextEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EF85C23D8A95600B2AAD1 /* TextEntryFieldModel.swift */; };
|
||||||
0A7EF85F23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EF85E23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift */; };
|
0A7EF85F23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7EF85E23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift */; };
|
||||||
@ -493,11 +497,15 @@
|
|||||||
0A6682A32434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableRadioButtonBodyTextModel.swift; sourceTree = "<group>"; };
|
0A6682A32434DB8D00AD3CA1 /* ListLeftVariableRadioButtonBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableRadioButtonBodyTextModel.swift; sourceTree = "<group>"; };
|
||||||
0A6682B3243769C700AD3CA1 /* TextView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextView.swift; sourceTree = "<group>"; };
|
0A6682B3243769C700AD3CA1 /* TextView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextView.swift; sourceTree = "<group>"; };
|
||||||
0A6682B4243769C700AD3CA1 /* TextViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextViewModel.swift; sourceTree = "<group>"; };
|
0A6682B4243769C700AD3CA1 /* TextViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextViewModel.swift; sourceTree = "<group>"; };
|
||||||
|
0A6682A92435125F00AD3CA1 /* Styler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Styler.swift; sourceTree = "<group>"; };
|
||||||
|
0A6682AB243531C300AD3CA1 /* Padding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Padding.swift; sourceTree = "<group>"; };
|
||||||
0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyRequiredModel.swift; sourceTree = "<group>"; };
|
0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyRequiredModel.swift; sourceTree = "<group>"; };
|
||||||
0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseDropdownEntryField.swift; sourceTree = "<group>"; };
|
0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseDropdownEntryField.swift; sourceTree = "<group>"; };
|
||||||
0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = "<group>"; };
|
0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = "<group>"; };
|
||||||
0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = "<group>"; };
|
0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = "<group>"; };
|
||||||
0A7BAFA2232BE63400FB8E22 /* CheckboxLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxLabel.swift; sourceTree = "<group>"; };
|
0A7BAFA2232BE63400FB8E22 /* CheckboxLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxLabel.swift; sourceTree = "<group>"; };
|
||||||
|
0A7ECC5C243CE85300C828E8 /* DoughnutChartItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DoughnutChartItemModel.swift; sourceTree = "<group>"; };
|
||||||
|
0A7ECC5E243CEB1200C828E8 /* ColorViewWithLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorViewWithLabel.swift; sourceTree = "<group>"; };
|
||||||
0A7EF85A23D8A52800B2AAD1 /* EntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntryFieldModel.swift; sourceTree = "<group>"; };
|
0A7EF85A23D8A52800B2AAD1 /* EntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntryFieldModel.swift; sourceTree = "<group>"; };
|
||||||
0A7EF85C23D8A95600B2AAD1 /* TextEntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextEntryFieldModel.swift; sourceTree = "<group>"; };
|
0A7EF85C23D8A95600B2AAD1 /* TextEntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextEntryFieldModel.swift; sourceTree = "<group>"; };
|
||||||
0A7EF85E23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MdnEntryFieldModel.swift; sourceTree = "<group>"; };
|
0A7EF85E23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MdnEntryFieldModel.swift; sourceTree = "<group>"; };
|
||||||
@ -1362,9 +1370,11 @@
|
|||||||
D260105723CF9CC500764D80 /* Doughnut */ = {
|
D260105723CF9CC500764D80 /* Doughnut */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
0A7ECC5C243CE85300C828E8 /* DoughnutChartItemModel.swift */,
|
||||||
C695A69323C9909000BFB94E /* DoughnutChartModel.swift */,
|
C695A69323C9909000BFB94E /* DoughnutChartModel.swift */,
|
||||||
C695A69523C990BC00BFB94E /* DoughnutChart.swift */,
|
C695A69523C990BC00BFB94E /* DoughnutChart.swift */,
|
||||||
C695A69723C990C200BFB94E /* DoughnutChartView.swift */,
|
C695A69723C990C200BFB94E /* DoughnutChartView.swift */,
|
||||||
|
0A7ECC5E243CEB1200C828E8 /* ColorViewWithLabel.swift */,
|
||||||
);
|
);
|
||||||
path = Doughnut;
|
path = Doughnut;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -1535,6 +1545,8 @@
|
|||||||
children = (
|
children = (
|
||||||
D29DF13821E68636003B2FB9 /* MFStyler.h */,
|
D29DF13821E68636003B2FB9 /* MFStyler.h */,
|
||||||
D29DF13921E68637003B2FB9 /* MFStyler.m */,
|
D29DF13921E68637003B2FB9 /* MFStyler.m */,
|
||||||
|
0A6682A92435125F00AD3CA1 /* Styler.swift */,
|
||||||
|
0A6682AB243531C300AD3CA1 /* Padding.swift */,
|
||||||
);
|
);
|
||||||
path = Styles;
|
path = Styles;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -2095,6 +2107,7 @@
|
|||||||
D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */,
|
D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */,
|
||||||
DBEFFA04225A829700230692 /* Label.swift in Sources */,
|
DBEFFA04225A829700230692 /* Label.swift in Sources */,
|
||||||
D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */,
|
D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */,
|
||||||
|
0A7ECC5D243CE85300C828E8 /* DoughnutChartItemModel.swift in Sources */,
|
||||||
0A7EF85F23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift in Sources */,
|
0A7EF85F23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift in Sources */,
|
||||||
011D959B240451E3000E3791 /* RuleRequiredModel.swift in Sources */,
|
011D959B240451E3000E3791 /* RuleRequiredModel.swift in Sources */,
|
||||||
526A265C240D1FF700B0D828 /* ListTwoColumnCompareChangesModel.swift in Sources */,
|
526A265C240D1FF700B0D828 /* ListTwoColumnCompareChangesModel.swift in Sources */,
|
||||||
@ -2131,6 +2144,7 @@
|
|||||||
8DD1E370243B3D0500D8F2DF /* ListThreeColumnInternationalData.swift in Sources */,
|
8DD1E370243B3D0500D8F2DF /* ListThreeColumnInternationalData.swift in Sources */,
|
||||||
D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */,
|
D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */,
|
||||||
01EB368F23609801006832FA /* LabelModel.swift in Sources */,
|
01EB368F23609801006832FA /* LabelModel.swift in Sources */,
|
||||||
|
0A6682AC243531C300AD3CA1 /* Padding.swift in Sources */,
|
||||||
AA1EC59924373994003D6F50 /* ListThreeColumnSpeedTestDivider.swift in Sources */,
|
AA1EC59924373994003D6F50 /* ListThreeColumnSpeedTestDivider.swift in Sources */,
|
||||||
942C378E2412F5B60066E45E /* ModalMoleculeStackTemplate.swift in Sources */,
|
942C378E2412F5B60066E45E /* ModalMoleculeStackTemplate.swift in Sources */,
|
||||||
8D4687E4242E2DF300802879 /* ListFourColumnDataUsageListItem.swift in Sources */,
|
8D4687E4242E2DF300802879 /* ListFourColumnDataUsageListItem.swift in Sources */,
|
||||||
@ -2203,6 +2217,7 @@
|
|||||||
C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */,
|
C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */,
|
||||||
0AE98BB523FF18D2004C5109 /* Arrow.swift in Sources */,
|
0AE98BB523FF18D2004C5109 /* Arrow.swift in Sources */,
|
||||||
D2D90B442404789000DD6EC9 /* MoleculeContainerProtocol.swift in Sources */,
|
D2D90B442404789000DD6EC9 /* MoleculeContainerProtocol.swift in Sources */,
|
||||||
|
0A7ECC5F243CEB1200C828E8 /* ColorViewWithLabel.swift in Sources */,
|
||||||
94C0150A24215643005811A9 /* ActionTopAlertModel.swift in Sources */,
|
94C0150A24215643005811A9 /* ActionTopAlertModel.swift in Sources */,
|
||||||
012A88DB238ED45900FE3DA1 /* CarouselModel.swift in Sources */,
|
012A88DB238ED45900FE3DA1 /* CarouselModel.swift in Sources */,
|
||||||
D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */,
|
D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */,
|
||||||
@ -2302,6 +2317,7 @@
|
|||||||
011D95AD2406BB57000E3791 /* FormHolderProtocol.swift in Sources */,
|
011D95AD2406BB57000E3791 /* FormHolderProtocol.swift in Sources */,
|
||||||
01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */,
|
01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */,
|
||||||
D260106523D0CEA700764D80 /* StackModel.swift in Sources */,
|
D260106523D0CEA700764D80 /* StackModel.swift in Sources */,
|
||||||
|
0A6682AA2435125F00AD3CA1 /* Styler.swift in Sources */,
|
||||||
D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */,
|
D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
|||||||
@ -25,11 +25,11 @@ open class CaretLink: Button, MVMCoreUIViewConstrainingProtocol {
|
|||||||
@objc public var rightViewHeight: NSNumber?
|
@objc public var rightViewHeight: NSNumber?
|
||||||
@objc public var rightViewWidth: NSNumber?
|
@objc public var rightViewWidth: NSNumber?
|
||||||
|
|
||||||
@objc public var enabledColor: UIColor = .black {
|
@objc public var enabledColor: UIColor = .mvmBlack {
|
||||||
didSet { changeCaretColor() }
|
didSet { changeCaretColor() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public var disabledColor: UIColor = .mfSilver() {
|
@objc public var disabledColor: UIColor = .mvmCoolGray3 {
|
||||||
didSet { changeCaretColor() }
|
didSet { changeCaretColor() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,8 +103,7 @@ open class CaretLink: Button, MVMCoreUIViewConstrainingProtocol {
|
|||||||
let width = CGFloat(rightViewWidth?.floatValue ?? CARET_VIEW_WIDTH)
|
let width = CGFloat(rightViewWidth?.floatValue ?? CARET_VIEW_WIDTH)
|
||||||
let height = CGFloat(rightViewHeight?.floatValue ?? CARET_VIEW_HEIGHT)
|
let height = CGFloat(rightViewHeight?.floatValue ?? CARET_VIEW_HEIGHT)
|
||||||
|
|
||||||
let edgeInsets: UIEdgeInsets = contentEdgeInsets
|
contentEdgeInsets.right = 4 + width
|
||||||
contentEdgeInsets = UIEdgeInsets(top: edgeInsets.top, left: edgeInsets.left, bottom: edgeInsets.bottom, right: 4 + width)
|
|
||||||
|
|
||||||
let caretView: UIView = rightView ?? createCaretView()
|
let caretView: UIView = rightView ?? createCaretView()
|
||||||
rightView = caretView
|
rightView = caretView
|
||||||
@ -114,12 +113,12 @@ open class CaretLink: Button, MVMCoreUIViewConstrainingProtocol {
|
|||||||
caretView.widthAnchor.constraint(equalToConstant: width).isActive = true
|
caretView.widthAnchor.constraint(equalToConstant: width).isActive = true
|
||||||
caretView.heightAnchor.constraint(equalToConstant: height).isActive = true
|
caretView.heightAnchor.constraint(equalToConstant: height).isActive = true
|
||||||
|
|
||||||
let caretLabelSpacing = NSLayoutConstraint(item: caretView, attribute: .left, relatedBy: .equal, toItem: titleLabel, attribute: .right, multiplier: 1.0, constant: 4)
|
let caretLabelSpacing = NSLayoutConstraint(item: caretView, attribute: .left, relatedBy: .equal, toItem: titleLabel, attribute: .right, multiplier: 1.0, constant: 7)
|
||||||
caretLabelSpacing.isActive = true
|
caretLabelSpacing.isActive = true
|
||||||
caretSpacingConstraint = caretLabelSpacing
|
caretSpacingConstraint = caretLabelSpacing
|
||||||
|
|
||||||
NSLayoutConstraint(item: caretView, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1.0, constant: 0).isActive = true
|
caretView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
|
||||||
NSLayoutConstraint(item: self, attribute: .right, relatedBy: .greaterThanOrEqual, toItem: caretView, attribute: .right, multiplier: 1.0, constant: 0).isActive = true
|
trailingAnchor.constraint(greaterThanOrEqualTo: caretView.trailingAnchor).isActive = true
|
||||||
caretView.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true
|
caretView.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true
|
||||||
bottomAnchor.constraint(greaterThanOrEqualTo: caretView.bottomAnchor).isActive = true
|
bottomAnchor.constraint(greaterThanOrEqualTo: caretView.bottomAnchor).isActive = true
|
||||||
contentHorizontalAlignment = .left
|
contentHorizontalAlignment = .left
|
||||||
@ -137,17 +136,21 @@ open class CaretLink: Button, MVMCoreUIViewConstrainingProtocol {
|
|||||||
// MARK: - Atomization
|
// MARK: - Atomization
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
guard let caretLinkModel = model as? CaretLinkModel else { return }
|
|
||||||
if let color = caretLinkModel.backgroundColor {
|
guard let model = model as? CaretLinkModel else { return }
|
||||||
|
|
||||||
|
if let color = model.backgroundColor {
|
||||||
backgroundColor = color.uiColor
|
backgroundColor = color.uiColor
|
||||||
}
|
}
|
||||||
enabledColor = caretLinkModel.enabledColor.uiColor
|
|
||||||
if let color = caretLinkModel.disabledColor {
|
enabledColor = model.enabledColor.uiColor
|
||||||
|
if let color = model.disabledColor {
|
||||||
disabledColor = color.uiColor
|
disabledColor = color.uiColor
|
||||||
}
|
}
|
||||||
isEnabled = caretLinkModel.enabled
|
|
||||||
set(with: caretLinkModel.action, delegateObject: delegateObject, additionalData: additionalData)
|
isEnabled = model.enabled
|
||||||
setTitle(caretLinkModel.title, for: .normal)
|
set(with: model.action, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
setTitle(model.title, for: .normal)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func needsToBeConstrained() -> Bool {
|
public func needsToBeConstrained() -> Bool {
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
|
|
||||||
@objcMembers open class RadioButton: Control {
|
@objcMembers open class RadioButton: Control {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
@ -19,8 +20,8 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public var enabledColor: UIColor = .black
|
public var enabledColor: UIColor = .mvmBlack
|
||||||
public var disabledColor: UIColor = .mfSilver()
|
public var disabledColor: UIColor = .mvmCoolGray6
|
||||||
public var delegateObject: MVMCoreUIDelegateObject?
|
public var delegateObject: MVMCoreUIDelegateObject?
|
||||||
|
|
||||||
public var radioModel: RadioButtonModel? {
|
public var radioModel: RadioButtonModel? {
|
||||||
@ -108,7 +109,7 @@ import UIKit
|
|||||||
open override func setupView() {
|
open override func setupView() {
|
||||||
super.setupView()
|
super.setupView()
|
||||||
|
|
||||||
backgroundColor = .white
|
backgroundColor = .mvmWhite
|
||||||
clipsToBounds = true
|
clipsToBounds = true
|
||||||
widthConstraint = widthAnchor.constraint(equalToConstant: 30)
|
widthConstraint = widthAnchor.constraint(equalToConstant: 30)
|
||||||
widthConstraint?.isActive = true
|
widthConstraint?.isActive = true
|
||||||
@ -132,7 +133,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override func reset() {
|
public override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
backgroundColor = .white
|
backgroundColor = .white
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,24 +7,36 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
|
||||||
|
|
||||||
@objcMembers public class RadioButtonSelectionHelper: FormFieldProtocol {
|
@objcMembers public class RadioButtonSelectionHelper: FormFieldProtocol {
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Properties
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
public var fieldKey: String?
|
public var fieldKey: String?
|
||||||
public var groupName: String = FormValidator.defaultGroupName
|
public var groupName: String = FormValidator.defaultGroupName
|
||||||
private var selectedRadioButton: RadioButton?
|
private var selectedRadioButton: RadioButton?
|
||||||
private var fieldGroupName: String?
|
private var fieldGroupName: String?
|
||||||
public var baseValue: AnyHashable?
|
public var baseValue: AnyHashable?
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Initializer
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
init(_ fieldKey: String?) {
|
init(_ fieldKey: String?) {
|
||||||
self.fieldKey = fieldKey
|
self.fieldKey = fieldKey
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Methods
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
public static func setupForRadioButtonGroup(_ radioButtonModel: RadioButtonModel, _ radioButton: RadioButton, delegateObject: MVMCoreUIDelegateObject?) {
|
public static func setupForRadioButtonGroup(_ radioButtonModel: RadioButtonModel, _ radioButton: RadioButton, delegateObject: MVMCoreUIDelegateObject?) {
|
||||||
|
|
||||||
guard let groupName = radioButtonModel.fieldKey,
|
guard let groupName = radioButtonModel.fieldKey,
|
||||||
let formValidator = delegateObject?.formHolderDelegate?.formValidator else {
|
let formValidator = delegateObject?.formHolderDelegate?.formValidator
|
||||||
return
|
else { return }
|
||||||
}
|
|
||||||
|
|
||||||
let radioButtonSelectionHelper = formValidator.radioButtonsModelByGroup[groupName] ?? RadioButtonSelectionHelper(radioButtonModel.fieldKey)
|
let radioButtonSelectionHelper = formValidator.radioButtonsModelByGroup[groupName] ?? RadioButtonSelectionHelper(radioButtonModel.fieldKey)
|
||||||
radioButtonSelectionHelper.fieldGroupName = radioButtonModel.fieldKey
|
radioButtonSelectionHelper.fieldGroupName = radioButtonModel.fieldKey
|
||||||
@ -37,6 +49,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func selected(_ radioButton: RadioButton) {
|
public func selected(_ radioButton: RadioButton) {
|
||||||
|
|
||||||
selectedRadioButton?.isSelected = false
|
selectedRadioButton?.isSelected = false
|
||||||
selectedRadioButton = radioButton
|
selectedRadioButton = radioButton
|
||||||
selectedRadioButton?.isSelected = true
|
selectedRadioButton?.isSelected = true
|
||||||
@ -45,8 +58,9 @@ import UIKit
|
|||||||
|
|
||||||
// MARK: - FormValidationFormFieldProtocol
|
// MARK: - FormValidationFormFieldProtocol
|
||||||
extension RadioButtonSelectionHelper {
|
extension RadioButtonSelectionHelper {
|
||||||
|
|
||||||
public func formFieldGroupName() -> String? {
|
public func formFieldGroupName() -> String? {
|
||||||
return selectedRadioButton?.formFieldGroupName() ?? self.fieldGroupName
|
return selectedRadioButton?.formFieldGroupName() ?? fieldGroupName
|
||||||
}
|
}
|
||||||
|
|
||||||
public func formFieldValue() -> AnyHashable? {
|
public func formFieldValue() -> AnyHashable? {
|
||||||
|
|||||||
@ -116,7 +116,7 @@ import UIKit
|
|||||||
for (index, field) in digitBoxes.enumerated() {
|
for (index, field) in digitBoxes.enumerated() {
|
||||||
if index < newValue.count {
|
if index < newValue.count {
|
||||||
let indexChar = newValue.index(newValue.startIndex, offsetBy: index)
|
let indexChar = newValue.index(newValue.startIndex, offsetBy: index)
|
||||||
field.digitField.attributedPlaceholder = NSAttributedString(string: String(newValue[indexChar]), attributes: [NSAttributedString.Key.foregroundColor: UIColor.mfBattleshipGrey()])
|
field.digitField.attributedPlaceholder = NSAttributedString(string: String(newValue[indexChar]), attributes: [NSAttributedString.Key.foregroundColor: UIColor.mvmCoolGray6])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,8 +20,8 @@ import UIKit
|
|||||||
|
|
||||||
public private(set) var titleLabel: Label = {
|
public private(set) var titleLabel: Label = {
|
||||||
let label = Label()
|
let label = Label()
|
||||||
label.font = MFStyler.fontB3()
|
label.font = MFStyler.fontRegularMicro()
|
||||||
label.textColor = .mvmCoolGray6
|
label.textColor = .mvmBlack
|
||||||
label.setContentCompressionResistancePriority(.required, for: .vertical)
|
label.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||||
return label
|
return label
|
||||||
}()
|
}()
|
||||||
@ -31,7 +31,7 @@ import UIKit
|
|||||||
/// Provides contextual information on the TextField.
|
/// Provides contextual information on the TextField.
|
||||||
public private(set) var feedbackLabel: Label = {
|
public private(set) var feedbackLabel: Label = {
|
||||||
let label = Label()
|
let label = Label()
|
||||||
label.font = MFStyler.fontForTextFieldUnderLabel()
|
label.font = MFStyler.fontRegularMicro()
|
||||||
label.textColor = .mvmBlack
|
label.textColor = .mvmBlack
|
||||||
label.setContentCompressionResistancePriority(.required, for: .vertical)
|
label.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||||
return label
|
return label
|
||||||
@ -65,7 +65,8 @@ import UIKit
|
|||||||
public var isEnabled: Bool {
|
public var isEnabled: Bool {
|
||||||
get { return entryFieldContainer.isEnabled }
|
get { return entryFieldContainer.isEnabled }
|
||||||
set (enabled) {
|
set (enabled) {
|
||||||
self.feedbackLabel.textColor = enabled ? .black : .mfSilver()
|
self.titleLabel.textColor = enabled ? .mvmBlack : .mvmCoolGray3
|
||||||
|
self.feedbackLabel.textColor = enabled ? .mvmBlack : .mvmCoolGray3
|
||||||
self.entryFieldContainer.isEnabled = enabled
|
self.entryFieldContainer.isEnabled = enabled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -233,15 +234,16 @@ import UIKit
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - MoleculeViewProtocol
|
// MARK: - MoleculeViewProtocol
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
@objc open override func reset() {
|
@objc open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
|
||||||
backgroundColor = .clear
|
backgroundColor = .clear
|
||||||
isAccessibilityElement = false
|
isAccessibilityElement = false
|
||||||
titleLabel.font = MFStyler.fontB3()
|
titleLabel.font = MFStyler.fontRegularMicro()
|
||||||
titleLabel.textColor = .mfBattleshipGrey()
|
titleLabel.textColor = .mvmBlack
|
||||||
feedbackLabel.font = MFStyler.fontForTextFieldUnderLabel()
|
feedbackLabel.font = MFStyler.fontRegularMicro()
|
||||||
feedbackLabel.textColor = .black
|
feedbackLabel.textColor = .mvmBlack
|
||||||
entryFieldContainer.reset()
|
entryFieldContainer.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,8 @@ import UIKit
|
|||||||
let textField = TextField()
|
let textField = TextField()
|
||||||
textField.isAccessibilityElement = true
|
textField.isAccessibilityElement = true
|
||||||
textField.setContentCompressionResistancePriority(.required, for: .vertical)
|
textField.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||||
textField.font = MFStyler.fontForTextField()
|
textField.font = MFStyler.fontRegularBodyLarge()
|
||||||
|
textField.textColor = .mvmBlack
|
||||||
textField.smartQuotesType = .no
|
textField.smartQuotesType = .no
|
||||||
textField.smartDashesType = .no
|
textField.smartDashesType = .no
|
||||||
textField.smartInsertDeleteType = .no
|
textField.smartInsertDeleteType = .no
|
||||||
@ -40,7 +41,7 @@ import UIKit
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
/// Set enabled and disabled colors to be utilized when setting this texfield's isEnabled property.
|
/// Set enabled and disabled colors to be utilized when setting this texfield's isEnabled property.
|
||||||
public var textColor: (enabled: UIColor?, disabled: UIColor?) = (.black, .mfSilver())
|
public var textColor: (enabled: UIColor?, disabled: UIColor?) = (.mvmBlack, .mvmCoolGray3)
|
||||||
|
|
||||||
private var observingForChange: Bool = false
|
private var observingForChange: Bool = false
|
||||||
|
|
||||||
@ -168,7 +169,7 @@ import UIKit
|
|||||||
|
|
||||||
@objc open override func setupFieldContainerContent(_ container: UIView) {
|
@objc open override func setupFieldContainerContent(_ container: UIView) {
|
||||||
|
|
||||||
MFStyler.styleTextField(textField)
|
textField.font = MFStyler.fontRegularBodyLarge()
|
||||||
container.addSubview(textField)
|
container.addSubview(textField)
|
||||||
|
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
@ -193,14 +194,14 @@ import UIKit
|
|||||||
@objc open override func updateView(_ size: CGFloat) {
|
@objc open override func updateView(_ size: CGFloat) {
|
||||||
super.updateView(size)
|
super.updateView(size)
|
||||||
|
|
||||||
MFStyler.styleTextField(textField)
|
textField.font = MFStyler.fontRegularBodyLarge()
|
||||||
layoutIfNeeded()
|
layoutIfNeeded()
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
|
||||||
textField.font = MFStyler.fontForTextField()
|
textField.font = MFStyler.fontRegularBodyLarge()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc deinit {
|
@objc deinit {
|
||||||
@ -252,6 +253,7 @@ import UIKit
|
|||||||
observingTextFieldDelegate?.isValid?(textfield: self)
|
observingTextFieldDelegate?.isValid?(textfield: self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Executes on UITextField.textDidBeginEditingNotification
|
/// Executes on UITextField.textDidBeginEditingNotification
|
||||||
@objc func startEditing() {
|
@objc func startEditing() {
|
||||||
isSelected = true
|
isSelected = true
|
||||||
@ -270,7 +272,7 @@ import UIKit
|
|||||||
resignFirstResponder()
|
resignFirstResponder()
|
||||||
if isValid {
|
if isValid {
|
||||||
showError = false
|
showError = false
|
||||||
entryFieldContainer.bottomBar?.backgroundColor = UIColor.black.cgColor
|
entryFieldContainer.bottomBar?.backgroundColor = UIColor.mvmBlack.cgColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,6 +280,10 @@ import UIKit
|
|||||||
resignFirstResponder()
|
resignFirstResponder()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - MoleculeViewProtocol
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
super.set(with: model, delegateObject, additionalData)
|
super.set(with: model, delegateObject, additionalData)
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@ import UIKit
|
|||||||
return "font"
|
return "font"
|
||||||
}
|
}
|
||||||
|
|
||||||
var style: LabelModel.FontStyle?
|
var style: Styler.Font?
|
||||||
var name: String?
|
var name: String?
|
||||||
var size: CGFloat?
|
var size: CGFloat?
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ import UIKit
|
|||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
style = try typeContainer.decodeIfPresent(LabelModel.FontStyle.self, forKey: .style)
|
style = try typeContainer.decodeIfPresent(Styler.Font.self, forKey: .style)
|
||||||
name = try typeContainer.decodeIfPresent(String.self, forKey: .name)
|
name = try typeContainer.decodeIfPresent(String.self, forKey: .name)
|
||||||
size = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .size)
|
size = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .size)
|
||||||
try super.init(from: decoder)
|
try super.init(from: decoder)
|
||||||
|
|||||||
@ -10,31 +10,6 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
@objcMembers public class LabelModel: MoleculeModelProtocol {
|
@objcMembers public class LabelModel: MoleculeModelProtocol {
|
||||||
|
|
||||||
public enum FontStyle: String, Codable {
|
|
||||||
case Title2XLarge
|
|
||||||
case TitleXLarge
|
|
||||||
case BoldTitleLarge
|
|
||||||
case RegularTitleLarge
|
|
||||||
case BoldTitleMedium
|
|
||||||
case RegularTitleMedium
|
|
||||||
case BoldBodyLarge
|
|
||||||
case RegularBodyLarge
|
|
||||||
case BoldBodySmall
|
|
||||||
case RegularBodySmall
|
|
||||||
case BoldMicro
|
|
||||||
case RegularMicro
|
|
||||||
// Legacy
|
|
||||||
case H1
|
|
||||||
case H2
|
|
||||||
case H3
|
|
||||||
case H32
|
|
||||||
case B1
|
|
||||||
case B2
|
|
||||||
case B3
|
|
||||||
case B20
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -44,7 +19,7 @@ import Foundation
|
|||||||
public var text: String
|
public var text: String
|
||||||
public var accessibilityText: String?
|
public var accessibilityText: String?
|
||||||
public var textColor: Color?
|
public var textColor: Color?
|
||||||
public var fontStyle: FontStyle?
|
public var fontStyle: Styler.Font?
|
||||||
public var fontName: String?
|
public var fontName: String?
|
||||||
public var fontSize: CGFloat?
|
public var fontSize: CGFloat?
|
||||||
public var textAlignment: NSTextAlignment?
|
public var textAlignment: NSTextAlignment?
|
||||||
@ -95,7 +70,7 @@ import Foundation
|
|||||||
accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText)
|
accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText)
|
||||||
textColor = try typeContainer.decodeIfPresent(Color.self, forKey: .textColor)
|
textColor = try typeContainer.decodeIfPresent(Color.self, forKey: .textColor)
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
fontStyle = try typeContainer.decodeIfPresent(FontStyle.self, forKey: .fontStyle)
|
fontStyle = try typeContainer.decodeIfPresent(Styler.Font.self, forKey: .fontStyle)
|
||||||
fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName)
|
fontName = try typeContainer.decodeIfPresent(String.self, forKey: .fontName)
|
||||||
fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .fontSize)
|
fontSize = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .fontSize)
|
||||||
textAlignment = try typeContainer.decodeIfPresent(NSTextAlignment.self, forKey: .textAlignment)
|
textAlignment = try typeContainer.decodeIfPresent(NSTextAlignment.self, forKey: .textAlignment)
|
||||||
|
|||||||
@ -25,13 +25,13 @@ public typealias ActionBlockConfirmation = () -> (Bool)
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
/// Holds the on and off colors for the container.
|
/// Holds the on and off colors for the container.
|
||||||
public var containerTintColor: (on: UIColor?, off: UIColor?)? = (on: .mvmGreen, off: .black)
|
public var containerTintColor: (on: UIColor?, off: UIColor?)? = (on: .mvmGreen, off: .mvmBlack)
|
||||||
|
|
||||||
/// Holds the on and off colors for the knob.
|
/// Holds the on and off colors for the knob.
|
||||||
public var knobTintColor: (on: UIColor?, off: UIColor?)? = (on: .white, off: .white)
|
public var knobTintColor: (on: UIColor?, off: UIColor?)? = (on: .mvmWhite, off: .mvmWhite)
|
||||||
|
|
||||||
/// Holds the on and off colors for the disabled state..
|
/// Holds the on and off colors for the disabled state..
|
||||||
public var disabledTintColor: (container: UIColor?, knob: UIColor?)? = (container: .mvmCoolGray3, knob: .white)
|
public var disabledTintColor: (container: UIColor?, knob: UIColor?)? = (container: .mvmCoolGray3, knob: .mvmWhite)
|
||||||
|
|
||||||
/// Set this flag to false if you do not want to animate state changes.
|
/// Set this flag to false if you do not want to animate state changes.
|
||||||
public var isAnimated = true
|
public var isAnimated = true
|
||||||
|
|||||||
73
MVMCoreUI/Atomic/Molecules/Doughnut/ColorViewWithLabel.swift
Normal file
73
MVMCoreUI/Atomic/Molecules/Doughnut/ColorViewWithLabel.swift
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
//
|
||||||
|
// ColorViewWithLabel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Kevin Christiano on 4/7/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
|
||||||
|
open class ColorViewWithLabel: View {
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Properties
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
public var label = Label.createLabelRegularBodySmall(true)
|
||||||
|
public var colorView = View()
|
||||||
|
private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: 8)!
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Lifecycle
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
public var heightConstraint: NSLayoutConstraint?
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Lifecycle
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
open override func setupView() {
|
||||||
|
super.setupView()
|
||||||
|
|
||||||
|
addSubview(colorView)
|
||||||
|
addSubview(label)
|
||||||
|
|
||||||
|
heightConstraint = colorView.heightAnchor.constraint(equalToConstant: sizeObject.getValueBasedOnApplicationWidth())
|
||||||
|
heightConstraint?.isActive = true
|
||||||
|
colorView.widthAnchor.constraint(equalTo: colorView.heightAnchor).isActive = true
|
||||||
|
colorView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
|
||||||
|
colorView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
|
||||||
|
|
||||||
|
label.leadingAnchor.constraint(equalTo: colorView.trailingAnchor, constant: PaddingOne).isActive = true
|
||||||
|
label.topAnchor.constraint(equalTo: topAnchor).isActive = true
|
||||||
|
trailingAnchor.constraint(equalTo: label.trailingAnchor).isActive = true
|
||||||
|
bottomAnchor.constraint(equalTo: label.bottomAnchor).isActive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
open override func updateView(_ size: CGFloat) {
|
||||||
|
super.updateView(size)
|
||||||
|
label.updateView(size)
|
||||||
|
heightConstraint?.constant = sizeObject.getValueBased(onSize: size)
|
||||||
|
setNeedsDisplay()
|
||||||
|
}
|
||||||
|
|
||||||
|
open override func reset() {
|
||||||
|
super.reset()
|
||||||
|
label.reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - MoleculeViewProtocol
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
|
super.set(with: model, delegateObject, additionalData)
|
||||||
|
|
||||||
|
guard let chartItemModel = model as? DoughnutChartItemModel else { return }
|
||||||
|
|
||||||
|
label.set(with: chartItemModel.label, delegateObject, additionalData)
|
||||||
|
colorView.backgroundColor = chartItemModel.color.uiColor
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -8,23 +8,38 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
open class DoughnutChart: View {
|
|
||||||
var doughnutLayer = CALayer()
|
|
||||||
var titleLabel = Label.commonLabelH3(true)
|
|
||||||
var subTitleLabel = Label.commonLabelB2(true)
|
|
||||||
var doughnutChartModel: DoughnutChartModel? {
|
|
||||||
get { return model as? DoughnutChartModel }
|
|
||||||
}
|
|
||||||
var labelContainer = MVMCoreUICommonViewsUtility.commonView()
|
|
||||||
var labelContainerLeftConstraint: NSLayoutConstraint?
|
|
||||||
var labelContainerTopConstraint: NSLayoutConstraint?
|
|
||||||
var labelContainerBottomConstraint: NSLayoutConstraint?
|
|
||||||
var labelContainerRightConstraint: NSLayoutConstraint?
|
|
||||||
var heightConstraint: NSLayoutConstraint?
|
|
||||||
|
|
||||||
static let heightConstant: CGFloat = 150
|
open class DoughnutChart: View {
|
||||||
private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: heightConstant)!
|
//--------------------------------------------------
|
||||||
var height: CGFloat = heightConstant {
|
// MARK: - Properties
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
public var doughnutLayer = CALayer()
|
||||||
|
public var titleLabel = Label.createLabelBoldTitleLarge(true)
|
||||||
|
public var subTitleLabel = Label.createLabelRegularMicro(true)
|
||||||
|
public var labelContainer = MVMCoreUICommonViewsUtility.commonView()
|
||||||
|
public static let heightConstant: CGFloat = 136
|
||||||
|
private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: heightConstant)!
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Constraints
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
public var labelContainerLeftConstraint: NSLayoutConstraint?
|
||||||
|
public var labelContainerTopConstraint: NSLayoutConstraint?
|
||||||
|
public var labelContainerBottomConstraint: NSLayoutConstraint?
|
||||||
|
public var labelContainerRightConstraint: NSLayoutConstraint?
|
||||||
|
public var heightConstraint: NSLayoutConstraint?
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Computed Properties
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
public var doughnutChartModel: DoughnutChartModel? {
|
||||||
|
get { return model as? DoughnutChartModel }
|
||||||
|
}
|
||||||
|
|
||||||
|
public var height: CGFloat = heightConstant {
|
||||||
didSet {
|
didSet {
|
||||||
if height != oldValue {
|
if height != oldValue {
|
||||||
sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: height)!
|
sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: height)!
|
||||||
@ -32,69 +47,89 @@ open class DoughnutChart: View {
|
|||||||
drawGraph()
|
drawGraph()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
open override func updateView(_ size: CGFloat) {
|
|
||||||
super.updateView(size)
|
|
||||||
titleLabel.updateView(size)
|
|
||||||
subTitleLabel.updateView(size)
|
|
||||||
updateContainer()
|
|
||||||
drawGraph()
|
|
||||||
}
|
|
||||||
|
|
||||||
open override func reset() {
|
|
||||||
super.reset()
|
|
||||||
titleLabel.reset()
|
|
||||||
subTitleLabel.reset()
|
|
||||||
clearLayers()
|
|
||||||
}
|
|
||||||
|
|
||||||
open override func setupView() {
|
|
||||||
super.setupView()
|
|
||||||
guard labelContainer.superview == nil else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
addSubview(labelContainer)
|
|
||||||
|
|
||||||
labelContainer.addSubview(titleLabel)
|
|
||||||
labelContainer.addSubview(subTitleLabel)
|
|
||||||
titleLabel.textAlignment = .center
|
|
||||||
subTitleLabel.textAlignment = .center
|
|
||||||
|
|
||||||
//Make label font size to adjust width if label content is high
|
|
||||||
titleLabel.numberOfLines = 1
|
|
||||||
titleLabel.adjustsFontSizeToFitWidth = true
|
|
||||||
|
|
||||||
layer.addSublayer(doughnutLayer)
|
|
||||||
heightConstraint = heightAnchor.constraint(equalToConstant:
|
|
||||||
sizeObject.getValueBasedOnApplicationWidth())
|
|
||||||
heightConstraint?.isActive = true
|
|
||||||
widthAnchor.constraint(equalTo: heightAnchor).isActive = true
|
|
||||||
|
|
||||||
labelContainerLeftConstraint = labelContainer.leftAnchor.constraint(greaterThanOrEqualTo: leftAnchor, constant: lineWidth())
|
|
||||||
labelContainerLeftConstraint?.isActive = true
|
|
||||||
labelContainerTopConstraint = labelContainer.topAnchor.constraint(greaterThanOrEqualTo: topAnchor, constant: lineWidth())
|
|
||||||
labelContainerTopConstraint?.isActive = true
|
|
||||||
labelContainerRightConstraint = rightAnchor.constraint(greaterThanOrEqualTo: labelContainer.rightAnchor, constant: lineWidth())
|
|
||||||
labelContainerRightConstraint?.isActive = true
|
|
||||||
labelContainerBottomConstraint = bottomAnchor.constraint(greaterThanOrEqualTo: labelContainer.bottomAnchor, constant: lineWidth())
|
|
||||||
labelContainerBottomConstraint?.isActive = true
|
|
||||||
labelContainer.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
|
|
||||||
labelContainer.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
|
|
||||||
|
|
||||||
NSLayoutConstraint.constraintPinSubview(titleLabel, pinTop: true, pinBottom: false, pinLeft: true, pinRight: true)
|
|
||||||
NSLayoutConstraint.constraintPinSubview(subTitleLabel, pinTop: false, pinBottom: true, pinLeft: true, pinRight: true)
|
|
||||||
_ = NSLayoutConstraint(pinFirstView: titleLabel, toSecondView: subTitleLabel, withConstant: 0, directionVertical: true)
|
|
||||||
//Rotate view for initial draw
|
|
||||||
doughnutLayer.transform = CATransform3DMakeRotation(1 * .pi, 0.0, 0.0, 1.0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
//--------------------------------------------------
|
||||||
|
// MARK: - Initializers
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
public override init(frame: CGRect) {
|
||||||
|
super.init(frame: .zero)
|
||||||
|
}
|
||||||
|
|
||||||
|
public convenience init() {
|
||||||
|
self.init(frame: .zero)
|
||||||
|
}
|
||||||
|
|
||||||
|
public required init?(coder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Lifecycle
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
open override func updateView(_ size: CGFloat) {
|
||||||
|
super.updateView(size)
|
||||||
|
titleLabel.updateView(size)
|
||||||
|
subTitleLabel.updateView(size)
|
||||||
|
updateContainer()
|
||||||
|
drawGraph()
|
||||||
|
}
|
||||||
|
|
||||||
|
open override func reset() {
|
||||||
|
super.reset()
|
||||||
|
titleLabel.reset()
|
||||||
|
subTitleLabel.reset()
|
||||||
|
clearLayers()
|
||||||
|
}
|
||||||
|
|
||||||
|
open override func setupView() {
|
||||||
|
super.setupView()
|
||||||
|
|
||||||
|
addSubview(labelContainer)
|
||||||
|
|
||||||
|
labelContainer.addSubview(titleLabel)
|
||||||
|
labelContainer.addSubview(subTitleLabel)
|
||||||
|
titleLabel.textAlignment = .center
|
||||||
|
subTitleLabel.textAlignment = .center
|
||||||
|
|
||||||
|
//Make label font size to adjust width if label content is high
|
||||||
|
titleLabel.numberOfLines = 1
|
||||||
|
titleLabel.adjustsFontSizeToFitWidth = true
|
||||||
|
|
||||||
|
layer.addSublayer(doughnutLayer)
|
||||||
|
heightConstraint = heightAnchor.constraint(equalToConstant: sizeObject.getValueBasedOnApplicationWidth())
|
||||||
|
heightConstraint?.isActive = true
|
||||||
|
widthAnchor.constraint(equalTo: heightAnchor).isActive = true
|
||||||
|
|
||||||
|
labelContainerLeftConstraint = labelContainer.leadingAnchor.constraint(greaterThanOrEqualTo: leadingAnchor, constant: lineWidth())
|
||||||
|
labelContainerLeftConstraint?.isActive = true
|
||||||
|
labelContainerTopConstraint = labelContainer.topAnchor.constraint(greaterThanOrEqualTo: topAnchor, constant: lineWidth())
|
||||||
|
labelContainerTopConstraint?.isActive = true
|
||||||
|
labelContainerRightConstraint = trailingAnchor.constraint(greaterThanOrEqualTo: labelContainer.trailingAnchor, constant: lineWidth())
|
||||||
|
labelContainerRightConstraint?.isActive = true
|
||||||
|
labelContainerBottomConstraint = bottomAnchor.constraint(greaterThanOrEqualTo: labelContainer.bottomAnchor, constant: lineWidth())
|
||||||
|
labelContainerBottomConstraint?.isActive = true
|
||||||
|
labelContainer.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
|
||||||
|
labelContainer.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
|
||||||
|
|
||||||
|
NSLayoutConstraint.constraintPinSubview(titleLabel, pinTop: true, pinBottom: false, pinLeft: true, pinRight: true)
|
||||||
|
NSLayoutConstraint.constraintPinSubview(subTitleLabel, pinTop: false, pinBottom: true, pinLeft: true, pinRight: true)
|
||||||
|
_ = NSLayoutConstraint(pinFirstView: titleLabel, toSecondView: subTitleLabel, withConstant: 0, directionVertical: true)
|
||||||
|
//Rotate view for initial draw
|
||||||
|
doughnutLayer.transform = CATransform3DMakeRotation(1 * .pi, 0, 0, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - MoleculeViewProtocol
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
super.set(with: model, delegateObject, additionalData)
|
super.set(with: model, delegateObject, additionalData)
|
||||||
clearLayers()
|
clearLayers()
|
||||||
guard let doughnutChartModel = doughnutChartModel else {
|
guard let doughnutChartModel = doughnutChartModel else { return }
|
||||||
return
|
|
||||||
}
|
|
||||||
titleLabel.setOptional(with: doughnutChartModel.title, delegateObject, additionalData)
|
titleLabel.setOptional(with: doughnutChartModel.title, delegateObject, additionalData)
|
||||||
subTitleLabel.setOptional(with: doughnutChartModel.subtitle, delegateObject, additionalData)
|
subTitleLabel.setOptional(with: doughnutChartModel.subtitle, delegateObject, additionalData)
|
||||||
titleLabel.textAlignment = .center
|
titleLabel.textAlignment = .center
|
||||||
@ -103,78 +138,83 @@ open class DoughnutChart: View {
|
|||||||
drawGraph()
|
drawGraph()
|
||||||
}
|
}
|
||||||
|
|
||||||
func drawGraph() {
|
//--------------------------------------------------
|
||||||
clearLayers()
|
// MARK: - Draw Graph
|
||||||
let widthHeight = sizeObject.getValueBasedOnApplicationWidth()
|
//--------------------------------------------------
|
||||||
doughnutLayer.frame = CGRect(x: 0, y: 0,
|
|
||||||
width: widthHeight,
|
private func drawGraph() {
|
||||||
height: widthHeight)
|
clearLayers()
|
||||||
if let doughnutChart = doughnutChartModel {
|
let widthHeight = sizeObject.getValueBasedOnApplicationWidth()
|
||||||
var prevPercent: CGFloat = 0.0
|
doughnutLayer.frame = CGRect(x: 0, y: 0, width: widthHeight, height: widthHeight)
|
||||||
for model in doughnutChart.sections {
|
|
||||||
|
if let doughnutChart = doughnutChartModel {
|
||||||
|
var prevPercent: CGFloat = 0.0
|
||||||
|
for model in doughnutChart.sections {
|
||||||
prevPercent += drawBar(model, prevPercent)
|
prevPercent += drawBar(model, prevPercent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func drawBar(_ chartModel: DoughnutChartItemModel, _ prevPercent: CGFloat) -> CGFloat {
|
private func drawBar(_ chartModel: DoughnutChartItemModel, _ prevPercent: CGFloat) -> CGFloat {
|
||||||
|
|
||||||
let shapeLayer = CAShapeLayer()
|
let shapeLayer = CAShapeLayer()
|
||||||
shapeLayer.frame = doughnutLayer.frame
|
shapeLayer.frame = doughnutLayer.frame
|
||||||
shapeLayer.lineWidth = lineWidth()
|
shapeLayer.lineWidth = lineWidth()
|
||||||
shapeLayer.fillColor = nil
|
shapeLayer.fillColor = nil
|
||||||
shapeLayer.strokeColor = chartModel.color.uiColor.cgColor
|
shapeLayer.strokeColor = chartModel.color.uiColor.cgColor
|
||||||
|
|
||||||
let arcCenter = shapeLayer.position
|
let arcCenter = shapeLayer.position
|
||||||
let radius = shapeLayer.bounds.size.width / 2.0 - lineWidth()/2.0
|
let radius = shapeLayer.bounds.size.width / 2.0 - lineWidth() / 2.0
|
||||||
|
|
||||||
let value: CGFloat = chartModel.percent
|
let value: CGFloat = chartModel.percent
|
||||||
let gap: CGFloat = spaceRequired() ? lineGap() : 0.0
|
let gap: CGFloat = spaceRequired() ? lineGap() : 0.0
|
||||||
let startAngle = ((prevPercent / 100.0) * 2 * .pi) - (0.5 * .pi)
|
let startAngle = ((prevPercent / 100.0) * 2 * .pi) - (0.5 * .pi)
|
||||||
let endAngle = ((value / 100.0) * 2 * .pi) + startAngle - gap
|
let endAngle = ((value / 100.0) * 2 * .pi) + startAngle - gap
|
||||||
let circlePath = UIBezierPath(arcCenter: arcCenter,
|
let circlePath = UIBezierPath(arcCenter: arcCenter,
|
||||||
radius: radius,
|
radius: radius,
|
||||||
startAngle: startAngle,
|
startAngle: startAngle,
|
||||||
endAngle: endAngle,
|
endAngle: endAngle,
|
||||||
clockwise: true)
|
clockwise: true)
|
||||||
|
|
||||||
shapeLayer.path = circlePath.cgPath
|
shapeLayer.path = circlePath.cgPath
|
||||||
doughnutLayer.addSublayer(shapeLayer)
|
doughnutLayer.addSublayer(shapeLayer)
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
func clearLayers() {
|
private func clearLayers() {
|
||||||
doughnutLayer.sublayers?.forEach({ $0.removeFromSuperlayer() })
|
doughnutLayer.sublayers?.forEach{ $0.removeFromSuperlayer() }
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateContainer() {
|
public func updateContainer() {
|
||||||
heightConstraint?.constant = sizeObject.getValueBasedOnApplicationWidth()
|
|
||||||
updateLabelContainer()
|
|
||||||
setNeedsDisplay()
|
|
||||||
}
|
|
||||||
|
|
||||||
func lineWidth() -> CGFloat {
|
heightConstraint?.constant = sizeObject.getValueBasedOnApplicationWidth()
|
||||||
return 30
|
updateLabelContainer()
|
||||||
}
|
setNeedsDisplay()
|
||||||
|
}
|
||||||
|
|
||||||
func lineGap() -> CGFloat {
|
public func lineWidth() -> CGFloat {
|
||||||
|
return 12
|
||||||
|
}
|
||||||
|
|
||||||
|
public func lineGap() -> CGFloat {
|
||||||
//If array is having the single item then no space required
|
//If array is having the single item then no space required
|
||||||
return doughnutChartModel?.sections.count == 1 ? 0.0 : 0.05
|
return doughnutChartModel?.sections.count == 1 ? 0.0 : 0.05
|
||||||
}
|
}
|
||||||
|
|
||||||
func spaceRequired() -> Bool {
|
public func spaceRequired() -> Bool {
|
||||||
return doughnutChartModel?.spaceRequired ?? true
|
return doughnutChartModel?.spaceRequired ?? true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func updateLabelContainer() {
|
||||||
|
|
||||||
func updateLabelContainer() {
|
|
||||||
labelContainer.setNeedsDisplay()
|
labelContainer.setNeedsDisplay()
|
||||||
labelContainer.layoutIfNeeded()
|
labelContainer.layoutIfNeeded()
|
||||||
let radius = sizeObject.getValueBasedOnApplicationWidth()/2 - lineWidth()
|
let radius = sizeObject.getValueBasedOnApplicationWidth() / 2 - lineWidth()
|
||||||
let labelheight = labelContainer.frame.height/2
|
let labelheight = labelContainer.frame.height / 2
|
||||||
let padding = sizeObject.getValueBasedOnApplicationWidth()/2 - sqrt(max(0, pow(radius, 2) - pow(labelheight, 2)))
|
let padding = sizeObject.getValueBasedOnApplicationWidth() / 2 - sqrt(max(0, pow(radius, 2) - pow(labelheight, 2)))
|
||||||
|
|
||||||
labelContainerLeftConstraint?.constant = padding
|
labelContainerLeftConstraint?.constant = round(padding)
|
||||||
labelContainerRightConstraint?.constant = padding
|
labelContainerRightConstraint?.constant = round(padding)
|
||||||
labelContainerTopConstraint?.constant = max(radius - labelheight, labelheight)
|
labelContainerTopConstraint?.constant = max(radius - labelheight, labelheight)
|
||||||
labelContainerBottomConstraint?.constant = max(radius - labelheight, labelheight)
|
labelContainerBottomConstraint?.constant = max(radius - labelheight, labelheight)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,44 @@
|
|||||||
|
//
|
||||||
|
// DoughnutChartItemModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Kevin Christiano on 4/7/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
@objcMembers public class DoughnutChartItemModel: MoleculeModelProtocol {
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Properties
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
public var backgroundColor: Color?
|
||||||
|
public static var identifier: String = "doughnutChartItem"
|
||||||
|
public var moleculeName: String = DoughnutChartItemModel.identifier
|
||||||
|
public var label: LabelModel
|
||||||
|
@Percent public var percent: CGFloat
|
||||||
|
public var color: Color
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Keys
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case backgroundColor
|
||||||
|
case label
|
||||||
|
case percent
|
||||||
|
case color
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Initializer
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
public init(percent: CGFloat, color: Color, label: LabelModel) {
|
||||||
|
self.percent = percent
|
||||||
|
self.color = color
|
||||||
|
self.label = label
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -8,7 +8,12 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
@objcMembers public class DoughnutChartModel: MoleculeModelProtocol {
|
@objcMembers public class DoughnutChartModel: MoleculeModelProtocol {
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Properties
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public static var identifier: String = "doughnutChart"
|
public static var identifier: String = "doughnutChart"
|
||||||
public var moleculeName: String = DoughnutChartModel.identifier
|
public var moleculeName: String = DoughnutChartModel.identifier
|
||||||
@ -17,22 +22,11 @@ import Foundation
|
|||||||
public var sections: [DoughnutChartItemModel]
|
public var sections: [DoughnutChartItemModel]
|
||||||
public var spaceRequired: Bool?
|
public var spaceRequired: Bool?
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Initializer
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
public init(sections: [DoughnutChartItemModel]) {
|
public init(sections: [DoughnutChartItemModel]) {
|
||||||
self.sections = sections
|
self.sections = sections
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objcMembers public class DoughnutChartItemModel: MoleculeModelProtocol {
|
|
||||||
public var backgroundColor: Color?
|
|
||||||
public static var identifier: String = "doughnutChartItem"
|
|
||||||
public var moleculeName: String = DoughnutChartItemModel.identifier
|
|
||||||
public var label: LabelModel
|
|
||||||
@Percent public var percent: CGFloat
|
|
||||||
public var color: Color
|
|
||||||
|
|
||||||
public init(percent: CGFloat, color: Color, label: LabelModel) {
|
|
||||||
self.percent = percent
|
|
||||||
self.color = color
|
|
||||||
self.label = label
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -8,46 +8,52 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
@objcMembers open class DoughnutChartView: View {
|
@objcMembers open class DoughnutChartView: View {
|
||||||
var doughnutChart = DoughnutChart(frame: CGRect.zero)
|
//--------------------------------------------------
|
||||||
|
// MARK: - Properties
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
public var doughnutChart = DoughnutChart()
|
||||||
var colorLablesStack = ColorViewLabelsStack()
|
var colorLablesStack = ColorViewLabelsStack()
|
||||||
var doughnutChartModel: DoughnutChartModel? {
|
|
||||||
get { return model as? DoughnutChartModel }
|
public var doughnutChartModel: DoughnutChartModel? {
|
||||||
|
get { return model as? DoughnutChartModel }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Lifecycle
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
open override func setupView() {
|
open override func setupView() {
|
||||||
super.setupView()
|
super.setupView()
|
||||||
guard doughnutChart.superview == nil else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
doughnutChart.translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
addSubview(doughnutChart)
|
addSubview(doughnutChart)
|
||||||
colorLablesStack.translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
addSubview(colorLablesStack)
|
addSubview(colorLablesStack)
|
||||||
|
|
||||||
doughnutChart.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
|
doughnutChart.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
|
||||||
doughnutChart.topAnchor.constraint(equalTo: topAnchor).isActive = true
|
doughnutChart.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true
|
||||||
|
|
||||||
bottomAnchor.constraint(greaterThanOrEqualTo: doughnutChart.bottomAnchor).isActive = true
|
bottomAnchor.constraint(greaterThanOrEqualTo: doughnutChart.bottomAnchor).isActive = true
|
||||||
|
|
||||||
let doughnutBottomAnchor = bottomAnchor.constraint(equalTo: doughnutChart.bottomAnchor)
|
let doughnutBottomAnchor = bottomAnchor.constraint(equalTo: doughnutChart.bottomAnchor)
|
||||||
doughnutBottomAnchor.priority = UILayoutPriority(rawValue: 200)
|
doughnutBottomAnchor.priority = UILayoutPriority(rawValue: 200)
|
||||||
doughnutBottomAnchor.isActive = true
|
doughnutBottomAnchor.isActive = true
|
||||||
|
|
||||||
|
bottomAnchor.constraint(greaterThanOrEqualTo: colorLablesStack.bottomAnchor).isActive = true
|
||||||
|
|
||||||
let colorLablesBottomAnchor = bottomAnchor.constraint(equalTo: colorLablesStack.bottomAnchor)
|
let colorLablesBottomAnchor = bottomAnchor.constraint(equalTo: colorLablesStack.bottomAnchor)
|
||||||
colorLablesBottomAnchor.priority = UILayoutPriority(rawValue: 204)
|
colorLablesBottomAnchor.priority = UILayoutPriority(rawValue: 204)
|
||||||
colorLablesBottomAnchor.isActive = true
|
colorLablesBottomAnchor.isActive = true
|
||||||
|
|
||||||
let colorLablesTopAnchor = colorLablesStack.topAnchor.constraint(equalTo: doughnutChart.topAnchor)
|
colorLablesStack.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true
|
||||||
|
|
||||||
|
let colorLablesTopAnchor = colorLablesStack.topAnchor.constraint(equalTo: topAnchor)
|
||||||
colorLablesTopAnchor.priority = .defaultLow
|
colorLablesTopAnchor.priority = .defaultLow
|
||||||
colorLablesTopAnchor.isActive = true
|
colorLablesTopAnchor.isActive = true
|
||||||
|
|
||||||
colorLablesStack.topAnchor.constraint(greaterThanOrEqualTo: doughnutChart.topAnchor).isActive = true
|
|
||||||
bottomAnchor.constraint(greaterThanOrEqualTo: colorLablesStack.bottomAnchor).isActive = true
|
|
||||||
trailingAnchor.constraint(equalTo: colorLablesStack.trailingAnchor).isActive = true
|
trailingAnchor.constraint(equalTo: colorLablesStack.trailingAnchor).isActive = true
|
||||||
|
doughnutChart.centerYAnchor.constraint(equalTo: colorLablesStack.centerYAnchor).isActive = true
|
||||||
let centerY = colorLablesStack.centerYAnchor.constraint(equalTo: doughnutChart.centerYAnchor)
|
|
||||||
centerY.priority = UILayoutPriority(rawValue: 500)
|
|
||||||
centerY.isActive = true
|
|
||||||
|
|
||||||
colorLablesStack.leadingAnchor.constraint(equalTo: doughnutChart.trailingAnchor, constant: PaddingThree).isActive = true
|
colorLablesStack.leadingAnchor.constraint(equalTo: doughnutChart.trailingAnchor, constant: PaddingThree).isActive = true
|
||||||
colorLablesStack.backgroundColor = .clear
|
colorLablesStack.backgroundColor = .clear
|
||||||
@ -65,7 +71,11 @@ import Foundation
|
|||||||
colorLablesStack.reset()
|
colorLablesStack.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
//--------------------------------------------------
|
||||||
|
// MARK: - MoleculeViewProtocol
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
super.set(with: model, delegateObject, additionalData)
|
super.set(with: model, delegateObject, additionalData)
|
||||||
|
|
||||||
guard let model = doughnutChartModel else { return }
|
guard let model = doughnutChartModel else { return }
|
||||||
@ -82,14 +92,17 @@ import Foundation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - MVMCoreUIViewConstrainingProtocol
|
||||||
extension DoughnutChartView: MVMCoreUIViewConstrainingProtocol {
|
extension DoughnutChartView: MVMCoreUIViewConstrainingProtocol {
|
||||||
|
|
||||||
open func horizontalAlignment() -> UIStackView.Alignment {
|
open func horizontalAlignment() -> UIStackView.Alignment {
|
||||||
return .leading
|
return .leading
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ColorViewLabelsStack: MoleculeStackView {
|
class ColorViewLabelsStack: MoleculeStackView {
|
||||||
override func createStackItemsFromModel(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
|
||||||
|
override func createStackItemsFromModel(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
guard let stackItemModels = stackModel?.molecules else { return }
|
guard let stackItemModels = stackModel?.molecules else { return }
|
||||||
for model in stackItemModels {
|
for model in stackItemModels {
|
||||||
let view = ColorViewWithLabel()
|
let view = ColorViewWithLabel()
|
||||||
@ -99,53 +112,3 @@ class ColorViewLabelsStack: MoleculeStackView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ColorViewWithLabel: View {
|
|
||||||
|
|
||||||
var label = Label.commonLabelB2(true)
|
|
||||||
var colorView = MVMCoreUICommonViewsUtility.commonView()
|
|
||||||
private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: 8)!
|
|
||||||
var heightConstraint: NSLayoutConstraint?
|
|
||||||
|
|
||||||
override func setupView() {
|
|
||||||
super.setupView()
|
|
||||||
guard colorView.superview == nil else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
addSubview(colorView)
|
|
||||||
addSubview(label)
|
|
||||||
|
|
||||||
heightConstraint = colorView.heightAnchor.constraint(equalToConstant: sizeObject.getValueBasedOnApplicationWidth())
|
|
||||||
heightConstraint?.isActive = true
|
|
||||||
colorView.widthAnchor.constraint(equalTo: colorView.heightAnchor).isActive = true
|
|
||||||
colorView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
|
|
||||||
colorView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
|
|
||||||
|
|
||||||
label.leadingAnchor.constraint(equalTo: colorView.trailingAnchor, constant: PaddingOne).isActive = true
|
|
||||||
label.topAnchor.constraint(equalTo: topAnchor).isActive = true
|
|
||||||
trailingAnchor.constraint(equalTo: label.trailingAnchor).isActive = true
|
|
||||||
bottomAnchor.constraint(equalTo: label.bottomAnchor).isActive = true
|
|
||||||
}
|
|
||||||
|
|
||||||
override func updateView(_ size: CGFloat) {
|
|
||||||
super.updateView(size)
|
|
||||||
label.updateView(size)
|
|
||||||
heightConstraint?.constant = sizeObject.getValueBased(onSize: size)
|
|
||||||
setNeedsDisplay()
|
|
||||||
}
|
|
||||||
|
|
||||||
override func reset() {
|
|
||||||
super.reset()
|
|
||||||
label.reset()
|
|
||||||
}
|
|
||||||
|
|
||||||
override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
|
||||||
super.set(with: model, delegateObject, additionalData)
|
|
||||||
guard let chartItemModel = model as? DoughnutChartItemModel else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
label.set(with: chartItemModel.label, delegateObject, additionalData)
|
|
||||||
colorView.backgroundColor = chartItemModel.color.uiColor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import UIKit
|
|||||||
/// The bottom border line. Height is dynamic based on scenario.
|
/// The bottom border line. Height is dynamic based on scenario.
|
||||||
public var bottomBar: CAShapeLayer? = {
|
public var bottomBar: CAShapeLayer? = {
|
||||||
let layer = CAShapeLayer()
|
let layer = CAShapeLayer()
|
||||||
layer.backgroundColor = UIColor.black.cgColor
|
layer.backgroundColor = UIColor.mvmBlack.cgColor
|
||||||
layer.drawsAsynchronously = true
|
layer.drawsAsynchronously = true
|
||||||
layer.anchorPoint = CGPoint(x: 0.5, y: 1.0);
|
layer.anchorPoint = CGPoint(x: 0.5, y: 1.0);
|
||||||
return layer
|
return layer
|
||||||
@ -46,7 +46,7 @@ import UIKit
|
|||||||
/// Determines if the top, left, and right borders should be drawn.
|
/// Determines if the top, left, and right borders should be drawn.
|
||||||
private var hideBorders = false
|
private var hideBorders = false
|
||||||
|
|
||||||
public var borderStrokeColor: UIColor = .mfSilver()
|
public var borderStrokeColor: UIColor = .mvmCoolGray3
|
||||||
private var borderPath: UIBezierPath = UIBezierPath()
|
private var borderPath: UIBezierPath = UIBezierPath()
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -210,8 +210,8 @@ import UIKit
|
|||||||
|
|
||||||
isUserInteractionEnabled = true
|
isUserInteractionEnabled = true
|
||||||
hideBorders = false
|
hideBorders = false
|
||||||
borderStrokeColor = .mfSilver()
|
borderStrokeColor = .mvmCoolGray3
|
||||||
bottomBar?.backgroundColor = UIColor.black.cgColor
|
bottomBar?.backgroundColor = UIColor.mvmBlack.cgColor
|
||||||
refreshUI(bottomBarSize: 1)
|
refreshUI(bottomBarSize: 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,8 +219,8 @@ import UIKit
|
|||||||
|
|
||||||
isUserInteractionEnabled = true
|
isUserInteractionEnabled = true
|
||||||
hideBorders = false
|
hideBorders = false
|
||||||
borderStrokeColor = .mfPumpkin()
|
borderStrokeColor = .mvmOrange
|
||||||
bottomBar?.backgroundColor = UIColor.mfPumpkin().cgColor
|
bottomBar?.backgroundColor = UIColor.mvmOrange.cgColor
|
||||||
refreshUI(bottomBarSize: 4)
|
refreshUI(bottomBarSize: 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,8 +228,8 @@ import UIKit
|
|||||||
|
|
||||||
isUserInteractionEnabled = true
|
isUserInteractionEnabled = true
|
||||||
hideBorders = false
|
hideBorders = false
|
||||||
borderStrokeColor = .black
|
borderStrokeColor = .mvmBlack
|
||||||
bottomBar?.backgroundColor = UIColor.mfPumpkin().cgColor
|
bottomBar?.backgroundColor = UIColor.mvmOrange.cgColor
|
||||||
refreshUI(bottomBarSize: 4)
|
refreshUI(bottomBarSize: 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,8 +237,8 @@ import UIKit
|
|||||||
|
|
||||||
isUserInteractionEnabled = true
|
isUserInteractionEnabled = true
|
||||||
hideBorders = false
|
hideBorders = false
|
||||||
borderStrokeColor = .black
|
borderStrokeColor = .mvmBlack
|
||||||
bottomBar?.backgroundColor = UIColor.black.cgColor
|
bottomBar?.backgroundColor = UIColor.mvmBlack.cgColor
|
||||||
refreshUI(bottomBarSize: 1)
|
refreshUI(bottomBarSize: 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ import UIKit
|
|||||||
|
|
||||||
isUserInteractionEnabled = false
|
isUserInteractionEnabled = false
|
||||||
hideBorders = false
|
hideBorders = false
|
||||||
borderStrokeColor = .mfSilver()
|
borderStrokeColor = .mvmCoolGray3
|
||||||
bottomBar?.backgroundColor = UIColor.mvmCoolGray3.cgColor
|
bottomBar?.backgroundColor = UIColor.mvmCoolGray3.cgColor
|
||||||
refreshUI(bottomBarSize: 1)
|
refreshUI(bottomBarSize: 1)
|
||||||
}
|
}
|
||||||
|
|||||||
48
MVMCoreUI/Styles/Padding.swift
Normal file
48
MVMCoreUI/Styles/Padding.swift
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
//
|
||||||
|
// Padding.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Kevin Christiano on 4/1/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
/// Padding is a multiple based on the number 4.
|
||||||
|
public struct Padding {
|
||||||
|
|
||||||
|
public static let OneHalf: CGFloat = 2
|
||||||
|
public static let One: CGFloat = 4
|
||||||
|
public static let Two: CGFloat = 8
|
||||||
|
public static let Three: CGFloat = 12
|
||||||
|
public static let Four: CGFloat = 16
|
||||||
|
public static let Five: CGFloat = 24
|
||||||
|
public static let Eight: CGFloat = 32
|
||||||
|
public static let Ten: CGFloat = 40
|
||||||
|
public static let Twelve: CGFloat = 48
|
||||||
|
public static let Eighteen: CGFloat = 72
|
||||||
|
|
||||||
|
public struct Component {
|
||||||
|
public static let Standard: CGFloat = 24
|
||||||
|
public static let HorizontalMarginSpacing: CGFloat = 32
|
||||||
|
public static let LargeVerticalMarginSpacing: CGFloat = 32
|
||||||
|
public static let VerticalMarginSpacing: CGFloat = 24
|
||||||
|
|
||||||
|
public static var horizontalPaddingForApplicationWidth: CGFloat {
|
||||||
|
return MFSizeObject(scalingStandardSize: HorizontalMarginSpacing)?.getValueBasedOnApplicationWidth() ?? HorizontalMarginSpacing
|
||||||
|
}
|
||||||
|
|
||||||
|
public static var verticalPaddingForApplicationWidth: CGFloat {
|
||||||
|
return MFSizeObject(scalingStandardSize: VerticalMarginSpacing)?.getValueBasedOnApplicationWidth() ?? VerticalMarginSpacing
|
||||||
|
}
|
||||||
|
|
||||||
|
public static func horizontalPaddingForSize(_ size: CGFloat) -> CGFloat {
|
||||||
|
return MFSizeObject(scalingStandardSize: HorizontalMarginSpacing)?.getValueBased(onSize: size) ?? HorizontalMarginSpacing
|
||||||
|
}
|
||||||
|
|
||||||
|
public static func verticalPaddingForSize(_ size: CGFloat) -> CGFloat {
|
||||||
|
return MFSizeObject(scalingStandardSize: VerticalMarginSpacing)?.getValueBased(onSize: size) ?? VerticalMarginSpacing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
228
MVMCoreUI/Styles/Styler.swift
Normal file
228
MVMCoreUI/Styles/Styler.swift
Normal file
@ -0,0 +1,228 @@
|
|||||||
|
//
|
||||||
|
// Styler.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Kevin Christiano on 4/1/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
open class Styler {
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Enums
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
public enum Font: String, Codable {
|
||||||
|
case Title2XLarge
|
||||||
|
case TitleXLarge
|
||||||
|
case BoldTitleLarge
|
||||||
|
case RegularTitleLarge
|
||||||
|
case BoldTitleMedium
|
||||||
|
case RegularTitleMedium
|
||||||
|
case BoldBodyLarge
|
||||||
|
case RegularBodyLarge
|
||||||
|
case BoldBodySmall
|
||||||
|
case RegularBodySmall
|
||||||
|
case BoldMicro
|
||||||
|
case RegularMicro
|
||||||
|
|
||||||
|
// Legacy Fonts
|
||||||
|
case H1
|
||||||
|
case H2
|
||||||
|
case H3
|
||||||
|
case H32
|
||||||
|
case B1
|
||||||
|
case B2
|
||||||
|
case B3
|
||||||
|
case B20
|
||||||
|
|
||||||
|
/// Returns the font size of the current enum case.
|
||||||
|
public func pointSize() -> CGFloat {
|
||||||
|
switch self {
|
||||||
|
case .H1:
|
||||||
|
return 40
|
||||||
|
|
||||||
|
case .Title2XLarge:
|
||||||
|
return 36
|
||||||
|
|
||||||
|
case .TitleXLarge,
|
||||||
|
.H32:
|
||||||
|
return 32
|
||||||
|
|
||||||
|
case .H2:
|
||||||
|
return 25
|
||||||
|
|
||||||
|
case .BoldTitleLarge,
|
||||||
|
.RegularTitleLarge:
|
||||||
|
return 24
|
||||||
|
|
||||||
|
case .BoldTitleMedium,
|
||||||
|
.RegularTitleMedium,
|
||||||
|
.B20:
|
||||||
|
return 20
|
||||||
|
|
||||||
|
case .H3:
|
||||||
|
return 18
|
||||||
|
|
||||||
|
case .BoldBodyLarge,
|
||||||
|
.RegularBodyLarge:
|
||||||
|
return 16
|
||||||
|
|
||||||
|
case .BoldBodySmall,
|
||||||
|
.RegularBodySmall,
|
||||||
|
.B1,
|
||||||
|
.B2:
|
||||||
|
return 13
|
||||||
|
|
||||||
|
case .BoldMicro,
|
||||||
|
.RegularMicro,
|
||||||
|
.B3:
|
||||||
|
return 11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Determines if the selected font case is bold or regular.
|
||||||
|
public func isBold() -> Bool {
|
||||||
|
|
||||||
|
switch self {
|
||||||
|
case .Title2XLarge,
|
||||||
|
.TitleXLarge,
|
||||||
|
.RegularTitleLarge,
|
||||||
|
.RegularTitleMedium,
|
||||||
|
.RegularBodyLarge,
|
||||||
|
.RegularBodySmall,
|
||||||
|
.RegularMicro,
|
||||||
|
.B2,
|
||||||
|
.B3,
|
||||||
|
.B20:
|
||||||
|
return false
|
||||||
|
|
||||||
|
case .BoldTitleLarge,
|
||||||
|
.BoldTitleMedium,
|
||||||
|
.BoldBodyLarge,
|
||||||
|
.BoldBodySmall,
|
||||||
|
.BoldMicro,
|
||||||
|
.H1,
|
||||||
|
.H2,
|
||||||
|
.H3,
|
||||||
|
.H32,
|
||||||
|
.B1:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Determines if the current enum is a legacy or modern font.
|
||||||
|
public func isLegacyFont() -> Bool {
|
||||||
|
|
||||||
|
switch self {
|
||||||
|
case .Title2XLarge,
|
||||||
|
.TitleXLarge,
|
||||||
|
.RegularTitleLarge,
|
||||||
|
.RegularTitleMedium,
|
||||||
|
.RegularBodyLarge,
|
||||||
|
.RegularBodySmall,
|
||||||
|
.RegularMicro,
|
||||||
|
.BoldTitleLarge,
|
||||||
|
.BoldTitleMedium,
|
||||||
|
.BoldBodyLarge,
|
||||||
|
.BoldBodySmall,
|
||||||
|
.BoldMicro:
|
||||||
|
return false
|
||||||
|
|
||||||
|
case .H1,
|
||||||
|
.H2,
|
||||||
|
.H3,
|
||||||
|
.H32,
|
||||||
|
.B1,
|
||||||
|
.B2,
|
||||||
|
.B3,
|
||||||
|
.B20:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the font based on the declared enum case.
|
||||||
|
public func getFont(_ genericScaling: Bool = true) -> UIFont? {
|
||||||
|
|
||||||
|
let size = genericScaling ? sizeFontGeneric(forCurrentDevice: pointSize()) : pointSize()
|
||||||
|
|
||||||
|
if isLegacyFont() {
|
||||||
|
switch self {
|
||||||
|
case .B2, .B3, .B20:
|
||||||
|
return MFFonts.mfFont55Rg(size)
|
||||||
|
|
||||||
|
default:
|
||||||
|
return MFFonts.mfFont75Bd(size)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if isBold() {
|
||||||
|
return size >= 15 ? MFFonts.mfFontDSBold(size) : MFFonts.mfFontTXBold(size)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return size >= 15 ? MFFonts.mfFontDSRegular(size) : MFFonts.mfFontTXRegular(size)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Styles the provided label to the declared enum Font case.
|
||||||
|
public func styleLabel(_ label: UILabel, textColor: UIColor = .mvmBlack, genericScaling: Bool = true) {
|
||||||
|
|
||||||
|
label.font = getFont(genericScaling)
|
||||||
|
label.textColor = textColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Functions
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
open class func sizeObjectGeneric(forCurrentDevice size: CGFloat) -> MFSizeObject? {
|
||||||
|
|
||||||
|
let sizeObject = MFSizeObject(standardSize: size, standardiPadPortraitSize: size * 1.3)
|
||||||
|
sizeObject?.addLargerThanCustomSize(size * 1.4, forThreshold: MFSizeStandardiPadLandscapeThreshold)
|
||||||
|
sizeObject?.addLargerThanCustomSize(size * 1.5, forThreshold: MFSizeiPadProLandscapeThreshold)
|
||||||
|
|
||||||
|
return sizeObject
|
||||||
|
}
|
||||||
|
|
||||||
|
open class func sizeFontGeneric(forCurrentDevice size: CGFloat) -> CGFloat {
|
||||||
|
return sizeObjectGeneric(forCurrentDevice: size)?.getValueBasedOnApplicationWidth() ?? size
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Spacing
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
open class func setDefaultMarginsFor(_ view: UIView?, size: CGFloat?, horizontal: Bool = true, vertical: Bool = false) {
|
||||||
|
|
||||||
|
var horizontalPadding: CGFloat = Padding.Component.HorizontalMarginSpacing
|
||||||
|
let verticalPadding: CGFloat = vertical ? Padding.Component.VerticalMarginSpacing : 0
|
||||||
|
|
||||||
|
if let size = size {
|
||||||
|
horizontalPadding = horizontal ? Padding.Component.horizontalPaddingForSize(size) : 0
|
||||||
|
}
|
||||||
|
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
MVMCoreUIUtility.setMarginsFor(view,
|
||||||
|
leading: horizontalPadding,
|
||||||
|
top: verticalPadding,
|
||||||
|
trailing: horizontalPadding,
|
||||||
|
bottom: verticalPadding)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class func setMarginsFor(_ view: UIView?, size: CGFloat, horizontal: CGFloat?, top: CGFloat, bottom: CGFloat) {
|
||||||
|
|
||||||
|
let horizontalPadding: CGFloat = horizontal ?? Padding.Component.horizontalPaddingForSize(size)
|
||||||
|
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
MVMCoreUIUtility.setMarginsFor(view,
|
||||||
|
leading: horizontalPadding,
|
||||||
|
top: top,
|
||||||
|
trailing: horizontalPadding,
|
||||||
|
bottom: bottom)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -117,7 +117,7 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed.";
|
|||||||
if ([type isEqualToString:ValueTypeError]) {
|
if ([type isEqualToString:ValueTypeError]) {
|
||||||
return [UIColor mvmOrange];
|
return [UIColor mvmOrange];
|
||||||
} else {
|
} else {
|
||||||
return [UIColor mfShamrock];
|
return [UIColor mvmGreen];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user