EmptyDelegate.swift 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. //
  2. // EmptyDelegate.swift
  3. // EmptyKit-Swift
  4. //
  5. // Created by archerzz on 16/11/18.
  6. // Copyright © 2016年 archerzz. All rights reserved.
  7. //
  8. import Foundation
  9. import UIKit
  10. /// EmptyDelegate
  11. public protocol EmptyDelegate: class {
  12. /**
  13. Asks the delegate to know if the empty dataset should fade in when displayed. Default is true.
  14. - author: archerzz
  15. - date: 2016-11-22
  16. - parameter view: empty view's superview
  17. - returns: true if the empty should fade in
  18. */
  19. func emptyShouldFadeIn(in view: UIView) -> Bool
  20. /**
  21. Asks the delegate to know if the empty dataset should display. Default is true.
  22. - author: archerzz
  23. - date: 2016-11-22
  24. - parameter view: empty view's superview
  25. - returns: true if the empty should display
  26. */
  27. func emptyShouldDisplay(in view: UIView) -> Bool
  28. /**
  29. Asks the delegate to know if the empty dataset should allow touch in when displayed. Default is true.
  30. - author: archerzz
  31. - date: 2016-11-22
  32. - parameter view: empty view's superview
  33. - returns: true if the empty should allow touch
  34. */
  35. func emptyShouldAllowTouch(in view: UIView) -> Bool
  36. /// Asks the delegate to know if the empty dataset should enble tap gesture whick is added to emtpyView . Default is ture
  37. ///
  38. /// - Parameter view: empty view's superview
  39. /// - Returns: true if the empty enable tap
  40. func emptyShouldEnableTapGesture(in view: UIView) -> Bool
  41. /**
  42. Asks the delegate to know if the empty dataset should allow scroll in when displayed. Default is true.
  43. - author: archerzz
  44. - date: 2016-11-22
  45. - parameter view: empty view's superview
  46. - returns: true if the empty should allow scroll
  47. */
  48. func emptyShouldAllowScroll(in view: UIView) -> Bool
  49. /**
  50. Asks the delegate to know if the empty dataset should animate imageview when displayed. Default is true.
  51. - author: archerzz
  52. - date: 2016-11-22
  53. - parameter view: empty view's superview
  54. - returns: true if the empty should animate imageview
  55. */
  56. func emptyShouldAnimateImageView(in view: UIView) -> Bool
  57. /**
  58. Tell the delegate button has been tapped in empty
  59. - author: archerzz
  60. - date: 2016-11-22
  61. - parameter button: tapped button
  62. - parameter view: empty view's superview
  63. */
  64. func emptyButton(_ button: UIButton, tappedIn view: UIView)
  65. /**
  66. Tell the delegate emptyView has been tapped in empty
  67. - author: archerzz
  68. - date: 2016-11-22
  69. - parameter emptyView: emptyView which is displayed
  70. - parameter view: empty view's superview
  71. */
  72. func emptyView(_ emptyView: UIView, tappedIn view: UIView)
  73. /**
  74. Tell the delegate to know emptyView will appear
  75. - author: archerzz
  76. - date: 2016-11-22
  77. - parameter view: empty view's superview
  78. */
  79. func emptyWillAppear(in view: UIView)
  80. /**
  81. Tell the delegate to know emptyView did appear
  82. - author: archerzz
  83. - date: 2016-11-22
  84. - parameter view: empty view's superview
  85. */
  86. func emptyDidAppear(in view: UIView)
  87. /**
  88. Tell the delegate to know emptyView will disappear
  89. - author: archerzz
  90. - date: 2016-11-22
  91. - parameter view: empty view's superview
  92. */
  93. func emptyWillDisAppear(in view: UIView)
  94. /**
  95. Tell the delegate to know emptyView did disappear
  96. - author: archerzz
  97. - date: 2016-11-22
  98. - parameter view: empty view's superview
  99. */
  100. func emptyDidDisAppear(in view: UIView)
  101. /// 是否允许自动增加Inset来调整位置(默认false)
  102. func emptyShouldAutoAddInsetWhenSuperviewIsScrollView(in view: UIView) -> Bool
  103. }
  104. // MARK: - Default
  105. public extension EmptyDelegate {
  106. func emptyShouldFadeIn(in view: UIView) -> Bool {
  107. return true
  108. }
  109. func emptyShouldDisplay(in view: UIView) -> Bool {
  110. return true
  111. }
  112. func emptyShouldAllowTouch(in view: UIView) -> Bool {
  113. return true
  114. }
  115. func emptyShouldEnableTapGesture(in view: UIView) -> Bool {
  116. return true
  117. }
  118. func emptyShouldAllowScroll(in view: UIView) -> Bool {
  119. return true
  120. }
  121. func emptyShouldAnimateImageView(in view: UIView) -> Bool {
  122. return true
  123. }
  124. func emptyButton(_ button: UIButton, tappedIn view: UIView) {
  125. }
  126. func emptyView(_ emptyView: UIView, tappedIn view: UIView) {
  127. }
  128. func emptyWillAppear(in view: UIView) {
  129. }
  130. func emptyDidAppear(in view: UIView) {
  131. }
  132. func emptyWillDisAppear(in view: UIView) {
  133. }
  134. func emptyDidDisAppear(in view: UIView) {
  135. }
  136. /// 是否允许自动增加Inset来调整位置(默认false)
  137. func emptyShouldAutoAddInsetWhenSuperviewIsScrollView(in view: UIView) -> Bool {
  138. return false
  139. }
  140. }