Skip to content

Commit

Permalink
refactor: Rename showSkeletonLeafBlock and do not return a block
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardbosch committed Dec 19, 2018
1 parent f3eff3a commit effb01d
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions Sources/SkeletonView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ extension UIView {
layoutIfNeeded()

addDummyDataSourceIfNeeded()
subviewsSkeletonables.recursiveSearch(
leafBlock: showSkeletonLeafBlock(withType: type, usingColors:colors, animated: animated, animation: animation)
){ subview in
subviewsSkeletonables.recursiveSearch(leafBlock: {
showSkeletonIfNotActive(withType: type, usingColors: colors, animated: animated, animation: animation)
}){ subview in
subview.recursiveShowSkeleton(withType: type, usingColors: colors, animated: animated, animation: animation)
}

Expand All @@ -101,7 +101,7 @@ extension UIView {
if isSkeletonActive {
updateSkeletonLayer(usingColors: colors, animated: animated, animation: animation)
} else {
showSkeletonLeafBlock(withType: type, usingColors:colors, animated: animated, animation: animation)()
showSkeletonIfNotActive(withType: type, usingColors:colors, animated: animated, animation: animation)
}
}) { subview in
subview.recursiveUpdateSkeleton(withType: type, usingColors: colors, animated: animated, animation: animation)
Expand All @@ -112,14 +112,12 @@ extension UIView {
}
}

fileprivate func showSkeletonLeafBlock(withType type: SkeletonType, usingColors colors: [UIColor], animated: Bool, animation: SkeletonLayerAnimation?) -> VoidBlock {
return {
guard !self.isSkeletonActive else { return }
self.isUserInteractionEnabled = false
self.saveViewState()
(self as? PrepareForSkeleton)?.prepareViewForSkeleton()
self.addSkeletonLayer(withType: type, usingColors: colors, animated: animated, animation: animation)
}
fileprivate func showSkeletonIfNotActive(withType type: SkeletonType, usingColors colors: [UIColor], animated: Bool, animation: SkeletonLayerAnimation?) {
guard !self.isSkeletonActive else { return }
self.isUserInteractionEnabled = false
self.saveViewState()
(self as? PrepareForSkeleton)?.prepareViewForSkeleton()
self.addSkeletonLayer(withType: type, usingColors: colors, animated: animated, animation: animation)
}


Expand Down

0 comments on commit effb01d

Please sign in to comment.