diff --git a/Sources/SkeletonFlow.swift b/Sources/SkeletonFlow.swift index da7d4e9f..4cf72663 100644 --- a/Sources/SkeletonFlow.swift +++ b/Sources/SkeletonFlow.swift @@ -2,6 +2,8 @@ import UIKit +import UIKit + protocol SkeletonFlowDelegate { func willBeginShowingSkeletons(rootView: UIView) func didShowSkeletons(rootView: UIView) @@ -15,17 +17,21 @@ protocol SkeletonFlowDelegate { class SkeletonFlowHandler: SkeletonFlowDelegate { func willBeginShowingSkeletons(rootView: UIView) { + NotificationCenter.default.post(name: .willBeginShowingSkeletons, object: rootView, userInfo: nil) rootView.addAppNotificationsObservers() } func didShowSkeletons(rootView: UIView) { printSkeletonHierarchy(in: rootView) + NotificationCenter.default.post(name: .didShowSkeletons, object: rootView, userInfo: nil) } - + func willBeginUpdatingSkeletons(rootView: UIView) { + NotificationCenter.default.post(name: .willBeginUpdatingSkeletons, object: rootView, userInfo: nil) } func didUpdateSkeletons(rootView: UIView) { + NotificationCenter.default.post(name: .didUpdateSkeletons, object: rootView, userInfo: nil) } func willBeginLayingSkeletonsIfNeeded(rootView: UIView) { @@ -35,10 +41,21 @@ class SkeletonFlowHandler: SkeletonFlowDelegate { } func willBeginHidingSkeletons(rootView: UIView) { + NotificationCenter.default.post(name: .willBeginHidingSkeletons, object: rootView, userInfo: nil) rootView.removeAppNoticationsObserver() } func didHideSkeletons(rootView: UIView) { rootView.flowDelegate = nil + NotificationCenter.default.post(name: .didHideSkeletons, object: rootView, userInfo: nil) } } + +public extension Notification.Name { + static let willBeginShowingSkeletons = Notification.Name("willBeginShowingSkeletons") + static let didShowSkeletons = Notification.Name("didShowSkeletons") + static let willBeginUpdatingSkeletons = Notification.Name("willBeginUpdatingSkeletons") + static let didUpdateSkeletons = Notification.Name("didUpdateSkeletons") + static let willBeginHidingSkeletons = Notification.Name("willBeginHidingSkeletons") + static let didHideSkeletons = Notification.Name("didHideSkeletons") +}