tabledirector extensions added

This commit is contained in:
nikAshanin 2017-04-06 14:23:16 +03:00
parent a4683f131f
commit d533e098f8
7 changed files with 93 additions and 5 deletions

View File

@ -74,6 +74,7 @@
CAA707D51E2E614E0022D732 /* ModuleConfigurator.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAA707D41E2E614E0022D732 /* ModuleConfigurator.swift */; };
CAA707D71E2E616D0022D732 /* BaseViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAA707D61E2E616D0022D732 /* BaseViewModel.swift */; };
CAA707D91E2E61A50022D732 /* ConfigurableController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAA707D81E2E61A50022D732 /* ConfigurableController.swift */; };
CAE698C21E965B47000394B0 /* TableDirector+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAE698C01E965B47000394B0 /* TableDirector+Extensions.swift */; };
E126CBB31DB68DDA00E1B2F8 /* UICollectionView+CellRegistration.swift in Sources */ = {isa = PBXBuildFile; fileRef = E126CBB21DB68DDA00E1B2F8 /* UICollectionView+CellRegistration.swift */; };
EF2921A61E165DF400E8F43B /* TimeInterval+DateComponents.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF2921A51E165DF400E8F43B /* TimeInterval+DateComponents.swift */; };
EF5FB5691E0141610030E4BE /* UIView+Rotation.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF5FB5681E0141610030E4BE /* UIView+Rotation.swift */; };
@ -163,6 +164,7 @@
CAA707D41E2E614E0022D732 /* ModuleConfigurator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ModuleConfigurator.swift; sourceTree = "<group>"; };
CAA707D61E2E616D0022D732 /* BaseViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseViewModel.swift; sourceTree = "<group>"; };
CAA707D81E2E61A50022D732 /* ConfigurableController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConfigurableController.swift; sourceTree = "<group>"; };
CAE698C01E965B47000394B0 /* TableDirector+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "TableDirector+Extensions.swift"; path = "TableDirector/TableDirector+Extensions.swift"; sourceTree = "<group>"; };
CC832342120EAD568C9F7FC3 /* Pods-LeadKitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LeadKitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-LeadKitTests/Pods-LeadKitTests.debug.xcconfig"; sourceTree = "<group>"; };
E126CBB21DB68DDA00E1B2F8 /* UICollectionView+CellRegistration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UICollectionView+CellRegistration.swift"; path = "UICollectionView/UICollectionView+CellRegistration.swift"; sourceTree = "<group>"; };
EF2921A51E165DF400E8F43B /* TimeInterval+DateComponents.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "TimeInterval+DateComponents.swift"; sourceTree = "<group>"; };
@ -450,6 +452,7 @@
78CFEE441C5C45E500F50370 /* Extensions */ = {
isa = PBXGroup;
children = (
CAE698BF1E965AE9000394B0 /* TableDirector */,
786D78E61D53C355006B2CEA /* Alamofire */,
780D23441DA416E80084620D /* CGContext */,
67788F9D1E6965F800484DEE /* CGFloat */,
@ -558,6 +561,14 @@
name = UIDevice;
sourceTree = "<group>";
};
CAE698BF1E965AE9000394B0 /* TableDirector */ = {
isa = PBXGroup;
children = (
CAE698C01E965B47000394B0 /* TableDirector+Extensions.swift */,
);
name = TableDirector;
sourceTree = "<group>";
};
E126CBB11DB68D9A00E1B2F8 /* UICollectionView */ = {
isa = PBXGroup;
children = (
@ -857,6 +868,7 @@
787682FA1CAD40C300532AB3 /* StaticEstimatedViewHeightProtocol.swift in Sources */,
CA1FE7091E27D7DE00968901 /* UIDevice+Extensions.swift in Sources */,
78A74EA91C6B373700FE9724 /* UIView+DefaultNibName.swift in Sources */,
CAE698C21E965B47000394B0 /* TableDirector+Extensions.swift in Sources */,
CAA707D91E2E61A50022D732 /* ConfigurableController.swift in Sources */,
7884DB9C1DC1439200E52A63 /* UserDefaults+MappableDataTypes.swift in Sources */,
CAA707D71E2E616D0022D732 /* BaseViewModel.swift in Sources */,

View File

@ -51,7 +51,7 @@ open class XibView: UIView {
frame = CGRect(origin: frame.origin, size: view.frame.size)
view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
addSubview(view)
}

View File

@ -0,0 +1,72 @@
//
// Copyright (c) 2017 Touch Instinct
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the Software), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
import TableKit
extension TableDirector {
@discardableResult
func replace(section: TableSection, atIndex index: Int, reload: Bool = true) -> Self {
if index < sections.count {
remove(sectionAt: index)
}
insert(section: section, atIndex: index)
if reload {
self.reload(sectionAtIndex: index)
}
return self
}
@discardableResult
func reload(sectionAtIndex index: Int, with animation: UITableViewRowAnimation = .none) -> Self {
let action = { [tableView] in
if index < tableView?.numberOfSections ?? 0 {
tableView?.reloadSections([index], with: animation)
} else {
tableView?.reloadData()
}
}
if animation == .none {
UIView.performWithoutAnimation(action)
} else {
action()
}
return self
}
@discardableResult
func replace(withSections sections: [TableSection]) -> Self {
clear().append(sections: sections).reload()
return self
}
@discardableResult
func replace(withSection section: TableSection) -> Self {
return replace(withSections: [section])
}
@discardableResult
func replace(withRows rows: [Row]) -> Self {
return replace(withSection: TableSection(rows: rows))
}
}

View File

@ -36,7 +36,7 @@ extension UIView {
public func startZRotation(duration: CFTimeInterval = 1, repeatCount: Float = Float.infinity, clockwise: Bool = true) {
let animation = CABasicAnimation(keyPath: UIView.rotationKeyPath)
let direction = clockwise ? 1.0 : -1.0
animation.toValue = NSNumber(value: M_PI * 2 * direction)
animation.toValue = NSNumber(value: .pi * 2 * direction)
animation.duration = duration
animation.isCumulative = true
animation.repeatCount = repeatCount

View File

@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.4.4</string>
<string>0.4.7</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>

View File

@ -10,7 +10,8 @@ target 'LeadKit' do
pod "RxAlamofire", '3.0.0'
pod "ObjectMapper", '~> 2.1'
pod "Toast-Swift", '~> 2.0.0'
pod "TableKit", '~> 2.3.1'
target 'LeadKitTests' do
inherit! :search_paths
# Pods for testing

View File

@ -12,6 +12,7 @@ PODS:
- RxCocoa (3.2.0):
- RxSwift (~> 3.1)
- RxSwift (3.2.0)
- TableKit (2.3.1)
- Toast-Swift (2.0.0)
DEPENDENCIES:
@ -20,6 +21,7 @@ DEPENDENCIES:
- RxAlamofire (= 3.0.0)
- RxCocoa (= 3.2.0)
- RxSwift (= 3.2.0)
- TableKit (~> 2.3.1)
- Toast-Swift (~> 2.0.0)
SPEC CHECKSUMS:
@ -29,8 +31,9 @@ SPEC CHECKSUMS:
RxAlamofire: 0b1fa48f545fffe7f7a28af2086bcaa3b5946cc9
RxCocoa: ccdf43101a70407097a29082f648ba1676075b30
RxSwift: 46574f70d416b7923c237195939cc488a7fbf3a0
TableKit: 02e041b443f75fa3e9f1ee6024d4b256305bd904
Toast-Swift: 5b2f8f720f7e78e48511f693df1f9c9a6e38a25a
PODFILE CHECKSUM: ee07f67e4cce90b2d448e0c18941bc51ab6180cc
PODFILE CHECKSUM: c85ee069c7ba0c53c44a486be3daf0ff5ed4e9fa
COCOAPODS: 1.2.0