Merge branch 'develop' into feature/list_star_rating
# Conflicts: # MVMCoreUI/Atomic/MoleculeObjectMapping.swift
This commit is contained in:
commit
ad3051743d
@ -257,6 +257,8 @@
|
||||
AAC6F167243332E400F295C1 /* RadioSwatchesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAC6F166243332E400F295C1 /* RadioSwatchesModel.swift */; };
|
||||
AAE7270C24AC8B8500A3ED0E /* HeadersH2CaretLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE7270B24AC8B8500A3ED0E /* HeadersH2CaretLinkModel.swift */; };
|
||||
AAE7270E24AC8B9300A3ED0E /* HeadersH2CaretLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE7270D24AC8B9300A3ED0E /* HeadersH2CaretLink.swift */; };
|
||||
AAE96FA225341F6A0037A989 /* ListStoreLocatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE96FA125341F6A0037A989 /* ListStoreLocatorModel.swift */; };
|
||||
AAE96FA525341F7D0037A989 /* ListStoreLocator.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE96FA425341F7D0037A989 /* ListStoreLocator.swift */; };
|
||||
BB105859248DEFF70069D008 /* UICollectionViewLeftAlignedLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */; };
|
||||
BB1D17E0244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */; };
|
||||
BB1D17E2244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */; };
|
||||
@ -796,6 +798,8 @@
|
||||
AAC6F166243332E400F295C1 /* RadioSwatchesModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioSwatchesModel.swift; sourceTree = "<group>"; };
|
||||
AAE7270B24AC8B8500A3ED0E /* HeadersH2CaretLinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2CaretLinkModel.swift; sourceTree = "<group>"; };
|
||||
AAE7270D24AC8B9300A3ED0E /* HeadersH2CaretLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2CaretLink.swift; sourceTree = "<group>"; };
|
||||
AAE96FA125341F6A0037A989 /* ListStoreLocatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListStoreLocatorModel.swift; sourceTree = "<group>"; };
|
||||
AAE96FA425341F7D0037A989 /* ListStoreLocator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListStoreLocator.swift; sourceTree = "<group>"; };
|
||||
BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICollectionViewLeftAlignedLayout.swift; sourceTree = "<group>"; };
|
||||
BB1D17DF244EAA30001D2002 /* ListDeviceComplexButtonMediumModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexButtonMediumModel.swift; sourceTree = "<group>"; };
|
||||
BB1D17E1244EAA46001D2002 /* ListDeviceComplexButtonMedium.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListDeviceComplexButtonMedium.swift; sourceTree = "<group>"; };
|
||||
@ -1354,6 +1358,15 @@
|
||||
path = TwoColumn;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
AAE96FA025341F410037A989 /* Miscellaneous */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
AAE96FA125341F6A0037A989 /* ListStoreLocatorModel.swift */,
|
||||
AAE96FA425341F7D0037A989 /* ListStoreLocator.swift */,
|
||||
);
|
||||
path = Miscellaneous;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D202AFE2242A5F1400E5BEDF /* Extensions */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -1524,6 +1537,7 @@
|
||||
D22B38EA23F4E08B00490EF6 /* List */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
AAE96FA025341F410037A989 /* Miscellaneous */,
|
||||
D20FFFB42451E32100A31DA2 /* Device */,
|
||||
52267A0523FFE0A900906CBA /* OneColumn */,
|
||||
D22D8396241FDE4700D3DF69 /* TwoColumn */,
|
||||
@ -2415,6 +2429,7 @@
|
||||
C07065C42395677300FBF997 /* Link.swift in Sources */,
|
||||
0A69F611241BDEA700F7231B /* RuleAnyRequiredModel.swift in Sources */,
|
||||
D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */,
|
||||
AAE96FA225341F6A0037A989 /* ListStoreLocatorModel.swift in Sources */,
|
||||
D28A838923CCCFCB00DFE4FC /* LinkModel.swift in Sources */,
|
||||
AA56A20F243C5EE900303286 /* ListTwoColumnSubsectionDividerModel.swift in Sources */,
|
||||
AAB9C10824346F4B00151545 /* RadioSwatches.swift in Sources */,
|
||||
@ -2554,6 +2569,7 @@
|
||||
0A849EFE246F1775009F277F /* RuleEqualsIgnoreCaseModel.swift in Sources */,
|
||||
D28764FB245A33A500CB882D /* TwoLinkViewModel.swift in Sources */,
|
||||
AAA74A192410C05800080241 /* HeadersH2NoButtonsBodyTextModel.swift in Sources */,
|
||||
AAE96FA525341F7D0037A989 /* ListStoreLocator.swift in Sources */,
|
||||
D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */,
|
||||
944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */,
|
||||
D213347723843825008E41B3 /* Line.swift in Sources */,
|
||||
|
||||
@ -201,6 +201,7 @@ import Foundation
|
||||
MoleculeObjectMapping.shared()?.register(viewClass: ListThreeColumnSpeedTest.self, viewModelClass: ListThreeColumnSpeedTestModel.self)
|
||||
MoleculeObjectMapping.shared()?.register(viewClass: ListFourColumnDataUsageListItem.self, viewModelClass: ListFourColumnDataUsageListItemModel.self)
|
||||
MoleculeObjectMapping.shared()?.register(viewClass: ListProgressBarThin.self, viewModelClass: ListProgressBarThinModel.self)
|
||||
MoleculeObjectMapping.shared()?.register(viewClass: ListStoreLocator.self, viewModelClass: ListStoreLocatorModel.self)
|
||||
MoleculeObjectMapping.shared()?.register(viewClass: ListStarRating.self, viewModelClass: ListStarRatingModel.self)
|
||||
|
||||
// MARK:- Designed Section Dividers
|
||||
|
||||
@ -0,0 +1,142 @@
|
||||
//
|
||||
// ListStoreLocator.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Lekshmi S on 12/10/20.
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
@objcMembers open class ListStoreLocator: TableViewCell {
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Outlets
|
||||
//--------------------------------------------------
|
||||
public let heart = Heart()
|
||||
public let leftHeadline = Label(fontStyle: .BoldBodySmall)
|
||||
public let leftBody = Label(fontStyle: .RegularBodySmall)
|
||||
public let leftSubBody = Label(fontStyle: .RegularBodySmall)
|
||||
public let rightLabel = Label(fontStyle: .RegularBodySmall)
|
||||
private lazy var rightLabelStackItem: StackItem = {
|
||||
return StackItem(andContain: rightLabel)
|
||||
}()
|
||||
public lazy var horizontalStack: Stack<StackModel> = {
|
||||
return Stack<StackModel>(with: StackModel(molecules: [StackItemModel(horizontalAlignment: .fill),
|
||||
StackItemModel(horizontalAlignment: .fill),
|
||||
StackItemModel(horizontalAlignment: .trailing)],
|
||||
axis: .horizontal, spacing: Padding.Two), stackItems: [StackItem(andContain: leftHeadline), StackItem(andContain: heart), rightLabelStackItem])
|
||||
}()
|
||||
public lazy var stack: Stack<StackModel> = {
|
||||
return Stack<StackModel>.createStack(with: [horizontalStack, leftBody, leftSubBody], axis: .vertical, spacing: 0)
|
||||
}()
|
||||
public var sizeObject: MFSizeObject? = MFSizeObject(standardSize: 12, standardiPadPortraitSize: 18)
|
||||
|
||||
//-------------------------------------------------------
|
||||
// MARK: - Lifecycle
|
||||
//-------------------------------------------------------
|
||||
open override func setupView() {
|
||||
super.setupView()
|
||||
|
||||
rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||
rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||
rightLabel.numberOfLines = 1
|
||||
addMolecule(stack)
|
||||
stack.restack()
|
||||
horizontalStack.restack()
|
||||
accessibilityHint = heart.accessibilityHint
|
||||
accessibilityTraits = heart.accessibilityTraits
|
||||
}
|
||||
|
||||
public override func updateView(_ size: CGFloat) {
|
||||
super.updateView(size)
|
||||
if let dimension = sizeObject?.getValueBased(onSize: size) {
|
||||
heart.widthConstraint?.constant = dimension
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// 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? ListStoreLocatorModel else { return }
|
||||
horizontalStack.updateContainedMolecules(with: [model.leftHeadline, model.heart, model.rightLabel], delegateObject, additionalData)
|
||||
leftBody.set(with: model.leftBody, delegateObject, additionalData)
|
||||
leftSubBody.set(with: model.leftSubBody, delegateObject, additionalData)
|
||||
updateAccessibilityLabel()
|
||||
}
|
||||
|
||||
open override func alignAccessoryToHero() -> CGPoint? {
|
||||
let heroCenter = super.alignAccessoryToHero()
|
||||
|
||||
if let heroCenter = heroCenter {
|
||||
let convertedPoint = horizontalStack.convert(heroCenter, from: self)
|
||||
rightLabelStackItem.containerHelper.alignCenterVerticalConstraint?.constant = convertedPoint.y - horizontalStack.bounds.midY
|
||||
}
|
||||
return heroCenter
|
||||
}
|
||||
|
||||
public override func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
||||
if listItemModel?.action != nil {
|
||||
super.didSelectCell(at: index, delegateObject: delegateObject, additionalData: additionalData)
|
||||
} else {
|
||||
heart.tapAction()
|
||||
updateAccessibilityLabel()
|
||||
}
|
||||
}
|
||||
|
||||
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||
return 120
|
||||
}
|
||||
|
||||
open override func reset() {
|
||||
super.reset()
|
||||
leftHeadline.setFontStyle(.BoldBodySmall)
|
||||
leftBody.setFontStyle(.RegularBodySmall)
|
||||
leftSubBody.setFontStyle(.RegularBodySmall)
|
||||
rightLabel.setFontStyle(.RegularBodySmall)
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Accessibility
|
||||
//--------------------------------------------------
|
||||
func getAccessibilityMessage() -> String? {
|
||||
var message = ""
|
||||
heart.updateAccessibilityLabel()
|
||||
|
||||
if let leftHeadlineText = leftHeadline.text, !leftHeadlineText.isEmpty {
|
||||
message += leftHeadlineText + ", "
|
||||
}
|
||||
|
||||
if let leftBodyText = leftBody.text, !leftBodyText.isEmpty {
|
||||
message += leftBodyText + ", "
|
||||
}
|
||||
|
||||
if let leftSubBodyText = leftSubBody.text, !leftSubBodyText.isEmpty {
|
||||
message += leftSubBodyText + ", "
|
||||
}
|
||||
|
||||
if let rightLabelText = rightLabel.text, !rightLabelText.isEmpty {
|
||||
message += rightLabelText
|
||||
}
|
||||
return message.count > 0 ? message : nil
|
||||
}
|
||||
|
||||
func updateAccessibilityLabel() {
|
||||
if let accessoryView = accessoryView {
|
||||
// Both caret and heart.
|
||||
isAccessibilityElement = false
|
||||
accessoryView.accessibilityLabel = getAccessibilityMessage()
|
||||
accessibilityElements = [accessoryView, heart]
|
||||
} else {
|
||||
// Make whole cell focusable if no action.
|
||||
isAccessibilityElement = true
|
||||
if let message = getAccessibilityMessage(),
|
||||
let heartLabel = heart.accessibilityLabel {
|
||||
accessibilityLabel = message + ", " + heartLabel
|
||||
} else {
|
||||
accessibilityLabel = getAccessibilityMessage()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
//
|
||||
// ListStoreLocatorModel.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Lekshmi S on 12/10/20.
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
public class ListStoreLocatorModel: ListItemModel, MoleculeModelProtocol {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
|
||||
public static var identifier = "listStoreLocator"
|
||||
public var heart: HeartModel
|
||||
public var leftHeadline: LabelModel
|
||||
public var leftBody: LabelModel
|
||||
public var leftSubBody: LabelModel
|
||||
public var rightLabel: LabelModel
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializer
|
||||
//--------------------------------------------------
|
||||
|
||||
public init(heart: HeartModel, leftHeadline: LabelModel, leftBody: LabelModel, leftSubBody: LabelModel, rightLabel: LabelModel) {
|
||||
self.heart = heart
|
||||
self.leftHeadline = leftHeadline
|
||||
self.leftBody = leftBody
|
||||
self.leftSubBody = leftSubBody
|
||||
self.rightLabel = rightLabel
|
||||
super.init()
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Method
|
||||
//--------------------------------------------------
|
||||
|
||||
override public func setDefaults() {
|
||||
super.setDefaults()
|
||||
leftHeadline.hero = 0
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Keys
|
||||
//--------------------------------------------------
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case moleculeName
|
||||
case heart
|
||||
case leftHeadline
|
||||
case leftBody
|
||||
case leftSubBody
|
||||
case rightLabel
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Codec
|
||||
//--------------------------------------------------
|
||||
|
||||
public required init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
heart = try typeContainer.decode(HeartModel.self, forKey:.heart)
|
||||
leftHeadline = try typeContainer.decode(LabelModel.self, forKey: .leftHeadline)
|
||||
leftBody = try typeContainer.decode(LabelModel.self, forKey: .leftBody)
|
||||
leftSubBody = try typeContainer.decode(LabelModel.self, forKey: .leftSubBody)
|
||||
rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel)
|
||||
try super.init(from: decoder)
|
||||
}
|
||||
|
||||
public override func encode(to encoder: Encoder) throws {
|
||||
try super.encode(to: encoder)
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(moleculeName, forKey: .moleculeName)
|
||||
try container.encode(heart, forKey: .heart)
|
||||
try container.encode(leftHeadline, forKey: .leftHeadline)
|
||||
try container.encode(leftBody, forKey: .leftBody)
|
||||
try container.encode(leftSubBody, forKey: .leftSubBody)
|
||||
try container.encode(rightLabel, forKey: .rightLabel)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user