diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f55038b..2e46ca53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. --- +## [1.0.0-rc.2](https://github.com/RxSwiftCommunity/RxDataSources/releases/tag/1.0.0-rc.2) + +#### Features + +* Makes rest of data source classes and methods open. +* Small polish for UI. +* Removes part of deprecated extensions. + ## [1.0.0-rc.1](https://github.com/RxSwiftCommunity/RxDataSources/releases/tag/1.0.0-rc.1) #### Features diff --git a/Example/Base.lproj/Main.storyboard b/Example/Base.lproj/Main.storyboard index 339087db..70a38158 100644 --- a/Example/Base.lproj/Main.storyboard +++ b/Example/Base.lproj/Main.storyboard @@ -1,11 +1,12 @@ - - + + - + + @@ -13,24 +14,24 @@ - + - + - + - + @@ -40,17 +41,17 @@ - + - + @@ -60,17 +61,17 @@ - + - + @@ -80,17 +81,17 @@ - + - + @@ -122,15 +123,14 @@ - + - - + - + @@ -156,30 +156,27 @@ - + - - + - + - + - @@ -197,19 +194,16 @@ - + - + - - - + @@ -226,19 +220,16 @@ - + - + - - - + @@ -257,7 +248,7 @@ - + @@ -283,16 +274,14 @@ - + - - + - - + @@ -308,13 +297,11 @@ - @@ -326,18 +313,17 @@ - + - - + + @@ -348,11 +334,10 @@ - - + - + @@ -379,7 +364,7 @@ @@ -405,25 +390,24 @@ - + - - + - + - + @@ -432,7 +416,7 @@ - + diff --git a/Example/Example2_RandomizedSectionsAnimation.swift b/Example/Example2_RandomizedSectionsAnimation.swift index 6edd7982..c3245cbc 100644 --- a/Example/Example2_RandomizedSectionsAnimation.swift +++ b/Example/Example2_RandomizedSectionsAnimation.swift @@ -118,9 +118,7 @@ extension ViewController { // MARK: Initial value func initialValue() -> [NumberSection] { - let generate = true - if generate { - + #if true let nSections = 10 let nItems = 100 @@ -133,10 +131,9 @@ extension ViewController { return (0 ..< nSections).map { (i: Int) in NumberSection(header: "Section \(i + 1)", numbers: $(Array(i * nItems ..< (i + 1) * nItems)), updated: Date()) } - } - else { + #else return _initialValue - } + #endif } diff --git a/Example/Example4_DifferentSectionAndItemTypes.swift b/Example/Example4_DifferentSectionAndItemTypes.swift index 5962f087..4ec40977 100644 --- a/Example/Example4_DifferentSectionAndItemTypes.swift +++ b/Example/Example4_DifferentSectionAndItemTypes.swift @@ -62,7 +62,7 @@ class MultipleSectionModelViewController: UIViewController { } dataSource.titleForHeaderInSection = { dataSource, index in - let section = dataSource.sectionAtIndex(index) + let section = dataSource[index] return section.title } diff --git a/Example/Support/AppDelegate.swift b/Example/Support/AppDelegate.swift index 635b1eb6..c817dce6 100644 --- a/Example/Support/AppDelegate.swift +++ b/Example/Support/AppDelegate.swift @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true } diff --git a/RxDataSources.podspec b/RxDataSources.podspec index 8326603c..78bac68a 100644 --- a/RxDataSources.podspec +++ b/RxDataSources.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "RxDataSources" - s.version = "1.0.0-rc.1" + s.version = "1.0.0-rc.2" s.summary = "This is a collection of reactive data sources for UITableView and UICollectionView." s.description = <<-DESC This is a collection of reactive data sources for UITableView and UICollectionView. diff --git a/RxDataSources.xcodeproj/project.pbxproj b/RxDataSources.xcodeproj/project.pbxproj index 0b308aa7..22b14d20 100644 --- a/RxDataSources.xcodeproj/project.pbxproj +++ b/RxDataSources.xcodeproj/project.pbxproj @@ -30,7 +30,6 @@ 9FCDA1751C3AF4A2000F5F94 /* RxCollectionViewSectionedReloadDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = C85EE5531C36F1FC0090614D /* RxCollectionViewSectionedReloadDataSource.swift */; }; 9FCDA1761C3AF4A2000F5F94 /* RxTableViewSectionedAnimatedDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = C85EE5541C36F1FC0090614D /* RxTableViewSectionedAnimatedDataSource.swift */; }; 9FCDA1771C3AF4A2000F5F94 /* RxTableViewSectionedReloadDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = C85EE5551C36F1FC0090614D /* RxTableViewSectionedReloadDataSource.swift */; }; - 9FCDA1781C3AF4A2000F5F94 /* UISectionedViewType+RxAnimatedDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = C85EE5561C36F1FC0090614D /* UISectionedViewType+RxAnimatedDataSource.swift */; }; 9FF3014A1C4AA6D1007376BD /* RxCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9FF301481C4AA6D1007376BD /* RxCocoa.framework */; }; 9FF3014B1C4AA6D1007376BD /* RxSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9FF301491C4AA6D1007376BD /* RxSwift.framework */; }; 9FF3014E1C4AA6DA007376BD /* RxCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9FF3014C1C4AA6DA007376BD /* RxCocoa.framework */; }; @@ -56,7 +55,6 @@ C85EE5611C36F1FC0090614D /* RxCollectionViewSectionedReloadDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = C85EE5531C36F1FC0090614D /* RxCollectionViewSectionedReloadDataSource.swift */; }; C85EE5621C36F1FC0090614D /* RxTableViewSectionedAnimatedDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = C85EE5541C36F1FC0090614D /* RxTableViewSectionedAnimatedDataSource.swift */; }; C85EE5631C36F1FC0090614D /* RxTableViewSectionedReloadDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = C85EE5551C36F1FC0090614D /* RxTableViewSectionedReloadDataSource.swift */; }; - C85EE5641C36F1FC0090614D /* UISectionedViewType+RxAnimatedDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = C85EE5561C36F1FC0090614D /* UISectionedViewType+RxAnimatedDataSource.swift */; }; C87DF3461D0219A7006308C5 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C87DF3431D0219A7006308C5 /* AppDelegate.swift */; }; C87DF3471D0219A7006308C5 /* NumberSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = C87DF3441D0219A7006308C5 /* NumberSection.swift */; }; C87DF3481D0219A7006308C5 /* Randomizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = C87DF3451D0219A7006308C5 /* Randomizer.swift */; }; @@ -103,7 +101,6 @@ C8BB76661C4C3E53002B21C8 /* SectionModelType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C85EE54E1C36F1FC0090614D /* SectionModelType.swift */; }; C8BB76671C4C3E53002B21C8 /* AnimatableSectionModelType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8BB76241C4C3CDF002B21C8 /* AnimatableSectionModelType.swift */; }; C8BB76691C4C3E53002B21C8 /* Differentiator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C85EE54B1C36F1FC0090614D /* Differentiator.swift */; }; - C8BB766A1C4C3E53002B21C8 /* UISectionedViewType+RxAnimatedDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = C85EE5561C36F1FC0090614D /* UISectionedViewType+RxAnimatedDataSource.swift */; }; C8BB766C1C4C3E53002B21C8 /* RxTableViewSectionedReloadDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = C85EE5551C36F1FC0090614D /* RxTableViewSectionedReloadDataSource.swift */; }; C8BB766D1C4C3E53002B21C8 /* CollectionViewSectionedDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = C85EE5491C36F1FC0090614D /* CollectionViewSectionedDataSource.swift */; }; C8BB766E1C4C3E53002B21C8 /* TableViewSectionedDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = C85EE54F1C36F1FC0090614D /* TableViewSectionedDataSource.swift */; }; @@ -212,7 +209,6 @@ C85EE5531C36F1FC0090614D /* RxCollectionViewSectionedReloadDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RxCollectionViewSectionedReloadDataSource.swift; sourceTree = ""; }; C85EE5541C36F1FC0090614D /* RxTableViewSectionedAnimatedDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RxTableViewSectionedAnimatedDataSource.swift; sourceTree = ""; }; C85EE5551C36F1FC0090614D /* RxTableViewSectionedReloadDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RxTableViewSectionedReloadDataSource.swift; sourceTree = ""; }; - C85EE5561C36F1FC0090614D /* UISectionedViewType+RxAnimatedDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UISectionedViewType+RxAnimatedDataSource.swift"; sourceTree = ""; }; C87DF3431D0219A7006308C5 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; C87DF3441D0219A7006308C5 /* NumberSection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberSection.swift; sourceTree = ""; }; C87DF3451D0219A7006308C5 /* Randomizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Randomizer.swift; sourceTree = ""; }; @@ -403,7 +399,6 @@ C85EE5531C36F1FC0090614D /* RxCollectionViewSectionedReloadDataSource.swift */, C85EE5541C36F1FC0090614D /* RxTableViewSectionedAnimatedDataSource.swift */, C85EE5551C36F1FC0090614D /* RxTableViewSectionedReloadDataSource.swift */, - C85EE5561C36F1FC0090614D /* UISectionedViewType+RxAnimatedDataSource.swift */, ); path = "DataSources+Rx"; sourceTree = ""; @@ -819,7 +814,6 @@ 9FCDA1711C3AF4A2000F5F94 /* SectionModelType.swift in Sources */, C8BB762F1C4C3CDF002B21C8 /* AnimatableSectionModelType.swift in Sources */, 9FCDA16E1C3AF4A2000F5F94 /* Differentiator.swift in Sources */, - 9FCDA1781C3AF4A2000F5F94 /* UISectionedViewType+RxAnimatedDataSource.swift in Sources */, C8477FBB1D29DBC90074454A /* IntegerType+IdentifiableType.swift in Sources */, 9FCDA1771C3AF4A2000F5F94 /* RxTableViewSectionedReloadDataSource.swift in Sources */, 9FCDA16C1C3AF4A2000F5F94 /* CollectionViewSectionedDataSource.swift in Sources */, @@ -851,7 +845,6 @@ C85EE55D1C36F1FC0090614D /* SectionModelType.swift in Sources */, C8BB762E1C4C3CDF002B21C8 /* AnimatableSectionModelType.swift in Sources */, C85EE55A1C36F1FC0090614D /* Differentiator.swift in Sources */, - C85EE5641C36F1FC0090614D /* UISectionedViewType+RxAnimatedDataSource.swift in Sources */, C8477FBA1D29DBC90074454A /* IntegerType+IdentifiableType.swift in Sources */, C85EE5631C36F1FC0090614D /* RxTableViewSectionedReloadDataSource.swift in Sources */, C85EE5581C36F1FC0090614D /* CollectionViewSectionedDataSource.swift in Sources */, @@ -927,7 +920,6 @@ C8BB76661C4C3E53002B21C8 /* SectionModelType.swift in Sources */, C8BB76671C4C3E53002B21C8 /* AnimatableSectionModelType.swift in Sources */, C8BB76691C4C3E53002B21C8 /* Differentiator.swift in Sources */, - C8BB766A1C4C3E53002B21C8 /* UISectionedViewType+RxAnimatedDataSource.swift in Sources */, C8477FB91D29DBC90074454A /* IntegerType+IdentifiableType.swift in Sources */, C8BB766C1C4C3E53002B21C8 /* RxTableViewSectionedReloadDataSource.swift in Sources */, C8BB766D1C4C3E53002B21C8 /* CollectionViewSectionedDataSource.swift in Sources */, diff --git a/Sources/DataSources+Rx/RxCollectionViewSectionedAnimatedDataSource.swift b/Sources/DataSources+Rx/RxCollectionViewSectionedAnimatedDataSource.swift index dfccfaac..a4b598a3 100644 --- a/Sources/DataSources+Rx/RxCollectionViewSectionedAnimatedDataSource.swift +++ b/Sources/DataSources+Rx/RxCollectionViewSectionedAnimatedDataSource.swift @@ -17,7 +17,7 @@ import RxCocoa This is commented becuse collection view has bugs when doing animated updates. Take a look at randomized sections. */ -public class RxCollectionViewSectionedAnimatedDataSource +open class RxCollectionViewSectionedAnimatedDataSource : CollectionViewSectionedDataSource , RxCollectionViewDataSourceType { public typealias Element = [S] @@ -44,12 +44,16 @@ public class RxCollectionViewSectionedAnimatedDataSource) { + /** + This method exists because collection view updates are throttled because of internal collection view bugs. + Collection view behaves poorly during fast updates, so this should remedy those issues. + */ + open func collectionView(_ collectionView: UICollectionView, throttledObservedEvent event: Event) { UIBindingObserver(UIElement: self) { dataSource, newSections in let oldSections = dataSource.sectionModels do { @@ -69,10 +73,10 @@ public class RxCollectionViewSectionedAnimatedDataSource) { + open func collectionView(_ collectionView: UICollectionView, observedEvent: Event) { UIBindingObserver(UIElement: self) { dataSource, newSections in #if DEBUG self._dataSourceBound = true diff --git a/Sources/DataSources+Rx/RxCollectionViewSectionedReloadDataSource.swift b/Sources/DataSources+Rx/RxCollectionViewSectionedReloadDataSource.swift index 1acbb7b6..1b422ad0 100644 --- a/Sources/DataSources+Rx/RxCollectionViewSectionedReloadDataSource.swift +++ b/Sources/DataSources+Rx/RxCollectionViewSectionedReloadDataSource.swift @@ -13,7 +13,7 @@ import RxSwift import RxCocoa #endif -public class RxCollectionViewSectionedReloadDataSource +open class RxCollectionViewSectionedReloadDataSource : CollectionViewSectionedDataSource , RxCollectionViewDataSourceType { @@ -23,7 +23,7 @@ public class RxCollectionViewSectionedReloadDataSource super.init() } - public func collectionView(_ collectionView: UICollectionView, observedEvent: Event) { + open func collectionView(_ collectionView: UICollectionView, observedEvent: Event) { UIBindingObserver(UIElement: self) { dataSource, element in #if DEBUG self._dataSourceBound = true diff --git a/Sources/DataSources+Rx/RxTableViewSectionedAnimatedDataSource.swift b/Sources/DataSources+Rx/RxTableViewSectionedAnimatedDataSource.swift index 11318334..96366c97 100644 --- a/Sources/DataSources+Rx/RxTableViewSectionedAnimatedDataSource.swift +++ b/Sources/DataSources+Rx/RxTableViewSectionedAnimatedDataSource.swift @@ -13,7 +13,7 @@ import RxSwift import RxCocoa #endif -public class RxTableViewSectionedAnimatedDataSource +open class RxTableViewSectionedAnimatedDataSource : TableViewSectionedDataSource , RxTableViewDataSourceType { @@ -26,7 +26,7 @@ public class RxTableViewSectionedAnimatedDataSource) { + open func tableView(_ tableView: UITableView, observedEvent: Event) { UIBindingObserver(UIElement: self) { dataSource, newSections in #if DEBUG self._dataSourceBound = true diff --git a/Sources/DataSources+Rx/RxTableViewSectionedReloadDataSource.swift b/Sources/DataSources+Rx/RxTableViewSectionedReloadDataSource.swift index 99f95842..e8bdb76b 100644 --- a/Sources/DataSources+Rx/RxTableViewSectionedReloadDataSource.swift +++ b/Sources/DataSources+Rx/RxTableViewSectionedReloadDataSource.swift @@ -13,7 +13,7 @@ import RxSwift import RxCocoa #endif -public class RxTableViewSectionedReloadDataSource +open class RxTableViewSectionedReloadDataSource : TableViewSectionedDataSource , RxTableViewDataSourceType { public typealias Element = [S] @@ -22,7 +22,7 @@ public class RxTableViewSectionedReloadDataSource super.init() } - public func tableView(_ tableView: UITableView, observedEvent: Event) { + open func tableView(_ tableView: UITableView, observedEvent: Event) { UIBindingObserver(UIElement: self) { dataSource, element in #if DEBUG self._dataSourceBound = true diff --git a/Sources/DataSources+Rx/UISectionedViewType+RxAnimatedDataSource.swift b/Sources/DataSources+Rx/UISectionedViewType+RxAnimatedDataSource.swift deleted file mode 100644 index 4e23eb5c..00000000 --- a/Sources/DataSources+Rx/UISectionedViewType+RxAnimatedDataSource.swift +++ /dev/null @@ -1,54 +0,0 @@ -// -// UISectionedViewType+RxAnimatedDataSource.swift -// RxExample -// -// Created by Krunoslav Zaher on 11/14/15. -// Copyright © 2015 Krunoslav Zaher. All rights reserved. -// - -import Foundation -import UIKit -#if !RX_NO_MODULE -import RxSwift -import RxCocoa -#endif - -extension Reactive where Base: UITableView { - @available(*, deprecated:0.7, renamed:"itemsWithDataSource", message:"You can just use normal `rx_itemsWithDataSource` extension.") - public func itemsAnimatedWithDataSource< - DataSource: RxTableViewDataSourceType & UITableViewDataSource, - S: Sequence, - O: ObservableType> - (_ dataSource: DataSource) - -> (_ source: O) - -> Disposable - where - DataSource.Element == S, - O.E == S, - S.Iterator.Element: AnimatableSectionModelType - { - return { source in - return self.items(dataSource: dataSource)(source) - } - } -} - -extension Reactive where Base: UICollectionView { - @available(*, deprecated:0.7, renamed:"itemsWithDataSource", message:"You can just use normal `rx_itemsWithDataSource` extension.") - public func itemsAnimatedWithDataSource< - DataSource: RxCollectionViewDataSourceType & UICollectionViewDataSource, - S: Sequence, - O: ObservableType> - (_ dataSource: DataSource) - -> (_ source: O) - -> Disposable - where - DataSource.Element == S, - O.E == S, - S.Iterator.Element: AnimatableSectionModelType - { - return { source in - return self.items(dataSource: dataSource)(source) - } - } -} diff --git a/Sources/DataSources/CollectionViewSectionedDataSource.swift b/Sources/DataSources/CollectionViewSectionedDataSource.swift index 314ebdfa..b1155333 100644 --- a/Sources/DataSources/CollectionViewSectionedDataSource.swift +++ b/Sources/DataSources/CollectionViewSectionedDataSource.swift @@ -16,51 +16,51 @@ open class _CollectionViewSectionedDataSource : NSObject , UICollectionViewDataSource { - func _numberOfSectionsInCollectionView(_ collectionView: UICollectionView) -> Int { + open func _rx_numberOfSections(in collectionView: UICollectionView) -> Int { return 0 } - public func numberOfSections(in collectionView: UICollectionView) -> Int { - return _numberOfSectionsInCollectionView(collectionView) + open func numberOfSections(in collectionView: UICollectionView) -> Int { + return _rx_numberOfSections(in: collectionView) } - func _rx_collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + open func _rx_collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return 0 } - public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + open func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return _rx_collectionView(collectionView, numberOfItemsInSection: section) } - func _rx_collectionView(_ collectionView: UICollectionView, cellForItemAtIndexPath indexPath: IndexPath) -> UICollectionViewCell { + open func _rx_collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { return (nil as UICollectionViewCell?)! } - public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - return _rx_collectionView(collectionView, cellForItemAtIndexPath: indexPath) + open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + return _rx_collectionView(collectionView, cellForItemAt: indexPath) } - func _rx_collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: IndexPath) -> UICollectionReusableView { + open func _rx_collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: IndexPath) -> UICollectionReusableView { return (nil as UICollectionReusableView?)! } - public func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { + open func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { return _rx_collectionView(collectionView, viewForSupplementaryElementOfKind: kind, atIndexPath: indexPath) } - func _rx_collectionView(_ collectionView: UICollectionView, canMoveItemAtIndexPath indexPath: IndexPath) -> Bool { + open func _rx_collectionView(_ collectionView: UICollectionView, canMoveItemAt indexPath: IndexPath) -> Bool { return true } public func collectionView(_ collectionView: UICollectionView, canMoveItemAt indexPath: IndexPath) -> Bool { - return _rx_collectionView(collectionView, canMoveItemAtIndexPath: indexPath) + return _rx_collectionView(collectionView, canMoveItemAt: indexPath) } - func _rx_collectionView(_ collectionView: UICollectionView, moveItemAtIndexPath sourceIndexPath: IndexPath, toIndexPath destinationIndexPath: IndexPath) { + open func _rx_collectionView(_ collectionView: UICollectionView, moveItemAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) { } public func collectionView(_ collectionView: UICollectionView, moveItemAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) { - _rx_collectionView(collectionView, moveItemAtIndexPath: sourceIndexPath, toIndexPath: destinationIndexPath) + _rx_collectionView(collectionView, moveItemAt: sourceIndexPath, to: destinationIndexPath) } } @@ -95,7 +95,7 @@ open class CollectionViewSectionedDataSource private var _sectionModels: [SectionModelSnapshot] = [] - public var sectionModels: [S] { + open var sectionModels: [S] { return _sectionModels.map { Section(original: $0.model, items: $0.items) } } @@ -119,7 +119,7 @@ open class CollectionViewSectionedDataSource return self[indexPath] } - public func setSections(_ sections: [S]) { + open func setSections(_ sections: [S]) { self._sectionModels = sections.map { SectionModelSnapshot(model: $0, items: $0.items) } } @@ -174,7 +174,7 @@ open class CollectionViewSectionedDataSource // UICollectionViewDataSource - open override func _numberOfSectionsInCollectionView(_ collectionView: UICollectionView) -> Int { + open override func _rx_numberOfSections(in collectionView: UICollectionView) -> Int { return _sectionModels.count } @@ -182,7 +182,7 @@ open class CollectionViewSectionedDataSource return _sectionModels[section].items.count } - open override func _rx_collectionView(_ collectionView: UICollectionView, cellForItemAtIndexPath indexPath: IndexPath) -> UICollectionViewCell { + open override func _rx_collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { precondition(indexPath.item < _sectionModels[indexPath.section].items.count) return configureCell(self, collectionView, indexPath, self[indexPath]) @@ -192,15 +192,15 @@ open class CollectionViewSectionedDataSource return supplementaryViewFactory(self, collectionView, kind, indexPath) } - open override func _rx_collectionView(_ collectionView: UICollectionView, canMoveItemAtIndexPath indexPath: IndexPath) -> Bool { + open override func _rx_collectionView(_ collectionView: UICollectionView, canMoveItemAt indexPath: IndexPath) -> Bool { guard let canMoveItem = canMoveItemAtIndexPath?(self, indexPath) else { - return super._rx_collectionView(collectionView, canMoveItemAtIndexPath: indexPath) + return super._rx_collectionView(collectionView, canMoveItemAt: indexPath) } return canMoveItem } - open override func _rx_collectionView(_ collectionView: UICollectionView, moveItemAtIndexPath sourceIndexPath: IndexPath, toIndexPath destinationIndexPath: IndexPath) { + open override func _rx_collectionView(_ collectionView: UICollectionView, moveItemAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) { self._sectionModels.moveFromSourceIndexPath(sourceIndexPath, destinationIndexPath: destinationIndexPath) self.moveItem?(self, sourceIndexPath, destinationIndexPath) } diff --git a/Sources/DataSources/TableViewSectionedDataSource.swift b/Sources/DataSources/TableViewSectionedDataSource.swift index 6a21cb03..b42d2ccd 100644 --- a/Sources/DataSources/TableViewSectionedDataSource.swift +++ b/Sources/DataSources/TableViewSectionedDataSource.swift @@ -17,85 +17,85 @@ open class _TableViewSectionedDataSource : NSObject , UITableViewDataSource { - func _numberOfSectionsInTableView(_ tableView: UITableView) -> Int { + open func _rx_numberOfSections(in tableView: UITableView) -> Int { return 1 } - public func numberOfSections(in tableView: UITableView) -> Int { - return _numberOfSectionsInTableView(tableView) + open func numberOfSections(in tableView: UITableView) -> Int { + return _rx_numberOfSections(in: tableView) } - func _rx_tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + open func _rx_tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 0 } - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + open func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return _rx_tableView(tableView, numberOfRowsInSection: section) } - func _rx_tableView(_ tableView: UITableView, cellForRowAtIndexPath indexPath: IndexPath) -> UITableViewCell { + open func _rx_tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { return (nil as UITableViewCell?)! } - public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - return _rx_tableView(tableView, cellForRowAtIndexPath: indexPath) + open func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + return _rx_tableView(tableView, cellForRowAt: indexPath) } - func _rx_tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + open func _rx_tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { return nil } - public func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + open func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { return _rx_tableView(tableView, titleForHeaderInSection: section) } - func _rx_tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { + open func _rx_tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { return nil } - public func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { + open func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { return _rx_tableView(tableView, titleForFooterInSection: section) } - func _rx_tableView(_ tableView: UITableView, canEditRowAtIndexPath indexPath: IndexPath) -> Bool { + open func _rx_tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { return false } - public func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { - return _rx_tableView(tableView, canEditRowAtIndexPath: indexPath) + open func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { + return _rx_tableView(tableView, canEditRowAt: indexPath) } - func _rx_tableView(_ tableView: UITableView, canMoveRowAtIndexPath indexPath: IndexPath) -> Bool { + open func _rx_tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { return false } - public func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { - return _rx_tableView(tableView, canMoveRowAtIndexPath: indexPath) + open func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { + return _rx_tableView(tableView, canMoveRowAt: indexPath) } #if os(iOS) - func _sectionIndexTitlesForTableView(_ tableView: UITableView) -> [String]? { + open func _rx_sectionIndexTitles(for tableView: UITableView) -> [String]? { return nil } - public func sectionIndexTitles(for tableView: UITableView) -> [String]? { - return _sectionIndexTitlesForTableView(tableView) + open func sectionIndexTitles(for tableView: UITableView) -> [String]? { + return _rx_sectionIndexTitles(for: tableView) } - func _rx_tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, atIndex index: Int) -> Int { + open func _rx_tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int { return 0 } - public func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int { - return _rx_tableView(tableView, sectionForSectionIndexTitle: title, atIndex: index) + open func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int { + return _rx_tableView(tableView, sectionForSectionIndexTitle: title, at: index) } #endif - func _rx_tableView(_ tableView: UITableView, moveRowAtIndexPath sourceIndexPath: IndexPath, toIndexPath destinationIndexPath: IndexPath) { + open func _rx_tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) { } - public func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) { - _rx_tableView(tableView, moveRowAtIndexPath: sourceIndexPath, toIndexPath: destinationIndexPath) + open func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) { + _rx_tableView(tableView, moveRowAt: sourceIndexPath, to: destinationIndexPath) } } @@ -130,7 +130,7 @@ open class TableViewSectionedDataSource private var _sectionModels: [SectionModelSnapshot] = [] - public var sectionModels: [S] { + open var sectionModels: [S] { return _sectionModels.map { Section(original: $0.model, items: $0.items) } } @@ -160,7 +160,7 @@ open class TableViewSectionedDataSource return self[indexPath] } - public func setSections(_ sections: [S]) { + open func setSections(_ sections: [S]) { self._sectionModels = sections.map { SectionModelSnapshot(model: $0, items: $0.items) } } @@ -234,7 +234,7 @@ open class TableViewSectionedDataSource // UITableViewDataSource - open override func _numberOfSectionsInTableView(_ tableView: UITableView) -> Int { + open override func _rx_numberOfSections(in tableView: UITableView) -> Int { return _sectionModels.count } @@ -242,7 +242,7 @@ open class TableViewSectionedDataSource return _sectionModels[section].items.count } - open override func _rx_tableView(_ tableView: UITableView, cellForRowAtIndexPath indexPath: IndexPath) -> UITableViewCell { + open override func _rx_tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { precondition(indexPath.item < _sectionModels[indexPath.section].items.count) return configureCell(self, tableView, indexPath, self[indexPath]) @@ -256,38 +256,38 @@ open class TableViewSectionedDataSource return titleForFooterInSection?(self, section) } - open override func _rx_tableView(_ tableView: UITableView, canEditRowAtIndexPath indexPath: IndexPath) -> Bool { + open override func _rx_tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { guard let canEditRow = canEditRowAtIndexPath?(self, indexPath) else { - return super._rx_tableView(tableView, canEditRowAtIndexPath: indexPath) + return super._rx_tableView(tableView, canEditRowAt: indexPath) } return canEditRow } - open override func _rx_tableView(_ tableView: UITableView, canMoveRowAtIndexPath indexPath: IndexPath) -> Bool { + open override func _rx_tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { guard let canMoveRow = canMoveRowAtIndexPath?(self, indexPath) else { - return super._rx_tableView(tableView, canMoveRowAtIndexPath: indexPath) + return super._rx_tableView(tableView, canMoveRowAt: indexPath) } return canMoveRow } - open override func _rx_tableView(_ tableView: UITableView, moveRowAtIndexPath sourceIndexPath: IndexPath, toIndexPath destinationIndexPath: IndexPath) { + open override func _rx_tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) { self._sectionModels.moveFromSourceIndexPath(sourceIndexPath, destinationIndexPath: destinationIndexPath) } #if os(iOS) - open override func _sectionIndexTitlesForTableView(_ tableView: UITableView) -> [String]? { + open override func _rx_sectionIndexTitles(for tableView: UITableView) -> [String]? { guard let titles = sectionIndexTitles?(self) else { - return super._sectionIndexTitlesForTableView(tableView) + return super._rx_sectionIndexTitles(for: tableView) } return titles } - open override func _rx_tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, atIndex index: Int) -> Int { + open override func _rx_tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int { guard let section = sectionForSectionIndexTitle?(self, title, index) else { - return super._rx_tableView(tableView, sectionForSectionIndexTitle: title, atIndex: index) + return super._rx_tableView(tableView, sectionForSectionIndexTitle: title, at: index) } return section