Skip to content

Commit

Permalink
Fixes a datasource crash by incorrectly setting flowlayouts
Browse files Browse the repository at this point in the history
  • Loading branch information
pavankataria committed Apr 6, 2017
1 parent 32dcc44 commit 78bc96e
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- SwiftDataTables (0.5.0)
- SwiftDataTables (0.5.3)

DEPENDENCIES:
- SwiftDataTables (from `../`)
Expand All @@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
SwiftDataTables: c6191386bf58e48178f0362170fa7d65439ccaf7
SwiftDataTables: 4d8361a5b6abff530e1f186eaa5853c330e28dcf

PODFILE CHECKSUM: 117ac710a88fe801ecac2a925baa29b1107fef2e

Expand Down
4 changes: 2 additions & 2 deletions Example/Pods/Local Podspecs/SwiftDataTables.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion SwiftDataTables.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'SwiftDataTables'
s.version = '0.5.2'
s.version = '0.5.3'
s.summary = 'A Swift Data Table package that allows ordering, searching, and paging with extensible options.'

# This description is used to generate tags and improve search results.
Expand Down
15 changes: 10 additions & 5 deletions SwiftDataTables/Classes/SwiftDataTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public class SwiftDataTable: UIView {
{
self.options = options!
super.init(frame: frame)
self.set(data: data, headerTitles: headerTitles, options: options)
self.set(data: data, headerTitles: headerTitles, options: options, shouldReplaceLayout: true)
self.registerObservers()


Expand Down Expand Up @@ -243,12 +243,15 @@ public class SwiftDataTable: UIView {
collectionView.register(UINib(nibName: menuLengthIdentifier, bundle: podBundle), forSupplementaryViewOfKind: SupplementaryViewType.searchHeader.rawValue, withReuseIdentifier: menuLengthIdentifier)
}

func set(data: DataTableContent, headerTitles: [String], options: DataTableConfiguration? = nil){
func set(data: DataTableContent, headerTitles: [String], options: DataTableConfiguration? = nil, shouldReplaceLayout: Bool = false){
self.dataStructure = DataStructureModel(data: data, headerTitles: headerTitles)
self.createDataCellViewModels(with: self.dataStructure)
self.layout = SwiftDataTableFlowLayout(dataTable: self)
self.calculateColumnWidths()
self.applyOptions(options)
if(shouldReplaceLayout){
self.layout = SwiftDataTableFlowLayout(dataTable: self)
}

}

func applyOptions(_ options: DataTableConfiguration?){
Expand Down Expand Up @@ -313,9 +316,11 @@ public class SwiftDataTable: UIView {
for index in 0..<numberOfRows {
data.append(self.dataSource.dataTable(self, dataForRowAt: index))
}

self.layout?.clearLayoutCache()
self.collectionView.resetScrollPositionToTop()
self.set(data: data, headerTitles: headerTitles, options: self.options)
self.collectionView.collectionViewLayout.invalidateLayout()
self.update()
self.collectionView.reloadData()
}
}

Expand Down
2 changes: 1 addition & 1 deletion SwiftDataTables/Classes/SwiftDataTableFlowLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SwiftDataTableFlowLayout: UICollectionViewFlowLayout {
return
}
self.dataTable.calculateColumnWidths()
let methodStart = Date()
//let methodStart = Date()

var xOffsets = [CGFloat]()
var yOffsets = [CGFloat]()
Expand Down

0 comments on commit 78bc96e

Please sign in to comment.