@@ -77,6 +77,20 @@ extension DSLoadable where Self: UIButton {
7777 public func loadableStopLoading( ) {
7878 return loadableStopLoading ( loadingViewType: DSLoadingView . self)
7979 }
80+
81+ /**
82+ Convenience method for controling the loading with a boolean value
83+
84+ - parameter shouldLoad: The boolean value that controls the loading overlay
85+ */
86+ public func loadable( shouldLoad: Bool ) {
87+ switch shouldLoad {
88+ case true :
89+ loadableStartLoading ( )
90+ case false :
91+ loadableStopLoading ( )
92+ }
93+ }
8094}
8195
8296extension DSLoadable where Self: UIView {
@@ -104,6 +118,22 @@ extension DSLoadable where Self: UIView {
104118 configuration ? ( self , loadingView)
105119 loadingView. removeFromSuperview ( )
106120 }
121+
122+ /**
123+ Convenience method for controling the loading with a boolean value
124+
125+ - parameter shouldLoad: The boolean value that controls the loading overlay
126+ - parameter loadingViewType: The type of the loading view
127+ - parameter configuration: The configuration closure that will be executed on the loading view
128+ */
129+ public func loadable( shouldLoad: Bool , loadingViewType: UIView . Type = DSLoadingView . self, configuration: ( ( UIView , UIView ) -> Void ) ? = nil ) {
130+ switch shouldLoad {
131+ case true :
132+ loadableStartLoading ( loadingViewType: loadingViewType, configuration: configuration)
133+ case false :
134+ loadableStopLoading ( loadingViewType: loadingViewType)
135+ }
136+ }
107137}
108138
109139extension DSLoadable where Self: UIView , Self: DSLoadableConfigurable {
@@ -114,6 +144,20 @@ extension DSLoadable where Self: UIView, Self: DSLoadableConfigurable {
114144 public func loadableStopLoading( ) {
115145 return loadableStopLoading ( loadingViewType: loadableLoadingViewType)
116146 }
147+
148+ /**
149+ Convenience method for controling the loading with a boolean value
150+
151+ - parameter shouldLoad: The boolean value that controls the loading overlay
152+ */
153+ public func loadable( shouldLoad: Bool ) {
154+ switch shouldLoad {
155+ case true :
156+ loadableStartLoading ( )
157+ case false :
158+ loadableStopLoading ( )
159+ }
160+ }
117161}
118162
119163extension UIView : DSLoadable { }
0 commit comments