Merge branch 'feature/gone_list_item' into 'develop'
Feature/gone list item ### Summary Making list items gone-able Co-authored-by: Scott Pfeil <Scott.Pfeil3@verizonwireless.com> See merge request https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui/-/merge_requests/1061
This commit is contained in:
commit
019f940092
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
//
|
//
|
||||||
// A base class that has common list item boilerplate model stuffs.
|
// A base class that has common list item boilerplate model stuffs.
|
||||||
|
import MVMCore
|
||||||
|
|
||||||
@objcMembers open class ListItemModel: ContainerModel, ListItemModelProtocol {
|
@objcMembers open class ListItemModel: ContainerModel, ListItemModelProtocol {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -18,6 +18,7 @@
|
|||||||
public var hideArrow: Bool?
|
public var hideArrow: Bool?
|
||||||
public var line: LineModel?
|
public var line: LineModel?
|
||||||
public var style: ListItemStyle?
|
public var style: ListItemStyle?
|
||||||
|
public var gone: Bool = false
|
||||||
public var accessibilityTraits: UIAccessibilityTraits?
|
public var accessibilityTraits: UIAccessibilityTraits?
|
||||||
public var accessibilityValue: String?
|
public var accessibilityValue: String?
|
||||||
public var accessibilityText: String?
|
public var accessibilityText: String?
|
||||||
@ -31,6 +32,7 @@
|
|||||||
case hideArrow
|
case hideArrow
|
||||||
case line
|
case line
|
||||||
case style
|
case style
|
||||||
|
case gone
|
||||||
case accessibilityTraits
|
case accessibilityTraits
|
||||||
case accessibilityValue
|
case accessibilityValue
|
||||||
case accessibilityText
|
case accessibilityText
|
||||||
@ -107,6 +109,7 @@
|
|||||||
hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow)
|
hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow)
|
||||||
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
|
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
|
||||||
style = try typeContainer.decodeIfPresent(ListItemStyle.self, forKey: .style)
|
style = try typeContainer.decodeIfPresent(ListItemStyle.self, forKey: .style)
|
||||||
|
gone = try typeContainer.decodeIfPresent(Bool.self, forKey: .gone) ?? false
|
||||||
accessibilityTraits = try typeContainer.decodeIfPresent(UIAccessibilityTraits.self, forKey: .accessibilityTraits)
|
accessibilityTraits = try typeContainer.decodeIfPresent(UIAccessibilityTraits.self, forKey: .accessibilityTraits)
|
||||||
accessibilityValue = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityValue)
|
accessibilityValue = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityValue)
|
||||||
try super.init(from: decoder)
|
try super.init(from: decoder)
|
||||||
@ -120,6 +123,7 @@
|
|||||||
try container.encodeIfPresent(hideArrow, forKey: .hideArrow)
|
try container.encodeIfPresent(hideArrow, forKey: .hideArrow)
|
||||||
try container.encodeIfPresent(line, forKey: .line)
|
try container.encodeIfPresent(line, forKey: .line)
|
||||||
try container.encodeIfPresent(style, forKey: .style)
|
try container.encodeIfPresent(style, forKey: .style)
|
||||||
|
try container.encode(gone, forKey: .gone)
|
||||||
try container.encodeIfPresent(accessibilityTraits, forKey: .accessibilityTraits)
|
try container.encodeIfPresent(accessibilityTraits, forKey: .accessibilityTraits)
|
||||||
try container.encodeIfPresent(accessibilityValue, forKey: .accessibilityValue)
|
try container.encodeIfPresent(accessibilityValue, forKey: .accessibilityValue)
|
||||||
try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText)
|
try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText)
|
||||||
|
|||||||
@ -20,6 +20,7 @@ public protocol ListItemModelProtocol: ContainerModelProtocol, AccessibilityMode
|
|||||||
var action: ActionModelProtocol? { get set }
|
var action: ActionModelProtocol? { get set }
|
||||||
var hideArrow: Bool? { get set }
|
var hideArrow: Bool? { get set }
|
||||||
var style: ListItemStyle? { get set }
|
var style: ListItemStyle? { get set }
|
||||||
|
var gone: Bool { get set }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not a strict requirement.
|
// Not a strict requirement.
|
||||||
|
|||||||
@ -135,6 +135,10 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
||||||
|
return (getMoleculeInfo(for: indexPath)?.molecule as? ListItemModelProtocol)?.gone == true ? 0 : UITableView.automaticDimension
|
||||||
|
}
|
||||||
|
|
||||||
open func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
|
open func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
|
||||||
guard let moleculeInfo = getMoleculeInfo(for: indexPath),
|
guard let moleculeInfo = getMoleculeInfo(for: indexPath),
|
||||||
let estimatedHeight = (moleculeInfo.class as? MoleculeViewProtocol.Type)?.estimatedHeight(with: moleculeInfo.molecule, delegateObject() as? MVMCoreUIDelegateObject)
|
let estimatedHeight = (moleculeInfo.class as? MoleculeViewProtocol.Type)?.estimatedHeight(with: moleculeInfo.molecule, delegateObject() as? MVMCoreUIDelegateObject)
|
||||||
@ -152,7 +156,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
|||||||
guard let moleculeInfo = getMoleculeInfo(for: indexPath),
|
guard let moleculeInfo = getMoleculeInfo(for: indexPath),
|
||||||
let cell = tableView.dequeueReusableCell(withIdentifier: moleculeInfo.identifier)
|
let cell = tableView.dequeueReusableCell(withIdentifier: moleculeInfo.identifier)
|
||||||
else { return UITableViewCell() }
|
else { return UITableViewCell() }
|
||||||
|
cell.isHidden = (getMoleculeInfo(for: indexPath)?.molecule as? ListItemModelProtocol)?.gone == true
|
||||||
(cell as? MoleculeViewProtocol)?.reset()
|
(cell as? MoleculeViewProtocol)?.reset()
|
||||||
(cell as? MoleculeListCellProtocol)?.setLines(with: templateModel?.line, delegateObject: delegateObjectIVar, additionalData: nil, indexPath: indexPath)
|
(cell as? MoleculeListCellProtocol)?.setLines(with: templateModel?.line, delegateObject: delegateObjectIVar, additionalData: nil, indexPath: indexPath)
|
||||||
if let moleculeView = cell as? MoleculeViewProtocol {
|
if let moleculeView = cell as? MoleculeViewProtocol {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user