Compare commits

..
6 Commits
Author SHA1 Message Date
Alex K adbd6a608b Fixes #144 2018-05-02 15:15:34 +03:00
Alex K 816fe67543 update podspec 2018-04-02 10:21:06 +03:00
Alex K a191c4bc05 refactoring, remove guard with fatal error 2018-04-02 10:15:04 +03:00
Alex K cbe678277d update podspec 2018-03-27 16:37:34 +03:00
Alex K a760de74ee Fixes #126 make closeAnimation and opentAnimation methods public 2018-03-27 16:35:20 +03:00
Alex K 7d639d3332 update podspec 2018-03-27 16:32:23 +03:00
3 changed files with 28 additions and 25 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'FoldingCell'
s.version = '3.0.3'
s.version = '3.0.6'
s.summary = 'UITableViewCell with folding animation.'
s.homepage = 'https://github.com/Ramotion/folding-cell'
s.license = 'MIT'
@@ -59,9 +59,12 @@
NSNumber *height = [self.cellHeights objectAtIndex:indexPath.row];
bool cellIsCollapsed = height.floatValue == self.kCloseCellHeight;
if (cellIsCollapsed) {
[(FoldingCell *) cell selectedAnimation:false animated:false completion: nil];
[(FoldingCell *)cell unfold:NO animated:NO completion:nil];
//[(FoldingCell *) cell selectedAnimation:false animated:false completion: nil];
} else {
[(FoldingCell *) cell selectedAnimation:true animated:false completion: nil];
[(FoldingCell *)cell unfold:YES animated:NO completion:nil];
//[(FoldingCell *) cell selectedAnimation:true animated:false completion: nil];
}
UIView *backgroundTopView = [cell viewWithTag:11];
@@ -108,11 +111,13 @@
bool cellIsCollapsed = height.floatValue == self.kCloseCellHeight;
if (cellIsCollapsed) {
[self.cellHeights setObject:[NSNumber numberWithFloat:self.kOpenCellHeight] atIndexedSubscript:indexPath.row];
[cell selectedAnimation:true animated:true completion: nil];
//[cell selectedAnimation:true animated:true completion: nil];
[cell unfold:YES animated:YES completion:nil];
duration = 0.5;
} else {
[self.cellHeights setObject:[NSNumber numberWithFloat:self.kCloseCellHeight] atIndexedSubscript:indexPath.row];
[cell selectedAnimation:false animated:true completion: nil];
//[cell selectedAnimation:false animated:true completion: nil];
[cell unfold:NO animated:YES completion:nil];
duration = 0.8;
}
+18 -20
View File
@@ -118,22 +118,20 @@ open class FoldingCell: UITableViewCell {
func configureAnimationItems(_ animationType: AnimationType) {
guard let animationViewSuperView = animationView?.subviews else {
fatalError()
}
if animationType == .open {
for view in animationViewSuperView.filter({ $0 is RotatedView }) {
view.alpha = 0
}
animationView?.subviews
.flatMap { $0 as? RotatedView }
.forEach { $0.alpha = 0 }
} else {
for case let view as RotatedView in animationViewSuperView.filter({ $0 is RotatedView }) {
if animationType == .open {
view.alpha = 0
} else {
view.alpha = 1
view.backView?.alpha = 0
}
animationView?.subviews
.flatMap { $0 as? RotatedView }
.forEach {
if animationType == .open {
$0.alpha = 0
} else {
$0.alpha = 1
$0.backView?.alpha = 0
}
}
}
}
@@ -265,7 +263,7 @@ open class FoldingCell: UITableViewCell {
/// - value: unfold = true; collapse = false.
/// - animated: animate changes.
/// - completion: A block object to be executed when the animation sequence ends.
open func unfold(_ value: Bool, animated: Bool = true, completion: (() -> Void)? = nil) {
@objc open func unfold(_ value: Bool, animated: Bool = true, completion: (() -> Void)? = nil) {
if animated {
value ? openAnimation(completion) : closeAnimation(completion)
} else {
@@ -274,7 +272,7 @@ open class FoldingCell: UITableViewCell {
}
}
open func isAnimating() -> Bool {
@objc open func isAnimating() -> Bool {
return animationView?.alpha == 1 ? true : false
}
@@ -286,8 +284,8 @@ open class FoldingCell: UITableViewCell {
return type == .close ? durationsForCollapsedState[itemIndex] : durationsForExpandedState[itemIndex]
}
open var durationsForExpandedState: [TimeInterval] = []
open var durationsForCollapsedState: [TimeInterval] = []
@objc open var durationsForExpandedState: [TimeInterval] = []
@objc open var durationsForCollapsedState: [TimeInterval] = []
func durationSequence(_ type: AnimationType) -> [TimeInterval] {
var durations = [TimeInterval]()
@@ -299,7 +297,7 @@ open class FoldingCell: UITableViewCell {
return durations
}
func openAnimation(_ completion: (() -> Void)?) {
public func openAnimation(_ completion: (() -> Void)?) {
isUnfolded = true
removeImageItemsFromAnimationView()
addImageItemsToAnimationView()
@@ -346,7 +344,7 @@ open class FoldingCell: UITableViewCell {
}
}
func closeAnimation(_ completion: (() -> Void)?) {
public func closeAnimation(_ completion: (() -> Void)?) {
isUnfolded = false
removeImageItemsFromAnimationView()
addImageItemsToAnimationView()