diff --git a/Sources/Extensions/UIView+Extension.swift b/Sources/Extensions/UIView+Extension.swift index db07be5f..d33f6296 100644 --- a/Sources/Extensions/UIView+Extension.swift +++ b/Sources/Extensions/UIView+Extension.swift @@ -14,6 +14,7 @@ enum ViewAssociatedKeys { static var labelViewState = "labelViewState" static var imageViewState = "imageViewState" static var buttonViewState = "buttonViewState" + static var headerFooterViewState = "headerFooterViewState" static var currentSkeletonConfig = "currentSkeletonConfig" static var skeletonCornerRadius = "skeletonCornerRadius" static var disabledWhenSkeletonIsActive = "disabledWhenSkeletonIsActive" diff --git a/Sources/Helpers/PrepareForSkeletonProtocol.swift b/Sources/Helpers/PrepareForSkeletonProtocol.swift index 4596e940..643c1790 100755 --- a/Sources/Helpers/PrepareForSkeletonProtocol.swift +++ b/Sources/Helpers/PrepareForSkeletonProtocol.swift @@ -121,3 +121,13 @@ extension UIButton { } } } + +extension UITableViewHeaderFooterView { + override func prepareViewForSkeleton() { + backgroundView?.backgroundColor = .clear + + if isUserInteractionDisabledWhenSkeletonIsActive { + isUserInteractionEnabled = false + } + } +} diff --git a/Sources/Recoverable/Recoverable.swift b/Sources/Recoverable/Recoverable.swift index a603f9c2..0890aecc 100644 --- a/Sources/Recoverable/Recoverable.swift +++ b/Sources/Recoverable/Recoverable.swift @@ -161,3 +161,22 @@ extension UIButton { } } } + +extension UITableViewHeaderFooterView { + var headerFooterState: RecoverableTableViewHeaderFooterViewState? { + get { return ao_get(pkey: &ViewAssociatedKeys.headerFooterViewState) as? RecoverableTableViewHeaderFooterViewState } + set { ao_setOptional(newValue, pkey: &ViewAssociatedKeys.headerFooterViewState) } + } + + override func saveViewState() { + super.saveViewState() + headerFooterState = RecoverableTableViewHeaderFooterViewState(view: self) + } + + override func recoverViewState(forced: Bool) { + super.recoverViewState(forced: forced) + startTransition { [weak self] in + self?.backgroundView?.backgroundColor = self?.headerFooterState?.backgroundViewColor + } + } +} diff --git a/Sources/Recoverable/RecoverableViewState.swift b/Sources/Recoverable/RecoverableViewState.swift index 5d124f90..70358af2 100644 --- a/Sources/Recoverable/RecoverableViewState.swift +++ b/Sources/Recoverable/RecoverableViewState.swift @@ -59,3 +59,11 @@ struct RecoverableButtonViewState { self.title = view.titleLabel?.text } } + +struct RecoverableTableViewHeaderFooterViewState { + var backgroundViewColor: UIColor? + + init(view: UITableViewHeaderFooterView) { + self.backgroundViewColor = view.backgroundView?.backgroundColor + } +}