From 1921ca0eba184b2a1ac11923cc81d8dac3c8c607 Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Thu, 16 Jul 2020 10:53:25 +0530 Subject: [PATCH 1/6] Initial commit MOBFIRST-21764 --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++ .../LockUps/LockupsPlanSMLXL.swift | 12 ++++ .../LockUps/LockupsPlanSMLXLModel.swift | 69 +++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXLModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index fceb829b..faf83920 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -126,6 +126,8 @@ 31BE15CC23D8924D00452370 /* CheckboxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15CA23D8924C00452370 /* CheckboxModel.swift */; }; 324FB6AA249366F3002552C7 /* ListLeftVariableNumberedListBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 324FB6A9249366F3002552C7 /* ListLeftVariableNumberedListBodyTextModel.swift */; }; 324FB6AC24936717002552C7 /* ListLeftVariableNumberedListBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 324FB6AB24936717002552C7 /* ListLeftVariableNumberedListBodyText.swift */; }; + 32EBBE6524BEEE58002F4266 /* LockupsPlanSMLXLModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32EBBE6424BEEE58002F4266 /* LockupsPlanSMLXLModel.swift */; }; + 32EBBE6724BEEE67002F4266 /* LockupsPlanSMLXL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32EBBE6624BEEE67002F4266 /* LockupsPlanSMLXL.swift */; }; 32F8804624765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32F8804524765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift */; }; 32F8804824765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32F8804724765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift */; }; 522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */; }; @@ -593,6 +595,8 @@ 31BE15CA23D8924C00452370 /* CheckboxModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxModel.swift; sourceTree = ""; }; 324FB6A9249366F3002552C7 /* ListLeftVariableNumberedListBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableNumberedListBodyTextModel.swift; sourceTree = ""; }; 324FB6AB24936717002552C7 /* ListLeftVariableNumberedListBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableNumberedListBodyText.swift; sourceTree = ""; }; + 32EBBE6424BEEE58002F4266 /* LockupsPlanSMLXLModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LockupsPlanSMLXLModel.swift; sourceTree = ""; }; + 32EBBE6624BEEE67002F4266 /* LockupsPlanSMLXL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LockupsPlanSMLXL.swift; sourceTree = ""; }; 32F8804524765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableNumberedListAllTextAndLinksModel.swift; sourceTree = ""; }; 32F8804724765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableNumberedListAllTextAndLinks.swift; sourceTree = ""; }; 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinks.swift; sourceTree = ""; }; @@ -1119,6 +1123,8 @@ children = ( 525019DB2406430700EED91C /* ListProgressBarDataModel.swift */, 525019DC2406430800EED91C /* ListProgressBarData.swift */, + 32EBBE6424BEEE58002F4266 /* LockupsPlanSMLXLModel.swift */, + 32EBBE6624BEEE67002F4266 /* LockupsPlanSMLXL.swift */, ); path = LockUps; sourceTree = ""; @@ -2503,6 +2509,7 @@ 27F973532466074500CAB5C5 /* PageBehavior.swift in Sources */, 94C2D9A323872C110006CF46 /* LabelAttributeStrikeThroughModel.swift in Sources */, D28A838523CCCA8900DFE4FC /* ScrollerModel.swift in Sources */, + 32EBBE6524BEEE58002F4266 /* LockupsPlanSMLXLModel.swift in Sources */, D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */, D23EA7FE247EBBB700D60C34 /* NavigationLabelButtonModel.swift in Sources */, D28A839123CD4FD400DFE4FC /* CornerLabelsModel.swift in Sources */, @@ -2513,6 +2520,7 @@ C003506123AA94CD00B6AC29 /* Button.swift in Sources */, DBC4391B224421A0001AB423 /* CaretLink.swift in Sources */, D264FA90243BCE6800D98315 /* ThreeLayerCollectionViewController.swift in Sources */, + 32EBBE6724BEEE67002F4266 /* LockupsPlanSMLXL.swift in Sources */, AA104B1C24474A76004D2810 /* HeadersH2ButtonsModel.swift in Sources */, 0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */, AAE7270C24AC8B8500A3ED0E /* HeadersH2CaretLinkModel.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift new file mode 100644 index 00000000..255d4719 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift @@ -0,0 +1,12 @@ +// +// LockupsPlanSMLXL.swift +// MVMCoreUI +// +// Created by Subhankar Acharya on 15/07/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + + + diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXLModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXLModel.swift new file mode 100644 index 00000000..38eda620 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXLModel.swift @@ -0,0 +1,69 @@ +// +// LockupsPlanSMLXLModel.swift +// MVMCoreUI +// +// Created by Subhankar Acharya on 15/07/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class LockupsPlanSMLXLModel: MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public static var identifier: String = "planLockup" + public var backgroundColor: Color? + public var planLabel : LabelModel + public var headline : LabelModel + public var subHeadline: LabelModel + public var body: LabelModel + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(planLabel: LabelModel, headline: LabelModel, subHeadline: LabelModel, body: LabelModel) { + self.planLabel = planLabel + self.headline = headline + self.subHeadline = subHeadline + self.body = body + } + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case moleculeName + case backgroundColor + case planLabel + case headline + case subHeadline + case body + } + + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + planLabel = try typeContainer.decode(LabelModel.self, forKey: .planLabel) + headline = try typeContainer.decode(LabelModel.self, forKey: .headline) + subHeadline = try typeContainer.decode(LabelModel.self, forKey: .subHeadline) + body = try typeContainer.decode(LabelModel.self, forKey: .body) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(moleculeName, forKey: .moleculeName) + try container.encode(planLabel, forKey: .planLabel) + try container.encode(headline, forKey: .headline) + try container.encode(subHeadline, forKey: .subHeadline) + try container.encode(body, forKey: .body) + } +} + From c4c806a72890d9da4cb91adcee276d7350d9be8a Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Fri, 17 Jul 2020 20:31:27 +0530 Subject: [PATCH 2/6] Code changes for lockups plan --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++ MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 + .../LockUps/LockupsPlanSMLXL.swift | 94 +++++++++++++++++++ .../LockUps/LockupsPlanSMLXLModel.swift | 8 ++ 4 files changed, 111 insertions(+) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 9f8d32fd..9846b6ef 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -126,6 +126,8 @@ 324FB6AC24936717002552C7 /* ListLeftVariableNumberedListBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 324FB6AB24936717002552C7 /* ListLeftVariableNumberedListBodyText.swift */; }; 3265B30224BCA737000D154B /* HeadersH1NoButtonsBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3265B30124BCA737000D154B /* HeadersH1NoButtonsBodyTextModel.swift */; }; 3265B30424BCA749000D154B /* HeadersH1NoButtonsBodyText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3265B30324BCA749000D154B /* HeadersH1NoButtonsBodyText.swift */; }; + 32D2609624C19E2100B56344 /* LockupsPlanSMLXL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32D2609424C19E2100B56344 /* LockupsPlanSMLXL.swift */; }; + 32D2609724C19E2100B56344 /* LockupsPlanSMLXLModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32D2609524C19E2100B56344 /* LockupsPlanSMLXLModel.swift */; }; 32F8804624765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32F8804524765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift */; }; 32F8804824765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32F8804724765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift */; }; 522679C123FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */; }; @@ -593,6 +595,8 @@ 324FB6AB24936717002552C7 /* ListLeftVariableNumberedListBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableNumberedListBodyText.swift; sourceTree = ""; }; 3265B30124BCA737000D154B /* HeadersH1NoButtonsBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH1NoButtonsBodyTextModel.swift; sourceTree = ""; }; 3265B30324BCA749000D154B /* HeadersH1NoButtonsBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH1NoButtonsBodyText.swift; sourceTree = ""; }; + 32D2609424C19E2100B56344 /* LockupsPlanSMLXL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LockupsPlanSMLXL.swift; sourceTree = ""; }; + 32D2609524C19E2100B56344 /* LockupsPlanSMLXLModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LockupsPlanSMLXLModel.swift; sourceTree = ""; }; 32F8804524765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableNumberedListAllTextAndLinksModel.swift; sourceTree = ""; }; 32F8804724765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableNumberedListAllTextAndLinks.swift; sourceTree = ""; }; 522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinks.swift; sourceTree = ""; }; @@ -1106,6 +1110,8 @@ 525239C32407FFCC00454969 /* LockUps */ = { isa = PBXGroup; children = ( + 32D2609524C19E2100B56344 /* LockupsPlanSMLXLModel.swift */, + 32D2609424C19E2100B56344 /* LockupsPlanSMLXL.swift */, 525019DB2406430700EED91C /* ListProgressBarDataModel.swift */, 525019DC2406430800EED91C /* ListProgressBarData.swift */, ); @@ -2210,6 +2216,7 @@ D2E2A98323D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift in Sources */, 012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */, BB6C6AC1242232DF005F7224 /* ListOneColumnTextWithWhitespaceDividerTall.swift in Sources */, + 32D2609724C19E2100B56344 /* LockupsPlanSMLXLModel.swift in Sources */, D2092351244F7BE80044AD09 /* ThreeLayerCenterTemplateModel.swift in Sources */, D21B7F77243BB70700051ABF /* MoleculeCollectionItemModel.swift in Sources */, AAB9C10A243496DD00151545 /* RadioSwatch.swift in Sources */, @@ -2318,6 +2325,7 @@ D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */, D209234F244F77FD0044AD09 /* ThreeLayerCenterTemplate.swift in Sources */, 525019E52406852100EED91C /* ListFourColumnDataUsageDividerModel.swift in Sources */, + 32D2609624C19E2100B56344 /* LockupsPlanSMLXL.swift in Sources */, 0A7EF86723D8B0AE00B2AAD1 /* DateDropdownEntryFieldModel.swift in Sources */, D29C94D5242901C9003813BA /* MVMCoreUICommonViewsUtility+Extension.swift in Sources */, D260105323CEA61600764D80 /* ToggleModel.swift in Sources */, diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 40808777..c3247b79 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -127,6 +127,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: HeadlineBodyToggle.self, viewModelClass: HeadlineBodyToggleModel.self) MoleculeObjectMapping.shared()?.register(viewClass: HeadlineBodyLinkToggle.self, viewModelClass: HeadlineBodyLinkToggleModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ActionDetailWithImage.self, viewModelClass: ActionDetailWithImageModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: LockupsPlanSMLXL.self, viewModelClass: LockupsPlanSMLXLModel.self) // MARK:- List items MoleculeObjectMapping.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: MoleculeListItemModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift index 255d4719..ba7c7ef7 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift @@ -8,5 +8,99 @@ import Foundation +@objcMembers open class LockupsPlanSMLXL: View { + //-------------------------------------------------- + // MARK: - Outlets + //-------------------------------------------------- + public let planLabel = Label() + public let headline = Label(fontStyle: .BoldTitleLarge) + public let subHeadline = Label(fontStyle: .RegularTitleLarge) + public let body = Label(fontStyle: .RegularBodySmall) + public let verticalStack: Stack + public var stack: Stack + + //------------------------------------------------------- + // MARK: - Initializers + //------------------------------------------------------- + public override init(frame: CGRect) { + verticalStack = Stack.createStack(with: [(view: headline, model: StackItemModel()), + (view: subHeadline, model: StackItemModel()), + (view: body, model: StackItemModel(horizontalAlignment: .fill))], + axis: .vertical, spacing: 0) + stack = Stack.createStack(with: [(view: planLabel, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .center)), + (view: verticalStack, model: StackItemModel(horizontalAlignment: .fill))], + axis: .horizontal) + super.init(frame: frame) + } + + public required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //------------------------------------------------------- + // MARK: - Lifecycle + //------------------------------------------------------- + open override func setupView() { + super.setupView() + addSubview(stack) + planLabel.setContentHuggingPriority(.defaultHigh, for: .vertical) + planLabel.setContentHuggingPriority(.defaultHigh, for: .horizontal) + NSLayoutConstraint.constraintPinSubview(toSuperview: stack) + stack.restack() + verticalStack.restack() + } + + //---------------------------------------------------- + // MARK: - Molecule + //------------------------------------------------------ + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? LockupsPlanSMLXLModel else { return } + planLabel.set(with: model.planLabel, delegateObject, additionalData) + headline.set(with: model.headline, delegateObject, additionalData) + subHeadline.set(with: model.subHeadline, delegateObject, additionalData) + body.set(with: model.body, delegateObject, additionalData) + updateAccessibilityLabel() + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 121 + } + + open override func reset() { + super.reset() + headline.setFontStyle(.BoldTitleLarge) + subHeadline.setFontStyle(.RegularTitleLarge) + body.setFontStyle(.RegularBodySmall) + } + + public override func updateView(_ size: CGFloat) { + super.updateView(size) + planLabel.updateView(size) + } + + //-------------------------------------------------- + // MARK: - Accessibility + //-------------------------------------------------- + func updateAccessibilityLabel() { + isAccessibilityElement = true + var message = "" + + if let planLabel = planLabel.text, !planLabel.isEmpty { + message += planLabel + ", " + } + if let headline = headline.text, !headline.isEmpty { + message += headline + ", " + } + if let subHeadline = subHeadline.text, !subHeadline.isEmpty { + message += subHeadline + ", " + } + if let body = body.text, !body.isEmpty { + message += body + } + accessibilityLabel = message + } +} + diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXLModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXLModel.swift index 38eda620..6f88f770 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXLModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXLModel.swift @@ -31,6 +31,12 @@ public class LockupsPlanSMLXLModel: MoleculeModelProtocol { self.body = body } + /// Defaults to set + public func setDefaults() { + planLabel.fontName = DSBold + planLabel.fontSize = 96.0 + } + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- @@ -55,11 +61,13 @@ public class LockupsPlanSMLXLModel: MoleculeModelProtocol { headline = try typeContainer.decode(LabelModel.self, forKey: .headline) subHeadline = try typeContainer.decode(LabelModel.self, forKey: .subHeadline) body = try typeContainer.decode(LabelModel.self, forKey: .body) + setDefaults() } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(planLabel, forKey: .planLabel) try container.encode(headline, forKey: .headline) try container.encode(subHeadline, forKey: .subHeadline) From ac1937165245e14a147e7e182be06103725cb7dc Mon Sep 17 00:00:00 2001 From: Subhankar Acharya Date: Mon, 20 Jul 2020 15:43:10 +0530 Subject: [PATCH 3/6] added constraint --- .../Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift index ba7c7ef7..24c47b46 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift @@ -43,6 +43,7 @@ import Foundation open override func setupView() { super.setupView() addSubview(stack) + planLabel.setContentCompressionResistancePriority(.required, for: .horizontal) planLabel.setContentHuggingPriority(.defaultHigh, for: .vertical) planLabel.setContentHuggingPriority(.defaultHigh, for: .horizontal) NSLayoutConstraint.constraintPinSubview(toSuperview: stack) From 7f6ac77340dc9bfcbb2a18f3609cee38638ef56b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 20 Jul 2020 15:01:21 -0400 Subject: [PATCH 4/6] order change --- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 07bf6f44..2f4e5985 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -127,7 +127,6 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: HeadlineBodyToggle.self, viewModelClass: HeadlineBodyToggleModel.self) MoleculeObjectMapping.shared()?.register(viewClass: HeadlineBodyLinkToggle.self, viewModelClass: HeadlineBodyLinkToggleModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ActionDetailWithImage.self, viewModelClass: ActionDetailWithImageModel.self) - MoleculeObjectMapping.shared()?.register(viewClass: LockupsPlanSMLXL.self, viewModelClass: LockupsPlanSMLXLModel.self) // MARK:- List items MoleculeObjectMapping.shared()?.register(viewClass: MoleculeTableViewCell.self, viewModelClass: MoleculeListItemModel.self) @@ -226,6 +225,7 @@ import Foundation // MARK:- LockUps MoleculeObjectMapping.shared()?.register(viewClass: LockUpsPlanNames.self, viewModelClass: LockUpsPlanNamesModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: LockupsPlanSMLXL.self, viewModelClass: LockupsPlanSMLXLModel.self) // MARK:- Helper models try? ModelRegistry.register(RuleRequiredModel.self) From 0e3c08f34118a21de428e61b2b7420844022b814 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 20 Jul 2020 17:28:12 -0400 Subject: [PATCH 5/6] fix alignments and defaults --- .../LockUps/LockupsPlanSMLXL.swift | 43 +++++++++++++++---- .../LockUps/LockupsPlanSMLXLModel.swift | 3 +- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift index 24c47b46..7d00f3a9 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift @@ -27,8 +27,8 @@ import Foundation (view: subHeadline, model: StackItemModel()), (view: body, model: StackItemModel(horizontalAlignment: .fill))], axis: .vertical, spacing: 0) - stack = Stack.createStack(with: [(view: planLabel, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .center)), - (view: verticalStack, model: StackItemModel(horizontalAlignment: .fill))], + stack = Stack.createStack(with: [(view: planLabel, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading)), + (view: verticalStack, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading))], axis: .horizontal) super.init(frame: frame) } @@ -42,6 +42,8 @@ import Foundation //------------------------------------------------------- open override func setupView() { super.setupView() + planLabel.font = MFStyler.getMVA3FontSize(96, bold: true) + planLabel.standardFontSize = 96 addSubview(stack) planLabel.setContentCompressionResistancePriority(.required, for: .horizontal) planLabel.setContentHuggingPriority(.defaultHigh, for: .vertical) @@ -51,6 +53,33 @@ import Foundation verticalStack.restack() } + public override func updateView(_ size: CGFloat) { + super.updateView(size) + stack.updateView(size) + cropPlanLabel() + } + + /// Ensures the label is the size of capital letters. + public func cropPlanLabel() { + guard let text = planLabel.text else { return } + let attributedString = NSMutableAttributedString(attributedString: planLabel.attributedText ?? NSAttributedString(string: text)) + let range = NSRange(location: 0, length: attributedString.length) + attributedString.removeAttribute(.paragraphStyle, range: range) + attributedString.removeAttribute(.baselineOffset, range: range) + + // Accounts for the overshoot of non flat characters. 5% is typically the highest. + let overshoot: CGFloat = planLabel.font.pointSize * 0.05 + + // When messing with the maximum line height, the baseline needs to be adjusted. + let baseLineOffset = planLabel.font.descender + (overshoot / 2.0) + + let paragraphStyle = NSMutableParagraphStyle() + paragraphStyle.maximumLineHeight = planLabel.font.capHeight + overshoot + attributedString.addAttribute(.paragraphStyle, value: paragraphStyle, range: range) + attributedString.addAttribute(.baselineOffset, value: baseLineOffset, range: range) + planLabel.attributedText = attributedString + } + //---------------------------------------------------- // MARK: - Molecule //------------------------------------------------------ @@ -70,16 +99,14 @@ import Foundation open override func reset() { super.reset() + stack.reset() + planLabel.font = MFStyler.getMVA3FontSize(96, bold: true) + planLabel.standardFontSize = 96 headline.setFontStyle(.BoldTitleLarge) subHeadline.setFontStyle(.RegularTitleLarge) body.setFontStyle(.RegularBodySmall) } - - public override func updateView(_ size: CGFloat) { - super.updateView(size) - planLabel.updateView(size) - } - + //-------------------------------------------------- // MARK: - Accessibility //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXLModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXLModel.swift index 6f88f770..433bc322 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXLModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXLModel.swift @@ -29,6 +29,7 @@ public class LockupsPlanSMLXLModel: MoleculeModelProtocol { self.headline = headline self.subHeadline = subHeadline self.body = body + setDefaults() } /// Defaults to set @@ -66,7 +67,7 @@ public class LockupsPlanSMLXLModel: MoleculeModelProtocol { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(moleculeName, forKey: .moleculeName) + try container.encode(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(planLabel, forKey: .planLabel) try container.encode(headline, forKey: .headline) From ddcb8bb93c06d7e58ffb83549b07b72b3d5d1069 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 21 Jul 2020 11:31:23 -0400 Subject: [PATCH 6/6] add headline ascender offset for better look --- .../DesignedComponents/LockUps/LockupsPlanSMLXL.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift index 7d00f3a9..8312e5da 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/LockupsPlanSMLXL.swift @@ -73,8 +73,11 @@ import Foundation // When messing with the maximum line height, the baseline needs to be adjusted. let baseLineOffset = planLabel.font.descender + (overshoot / 2.0) + // We want the top to align with the top of the headline capitals, ignoring ascenders. + let headlineMatchingOffset = headline.font.ascender - headline.font.capHeight + let paragraphStyle = NSMutableParagraphStyle() - paragraphStyle.maximumLineHeight = planLabel.font.capHeight + overshoot + paragraphStyle.maximumLineHeight = planLabel.font.capHeight + overshoot + headlineMatchingOffset attributedString.addAttribute(.paragraphStyle, value: paragraphStyle, range: range) attributedString.addAttribute(.baselineOffset, value: baseLineOffset, range: range) planLabel.attributedText = attributedString