footerlessSpacerHeight + footerlessSpacerColor to adjust footerless padding.

This commit is contained in:
Hedden, Kyle Matthew 2024-03-11 19:35:45 -04:00
parent b9675ce5f1
commit 582cd33a1c
2 changed files with 22 additions and 9 deletions

View File

@ -18,6 +18,8 @@
public var line: LineModel?
public var scrollToRowIndex: Int?
public var singleCellSelection: Bool = false
public var footerlessSpacerHeight: CGFloat?
public var footerlessSpacerColor: Color?
public override var rootMolecules: [MoleculeModelProtocol] {
if let molecules = molecules {
@ -60,6 +62,8 @@
case line
case scrollToRowIndex
case singleCellSelection
case footerlessSpacerHeight
case footerlessSpacerColor
}
//--------------------------------------------------
@ -74,6 +78,8 @@
if let singleCellSelection = try typeContainer.decodeIfPresent(Bool.self, forKey: .singleCellSelection) {
self.singleCellSelection = singleCellSelection
}
footerlessSpacerColor = try typeContainer.decodeIfPresent(Color.self, forKey: .footerlessSpacerColor)
footerlessSpacerHeight = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .footerlessSpacerHeight)
try super.init(from: decoder)
try validateModelHasContent()
}
@ -85,5 +91,7 @@
try container.encode(line, forKey: .line)
try container.encode(singleCellSelection, forKey: .singleCellSelection)
try container.encodeIfPresent(scrollToRowIndex, forKey: .scrollToRowIndex)
try container.encodeIfPresent(footerlessSpacerColor, forKey: .footerlessSpacerColor)
try container.encodeIfPresent(footerlessSpacerHeight, forKey: .footerlessSpacerHeight)
}
}

View File

@ -69,16 +69,21 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
return molecule
}
override open func viewForBottom() -> UIView {
guard let footerModel = templateModel?.footer,
let molecule = generateMoleculeView(from: footerModel)
else {
let view = super.viewForBottom()
view.backgroundColor = templateModel?.backgroundColor?.uiColor ?? .clear
return view
open override func viewForBottom() -> UIView {
// If there is a footer molecule return the molecule.
if let footerModel = templateModel?.footer,
let molecule = generateMoleculeView(from: footerModel) {
return molecule
}
return molecule
// Otherwise setup a bottom spacer view.
let view: UIView
if let footerlessSpacerHeight = templateModel?.footerlessSpacerHeight {
view = MVMCoreUICommonViewsUtility.getView(with: footerlessSpacerHeight <= 0.5 ? 0.5 : footerlessSpacerHeight)
} else {
view = super.viewForBottom()
}
view.backgroundColor = templateModel?.footerlessSpacerColor?.uiColor ?? templateModel?.backgroundColor?.uiColor ?? .clear
return view
}
open override func handleNewData() {