List item updates
This commit is contained in:
parent
f610264327
commit
092dfd6ad0
@ -664,6 +664,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)setAsMolecule {
|
- (void)setAsMolecule {
|
||||||
|
self.translatesAutoresizingMaskIntoConstraints = false;
|
||||||
[self setAsStandardCustom];
|
[self setAsStandardCustom];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -713,6 +714,10 @@
|
|||||||
[self setWithActionMap:json delegateObject:delegateObject additionalData:additionalData];
|
[self setWithActionMap:json delegateObject:delegateObject additionalData:additionalData];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (UIStackViewAlignment)horizontalAlignment {
|
||||||
|
return UIStackViewAlignmentCenter;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Handling Validations
|
#pragma mark - Handling Validations
|
||||||
|
|
||||||
- (void)setEnabledByValidity {
|
- (void)setEnabledByValidity {
|
||||||
|
|||||||
@ -168,6 +168,20 @@ public class ContainerHelper: NSObject {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func set(with JSON: [AnyHashable: Any]?, for contained: UIView) {
|
||||||
|
if let horizontalAlignmentString = JSON?.optionalStringForKey("horizontalAlignment"), let alignment = ContainerHelper.getAlignment(for: horizontalAlignmentString) ?? (contained as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() {
|
||||||
|
alignHorizontal(alignment)
|
||||||
|
} else if let alignment = (contained as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() {
|
||||||
|
alignHorizontal(alignment)
|
||||||
|
}
|
||||||
|
|
||||||
|
if let verticalAlignmentString = JSON?.optionalStringForKey("verticalAlignment"), let alignment = ContainerHelper.getAlignment(for: verticalAlignmentString) ?? (contained as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() {
|
||||||
|
alignVertical(alignment)
|
||||||
|
} else if let alignment = (contained as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() {
|
||||||
|
alignVertical(alignment)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open class Container: View {
|
open class Container: View {
|
||||||
@ -194,6 +208,7 @@ public extension Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func addAndContain(_ view: UIView) {
|
func addAndContain(_ view: UIView) {
|
||||||
|
view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
addSubview(view)
|
addSubview(view)
|
||||||
containerHelper.constrainView(view)
|
containerHelper.constrainView(view)
|
||||||
self.view = view
|
self.view = view
|
||||||
@ -209,18 +224,8 @@ public extension Container {
|
|||||||
public extension Container {
|
public extension Container {
|
||||||
override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
||||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
guard let view = view else { return }
|
||||||
if let horizontalAlignmentString = json?.optionalStringForKey("horizontalAlignment"), let alignment = ContainerHelper.getAlignment(for: horizontalAlignmentString) ?? (view as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() {
|
containerHelper.set(with: json, for: view)
|
||||||
containerHelper.alignHorizontal(alignment)
|
|
||||||
} else if let alignment = (view as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() {
|
|
||||||
containerHelper.alignHorizontal(alignment)
|
|
||||||
}
|
|
||||||
|
|
||||||
if let verticalAlignmentString = json?.optionalStringForKey("verticalAlignment"), let alignment = ContainerHelper.getAlignment(for: verticalAlignmentString) ?? (view as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() {
|
|
||||||
containerHelper.alignVertical(alignment)
|
|
||||||
} else if let alignment = (view as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() {
|
|
||||||
containerHelper.alignVertical(alignment)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func reset() {
|
override func reset() {
|
||||||
|
|||||||
@ -11,11 +11,20 @@ import UIKit
|
|||||||
@objcMembers open class MoleculeTableViewCell: TableViewCell {
|
@objcMembers open class MoleculeTableViewCell: TableViewCell {
|
||||||
|
|
||||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||||
public override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
public override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?)
|
||||||
|
{
|
||||||
|
guard let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule) else {
|
||||||
|
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if molecule == nil {
|
||||||
|
if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject, constrainIfNeeded: false) {
|
||||||
|
addMolecule(moleculeView)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
molecule?.setWithJSON(moleculeJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
}
|
||||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
|
||||||
guard molecule == nil, let json = json, let moleculeJSON = json.optionalDictionaryForKey(KeyMolecule), let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject, constrainIfNeeded: true) else { return }
|
|
||||||
addMolecule(moleculeView)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override class func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
public override class func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
||||||
|
|||||||
@ -11,7 +11,8 @@ import UIKit
|
|||||||
@objcMembers open class TableViewCell: UITableViewCell, MVMCoreUIMoleculeViewProtocol, MoleculeListCellProtocol {
|
@objcMembers open class TableViewCell: UITableViewCell, MVMCoreUIMoleculeViewProtocol, MoleculeListCellProtocol {
|
||||||
open var molecule: (UIView & MVMCoreUIMoleculeViewProtocol)?
|
open var molecule: (UIView & MVMCoreUIMoleculeViewProtocol)?
|
||||||
open var json: [AnyHashable: Any]?
|
open var json: [AnyHashable: Any]?
|
||||||
|
public let containerHelper = ContainerHelper()
|
||||||
|
|
||||||
// In updateView, will set padding to default.
|
// In updateView, will set padding to default.
|
||||||
open var updateViewHorizontalDefaults = true
|
open var updateViewHorizontalDefaults = true
|
||||||
|
|
||||||
@ -78,14 +79,7 @@ import UIKit
|
|||||||
/// Adds the molecule to the view.
|
/// Adds the molecule to the view.
|
||||||
open func addMolecule(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) {
|
open func addMolecule(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) {
|
||||||
contentView.addSubview(molecule)
|
contentView.addSubview(molecule)
|
||||||
let standardConstraints = (molecule as? MVMCoreUIViewConstrainingProtocol)?.useStandardConstraints?() ?? true
|
containerHelper.constrainView(molecule)
|
||||||
NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: molecule, useMargins: standardConstraints).values))
|
|
||||||
|
|
||||||
// This molecule will by default handle margins.
|
|
||||||
if let castView = molecule as? MVMCoreUIViewConstrainingProtocol {
|
|
||||||
castView.shouldSetHorizontalMargins?(false)
|
|
||||||
castView.shouldSetVerticalMargins?(false)
|
|
||||||
}
|
|
||||||
self.molecule = molecule
|
self.molecule = molecule
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,14 +170,8 @@ import UIKit
|
|||||||
bottomSeparatorView?.setWithJSON(separator, delegateObject: delegateObject, additionalData: additionalData)
|
bottomSeparatorView?.setWithJSON(separator, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let moleculeJSON = json.optionalDictionaryForKey(KeyMolecule) else { return }
|
guard let molecule = molecule else { return }
|
||||||
molecule?.setWithJSON(moleculeJSON, delegateObject: delegateObject, additionalData: additionalData)
|
containerHelper.set(with: json, for: molecule)
|
||||||
|
|
||||||
// This molecule will by default handle margins.
|
|
||||||
if let castView = molecule as? MVMCoreUIViewConstrainingProtocol {
|
|
||||||
castView.shouldSetHorizontalMargins?(false)
|
|
||||||
castView.shouldSetVerticalMargins?(false)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public func reset() {
|
public func reset() {
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
mapping = [@{
|
mapping = [@{
|
||||||
@"label": Label.class,
|
@"label": Label.class,
|
||||||
@"line": Line.class,
|
@"line": Line.class,
|
||||||
@"button": ButtonView.class,
|
@"button": PrimaryButton.class,
|
||||||
@"textButton": MFTextButton.class,
|
@"textButton": MFTextButton.class,
|
||||||
@"header": StandardHeaderView.class,
|
@"header": StandardHeaderView.class,
|
||||||
@"moleculeStack": MoleculeStackView.class,
|
@"moleculeStack": MoleculeStackView.class,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user