columns
This commit is contained in:
parent
40efdc4968
commit
b7edafc5d8
@ -257,6 +257,7 @@
|
|||||||
D264FA90243BCE6800D98315 /* ThreeLayerCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FA8F243BCE6800D98315 /* ThreeLayerCollectionViewController.swift */; };
|
D264FA90243BCE6800D98315 /* ThreeLayerCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FA8F243BCE6800D98315 /* ThreeLayerCollectionViewController.swift */; };
|
||||||
D264FAA1243CF66B00D98315 /* ContainerCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FAA0243CF66B00D98315 /* ContainerCollectionReusableView.swift */; };
|
D264FAA1243CF66B00D98315 /* ContainerCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FAA0243CF66B00D98315 /* ContainerCollectionReusableView.swift */; };
|
||||||
D264FAA3243E632F00D98315 /* ProgrammaticCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FAA2243E632F00D98315 /* ProgrammaticCollectionViewController.swift */; };
|
D264FAA3243E632F00D98315 /* ProgrammaticCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FAA2243E632F00D98315 /* ProgrammaticCollectionViewController.swift */; };
|
||||||
|
D264FAA5243F66A500D98315 /* CollectionTemplateItemProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D264FAA4243F66A500D98315 /* CollectionTemplateItemProtocol.swift */; };
|
||||||
D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; };
|
D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; };
|
||||||
D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */; };
|
D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */; };
|
||||||
D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D26C5A6A23F4A40D007AEECE /* ListItemModel.swift */; };
|
D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D26C5A6A23F4A40D007AEECE /* ListItemModel.swift */; };
|
||||||
@ -670,6 +671,7 @@
|
|||||||
D264FA8F243BCE6800D98315 /* ThreeLayerCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerCollectionViewController.swift; sourceTree = "<group>"; };
|
D264FA8F243BCE6800D98315 /* ThreeLayerCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerCollectionViewController.swift; sourceTree = "<group>"; };
|
||||||
D264FAA0243CF66B00D98315 /* ContainerCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerCollectionReusableView.swift; sourceTree = "<group>"; };
|
D264FAA0243CF66B00D98315 /* ContainerCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerCollectionReusableView.swift; sourceTree = "<group>"; };
|
||||||
D264FAA2243E632F00D98315 /* ProgrammaticCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgrammaticCollectionViewController.swift; sourceTree = "<group>"; };
|
D264FAA2243E632F00D98315 /* ProgrammaticCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgrammaticCollectionViewController.swift; sourceTree = "<group>"; };
|
||||||
|
D264FAA4243F66A500D98315 /* CollectionTemplateItemProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionTemplateItemProtocol.swift; sourceTree = "<group>"; };
|
||||||
D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DropDownFilterTableViewCell.swift; sourceTree = "<group>"; };
|
D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DropDownFilterTableViewCell.swift; sourceTree = "<group>"; };
|
||||||
D26C5A6A23F4A40D007AEECE /* ListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListItemModel.swift; sourceTree = "<group>"; };
|
D26C5A6A23F4A40D007AEECE /* ListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListItemModel.swift; sourceTree = "<group>"; };
|
||||||
D274CA322236A78900B01B62 /* FooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterView.swift; sourceTree = "<group>"; };
|
D274CA322236A78900B01B62 /* FooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterView.swift; sourceTree = "<group>"; };
|
||||||
@ -1442,6 +1444,7 @@
|
|||||||
942C378B2412F4FA0066E45E /* ModalMoleculeListTemplate.swift */,
|
942C378B2412F4FA0066E45E /* ModalMoleculeListTemplate.swift */,
|
||||||
014AA72A23C5059B006F3E93 /* ThreeLayerPageTemplateModel.swift */,
|
014AA72A23C5059B006F3E93 /* ThreeLayerPageTemplateModel.swift */,
|
||||||
D2D6CD4122E78FAB00D701B8 /* ThreeLayerTemplate.swift */,
|
D2D6CD4122E78FAB00D701B8 /* ThreeLayerTemplate.swift */,
|
||||||
|
D264FAA4243F66A500D98315 /* CollectionTemplateItemProtocol.swift */,
|
||||||
D264FA8B243BCD8E00D98315 /* CollectionTemplateModel.swift */,
|
D264FA8B243BCD8E00D98315 /* CollectionTemplateModel.swift */,
|
||||||
D264FA8D243BCD9A00D98315 /* CollectionTemplate.swift */,
|
D264FA8D243BCD9A00D98315 /* CollectionTemplate.swift */,
|
||||||
);
|
);
|
||||||
@ -2237,6 +2240,7 @@
|
|||||||
01EB3684236097C0006832FA /* MoleculeModelProtocol.swift in Sources */,
|
01EB3684236097C0006832FA /* MoleculeModelProtocol.swift in Sources */,
|
||||||
D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */,
|
D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */,
|
||||||
8D070BB2241B56AD0099AC56 /* ListRightVariableTotalData.swift in Sources */,
|
8D070BB2241B56AD0099AC56 /* ListRightVariableTotalData.swift in Sources */,
|
||||||
|
D264FAA5243F66A500D98315 /* CollectionTemplateItemProtocol.swift in Sources */,
|
||||||
D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */,
|
D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */,
|
||||||
8DD1E36E243B3CFB00D8F2DF /* ListThreeColumnInternationalDataModel.swift in Sources */,
|
8DD1E36E243B3CFB00D8F2DF /* ListThreeColumnInternationalDataModel.swift in Sources */,
|
||||||
D243859923A16B1800332775 /* Container.swift in Sources */,
|
D243859923A16B1800332775 /* Container.swift in Sources */,
|
||||||
|
|||||||
@ -83,11 +83,23 @@ import Foundation
|
|||||||
registerCells()
|
registerCells()
|
||||||
super.handleNewData()
|
super.handleNewData()
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Collection
|
// MARK: - Collection
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
open override func update(cell: UICollectionViewCell, size: CGFloat) {
|
||||||
|
super.update(cell: cell, size: size)
|
||||||
|
|
||||||
|
// Update the width for columns.
|
||||||
|
if let collectionView = collectionView,
|
||||||
|
let columns = templateModel?.columns, columns > 0,
|
||||||
|
let cell = cell as? CollectionTemplateItemProtocol {
|
||||||
|
let width = (size - collectionView.adjustedContentInset.left - collectionView.adjustedContentInset.right) / CGFloat(columns)
|
||||||
|
cell.set(width: width)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open override func registerCells() {
|
open override func registerCells() {
|
||||||
super.registerCells()
|
super.registerCells()
|
||||||
guard let moleculesInfo = moleculesInfo else { return }
|
guard let moleculesInfo = moleculesInfo else { return }
|
||||||
@ -111,13 +123,20 @@ import Foundation
|
|||||||
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: moleculeInfo.identifier, for: indexPath)
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: moleculeInfo.identifier, for: indexPath)
|
||||||
(cell as? MoleculeViewProtocol)?.reset()
|
(cell as? MoleculeViewProtocol)?.reset()
|
||||||
(cell as? MoleculeViewProtocol)?.set(with: moleculeInfo.molecule, delegateObjectIVar, nil)
|
(cell as? MoleculeViewProtocol)?.set(with: moleculeInfo.molecule, delegateObjectIVar, nil)
|
||||||
(cell as? MVMCoreViewProtocol)?.updateView(view.bounds.width)
|
update(cell: cell, size: view.frame.width)
|
||||||
|
|
||||||
// Neded to fix an apple defect where the cell is not the correct size on certain devices for certain cells
|
// Neded to fix an apple defect where the cell is not the correct size on certain devices for certain cells
|
||||||
cell.layoutIfNeeded()
|
cell.layoutIfNeeded()
|
||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||||
|
(collectionView.cellForItem(at: indexPath) as? CollectionTemplateItemProtocol)?.didSelectCell(at: indexPath, delegateObject: delegateObjectIVar, additionalData: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
|
||||||
|
(cell as? CollectionTemplateItemProtocol)?.willDisplay()
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Convenience
|
// MARK: - Convenience
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -0,0 +1,29 @@
|
|||||||
|
//
|
||||||
|
// CollectionTemplateItemProtocol.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Scott Pfeil on 4/9/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
/// A protocol that items of the CollectionTemplate must conform to.
|
||||||
|
public protocol CollectionTemplateItemProtocol: UICollectionViewCell {
|
||||||
|
|
||||||
|
/// Set the width of the item. Used for the columns functionality
|
||||||
|
func set(width: CGFloat)
|
||||||
|
|
||||||
|
/// Handle action when cell is pressed
|
||||||
|
func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?)
|
||||||
|
|
||||||
|
/// Called when the cell will display.
|
||||||
|
func willDisplay()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default implementation does nothing
|
||||||
|
extension CollectionTemplateItemProtocol {
|
||||||
|
public func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {}
|
||||||
|
|
||||||
|
public func willDisplay() {}
|
||||||
|
}
|
||||||
@ -9,12 +9,13 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// A base collection view cell with basic mvm functionality.
|
/// A base collection view cell with basic mvm functionality.
|
||||||
open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCoreViewProtocol {
|
open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCoreViewProtocol, CollectionTemplateItemProtocol {
|
||||||
|
|
||||||
// Convenience helpers
|
// Convenience helpers
|
||||||
open var molecule: MoleculeViewProtocol?
|
open var molecule: MoleculeViewProtocol?
|
||||||
public let containerHelper = ContainerHelper()
|
public let containerHelper = ContainerHelper()
|
||||||
open var model: CollectionItemModelProtocol?
|
open var model: CollectionItemModelProtocol?
|
||||||
|
open var widthConstraint: NSLayoutConstraint?
|
||||||
|
|
||||||
private var initialSetupPerformed = false
|
private var initialSetupPerformed = false
|
||||||
|
|
||||||
@ -56,6 +57,7 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo
|
|||||||
open func reset() {
|
open func reset() {
|
||||||
molecule?.reset()
|
molecule?.reset()
|
||||||
backgroundColor = .white
|
backgroundColor = .white
|
||||||
|
widthConstraint?.isActive = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - MoleculeViewProtocol
|
// MARK: - MoleculeViewProtocol
|
||||||
@ -80,4 +82,15 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo
|
|||||||
containerHelper.constrainView(molecule)
|
containerHelper.constrainView(molecule)
|
||||||
self.molecule = molecule
|
self.molecule = molecule
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - CollectionTemplateItemProtocol
|
||||||
|
public func set(width: CGFloat) {
|
||||||
|
if let widthConstraint = widthConstraint {
|
||||||
|
widthConstraint.constant = width
|
||||||
|
widthConstraint.isActive = true
|
||||||
|
} else {
|
||||||
|
widthConstraint = contentView.widthAnchor.constraint(equalToConstant: width)
|
||||||
|
widthConstraint?.isActive = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,7 +50,7 @@ import Foundation
|
|||||||
currentSpaceForCompare = currentSpace * 2;
|
currentSpaceForCompare = currentSpace * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !MVMCoreGetterUtility.cgfequalwiththreshold(newSpace, currentSpaceForCompare, 2) {
|
if !MVMCoreGetterUtility.cgfequalwiththreshold(newSpace, currentSpaceForCompare, 1) {
|
||||||
if fillTop && fillBottom {
|
if fillTop && fillBottom {
|
||||||
// space both
|
// space both
|
||||||
let half = newSpace / 2
|
let half = newSpace / 2
|
||||||
@ -72,19 +72,22 @@ import Foundation
|
|||||||
//MARK: - ViewController
|
//MARK: - ViewController
|
||||||
open override func updateViews() {
|
open override func updateViews() {
|
||||||
super.updateViews()
|
super.updateViews()
|
||||||
let width = view.bounds.width
|
// Needed due to dispatch in reloadCollectionData.
|
||||||
if let topView = topView as? MVMCoreViewProtocol {
|
DispatchQueue.main.async {
|
||||||
topView.updateView(width)
|
let width = self.view.bounds.width
|
||||||
}
|
if let topView = self.topView as? MVMCoreViewProtocol {
|
||||||
if let bottomView = bottomView as? MVMCoreViewProtocol {
|
topView.updateView(width)
|
||||||
bottomView.updateView(width)
|
|
||||||
}
|
|
||||||
if let cells = collectionView?.visibleCells {
|
|
||||||
for cell in cells {
|
|
||||||
(cell as? MVMCoreViewProtocol)?.updateView(width)
|
|
||||||
}
|
}
|
||||||
|
if let bottomView = self.bottomView as? MVMCoreViewProtocol {
|
||||||
|
bottomView.updateView(width)
|
||||||
|
}
|
||||||
|
if let cells = self.collectionView?.visibleCells {
|
||||||
|
for cell in cells {
|
||||||
|
self.update(cell: cell, size: width)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.invalidateCollectionLayout()
|
||||||
}
|
}
|
||||||
invalidateCollectionLayout()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func handleNewData() {
|
open override func handleNewData() {
|
||||||
@ -168,6 +171,11 @@ import Foundation
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Called in updateView, updates the cell.
|
||||||
|
open func update(cell: UICollectionViewCell, size: CGFloat) {
|
||||||
|
(cell as? MVMCoreViewProtocol)?.updateView(size)
|
||||||
|
}
|
||||||
|
|
||||||
open override func registerCells() {
|
open override func registerCells() {
|
||||||
super.registerCells()
|
super.registerCells()
|
||||||
collectionView?.register(ContainerCollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: headerID)
|
collectionView?.register(ContainerCollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: headerID)
|
||||||
|
|||||||
@ -169,7 +169,6 @@
|
|||||||
bottomInset = scrollview.adjustedContentInset.bottom;
|
bottomInset = scrollview.adjustedContentInset.bottom;
|
||||||
}
|
}
|
||||||
CGFloat remainingSpace = frameHeight - contentSizeHeight - topInset - bottomInset;
|
CGFloat remainingSpace = frameHeight - contentSizeHeight - topInset - bottomInset;
|
||||||
NSLog(@"scc SPACCEEE remaining: %f frame: %f, content: %f, insets:(%f,%f)",remainingSpace,frameHeight,contentSizeHeight,topInset,bottomInset);
|
|
||||||
return remainingSpace - 1;
|
return remainingSpace - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user