fix: Skeleton new cells if container is skeletoned
This commit is contained in:
@@ -38,6 +38,7 @@ extension SkeletonCollectionDataSource: UITableViewDataSource {
|
||||
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let cellIdentifier = originalTableViewDataSource?.collectionSkeletonView(tableView, cellIdentifierForRowAt: indexPath) ?? ""
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath)
|
||||
skeletonCellIfContainerSkeletonIsActive(container: tableView, cell: cell)
|
||||
return cell
|
||||
}
|
||||
}
|
||||
@@ -56,6 +57,18 @@ extension SkeletonCollectionDataSource: UICollectionViewDataSource {
|
||||
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||
let cellIdentifier = originalCollectionViewDataSource?.collectionSkeletonView(collectionView, cellIdentifierForItemAt: indexPath) ?? ""
|
||||
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellIdentifier, for: indexPath)
|
||||
skeletonCellIfContainerSkeletonIsActive(container: collectionView, cell: cell)
|
||||
return cell
|
||||
}
|
||||
}
|
||||
|
||||
extension SkeletonCollectionDataSource {
|
||||
private func skeletonCellIfContainerSkeletonIsActive(container: UIView, cell: UIView) {
|
||||
guard container.isSkeletonActive,
|
||||
let skeletonConfig = container.currentSkeletonConfig else {
|
||||
return
|
||||
}
|
||||
|
||||
cell.showSkeleton(usingConfig: skeletonConfig)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,10 @@ public extension UIView {
|
||||
showSkeleton(withType: .gradient, usingColors: gradient.colors, animated: true, animation: animation)
|
||||
}
|
||||
|
||||
internal func showSkeleton(usingConfig config: SkeletonConfig) {
|
||||
showSkeleton(withType: config.type, usingColors: config.colors, animated: config.animated, animation: config.animation)
|
||||
}
|
||||
|
||||
func updateSkeleton(usingColor color: UIColor = SkeletonAppearance.default.tintColor) {
|
||||
updateSkeleton(withType: .solid, usingColors: [color])
|
||||
}
|
||||
@@ -81,6 +85,8 @@ extension UIView {
|
||||
fileprivate func recursiveShowSkeleton(withType type: SkeletonType, usingColors colors: [UIColor], animated: Bool, animation: SkeletonLayerAnimation?, root: UIView? = nil) {
|
||||
layoutIfNeeded()
|
||||
|
||||
currentSkeletonConfig = SkeletonConfig(type: type, colors: colors, gradientDirection: nil, animated: animated, animation: animation)
|
||||
|
||||
addDummyDataSourceIfNeeded()
|
||||
subviewsSkeletonables.recursiveSearch(leafBlock: {
|
||||
showSkeletonIfNotActive(withType: type, usingColors: colors, animated: animated, animation: animation)
|
||||
@@ -96,6 +102,8 @@ extension UIView {
|
||||
fileprivate func recursiveUpdateSkeleton(withType type: SkeletonType, usingColors colors: [UIColor], animated: Bool, animation: SkeletonLayerAnimation?, root: UIView? = nil) {
|
||||
layoutIfNeeded()
|
||||
|
||||
currentSkeletonConfig = SkeletonConfig(type: type, colors: colors, gradientDirection: nil, animated: animated, animation: animation)
|
||||
|
||||
updateDummyDataSourceIfNeeded()
|
||||
subviewsSkeletonables.recursiveSearch(leafBlock: {
|
||||
guard isSkeletonActive else { return }
|
||||
@@ -195,7 +203,6 @@ extension UIView {
|
||||
layer.insertSublayer(skeletonLayer.contentLayer, at: UInt32.max)
|
||||
if animated { skeletonLayer.start(animation) }
|
||||
status = .on
|
||||
currentSkeletonConfig = SkeletonConfig(type: type, colors: colors, gradientDirection: direction, animated: animated, animation: animation)
|
||||
}
|
||||
|
||||
func updateSkeletonLayer(usingColors colors: [UIColor], gradientDirection direction: GradientDirection? = nil, animated: Bool, animation: SkeletonLayerAnimation? = nil) {
|
||||
|
||||
Reference in New Issue
Block a user