Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 519d724e17 | |||
| d80114e454 | |||
| 1d4c698ab0 | |||
| 0ebf480310 | |||
| b178f69898 | |||
| 62782d83f9 | |||
| b3038a90ec | |||
| 03ba583c49 | |||
| f29e4b0716 | |||
| 41ce466ae3 | |||
| c3688a9e1d | |||
| 512885a166 | |||
| 8fad95711e | |||
| d6e792e3ec |
+1
-1
@@ -1 +1 @@
|
||||
4.0
|
||||
5.0
|
||||
|
||||
+7
-8
@@ -2,13 +2,12 @@
|
||||
# * http://www.objc.io/issue-6/travis-ci.html
|
||||
# * https://github.com/supermarin/xcpretty#usage
|
||||
|
||||
osx_image: xcode7.3
|
||||
language: objective-c
|
||||
# cache: cocoapods
|
||||
# podfile: Example/Podfile
|
||||
# before_install:
|
||||
# - gem install cocoapods # Since Travis is not always on latest version
|
||||
# - pod install --project-directory=Example
|
||||
osx_image: xcode10.2
|
||||
language: swift
|
||||
before_install:
|
||||
- gem install cocoapods # Since Travis is not always on latest version
|
||||
- pod repo update
|
||||
- pod install --project-directory=Example
|
||||
script:
|
||||
- set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/InfiniteLayout.xcworkspace -scheme InfiniteLayout-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty
|
||||
- set -o pipefail && xcodebuild -workspace Example/InfiniteLayout.xcworkspace -scheme InfiniteLayout-Example -sdk iphonesimulator build CODE_SIGNING_REQUIRED=NO | xcpretty -c
|
||||
- pod lib lint
|
||||
|
||||
@@ -262,18 +262,18 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0830;
|
||||
LastUpgradeCheck = 0830;
|
||||
LastUpgradeCheck = 1020;
|
||||
ORGANIZATIONNAME = CocoaPods;
|
||||
TargetAttributes = {
|
||||
607FACCF1AFB9204008FA782 = {
|
||||
CreatedOnToolsVersion = 6.3.1;
|
||||
DevelopmentTeam = CPE39ZT2AY;
|
||||
LastSwiftMigration = 0900;
|
||||
LastSwiftMigration = 1020;
|
||||
};
|
||||
607FACE41AFB9204008FA782 = {
|
||||
CreatedOnToolsVersion = 6.3.1;
|
||||
DevelopmentTeam = CPE39ZT2AY;
|
||||
LastSwiftMigration = 0900;
|
||||
LastSwiftMigration = 1020;
|
||||
TestTargetID = 607FACCF1AFB9204008FA782;
|
||||
};
|
||||
};
|
||||
@@ -283,6 +283,7 @@
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
English,
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
@@ -324,12 +325,13 @@
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${SRCROOT}/Pods/Target Support Files/Pods-InfiniteLayout_Example/Pods-InfiniteLayout_Example-frameworks.sh",
|
||||
"${PODS_ROOT}/Target Support Files/Pods-InfiniteLayout_Example/Pods-InfiniteLayout_Example-frameworks.sh",
|
||||
"${BUILT_PRODUCTS_DIR}/CocoaProxy/CocoaProxy.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/Differentiator/Differentiator.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/InfiniteLayout/InfiniteLayout.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/RxCocoa/RxCocoa.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/RxDataSources/RxDataSources.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/RxRelay/RxRelay.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/RxSwift/RxSwift.framework",
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
@@ -339,11 +341,12 @@
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/InfiniteLayout.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxCocoa.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxDataSources.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxRelay.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxSwift.framework",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InfiniteLayout_Example/Pods-InfiniteLayout_Example-frameworks.sh\"\n";
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-InfiniteLayout_Example/Pods-InfiniteLayout_Example-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
BB5E5FB53E7C451064DBC9A2 /* [CP] Check Pods Manifest.lock */ = {
|
||||
@@ -441,6 +444,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
@@ -449,12 +453,14 @@
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
@@ -487,6 +493,7 @@
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -494,6 +501,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
@@ -502,12 +510,14 @@
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
@@ -532,6 +542,7 @@
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 5.0;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
@@ -547,8 +558,7 @@
|
||||
MODULE_NAME = ExampleApp;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||
SWIFT_VERSION = 4.0;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = 1;
|
||||
};
|
||||
name = Debug;
|
||||
@@ -564,8 +574,7 @@
|
||||
MODULE_NAME = ExampleApp;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||
SWIFT_VERSION = 4.0;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = 1;
|
||||
};
|
||||
name = Release;
|
||||
@@ -587,8 +596,7 @@
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||
SWIFT_VERSION = 4.0;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -605,8 +613,7 @@
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||
SWIFT_VERSION = 4.0;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
||||
+1
-3
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0900"
|
||||
LastUpgradeVersion = "1020"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -40,7 +40,6 @@
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
@@ -70,7 +69,6 @@
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
|
||||
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
var window: UIWindow?
|
||||
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
// Override point for customization after application launch.
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ enum CellStyle {
|
||||
let colors = [#colorLiteral(red: 0.5254901961, green: 0.6901960784, blue: 0.9137254902, alpha: 1), #colorLiteral(red: 0.5254901961, green: 0.6196078431, blue: 0.9137254902, alpha: 1), #colorLiteral(red: 0.6078431373, green: 0.5254901961, blue: 0.9137254902, alpha: 1), #colorLiteral(red: 0.9137254902, green: 0.5254901961, blue: 0.8392156863, alpha: 1), #colorLiteral(red: 0.9137254902, green: 0.5254901961, blue: 0.6, alpha: 1), #colorLiteral(red: 0.9137254902, green: 0.6784313725, blue: 0.5254901961, alpha: 1), #colorLiteral(red: 0.9137254902, green: 0.9058823529, blue: 0.5254901961, alpha: 1), #colorLiteral(red: 0.5254901961, green: 0.9137254902, blue: 0.5921568627, alpha: 1), #colorLiteral(red: 0.5254901961, green: 0.8, blue: 0.9137254902, alpha: 1)]
|
||||
|
||||
@IBInspectable var styleIndex: Int {
|
||||
get { return CellStyle.all.index(of: style)! }
|
||||
get { return CellStyle.all.firstIndex(of: style)! }
|
||||
set { style = CellStyle.all[newValue % CellStyle.all.count] }
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import InfiniteLayout
|
||||
class CustomViewController: UIViewController {
|
||||
|
||||
@IBOutlet weak var infiniteCollectionView: InfiniteCollectionView!
|
||||
|
||||
}
|
||||
|
||||
extension CustomViewController: UICollectionViewDataSource {
|
||||
|
||||
+1
-2
@@ -1,4 +1,5 @@
|
||||
use_frameworks!
|
||||
platform :ios, '10.0'
|
||||
|
||||
target 'InfiniteLayout_Example' do
|
||||
pod 'InfiniteLayout', :path => '../'
|
||||
@@ -6,7 +7,5 @@ target 'InfiniteLayout_Example' do
|
||||
|
||||
target 'InfiniteLayout_Tests' do
|
||||
inherit! :search_paths
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
+27
-22
@@ -1,24 +1,27 @@
|
||||
PODS:
|
||||
- CocoaProxy (0.1.1)
|
||||
- Differentiator (3.0.2)
|
||||
- InfiniteLayout (0.2.3.1):
|
||||
- Differentiator (4.0.1)
|
||||
- InfiniteLayout (0.4.1):
|
||||
- CocoaProxy (~> 0)
|
||||
- InfiniteLayout/Core (= 0.2.3.1)
|
||||
- InfiniteLayout/Core (0.2.3.1):
|
||||
- InfiniteLayout/Core (= 0.4.1)
|
||||
- InfiniteLayout/Core (0.4.1):
|
||||
- CocoaProxy (~> 0)
|
||||
- InfiniteLayout/Rx (0.2.3.1):
|
||||
- InfiniteLayout/Rx (0.4.1):
|
||||
- CocoaProxy (~> 0)
|
||||
- InfiniteLayout/Core (~> 0)
|
||||
- RxCocoa (~> 4)
|
||||
- RxDataSources (~> 3)
|
||||
- RxSwift (~> 4)
|
||||
- RxCocoa (4.1.0):
|
||||
- RxSwift (~> 4.0)
|
||||
- RxDataSources (3.0.2):
|
||||
- Differentiator (~> 3.0)
|
||||
- RxCocoa (~> 4.0)
|
||||
- RxSwift (~> 4.0)
|
||||
- RxSwift (4.1.0)
|
||||
- RxCocoa (~> 5)
|
||||
- RxDataSources (~> 4)
|
||||
- RxSwift (~> 5)
|
||||
- RxCocoa (5.0.0):
|
||||
- RxRelay (~> 5)
|
||||
- RxSwift (~> 5)
|
||||
- RxDataSources (4.0.1):
|
||||
- Differentiator (~> 4.0)
|
||||
- RxCocoa (~> 5.0)
|
||||
- RxSwift (~> 5.0)
|
||||
- RxRelay (5.0.0):
|
||||
- RxSwift (~> 5)
|
||||
- RxSwift (5.0.0)
|
||||
|
||||
DEPENDENCIES:
|
||||
- InfiniteLayout (from `../`)
|
||||
@@ -30,6 +33,7 @@ SPEC REPOS:
|
||||
- Differentiator
|
||||
- RxCocoa
|
||||
- RxDataSources
|
||||
- RxRelay
|
||||
- RxSwift
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
@@ -38,12 +42,13 @@ EXTERNAL SOURCES:
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
CocoaProxy: 35ab81e24325b33834cffe45a3d1fd48ca67ef3a
|
||||
Differentiator: a87be69eba49ec4ab460c7671143ee3a9eececfd
|
||||
InfiniteLayout: 17bbab705aa4d941fa82a7e9b658c96d13ce91a3
|
||||
RxCocoa: cc1fec49cdc8fabe645964de7c51c099a36c2aa8
|
||||
RxDataSources: cb7c31e652a87ebb919da45f716bbb87b3765f6b
|
||||
RxSwift: 4219941c1244c88002901bd87a69d3aea9ae71f0
|
||||
Differentiator: 886080237d9f87f322641dedbc5be257061b0602
|
||||
InfiniteLayout: 458eadbcb94afc3d777141990fbfe7a804a35609
|
||||
RxCocoa: fcf32050ac00d801f34a7f71d5e8e7f23026dcd8
|
||||
RxDataSources: efee07fa4de48477eca0a4611e6d11e2da9c1114
|
||||
RxRelay: 4f7409406a51a55cd88483f21ed898c234d60f18
|
||||
RxSwift: 8b0671caa829a763bbce7271095859121cbd895f
|
||||
|
||||
PODFILE CHECKSUM: 3501aeed91e62112dd38178a52f26b204b97c8c0
|
||||
PODFILE CHECKSUM: 0dc7a9b37f9b7c5d5266beaab9e94861b80aa80f
|
||||
|
||||
COCOAPODS: 1.5.3
|
||||
COCOAPODS: 1.6.1
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'InfiniteLayout'
|
||||
s.version = '0.2.3.3'
|
||||
s.version = '0.4.1'
|
||||
s.summary = 'Horizontal and Vertical infinite scrolling feature for UICollectionView with Paging, NSProxy delegate, Reactive extension'
|
||||
|
||||
# This description is used to generate tags and improve search results.
|
||||
@@ -49,9 +49,9 @@ Horizontal and Vertical infinite scrolling feature for UICollectionView with Pag
|
||||
|
||||
s.subspec 'Rx' do |rx|
|
||||
rx.dependency 'InfiniteLayout/Core', '~> 0'
|
||||
rx.dependency 'RxSwift', '~> 4'
|
||||
rx.dependency 'RxCocoa', '~> 4'
|
||||
rx.dependency 'RxDataSources', '~> 3'
|
||||
rx.dependency 'RxSwift', '~> 5'
|
||||
rx.dependency 'RxCocoa', '~> 5'
|
||||
rx.dependency 'RxDataSources', '~> 4'
|
||||
rx.source_files = 'InfiniteLayout/Rx/**/*'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -134,7 +134,7 @@ extension InfiniteCollectionView: UICollectionViewDataSource {
|
||||
}
|
||||
|
||||
private var multiplier: Int {
|
||||
return InfiniteDataSources.multiplier(estimatedItemSize: self.infiniteLayout.itemSize)
|
||||
return InfiniteDataSources.multiplier(estimatedItemSize: self.infiniteLayout.itemSize, enabled: self.infiniteLayout.isEnabled)
|
||||
}
|
||||
|
||||
public func section(from infiniteSection: Int) -> Int {
|
||||
@@ -202,5 +202,6 @@ extension InfiniteCollectionView: UICollectionViewDelegate {
|
||||
if isItemPagingEnabled {
|
||||
self.infiniteLayout.centerCollectionView(withVelocity: velocity, targetContentOffset: targetContentOffset)
|
||||
}
|
||||
self.delegateProxy.delegate?.scrollViewWillEndDragging?(scrollView, withVelocity: velocity, targetContentOffset: targetContentOffset)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,10 @@ class InfiniteDataSources {
|
||||
return IndexPath(item: infiniteIndexPath.item % numberOfItems, section: self.section(from: infiniteIndexPath.section, numberOfSections: numberOfSections))
|
||||
}
|
||||
|
||||
static func multiplier(estimatedItemSize: CGSize) -> Int {
|
||||
static func multiplier(estimatedItemSize: CGSize, enabled: Bool) -> Int {
|
||||
guard enabled else {
|
||||
return 1
|
||||
}
|
||||
let min = Swift.min(estimatedItemSize.width, estimatedItemSize.height)
|
||||
let count = ceil(InfiniteLayout.minimumContentSize / min)
|
||||
return Int(count)
|
||||
|
||||
@@ -15,7 +15,13 @@ open class InfiniteLayout: UICollectionViewFlowLayout {
|
||||
|
||||
private var contentSize: CGSize = .zero
|
||||
|
||||
private (set) var isEnabled: Bool = false
|
||||
private var hasValidLayout: Bool = false
|
||||
|
||||
@IBInspectable public var isEnabled: Bool = true {
|
||||
didSet {
|
||||
self.invalidateLayout()
|
||||
}
|
||||
}
|
||||
|
||||
public var currentPage: CGPoint {
|
||||
guard let collectionView = self.collectionView else {
|
||||
@@ -49,8 +55,8 @@ open class InfiniteLayout: UICollectionViewFlowLayout {
|
||||
override open func prepare() {
|
||||
let collectionViewContentSize = super.collectionViewContentSize
|
||||
self.contentSize = CGSize(width: collectionViewContentSize.width, height: collectionViewContentSize.height)
|
||||
self.isEnabled = {
|
||||
guard let collectionView = self.collectionView, collectionView.bounds != .zero else {
|
||||
self.hasValidLayout = {
|
||||
guard let collectionView = self.collectionView, collectionView.bounds != .zero, self.isEnabled else {
|
||||
return false
|
||||
}
|
||||
return (scrollDirection == .horizontal ? self.contentSize.width : self.contentSize.height) >=
|
||||
@@ -60,8 +66,8 @@ open class InfiniteLayout: UICollectionViewFlowLayout {
|
||||
}
|
||||
|
||||
override open var collectionViewContentSize: CGSize {
|
||||
guard isEnabled else {
|
||||
return super.collectionViewContentSize
|
||||
guard hasValidLayout else {
|
||||
return self.contentSize
|
||||
}
|
||||
return CGSize(width: scrollDirection == .horizontal ? self.contentSize.width * multiplier : self.contentSize.width,
|
||||
height: scrollDirection == .vertical ? self.contentSize.height * multiplier : self.contentSize.height)
|
||||
@@ -75,7 +81,7 @@ open class InfiniteLayout: UICollectionViewFlowLayout {
|
||||
}
|
||||
|
||||
override open func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
|
||||
guard isEnabled else {
|
||||
guard hasValidLayout else {
|
||||
return super.layoutAttributesForElements(in: rect)
|
||||
}
|
||||
let page = self.page(for: rect.origin)
|
||||
@@ -157,7 +163,7 @@ open class InfiniteLayout: UICollectionViewFlowLayout {
|
||||
}
|
||||
|
||||
public func loopCollectionViewIfNeeded() {
|
||||
guard let collectionView = self.collectionView, self.isEnabled else {
|
||||
guard let collectionView = self.collectionView, self.hasValidLayout else {
|
||||
return
|
||||
}
|
||||
let page = self.pageIndex(from: self.page(for: collectionView.contentOffset))
|
||||
@@ -247,7 +253,7 @@ open class InfiniteLayout: UICollectionViewFlowLayout {
|
||||
}
|
||||
|
||||
public func centerCollectionView(withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
|
||||
guard let collectionView = self.collectionView, self.isEnabled else {
|
||||
guard let collectionView = self.collectionView, self.hasValidLayout else {
|
||||
return
|
||||
}
|
||||
let newTarget = CGPoint(x: self.scrollDirection == .horizontal ? collectionView.contentOffset.x + velocity.x * velocityMultiplier : targetContentOffset.pointee.x,
|
||||
@@ -261,7 +267,7 @@ open class InfiniteLayout: UICollectionViewFlowLayout {
|
||||
}
|
||||
|
||||
public func centerCollectionViewIfNeeded(indexPath: IndexPath? = nil) {
|
||||
guard let collectionView = self.collectionView, self.isEnabled else {
|
||||
guard let collectionView = self.collectionView, self.hasValidLayout else {
|
||||
return
|
||||
}
|
||||
guard let preferredAttributes = self.preferredVisibleLayoutAttributes(indexPath: indexPath),
|
||||
|
||||
@@ -31,7 +31,7 @@ class RxInfiniteCollectionViewDelegate: DelegateProxy<InfiniteCollectionView, In
|
||||
}
|
||||
}
|
||||
|
||||
public extension Reactive where Base: InfiniteCollectionView {
|
||||
extension Reactive where Base: InfiniteCollectionView {
|
||||
|
||||
private var infiniteDelegate: RxInfiniteCollectionViewDelegate {
|
||||
return RxInfiniteCollectionViewDelegate.proxy(for: self.base)
|
||||
@@ -52,13 +52,13 @@ public extension Reactive where Base: InfiniteCollectionView {
|
||||
}
|
||||
}
|
||||
|
||||
public extension Reactive where Base: RxInfiniteCollectionView {
|
||||
extension Reactive where Base: RxInfiniteCollectionView {
|
||||
|
||||
public func items<S: Sequence, O: ObservableType>
|
||||
(infinite: Bool)
|
||||
-> (_ source: O)
|
||||
-> (_ cellFactory: @escaping (UICollectionView, Int, S.Iterator.Element) -> UICollectionViewCell)
|
||||
-> Disposable where O.E == S {
|
||||
-> Disposable where O.Element == S {
|
||||
return { source in
|
||||
guard infinite else {
|
||||
return self.items(source)
|
||||
@@ -76,7 +76,7 @@ public extension Reactive where Base: RxInfiniteCollectionView {
|
||||
(cellIdentifier: String, cellType: Cell.Type = Cell.self, infinite: Bool)
|
||||
-> (_ source: O)
|
||||
-> (_ configureCell: @escaping (Int, S.Iterator.Element, Cell) -> Void)
|
||||
-> Disposable where O.E == S {
|
||||
-> Disposable where O.Element == S {
|
||||
guard infinite else {
|
||||
return self.items(cellIdentifier: cellIdentifier, cellType: cellType)
|
||||
}
|
||||
|
||||
@@ -9,13 +9,15 @@ import UIKit
|
||||
import RxDataSources
|
||||
|
||||
open class RxInfiniteCollectionViewSectionedReloadDataSource<S: SectionModelType>: RxCollectionViewSectionedReloadDataSource<S> {
|
||||
|
||||
public var isEnabled: Bool = true
|
||||
|
||||
open override subscript(section: Int) -> S {
|
||||
let section = InfiniteDataSources.section(from: section, numberOfSections: sectionModels.count)
|
||||
return self.sectionModels[section]
|
||||
}
|
||||
|
||||
open override subscript(indexPath: IndexPath) -> I {
|
||||
open override subscript(indexPath: IndexPath) -> Item {
|
||||
get {
|
||||
let indexPath = InfiniteDataSources.indexPath(from: indexPath,
|
||||
numberOfSections: sectionModels.count,
|
||||
@@ -33,7 +35,7 @@ open class RxInfiniteCollectionViewSectionedReloadDataSource<S: SectionModelType
|
||||
guard let layout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout else {
|
||||
fatalError()
|
||||
}
|
||||
return InfiniteDataSources.multiplier(estimatedItemSize: layout.itemSize)
|
||||
return InfiniteDataSources.multiplier(estimatedItemSize: layout.itemSize, enabled: isEnabled)
|
||||
}
|
||||
|
||||
open override func numberOfSections(in collectionView: UICollectionView) -> Int {
|
||||
@@ -54,12 +56,14 @@ open class RxInfiniteCollectionViewSectionedReloadDataSource<S: SectionModelType
|
||||
|
||||
open class RxInfiniteCollectionViewSectionedAnimatedDataSource<S: AnimatableSectionModelType>: RxCollectionViewSectionedAnimatedDataSource<S> {
|
||||
|
||||
public var isEnabled: Bool = true
|
||||
|
||||
open override subscript(section: Int) -> S {
|
||||
let section = InfiniteDataSources.section(from: section, numberOfSections: sectionModels.count)
|
||||
return self.sectionModels[section]
|
||||
}
|
||||
|
||||
open override subscript(indexPath: IndexPath) -> I {
|
||||
open override subscript(indexPath: IndexPath) -> Item {
|
||||
get {
|
||||
let indexPath = InfiniteDataSources.indexPath(from: indexPath,
|
||||
numberOfSections: sectionModels.count,
|
||||
@@ -77,7 +81,7 @@ open class RxInfiniteCollectionViewSectionedAnimatedDataSource<S: AnimatableSect
|
||||
guard let layout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout else {
|
||||
fatalError()
|
||||
}
|
||||
return InfiniteDataSources.multiplier(estimatedItemSize: layout.itemSize)
|
||||
return InfiniteDataSources.multiplier(estimatedItemSize: layout.itemSize, enabled: isEnabled)
|
||||
}
|
||||
|
||||
open override func numberOfSections(in collectionView: UICollectionView) -> Int {
|
||||
|
||||
Reference in New Issue
Block a user