Code changes for lockups plan

This commit is contained in:
Subhankar Acharya 2020-07-17 20:31:27 +05:30
parent 9c788848d2
commit c4c806a728
4 changed files with 111 additions and 0 deletions

View File

@ -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 = "<group>"; };
3265B30124BCA737000D154B /* HeadersH1NoButtonsBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH1NoButtonsBodyTextModel.swift; sourceTree = "<group>"; };
3265B30324BCA749000D154B /* HeadersH1NoButtonsBodyText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH1NoButtonsBodyText.swift; sourceTree = "<group>"; };
32D2609424C19E2100B56344 /* LockupsPlanSMLXL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LockupsPlanSMLXL.swift; sourceTree = "<group>"; };
32D2609524C19E2100B56344 /* LockupsPlanSMLXLModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LockupsPlanSMLXLModel.swift; sourceTree = "<group>"; };
32F8804524765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableNumberedListAllTextAndLinksModel.swift; sourceTree = "<group>"; };
32F8804724765C8400C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLeftVariableNumberedListAllTextAndLinks.swift; sourceTree = "<group>"; };
522679BF23FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableCheckboxAllTextAndLinks.swift; sourceTree = "<group>"; };
@ -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 */,

View File

@ -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)

View File

@ -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<StackModel>
public var stack: Stack<StackModel>
//-------------------------------------------------------
// MARK: - Initializers
//-------------------------------------------------------
public override init(frame: CGRect) {
verticalStack = Stack<StackModel>.createStack(with: [(view: headline, model: StackItemModel()),
(view: subHeadline, model: StackItemModel()),
(view: body, model: StackItemModel(horizontalAlignment: .fill))],
axis: .vertical, spacing: 0)
stack = Stack<StackModel>.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
}
}

View File

@ -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)