New TableView base
This commit is contained in:
parent
a97132c897
commit
c82b865404
@ -240,6 +240,7 @@
|
|||||||
D2092353244F7D630044AD09 /* MVMCoreUIViewControllerMappingObject+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2092352244F7D630044AD09 /* MVMCoreUIViewControllerMappingObject+Extension.swift */; };
|
D2092353244F7D630044AD09 /* MVMCoreUIViewControllerMappingObject+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2092352244F7D630044AD09 /* MVMCoreUIViewControllerMappingObject+Extension.swift */; };
|
||||||
D2092355244FA0FD0044AD09 /* ThreeLayerTemplateModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2092354244FA0FD0044AD09 /* ThreeLayerTemplateModelProtocol.swift */; };
|
D2092355244FA0FD0044AD09 /* ThreeLayerTemplateModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2092354244FA0FD0044AD09 /* ThreeLayerTemplateModelProtocol.swift */; };
|
||||||
D2092357244FA1EF0044AD09 /* ThreeLayerModelBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2092356244FA1EF0044AD09 /* ThreeLayerModelBase.swift */; };
|
D2092357244FA1EF0044AD09 /* ThreeLayerModelBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2092356244FA1EF0044AD09 /* ThreeLayerModelBase.swift */; };
|
||||||
|
D20923592450ECE00044AD09 /* TableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20923582450ECE00044AD09 /* TableView.swift */; };
|
||||||
D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; };
|
D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; };
|
||||||
D20FB165241A5D75004AFC3A /* NavigationItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20FB164241A5D75004AFC3A /* NavigationItemModelProtocol.swift */; };
|
D20FB165241A5D75004AFC3A /* NavigationItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20FB164241A5D75004AFC3A /* NavigationItemModelProtocol.swift */; };
|
||||||
D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; };
|
D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; };
|
||||||
@ -684,6 +685,7 @@
|
|||||||
D2092352244F7D630044AD09 /* MVMCoreUIViewControllerMappingObject+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIViewControllerMappingObject+Extension.swift"; sourceTree = "<group>"; };
|
D2092352244F7D630044AD09 /* MVMCoreUIViewControllerMappingObject+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIViewControllerMappingObject+Extension.swift"; sourceTree = "<group>"; };
|
||||||
D2092354244FA0FD0044AD09 /* ThreeLayerTemplateModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerTemplateModelProtocol.swift; sourceTree = "<group>"; };
|
D2092354244FA0FD0044AD09 /* ThreeLayerTemplateModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerTemplateModelProtocol.swift; sourceTree = "<group>"; };
|
||||||
D2092356244FA1EF0044AD09 /* ThreeLayerModelBase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerModelBase.swift; sourceTree = "<group>"; };
|
D2092356244FA1EF0044AD09 /* ThreeLayerModelBase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerModelBase.swift; sourceTree = "<group>"; };
|
||||||
|
D20923582450ECE00044AD09 /* TableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableView.swift; sourceTree = "<group>"; };
|
||||||
D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = "<group>"; };
|
D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = "<group>"; };
|
||||||
D20FB164241A5D75004AFC3A /* NavigationItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationItemModelProtocol.swift; sourceTree = "<group>"; };
|
D20FB164241A5D75004AFC3A /* NavigationItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationItemModelProtocol.swift; sourceTree = "<group>"; };
|
||||||
D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = "<group>"; };
|
D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = "<group>"; };
|
||||||
@ -1900,6 +1902,7 @@
|
|||||||
D2B18B7E2360913400A9AEDC /* Control.swift */,
|
D2B18B7E2360913400A9AEDC /* Control.swift */,
|
||||||
D2B18B802360945C00A9AEDC /* View.swift */,
|
D2B18B802360945C00A9AEDC /* View.swift */,
|
||||||
0AE14F63238315D2005417F8 /* TextField.swift */,
|
0AE14F63238315D2005417F8 /* TextField.swift */,
|
||||||
|
D20923582450ECE00044AD09 /* TableView.swift */,
|
||||||
D2755D7A23689C7500485468 /* TableViewCell.swift */,
|
D2755D7A23689C7500485468 /* TableViewCell.swift */,
|
||||||
D21B7F70243BAC1600051ABF /* CollectionViewCell.swift */,
|
D21B7F70243BAC1600051ABF /* CollectionViewCell.swift */,
|
||||||
D264FAA92440F97600D98315 /* CollectionView.swift */,
|
D264FAA92440F97600D98315 /* CollectionView.swift */,
|
||||||
@ -2245,6 +2248,7 @@
|
|||||||
D2092357244FA1EF0044AD09 /* ThreeLayerModelBase.swift in Sources */,
|
D2092357244FA1EF0044AD09 /* ThreeLayerModelBase.swift in Sources */,
|
||||||
0A1B4A96233BB18F005B3FB4 /* CheckboxLabel.swift in Sources */,
|
0A1B4A96233BB18F005B3FB4 /* CheckboxLabel.swift in Sources */,
|
||||||
0A21DB8B235E06EF00C160A2 /* MFDigitTextBox.m in Sources */,
|
0A21DB8B235E06EF00C160A2 /* MFDigitTextBox.m in Sources */,
|
||||||
|
D20923592450ECE00044AD09 /* TableView.swift in Sources */,
|
||||||
D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */,
|
D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */,
|
||||||
BB47A586241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift in Sources */,
|
BB47A586241615EF002BB23C /* ListOneColumnFullWidthTextDividerSubsectionModel.swift in Sources */,
|
||||||
AA69AAF82445BF6800AF3D3B /* ListLeftVariableCheckboxBodyTextModel.swift in Sources */,
|
AA69AAF82445BF6800AF3D3B /* ListLeftVariableCheckboxBodyTextModel.swift in Sources */,
|
||||||
|
|||||||
25
MVMCoreUI/BaseClasses/TableView.swift
Normal file
25
MVMCoreUI/BaseClasses/TableView.swift
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// TableView.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Scott Pfeil on 4/22/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
@objcMembers open class TableView: UITableView {
|
||||||
|
|
||||||
|
/// A block that gets called on tableview frame changes
|
||||||
|
public var frameChangeAction: (() -> Void)?
|
||||||
|
|
||||||
|
private var previousFrame = CGRect.zero
|
||||||
|
|
||||||
|
open override func layoutSubviews() {
|
||||||
|
super.layoutSubviews()
|
||||||
|
if frame != previousFrame {
|
||||||
|
frameChangeAction?()
|
||||||
|
}
|
||||||
|
previousFrame = frame
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,9 +9,9 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
open class ProgrammaticTableViewController: ProgrammaticScrollViewController, UITableViewDelegate, UITableViewDataSource {
|
open class ProgrammaticTableViewController: ProgrammaticScrollViewController, UITableViewDelegate, UITableViewDataSource {
|
||||||
@IBOutlet public var tableView: UITableView!
|
@IBOutlet public var tableView: TableView!
|
||||||
|
|
||||||
public init(with tableView: UITableView) {
|
public init(with tableView: TableView) {
|
||||||
self.tableView = tableView
|
self.tableView = tableView
|
||||||
super.init(with: tableView)
|
super.init(with: tableView)
|
||||||
}
|
}
|
||||||
@ -48,8 +48,8 @@ open class ProgrammaticTableViewController: ProgrammaticScrollViewController, UI
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// This class should create the table view that will be used here. Subclass this for different table styles.
|
/// This class should create the table view that will be used here. Subclass this for different table styles.
|
||||||
open func createTableView() -> UITableView {
|
open func createTableView() -> TableView {
|
||||||
let tableView = UITableView(frame: .zero, style: .grouped)
|
let tableView = TableView(frame: .zero, style: .grouped)
|
||||||
tableView.backgroundColor = .clear
|
tableView.backgroundColor = .clear
|
||||||
tableView.separatorStyle = UITableViewCell.SeparatorStyle.none
|
tableView.separatorStyle = UITableViewCell.SeparatorStyle.none
|
||||||
tableView.delegate = self
|
tableView.delegate = self
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import Foundation
|
|||||||
|
|
||||||
/// Updates the padding for flexible space (header or footer)
|
/// Updates the padding for flexible space (header or footer)
|
||||||
private func updateFlexibleSpace() {
|
private func updateFlexibleSpace() {
|
||||||
guard let tableView = collectionView else { return }
|
guard false,let collectionView = collectionView else { return }
|
||||||
|
|
||||||
let minimumSpace: CGFloat = minimumFillSpace()
|
let minimumSpace: CGFloat = minimumFillSpace()
|
||||||
var currentSpace: CGFloat = 0
|
var currentSpace: CGFloat = 0
|
||||||
@ -43,18 +43,18 @@ import Foundation
|
|||||||
}
|
}
|
||||||
|
|
||||||
guard fillTop || fillBottom else { return }
|
guard fillTop || fillBottom else { return }
|
||||||
let newSpace = MVMCoreUIUtility.getVariableConstraintHeight(currentSpace, in: tableView, minimumHeight: totalMinimumSpace)
|
let newSpace = MVMCoreUIUtility.getVariableConstraintHeight(currentSpace, in: collectionView, minimumHeight: totalMinimumSpace)
|
||||||
if !MVMCoreGetterUtility.cgfequalwiththreshold(newSpace, currentSpace, 1) {
|
if !MVMCoreGetterUtility.cgfequalwiththreshold(newSpace, currentSpace, 1) {
|
||||||
if fillTop && fillBottom {
|
if fillTop && fillBottom {
|
||||||
// space both
|
// space both
|
||||||
let half = newSpace / 2
|
let half = newSpace / 2
|
||||||
headerView?.bottomConstraint?.constant = half
|
headerView?.bottomConstraint?.constant = half
|
||||||
footerView?.topConstraint?.constant = half
|
footerView?.topConstraint?.constant = half
|
||||||
collectionView?.collectionViewLayout.invalidateLayout()
|
collectionView.collectionViewLayout.invalidateLayout()
|
||||||
} else if fillTop {
|
} else if fillTop {
|
||||||
// Only top is spaced.
|
// Only top is spaced.
|
||||||
headerView?.bottomConstraint?.constant = newSpace
|
headerView?.bottomConstraint?.constant = newSpace
|
||||||
collectionView?.collectionViewLayout.invalidateLayout()
|
collectionView.collectionViewLayout.invalidateLayout()
|
||||||
} else if fillBottom {
|
} else if fillBottom {
|
||||||
// Only bottom is spaced.
|
// Only bottom is spaced.
|
||||||
footerView?.topConstraint?.constant = newSpace
|
footerView?.topConstraint?.constant = newSpace
|
||||||
|
|||||||
@ -46,6 +46,11 @@ open class ThreeLayerTableViewController: ProgrammaticTableViewController {
|
|||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
// Do any additional setup after loading the view.
|
// Do any additional setup after loading the view.
|
||||||
setNoSectionHeadersFooters()
|
setNoSectionHeadersFooters()
|
||||||
|
|
||||||
|
// Ensures the footer and headers are the right size
|
||||||
|
tableView.frameChangeAction = { [weak self] in
|
||||||
|
self?.view.setNeedsUpdateConstraints()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//MARK: - Spacing
|
//MARK: - Spacing
|
||||||
@ -239,4 +244,9 @@ open class ThreeLayerTableViewController: ProgrammaticTableViewController {
|
|||||||
deinit {
|
deinit {
|
||||||
tableView?.delegate = nil
|
tableView?.delegate = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensures the footer and headers are the right size
|
||||||
|
func scrollViewDidChangeAdjustedContentInset(_ scrollView: UIScrollView) {
|
||||||
|
view.setNeedsUpdateConstraints()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user