TemplateInfo 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (226) hide show
  1. data/.DS_Store +0 -0
  2. data/.gitignore +2 -0
  3. data/TemplateInfo.gemspec +1 -1
  4. data/bin/tif_create.rb +157 -0
  5. data/lib/TemplateInfo/version.rb +1 -1
  6. data/test.xctemplate/.DS_Store +0 -0
  7. data/test.xctemplate/TemplateInfo.plist +2830 -0
  8. data/test.xctemplate/TemplateInfo.xml +2842 -0
  9. data/test.xctemplate/libs/BeeFramework/Bee.h +35 -0
  10. data/test.xctemplate/libs/BeeFramework/Bee_Precompile.h +143 -0
  11. data/test.xctemplate/libs/BeeFramework/Core/Bee_Core.h +36 -0
  12. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Bee_Foundation.h +54 -0
  13. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Bee_Foundation.mm +33 -0
  14. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Bee_Log.h +64 -0
  15. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Bee_Log.mm +164 -0
  16. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Bee_Performance.h +111 -0
  17. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Bee_Performance.mm +122 -0
  18. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Bee_Runtime.h +98 -0
  19. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Bee_Runtime.mm +437 -0
  20. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Bee_Sandbox.h +45 -0
  21. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Bee_Sandbox.mm +81 -0
  22. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Bee_Singleton.h +47 -0
  23. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Bee_Singleton.mm +34 -0
  24. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Bee_SystemInfo.h +62 -0
  25. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Bee_SystemInfo.m +147 -0
  26. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Bee_Thread.h +64 -0
  27. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Bee_Thread.mm +91 -0
  28. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSArray+BeeExtension.h +76 -0
  29. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSArray+BeeExtension.m +300 -0
  30. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSData+BeeExtension.h +44 -0
  31. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSData+BeeExtension.m +92 -0
  32. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSDate+BeeExtension.h +44 -0
  33. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSDate+BeeExtension.m +85 -0
  34. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSDictionary+BeeExtension.h +90 -0
  35. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSDictionary+BeeExtension.m +509 -0
  36. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSNumber+BeeExtension.h +50 -0
  37. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSNumber+BeeExtension.m +64 -0
  38. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSObject+BeeJSON.h +43 -0
  39. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSObject+BeeJSON.m +116 -0
  40. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSObject+BeeNotification.h +66 -0
  41. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSObject+BeeNotification.m +150 -0
  42. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSObject+BeeProperty.h +210 -0
  43. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSObject+BeeProperty.m +34 -0
  44. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSObject+BeeTicker.h +41 -0
  45. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSObject+BeeTicker.m +156 -0
  46. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSObject+BeeTypeConversion.h +49 -0
  47. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSObject+BeeTypeConversion.m +109 -0
  48. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSString+BeeExtension.h +86 -0
  49. data/test.xctemplate/libs/BeeFramework/Core/Foundation/Extension/NSString+BeeExtension.m +464 -0
  50. data/test.xctemplate/libs/BeeFramework/Core/Network/Bee_Network.h +36 -0
  51. data/test.xctemplate/libs/BeeFramework/Core/Network/Bee_Network.m +33 -0
  52. data/test.xctemplate/libs/BeeFramework/Core/Network/Bee_Request.h +144 -0
  53. data/test.xctemplate/libs/BeeFramework/Core/Network/Bee_Request.m +560 -0
  54. data/test.xctemplate/libs/BeeFramework/Core/Network/Bee_RequestQueue.h +99 -0
  55. data/test.xctemplate/libs/BeeFramework/Core/Network/Bee_RequestQueue.m +742 -0
  56. data/test.xctemplate/libs/BeeFramework/Core/Network/Extension/NSObject+BeeRequest.h +62 -0
  57. data/test.xctemplate/libs/BeeFramework/Core/Network/Extension/NSObject+BeeRequest.m +175 -0
  58. data/test.xctemplate/libs/BeeFramework/Core/Storage/0.2.4.zip +0 -0
  59. data/test.xctemplate/libs/BeeFramework/Core/Storage/Bee_ActiveBase.h +133 -0
  60. data/test.xctemplate/libs/BeeFramework/Core/Storage/Bee_ActiveBase.m +641 -0
  61. data/test.xctemplate/libs/BeeFramework/Core/Storage/Bee_ActiveRecord.h +106 -0
  62. data/test.xctemplate/libs/BeeFramework/Core/Storage/Bee_ActiveRecord.m +1956 -0
  63. data/test.xctemplate/libs/BeeFramework/Core/Storage/Bee_Cache.h +91 -0
  64. data/test.xctemplate/libs/BeeFramework/Core/Storage/Bee_Cache.m +318 -0
  65. data/test.xctemplate/libs/BeeFramework/Core/Storage/Bee_Database.h +223 -0
  66. data/test.xctemplate/libs/BeeFramework/Core/Storage/Bee_Database.m +3007 -0
  67. data/test.xctemplate/libs/BeeFramework/Core/Storage/Bee_Keychain.h +55 -0
  68. data/test.xctemplate/libs/BeeFramework/Core/Storage/Bee_Keychain.m +173 -0
  69. data/test.xctemplate/libs/BeeFramework/Core/Storage/Bee_Storage.h +39 -0
  70. data/test.xctemplate/libs/BeeFramework/Core/Storage/Bee_Storage.m +33 -0
  71. data/test.xctemplate/libs/BeeFramework/Core/Storage/Extension/NSObject+BeeDatabase.h +47 -0
  72. data/test.xctemplate/libs/BeeFramework/Core/Storage/Extension/NSObject+BeeDatabase.m +81 -0
  73. data/test.xctemplate/libs/BeeFramework/Core/Storage/Extension/NSObject+BeeKeychain.h +44 -0
  74. data/test.xctemplate/libs/BeeFramework/Core/Storage/Extension/NSObject+BeeKeychain.m +57 -0
  75. data/test.xctemplate/libs/BeeFramework/MVC/Bee_MVC.h +49 -0
  76. data/test.xctemplate/libs/BeeFramework/MVC/Controller/Bee_Controller.h +66 -0
  77. data/test.xctemplate/libs/BeeFramework/MVC/Controller/Bee_Controller.mm +228 -0
  78. data/test.xctemplate/libs/BeeFramework/MVC/Controller/Bee_Message.h +209 -0
  79. data/test.xctemplate/libs/BeeFramework/MVC/Controller/Bee_Message.mm +873 -0
  80. data/test.xctemplate/libs/BeeFramework/MVC/Controller/Bee_MessageQueue.h +75 -0
  81. data/test.xctemplate/libs/BeeFramework/MVC/Controller/Bee_MessageQueue.mm +389 -0
  82. data/test.xctemplate/libs/BeeFramework/MVC/Controller/Extension/BeeMessage+ActiveRecord.h +52 -0
  83. data/test.xctemplate/libs/BeeFramework/MVC/Controller/Extension/BeeMessage+ActiveRecord.m +150 -0
  84. data/test.xctemplate/libs/BeeFramework/MVC/Controller/Extension/BeeMessage+HTTP.h +49 -0
  85. data/test.xctemplate/libs/BeeFramework/MVC/Controller/Extension/BeeMessage+HTTP.mm +201 -0
  86. data/test.xctemplate/libs/BeeFramework/MVC/Controller/Extension/BeeMessage+JSON.h +52 -0
  87. data/test.xctemplate/libs/BeeFramework/MVC/Controller/Extension/BeeMessage+JSON.mm +118 -0
  88. data/test.xctemplate/libs/BeeFramework/MVC/Controller/Extension/BeeMessage+XML.h +49 -0
  89. data/test.xctemplate/libs/BeeFramework/MVC/Controller/Extension/BeeMessage+XML.mm +78 -0
  90. data/test.xctemplate/libs/BeeFramework/MVC/Controller/Extension/NSObject+BeeMessage.h +57 -0
  91. data/test.xctemplate/libs/BeeFramework/MVC/Controller/Extension/NSObject+BeeMessage.mm +138 -0
  92. data/test.xctemplate/libs/BeeFramework/MVC/Model/Bee_Model.h +64 -0
  93. data/test.xctemplate/libs/BeeFramework/MVC/Model/Bee_Model.m +190 -0
  94. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIActionSheet.h +71 -0
  95. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIActionSheet.m +307 -0
  96. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIActivityIndicatorView.h +52 -0
  97. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIActivityIndicatorView.m +152 -0
  98. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIAlertView.h +73 -0
  99. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIAlertView.m +234 -0
  100. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIButton.h +97 -0
  101. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIButton.m +424 -0
  102. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIDatePicker.h +78 -0
  103. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIDatePicker.m +362 -0
  104. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIGridCell.h +82 -0
  105. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIGridCell.m +298 -0
  106. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIImageView.h +110 -0
  107. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIImageView.m +541 -0
  108. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIKeyboard.h +74 -0
  109. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIKeyboard.m +243 -0
  110. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UILabel.h +46 -0
  111. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UILabel.m +99 -0
  112. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIMatrixView.h +124 -0
  113. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIMatrixView.m +821 -0
  114. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UINavigationBar.h +57 -0
  115. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UINavigationBar.m +161 -0
  116. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIOrientation.h +60 -0
  117. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIOrientation.m +146 -0
  118. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIPageControl.h +61 -0
  119. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIPageControl.m +190 -0
  120. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIProgressView.h +47 -0
  121. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIProgressView.m +113 -0
  122. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIPullLoader.h +71 -0
  123. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIPullLoader.m +236 -0
  124. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIScrollView.h +146 -0
  125. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIScrollView.m +1487 -0
  126. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UISegmentedControl.h +60 -0
  127. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UISegmentedControl.m +192 -0
  128. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UISignal.h +126 -0
  129. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UISignal.m +453 -0
  130. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UITabBar.h +70 -0
  131. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UITabBar.m +249 -0
  132. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UITextField.h +67 -0
  133. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UITextField.m +242 -0
  134. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UITextView.h +75 -0
  135. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UITextView.m +311 -0
  136. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UITipsView.h +184 -0
  137. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UITipsView.m +911 -0
  138. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIWebView.h +65 -0
  139. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIWebView.m +242 -0
  140. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIZoomView.h +91 -0
  141. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_UIZoomView.m +444 -0
  142. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_View.h +72 -0
  143. data/test.xctemplate/libs/BeeFramework/MVC/View/Bee_View.m +38 -0
  144. data/test.xctemplate/libs/BeeFramework/MVC/View/Extension/CGRect+BeeExtension.h +79 -0
  145. data/test.xctemplate/libs/BeeFramework/MVC/View/Extension/CGRect+BeeExtension.m +288 -0
  146. data/test.xctemplate/libs/BeeFramework/MVC/View/Extension/UIColor+BeeExtension.h +65 -0
  147. data/test.xctemplate/libs/BeeFramework/MVC/View/Extension/UIColor+BeeExtension.m +161 -0
  148. data/test.xctemplate/libs/BeeFramework/MVC/View/Extension/UIFont+BeeExtension.h +45 -0
  149. data/test.xctemplate/libs/BeeFramework/MVC/View/Extension/UIFont+BeeExtension.m +137 -0
  150. data/test.xctemplate/libs/BeeFramework/MVC/View/Extension/UIImage+BeeExtension.h +56 -0
  151. data/test.xctemplate/libs/BeeFramework/MVC/View/Extension/UIImage+BeeExtension.m +218 -0
  152. data/test.xctemplate/libs/BeeFramework/MVC/View/Extension/UIView+BeeExtension.h +105 -0
  153. data/test.xctemplate/libs/BeeFramework/MVC/View/Extension/UIView+BeeExtension.m +556 -0
  154. data/test.xctemplate/libs/BeeFramework/MVC/View/Extension/UIView+BeeUISignal.h +53 -0
  155. data/test.xctemplate/libs/BeeFramework/MVC/View/Extension/UIView+BeeUISignal.m +104 -0
  156. data/test.xctemplate/libs/BeeFramework/MVC/View/Extension/UIView+HoldGesture.h +52 -0
  157. data/test.xctemplate/libs/BeeFramework/MVC/View/Extension/UIView+HoldGesture.m +170 -0
  158. data/test.xctemplate/libs/BeeFramework/MVC/View/Extension/UIView+PanGesture.h +54 -0
  159. data/test.xctemplate/libs/BeeFramework/MVC/View/Extension/UIView+PanGesture.m +166 -0
  160. data/test.xctemplate/libs/BeeFramework/MVC/View/Extension/UIView+SwipeGesture.h +54 -0
  161. data/test.xctemplate/libs/BeeFramework/MVC/View/Extension/UIView+SwipeGesture.m +184 -0
  162. data/test.xctemplate/libs/BeeFramework/MVC/View/Extension/UIView+TapGesture.h +57 -0
  163. data/test.xctemplate/libs/BeeFramework/MVC/View/Extension/UIView+TapGesture.m +275 -0
  164. data/test.xctemplate/libs/BeeFramework/MVC/ViewController/Bee_UIBoard.h +212 -0
  165. data/test.xctemplate/libs/BeeFramework/MVC/ViewController/Bee_UIBoard.m +1219 -0
  166. data/test.xctemplate/libs/BeeFramework/MVC/ViewController/Bee_UIStack.h +111 -0
  167. data/test.xctemplate/libs/BeeFramework/MVC/ViewController/Bee_UIStack.m +694 -0
  168. data/test.xctemplate/libs/BeeFramework/MVC/ViewController/Bee_UIStackGroup.h +71 -0
  169. data/test.xctemplate/libs/BeeFramework/MVC/ViewController/Bee_UIStackGroup.m +258 -0
  170. data/test.xctemplate/libs/BeeFramework/MVC/ViewController/Bee_ViewController.h +45 -0
  171. data/test.xctemplate/libs/BeeFramework/MVC/ViewController/Bee_ViewController.m +36 -0
  172. data/test.xctemplate/libs/BeeFramework/MVC/ViewController/Extension/UIViewController+BeeExtension.h +57 -0
  173. data/test.xctemplate/libs/BeeFramework/MVC/ViewController/Extension/UIViewController+BeeExtension.m +151 -0
  174. data/test.xctemplate/libs/BeeFramework/MVC/ViewController/Extension/UIViewController+BeeUISignal.h +53 -0
  175. data/test.xctemplate/libs/BeeFramework/MVC/ViewController/Extension/UIViewController+BeeUISignal.m +92 -0
  176. data/test.xctemplate/libs/BeeFramework/MVC/ViewController/Extension/UIViewController+UINavigationBar.h +72 -0
  177. data/test.xctemplate/libs/BeeFramework/MVC/ViewController/Extension/UIViewController+UINavigationBar.m +175 -0
  178. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_UICollection.h +59 -0
  179. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_UICollection.m +249 -0
  180. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_UILayout.h +199 -0
  181. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_UILayout.m +1170 -0
  182. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_UIQuery.h +113 -0
  183. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_UIQuery.m +710 -0
  184. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_UIStyle.h +66 -0
  185. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_UIStyle.m +189 -0
  186. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_UITemplate.h +69 -0
  187. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_UITemplate.m +210 -0
  188. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_UITemplateAndroid.h +45 -0
  189. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_UITemplateAndroid.m +59 -0
  190. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_UITemplateHTML.h +45 -0
  191. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_UITemplateHTML.m +55 -0
  192. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_UITemplateJSON.h +45 -0
  193. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_UITemplateJSON.m +54 -0
  194. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_UITemplateOmniGraffle.h +45 -0
  195. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_UITemplateOmniGraffle.m +54 -0
  196. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_UITemplateXML.h +45 -0
  197. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_UITemplateXML.m +438 -0
  198. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_ViewLayout.h +60 -0
  199. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Bee_ViewLayout.m +37 -0
  200. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/BeeUIQuery+BeeUIStyle.h +45 -0
  201. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/BeeUIQuery+BeeUIStyle.m +55 -0
  202. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/BeeUIStyle+BeeUIQuery.h +45 -0
  203. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/BeeUIStyle+BeeUIQuery.m +55 -0
  204. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UIButton+BeeUIStyle.h +41 -0
  205. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UIButton+BeeUIStyle.m +100 -0
  206. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UIImageView+BeeUIStyle.h +41 -0
  207. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UIImageView+BeeUIStyle.m +101 -0
  208. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UILabel+BeeUIStyle.h +41 -0
  209. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UILabel+BeeUIStyle.m +48 -0
  210. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UITextField+BeeUIStyle.h +41 -0
  211. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UITextField+BeeUIStyle.m +77 -0
  212. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UITextView+BeeUIStyle.h +41 -0
  213. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UITextView+BeeUIStyle.m +47 -0
  214. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UIView+BeeUILayout.h +52 -0
  215. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UIView+BeeUILayout.m +177 -0
  216. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UIView+BeeUIQuery.h +44 -0
  217. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UIView+BeeUIQuery.m +57 -0
  218. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UIView+BeeUIStyle.h +50 -0
  219. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UIView+BeeUIStyle.m +283 -0
  220. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UIViewController+BeeUILayout.h +52 -0
  221. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UIViewController+BeeUILayout.m +178 -0
  222. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UIViewController+BeeUIQuery.h +44 -0
  223. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UIViewController+BeeUIQuery.m +58 -0
  224. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UIViewController+BeeUIStyle.h +44 -0
  225. data/test.xctemplate/libs/BeeFramework/MVC/ViewLayout/Extension/UIViewController+BeeUIStyle.m +57 -0
  226. metadata +226 -3
@@ -0,0 +1,1487 @@
1
+ //
2
+ // ______ ______ ______
3
+ // /\ __ \ /\ ___\ /\ ___\
4
+ // \ \ __< \ \ __\_ \ \ __\_
5
+ // \ \_____\ \ \_____\ \ \_____\
6
+ // \/_____/ \/_____/ \/_____/
7
+ //
8
+ // Copyright (c) 2012 BEE creators
9
+ // http://www.whatsbug.com
10
+ //
11
+ // Permission is hereby granted, free of charge, to any person obtaining a
12
+ // copy of this software and associated documentation files (the "Software"),
13
+ // to deal in the Software without restriction, including without limitation
14
+ // the rights to use, copy, modify, merge, publish, distribute, sublicense,
15
+ // and/or sell copies of the Software, and to permit persons to whom the
16
+ // Software is furnished to do so, subject to the following conditions:
17
+ //
18
+ // The above copyright notice and this permission notice shall be included in
19
+ // all copies or substantial portions of the Software.
20
+ //
21
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
+ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27
+ // IN THE SOFTWARE.
28
+ //
29
+ //
30
+ // Bee_UIScrollView.m
31
+ //
32
+
33
+ #undef MAX_QUEUED_ITEMS
34
+ #define MAX_QUEUED_ITEMS (32)
35
+
36
+ #undef PULL_LOADER_SIZE
37
+ #define PULL_LOADER_SIZE (60.0f)
38
+
39
+ #if (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
40
+
41
+ #import "Bee_Precompile.h"
42
+ #import "Bee_UIScrollView.h"
43
+ #import "Bee_Runtime.h"
44
+ #import "Bee_Log.h"
45
+ #import "UIView+BeeExtension.h"
46
+ #import "UIView+BeeUISignal.h"
47
+
48
+ #pragma mark -
49
+
50
+ @interface BeeUIScrollItem : NSObject
51
+ {
52
+ BOOL _visible;
53
+ NSInteger _index;
54
+ NSInteger _line;
55
+ CGFloat _scale;
56
+ CGSize _size;
57
+ CGRect _rect;
58
+ UIView * _view;
59
+ }
60
+
61
+ @property (nonatomic, assign) BOOL visible;
62
+ @property (nonatomic, assign) NSInteger index;
63
+ @property (nonatomic, assign) NSInteger line;
64
+ @property (nonatomic, assign) CGFloat scale;
65
+ @property (nonatomic, assign) CGSize size;
66
+ @property (nonatomic, assign) CGRect rect;
67
+ @property (nonatomic, assign) UIView * view;
68
+
69
+ @end
70
+
71
+ #pragma mark -
72
+
73
+ @implementation BeeUIScrollItem
74
+
75
+ @synthesize visible = _visible;
76
+ @synthesize index = _index;
77
+ @synthesize line = _line;
78
+ @synthesize scale = _scale;
79
+ @synthesize size = _size;
80
+ @synthesize rect = _rect;
81
+ @synthesize view = _view;
82
+
83
+ - (id)init
84
+ {
85
+ self = [super init];
86
+ if ( self )
87
+ {
88
+ _visible = NO;
89
+ _index = 0;
90
+ _line = 0;
91
+ _scale = 1.0f;
92
+ _size = CGSizeZero;
93
+ _rect = CGRectZero;
94
+ _view = nil;
95
+ }
96
+ return self;
97
+ }
98
+
99
+ - (void)dealloc
100
+ {
101
+ [_view removeFromSuperview];
102
+ [_view release];
103
+
104
+ [super dealloc];
105
+ }
106
+
107
+ @end
108
+
109
+ #pragma mark -
110
+
111
+ @interface BeeUIScrollView(Private)
112
+ - (void)initSelf;
113
+
114
+ - (void)syncPositions;
115
+ - (void)calcPositions;
116
+
117
+ - (void)syncPullPositions;
118
+ - (void)syncPullInsets;
119
+
120
+ - (void)releaseAllViews;
121
+ - (void)releaseViewsBefore:(NSInteger)index;
122
+ - (void)releaseViewsAfter:(NSInteger)index;
123
+
124
+ - (NSInteger)getShortestLine;
125
+ - (NSInteger)getLongestLine;
126
+
127
+ - (void)operateReloadData;
128
+ - (void)internalReloadData;
129
+ @end
130
+
131
+ #pragma mark -
132
+
133
+ @implementation BeeUIScrollView
134
+
135
+ DEF_SIGNAL( RELOADED ) // 数据重新加载
136
+ DEF_SIGNAL( REACH_TOP ) // 触顶
137
+ DEF_SIGNAL( REACH_BOTTOM ) // 触底
138
+
139
+ DEF_SIGNAL( DID_DRAG )
140
+ DEF_SIGNAL( DID_STOP )
141
+ DEF_SIGNAL( DID_SCROLL )
142
+
143
+ DEF_SIGNAL( HEADER_REFRESH ) // 下拉刷新
144
+ DEF_SIGNAL( FOOTER_REFRESH ) // 上拉刷新
145
+
146
+ DEF_INT( DIRECTION_HORIZONTAL, 0 )
147
+ DEF_INT( DIRECTION_VERTICAL, 1 )
148
+
149
+ @synthesize dataSource = _dataSource;
150
+
151
+ @dynamic horizontal;
152
+ @dynamic vertical;
153
+
154
+ @dynamic visibleStart;
155
+ @dynamic visibleEnd;
156
+
157
+ @dynamic visibleRange;
158
+ @dynamic visiblePageIndex;
159
+
160
+ @synthesize reloaded = _reloaded;
161
+ @synthesize reloading = _reloading;
162
+ @synthesize reuseQueue = _reuseQueue;
163
+
164
+ @synthesize scrollSpeed = _scrollSpeed;
165
+ @synthesize scrollPercent;
166
+ @synthesize height;
167
+
168
+ @synthesize headerLoader = _headerLoader;
169
+ @synthesize footerLoader = _footerLoader;
170
+
171
+ + (BeeUIScrollView *)spawn
172
+ {
173
+ return [[[BeeUIScrollView alloc] initWithFrame:CGRectZero] autorelease];
174
+ }
175
+
176
+ + (BeeUIScrollView *)spawn:(NSString *)tagString
177
+ {
178
+ BeeUIScrollView * view = [[[BeeUIScrollView alloc] init] autorelease];
179
+ view.tagString = tagString;
180
+ return view;
181
+ }
182
+
183
+ - (id)init
184
+ {
185
+ self = [super initWithFrame:CGRectZero];
186
+ if ( self )
187
+ {
188
+ [self initSelf];
189
+ }
190
+ return self;
191
+ }
192
+
193
+ - (id)initWithFrame:(CGRect)frame
194
+ {
195
+ self = [super initWithFrame:frame];
196
+ if ( self )
197
+ {
198
+ [self initSelf];
199
+ }
200
+ return self;
201
+ }
202
+
203
+ // thanks to @ilikeido
204
+ - (id)initWithCoder:(NSCoder *)aDecoder
205
+ {
206
+ self = [super initWithCoder:aDecoder];
207
+ if ( self )
208
+ {
209
+ [self initSelf];
210
+ }
211
+ return self;
212
+ }
213
+
214
+ - (void)initSelf
215
+ {
216
+ _direction = BeeUIScrollView.DIRECTION_VERTICAL;
217
+ _dataSource = self;
218
+
219
+ _shouldNotify = YES;
220
+ _reloaded = NO;
221
+ _lineCount = 0;
222
+
223
+ _total = 0;
224
+ [_items release];
225
+ _items = [[NSMutableArray alloc] init];
226
+
227
+ [_reuseQueue release];
228
+ _reuseQueue = [[NSMutableArray alloc] init];
229
+
230
+ _visibleStart = 0;
231
+ _visibleEnd = 0;
232
+
233
+ _reachTop = NO;
234
+ _reachEnd = NO;
235
+ _baseInsets = UIEdgeInsetsZero;
236
+
237
+ self.backgroundColor = [UIColor clearColor];
238
+ self.contentSize = self.bounds.size;
239
+ self.contentInset = _baseInsets;
240
+ self.alwaysBounceVertical = NO;
241
+ self.alwaysBounceHorizontal = NO;
242
+ self.directionalLockEnabled = YES;
243
+ self.bounces = YES;
244
+ self.scrollEnabled = YES;
245
+ self.showsVerticalScrollIndicator = NO;
246
+ self.showsHorizontalScrollIndicator = NO;
247
+ self.alpha = 1.0f;
248
+ self.delegate = self;
249
+ self.layer.masksToBounds = YES;
250
+ }
251
+
252
+ - (void)dealloc
253
+ {
254
+ [self releaseAllViews];
255
+
256
+ [_reuseQueue removeAllObjects];
257
+ [_reuseQueue release];
258
+ _reuseQueue = nil;
259
+
260
+ [_items removeAllObjects];
261
+ [_items release];
262
+ _items = nil;
263
+
264
+ [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(operateReloadData) object:nil];
265
+ [NSObject cancelPreviousPerformRequestsWithTarget:self];
266
+
267
+ [super dealloc];
268
+ }
269
+
270
+ - (BOOL)horizontal
271
+ {
272
+ return BeeUIScrollView.DIRECTION_HORIZONTAL == _direction ? YES : NO;
273
+ }
274
+
275
+ - (void)setHorizontal:(BOOL)horizonal
276
+ {
277
+ if ( horizonal )
278
+ {
279
+ _direction = BeeUIScrollView.DIRECTION_HORIZONTAL;
280
+
281
+ self.alwaysBounceHorizontal = YES;
282
+ self.showsHorizontalScrollIndicator = NO;
283
+
284
+ self.alwaysBounceVertical = NO;
285
+ self.showsVerticalScrollIndicator = NO;
286
+ }
287
+ }
288
+
289
+ - (BOOL)vertical
290
+ {
291
+ return BeeUIScrollView.DIRECTION_VERTICAL == _direction ? YES : NO;
292
+ }
293
+
294
+ - (void)setVertical:(BOOL)vertical
295
+ {
296
+ if ( vertical )
297
+ {
298
+ _direction = BeeUIScrollView.DIRECTION_VERTICAL;
299
+
300
+ self.alwaysBounceVertical = YES;
301
+ self.showsVerticalScrollIndicator = NO;
302
+
303
+ self.alwaysBounceHorizontal = NO;
304
+ self.showsHorizontalScrollIndicator = NO;
305
+ }
306
+ }
307
+
308
+ - (NSInteger)visibleStart
309
+ {
310
+ return _visibleStart;
311
+ }
312
+
313
+ - (NSInteger)visibleEnd
314
+ {
315
+ return _visibleEnd;
316
+ }
317
+
318
+ - (NSRange)visibleRange
319
+ {
320
+ return NSMakeRange( _visibleStart, _visibleEnd - _visibleStart );
321
+ }
322
+
323
+ - (NSUInteger)visiblePageIndex
324
+ {
325
+ // special thanks to @Royall
326
+
327
+ if ( BeeUIScrollView.DIRECTION_HORIZONTAL == _direction )
328
+ {
329
+ return (NSUInteger)floorf(_total - ((self.contentSize.width - self.contentOffset.x) / self.bounds.size.width) + 0.5);
330
+ }
331
+ else
332
+ {
333
+ return (NSUInteger)floorf(_total - ((self.contentSize.height - self.contentOffset.y) / self.bounds.size.height) + 0.5);
334
+ }
335
+ }
336
+
337
+ - (float)getScrollPercent
338
+ {
339
+ float percent = 0.0f;
340
+
341
+ if ( BeeUIScrollView.DIRECTION_HORIZONTAL == _direction )
342
+ {
343
+ percent = self.contentOffset.x / self.contentSize.width;
344
+ }
345
+ else
346
+ {
347
+ percent = self.contentOffset.y / self.contentSize.height;
348
+ }
349
+
350
+ CC( @"percent = %0.2f", percent );
351
+ return percent;
352
+ }
353
+
354
+ - (void)setBaseInsets:(UIEdgeInsets)insets
355
+ {
356
+ _baseInsets = insets;
357
+ self.contentInset = insets;
358
+
359
+ [self syncPullPositions];
360
+ [self syncPullInsets];
361
+ }
362
+
363
+ - (UIEdgeInsets)getBaseInsets
364
+ {
365
+ return _baseInsets;
366
+ }
367
+
368
+ - (void)reloadData
369
+ {
370
+ [self syncReloadData];
371
+ }
372
+
373
+ - (void)syncReloadData
374
+ {
375
+ self.userInteractionEnabled = NO;
376
+
377
+ [self cancelReloadData];
378
+ _reloading = YES;
379
+ [self operateReloadData];
380
+
381
+ self.userInteractionEnabled = YES;
382
+ }
383
+
384
+ - (void)asyncReloadData
385
+ {
386
+ if ( NO == _reloading )
387
+ {
388
+ [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(operateReloadData) object:nil];
389
+ [self performSelector:@selector(operateReloadData) withObject:nil afterDelay:0.2f];
390
+ _reloading = YES;
391
+ }
392
+ }
393
+
394
+ - (void)cancelReloadData
395
+ {
396
+ if ( YES == _reloading )
397
+ {
398
+ [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(operateReloadData) object:nil];
399
+ _reloading = NO;
400
+ }
401
+ }
402
+
403
+ - (void)operateReloadData
404
+ {
405
+ if ( YES == _reloading )
406
+ {
407
+ _reloading = NO;
408
+
409
+ [self internalReloadData];
410
+
411
+ if ( _shouldNotify )
412
+ {
413
+ [self sendUISignal:BeeUIScrollView.RELOADED];
414
+ }
415
+ }
416
+ }
417
+
418
+ - (void)internalReloadData
419
+ {
420
+ if ( nil == _dataSource )
421
+ return;
422
+
423
+ _lineCount = [_dataSource numberOfLinesInScrollView:self];
424
+
425
+ for ( NSInteger i = 0; i < BEE_SCROLL_MAX_LINES; ++i )
426
+ {
427
+ _lineHeights[i] = 0.0f;
428
+ }
429
+
430
+ _total = [_dataSource numberOfViewsInScrollView:self];
431
+
432
+ [self releaseAllViews];
433
+ [self calcPositions];
434
+ [self syncPositions];
435
+ [self syncPullPositions];
436
+ [self syncPullInsets];
437
+
438
+ _reloaded = YES;
439
+ }
440
+
441
+ - (void)setFrame:(CGRect)frame
442
+ {
443
+ _shouldNotify = NO;
444
+
445
+ [super setFrame:frame];
446
+
447
+ if ( CGSizeEqualToSize(self.contentSize, CGSizeZero) )
448
+ {
449
+ self.contentSize = frame.size;
450
+ self.contentInset = _baseInsets;
451
+ }
452
+
453
+ _shouldNotify = YES;
454
+
455
+ if ( NO == _reloaded )
456
+ {
457
+ [self syncReloadData];
458
+ }
459
+ else
460
+ {
461
+ [self asyncReloadData];
462
+ }
463
+
464
+ [self syncPullPositions];
465
+ [self syncPullInsets];
466
+ }
467
+
468
+ - (void)scrollToFirstPage:(BOOL)animated
469
+ {
470
+ CGPoint offset;
471
+
472
+ if ( BeeUIScrollView.DIRECTION_HORIZONTAL == _direction )
473
+ {
474
+ offset.x = -1.0f * _baseInsets.left;
475
+ offset.y = self.contentOffset.y;
476
+ }
477
+ else
478
+ {
479
+ offset.x = self.contentOffset.x;
480
+ offset.y = -1.0f * _baseInsets.top;
481
+ }
482
+
483
+ [self setContentOffset:offset animated:animated];
484
+ }
485
+
486
+ - (void)scrollToLastPage:(BOOL)animated
487
+ {
488
+ CGPoint offset;
489
+
490
+ if ( BeeUIScrollView.DIRECTION_HORIZONTAL == _direction )
491
+ {
492
+ offset.x = self.contentOffset.x + self.contentSize.width + 1.0f * _baseInsets.right;
493
+ offset.y = self.contentOffset.y;
494
+ }
495
+ else
496
+ {
497
+ offset.x = self.contentOffset.x;
498
+ offset.y = self.contentOffset.y + self.contentSize.height + 1.0f * _baseInsets.bottom;
499
+ }
500
+
501
+ [self setContentOffset:offset animated:animated];
502
+ }
503
+
504
+ - (void)scrollToPrevPage:(BOOL)animated
505
+ {
506
+ CGPoint offset;
507
+
508
+ if ( BeeUIScrollView.DIRECTION_HORIZONTAL == _direction )
509
+ {
510
+ if ( self.contentSize.width < self.bounds.size.width )
511
+ return;
512
+
513
+ offset.x = self.contentOffset.x - self.bounds.size.width;
514
+ offset.y = self.contentOffset.y;
515
+
516
+ if ( offset.x < -1.0f * _baseInsets.left )
517
+ {
518
+ offset.x = -1.0f * _baseInsets.left;
519
+ }
520
+ }
521
+ else
522
+ {
523
+ if ( self.contentSize.height < self.bounds.size.height )
524
+ return;
525
+
526
+ offset.x = self.contentOffset.x;
527
+ offset.y = self.contentOffset.y - self.bounds.size.height;
528
+
529
+ if ( offset.x < -1.0f * _baseInsets.top )
530
+ {
531
+ offset.x = -1.0f * _baseInsets.top;
532
+ }
533
+ }
534
+
535
+ [self setContentOffset:offset animated:animated];
536
+ }
537
+
538
+ - (void)scrollToNextPage:(BOOL)animated
539
+ {
540
+ CGPoint offset;
541
+
542
+ if ( BeeUIScrollView.DIRECTION_HORIZONTAL == _direction )
543
+ {
544
+ if ( self.contentSize.width < self.bounds.size.width )
545
+ return;
546
+
547
+ offset.x = self.contentOffset.x + self.bounds.size.width;
548
+ offset.y = self.contentOffset.y;
549
+
550
+ CGFloat rightBound = self.contentOffset.x + self.contentSize.width + 1.0f * _baseInsets.right;
551
+
552
+ if ( self.contentSize.width > self.bounds.size.width )
553
+ {
554
+ if (self.contentOffset.x < (self.contentSize.width - self.bounds.size.width) )
555
+ {
556
+ offset.x = rightBound - self.bounds.size.width;
557
+ }
558
+ else
559
+ {
560
+ offset.x = (self.contentSize.width - self.bounds.size.width + 1.0f * _baseInsets.right);
561
+ }
562
+ }
563
+ else
564
+ {
565
+ offset.x = (self.contentSize.width - self.bounds.size.width + 1.0f * _baseInsets.right);
566
+ }
567
+ }
568
+ else
569
+ {
570
+ if ( self.contentSize.height < self.bounds.size.height )
571
+ return;
572
+
573
+ offset.x = self.contentOffset.x;
574
+ offset.y = self.contentOffset.y + self.bounds.size.height;
575
+
576
+ CGFloat bottomBound = self.contentOffset.y + self.contentSize.height + 1.0f * _baseInsets.bottom;
577
+
578
+ if ( offset.y > bottomBound )
579
+ {
580
+ offset.y = bottomBound - self.bounds.size.height;
581
+ }
582
+ }
583
+
584
+ [self setContentOffset:offset animated:animated];
585
+ }
586
+
587
+ - (id)dequeueWithContentClass:(Class)clazz
588
+ {
589
+ for ( UIView * reuseView in _reuseQueue )
590
+ {
591
+ if ( [reuseView isKindOfClass:clazz] )
592
+ {
593
+ CC( @"UIScrollView, dequeue <= (%p)", reuseView );
594
+
595
+ [reuseView retain];
596
+ [_reuseQueue removeObject:reuseView];
597
+ // return reuseView;
598
+ return [reuseView autorelease];
599
+ }
600
+ }
601
+
602
+ UIView * newView = (UIView *)[BeeRuntime allocByClass:clazz];
603
+ return [[newView initWithFrame:CGRectZero] autorelease];
604
+ }
605
+
606
+ - (void)syncPositions
607
+ {
608
+ CC( @"UIScrollView, subviews = %d", [self.subviews count] );
609
+
610
+ NSInteger lineFits = 0;
611
+ CGFloat linePixels[BEE_SCROLL_MAX_LINES] = { 0.0f };
612
+
613
+ _visibleStart = 0;
614
+ _visibleEnd = 0;
615
+
616
+ for ( NSInteger i = 0; i < _total; ++i )
617
+ {
618
+ BeeUIScrollItem * item = [_items objectAtIndex:i];
619
+ item.visible = NO;
620
+
621
+ // 先找起始INDEX
622
+ if ( BeeUIScrollView.DIRECTION_HORIZONTAL == _direction )
623
+ {
624
+ if ( CGRectGetMaxX(item.rect) >= self.contentOffset.x )
625
+ {
626
+ _visibleStart = i;
627
+ break;
628
+ }
629
+ }
630
+ else
631
+ {
632
+ if ( CGRectGetMaxY(item.rect) >= self.contentOffset.y )
633
+ {
634
+ _visibleStart = i;
635
+ break;
636
+ }
637
+ }
638
+
639
+ if ( item.view )
640
+ {
641
+ if ( _reuseQueue.count >= MAX_QUEUED_ITEMS )
642
+ {
643
+ [_reuseQueue removeObject:[_reuseQueue objectAtIndex:0]];
644
+ }
645
+
646
+ CC( @"UIScrollView, enqueue => (%p)", item.view );
647
+ [_reuseQueue addObject:item.view];
648
+
649
+ [item.view removeFromSuperview];
650
+ item.view = nil;
651
+ }
652
+ }
653
+
654
+ // CGFloat rightEdge = self.contentOffset.x + (self.contentInset.left + self.contentInset.right) + self.bounds.size.width;
655
+ // CGFloat bottomEdge = self.contentOffset.y + (self.contentInset.top + self.contentInset.bottom) + self.bounds.size.height;
656
+
657
+ for ( NSInteger j = _visibleStart; j < _total; ++j )
658
+ {
659
+ BOOL itemFlag = NO;
660
+ BeeUIScrollItem * item = [_items objectAtIndex:j];
661
+
662
+ if ( BeeUIScrollView.DIRECTION_HORIZONTAL == _direction )
663
+ {
664
+ if ( linePixels[item.line] < self.bounds.size.width )
665
+ {
666
+ item.visible = YES;
667
+
668
+ if ( item.rect.origin.x < self.contentOffset.x )
669
+ {
670
+ linePixels[item.line] += item.rect.origin.x + item.rect.size.width - self.contentOffset.x;
671
+ }
672
+ // else if ( item.rect.origin.x > rightEdge )
673
+ // {
674
+ // linePixels[item.line] += 0.0f;
675
+ // }
676
+ else
677
+ {
678
+ linePixels[item.line] += item.rect.size.width;
679
+ }
680
+
681
+ if ( linePixels[item.line] >= self.bounds.size.width )
682
+ {
683
+ lineFits += 1;
684
+ }
685
+
686
+ itemFlag = YES;
687
+ }
688
+ }
689
+ else
690
+ {
691
+ if ( linePixels[item.line] < self.bounds.size.height )
692
+ {
693
+ item.visible = YES;
694
+
695
+ if ( item.rect.origin.y < self.contentOffset.y )
696
+ {
697
+ linePixels[item.line] += item.rect.origin.y + item.rect.size.height - self.contentOffset.y;
698
+ }
699
+ // else if ( item.rect.origin.y > bottomEdge )
700
+ // {
701
+ // linePixels[item.line] += 0.0f;
702
+ // }
703
+ else
704
+ {
705
+ linePixels[item.line] += item.rect.size.height;
706
+ }
707
+
708
+ if ( linePixels[item.line] >= self.bounds.size.height )
709
+ {
710
+ lineFits += 1;
711
+ }
712
+
713
+ itemFlag = YES;
714
+ }
715
+ }
716
+
717
+ if ( NO == itemFlag )
718
+ {
719
+ item.visible = NO;
720
+
721
+ if ( item.view )
722
+ {
723
+ if ( _reuseQueue.count >= MAX_QUEUED_ITEMS )
724
+ {
725
+ [_reuseQueue removeObject:[_reuseQueue objectAtIndex:0]];
726
+ }
727
+
728
+ CC( @"UIScrollView, enqueue => (%p)", item.view );
729
+ [_reuseQueue addObject:item.view];
730
+
731
+ [item.view removeFromSuperview];
732
+ item.view = nil;
733
+ }
734
+ }
735
+
736
+ // 再找终止INDEX
737
+ if ( lineFits >= _lineCount )
738
+ {
739
+ _visibleEnd = j;
740
+ break;
741
+ }
742
+ }
743
+
744
+ if ( 0 == _visibleEnd )
745
+ {
746
+ _visibleEnd = (_total > 0) ? (_total - 1) : 0;
747
+ }
748
+
749
+ for ( NSInteger k = _visibleEnd + 1; k < _total; ++k )
750
+ {
751
+ BeeUIScrollItem * item = [_items objectAtIndex:k];
752
+ item.visible = NO;
753
+
754
+ if ( item.view )
755
+ {
756
+ if ( _reuseQueue.count >= MAX_QUEUED_ITEMS )
757
+ {
758
+ [_reuseQueue removeObject:[_reuseQueue objectAtIndex:0]];
759
+ }
760
+
761
+ CC( @"UIScrollView, enqueue => (%p)", item.view );
762
+ [_reuseQueue addObject:item.view];
763
+
764
+ [item.view removeFromSuperview];
765
+ item.view = nil;
766
+ }
767
+ }
768
+
769
+ CC( @"start = %d, end = %d", _visibleStart, _visibleEnd );
770
+
771
+ // if ( BEE_SCROLL_DIRECTION_HORIZONTAL == _direction )
772
+ // {
773
+ // CGFloat offset = self.contentOffset.x + self.bounds.size.width;
774
+ // CGFloat bound = self.contentSize.width;
775
+ //
776
+ // if ( offset <= bound )
777
+ // {
778
+ // if ( _reachEnd )
779
+ // {
780
+ // _reachEnd = NO;
781
+ // }
782
+ // }
783
+ // }
784
+ // else
785
+ // {
786
+ // CGFloat offset = self.contentOffset.y + self.bounds.size.height;
787
+ // CGFloat bound = self.contentSize.height;
788
+ //
789
+ // if ( offset <= bound )
790
+ // {
791
+ // if ( _reachEnd )
792
+ // {
793
+ // _reachEnd = NO;
794
+ // }
795
+ // }
796
+ // }
797
+
798
+ if ( _total > 0 )
799
+ {
800
+ for ( NSInteger l = _visibleStart; l <= _visibleEnd; ++l )
801
+ {
802
+ BeeUIScrollItem * item = [_items objectAtIndex:l];
803
+ if ( NO == item.visible )
804
+ continue;
805
+
806
+ if ( nil == item.view )
807
+ {
808
+ item.view = [_dataSource scrollView:self viewForIndex:l scale:item.scale];
809
+ item.view.frame = item.rect;
810
+ }
811
+
812
+ if ( item.view && item.view.superview != self )
813
+ {
814
+ // [item.view retain];
815
+ [item.view removeFromSuperview];
816
+ [self addSubview:item.view];
817
+ // [item.view release];
818
+ }
819
+
820
+ // CC( @"%p, (%f, %f), (%f, %f)",
821
+ // item.view,
822
+ // item.rect.origin.x, item.rect.origin.y,
823
+ // item.rect.size.width, item.rect.size.height );
824
+ }
825
+
826
+ BOOL reachTop = (0 == _visibleStart) ? YES : NO;
827
+ if ( reachTop )
828
+ {
829
+ if ( NO == _reachTop )
830
+ {
831
+ if ( _shouldNotify )
832
+ {
833
+ [self sendUISignal:BeeUIScrollView.REACH_TOP];
834
+ }
835
+
836
+ _reachTop = YES;
837
+ }
838
+ }
839
+ else
840
+ {
841
+ _reachTop = NO;
842
+ }
843
+
844
+ BOOL reachEnd = (_visibleEnd + 1 >= _total) ? YES : NO;
845
+ if ( reachEnd )
846
+ {
847
+ if ( NO == _reachEnd )
848
+ {
849
+ if ( _shouldNotify )
850
+ {
851
+ [self sendUISignal:BeeUIScrollView.REACH_BOTTOM];
852
+ }
853
+
854
+ _reachEnd = YES;
855
+ }
856
+ }
857
+ else
858
+ {
859
+ _reachEnd = NO;
860
+ }
861
+ }
862
+
863
+ CGPoint currentOffset = self.contentOffset;
864
+ NSTimeInterval currentTime = [NSDate timeIntervalSinceReferenceDate];
865
+ NSTimeInterval timeDiff = currentTime - _lastOffsetCapture;
866
+
867
+ if ( timeDiff > 0.1 )
868
+ {
869
+ _scrollSpeed.x = ((currentOffset.x - _lastOffset.x) / 1000.0f);
870
+ _scrollSpeed.y = ((currentOffset.y - _lastOffset.y) / 1000.0f);
871
+
872
+ _lastOffset = currentOffset;
873
+ _lastOffsetCapture = currentTime;
874
+ }
875
+
876
+ CC( @"scrollSpeed = (%f, %f)", _scrollSpeed.x, _scrollSpeed.y );
877
+ }
878
+
879
+ - (void)calcPositions
880
+ {
881
+ if ( 0 == _total )
882
+ return;
883
+
884
+ CGRect bounds = self.bounds;
885
+ CGFloat itemPixels = 0.0f;
886
+
887
+ if ( BeeUIScrollView.DIRECTION_HORIZONTAL == _direction )
888
+ {
889
+ itemPixels = bounds.size.height / _lineCount;
890
+ }
891
+ else
892
+ {
893
+ itemPixels = bounds.size.width / _lineCount;
894
+ }
895
+
896
+ BeeUIScrollItem * item = nil;
897
+
898
+ for ( NSInteger i = 0; i < _total; ++i )
899
+ {
900
+ if ( i >= [_items count] )
901
+ {
902
+ item = [[BeeUIScrollItem alloc] init];
903
+ item.index = i;
904
+ [_items addObject:item];
905
+ [item release];
906
+
907
+ // CC( @"%@", [item description] );
908
+ }
909
+ else
910
+ {
911
+ item = [_items objectAtIndex:i];
912
+ }
913
+
914
+ item.size = [_dataSource scrollView:self sizeForIndex:i];
915
+ item.line = [self getShortestLine];
916
+
917
+ if ( BeeUIScrollView.DIRECTION_HORIZONTAL == _direction )
918
+ {
919
+ item.scale = (0.0f == item.size.height) ? 1.0f : (itemPixels / item.size.height);
920
+ item.rect = CGRectMake( _lineHeights[item.line], item.line * itemPixels, item.size.width * item.scale, itemPixels );
921
+
922
+ if ( item.line < _lineCount )
923
+ {
924
+ _lineHeights[item.line] += item.rect.size.width;
925
+ }
926
+ else
927
+ {
928
+ _lineHeights[item.line] += 0.0f;
929
+ }
930
+ }
931
+ else
932
+ {
933
+ item.scale = (0.0f == item.size.width) ? 1.0f : (itemPixels / item.size.width);
934
+ item.rect = CGRectMake( item.line * itemPixels, _lineHeights[item.line], itemPixels, item.size.height * item.scale );
935
+
936
+ if ( item.line < _lineCount )
937
+ {
938
+ _lineHeights[item.line] += item.rect.size.height;
939
+ }
940
+ else
941
+ {
942
+ _lineHeights[item.line] += 0.0f;
943
+ }
944
+ }
945
+ }
946
+
947
+ NSInteger line = [self getLongestLine];
948
+ if ( line < _lineCount )
949
+ {
950
+ if ( BeeUIScrollView.DIRECTION_HORIZONTAL == _direction )
951
+ {
952
+ self.contentSize = CGSizeMake( _lineHeights[line], self.bounds.size.height );
953
+ }
954
+ else
955
+ {
956
+ self.contentSize = CGSizeMake( self.bounds.size.width, _lineHeights[line] );
957
+ }
958
+ }
959
+ else
960
+ {
961
+ if ( BeeUIScrollView.DIRECTION_HORIZONTAL == _direction )
962
+ {
963
+ self.contentSize = CGSizeMake( 0.0f, self.bounds.size.height );
964
+ }
965
+ else
966
+ {
967
+ self.contentSize = CGSizeMake( self.bounds.size.width, 0.0f );
968
+ }
969
+ }
970
+
971
+ for ( BeeUIScrollItem * item in _items )
972
+ {
973
+ CC( @"index = %d, visible = %d, line = %d, rect = (%.1f,%.1f, %.1f,%.1f)",
974
+ item.index, item.visible, item.line,
975
+ item.rect.origin.x, item.rect.origin.y,
976
+ item.rect.size.width, item.rect.size.height );
977
+ }
978
+ }
979
+
980
+ - (CGFloat)getHeight
981
+ {
982
+ NSInteger line = [self getLongestLine];
983
+ if ( line < _total )
984
+ {
985
+ return _lineHeights[line];
986
+ }
987
+ else
988
+ {
989
+ return 0.0f;
990
+ }
991
+ }
992
+
993
+ - (NSInteger)getLongestLine
994
+ {
995
+ if ( 0 == _total )
996
+ {
997
+ return _lineCount + 1;
998
+ }
999
+
1000
+ NSInteger longest = 0;
1001
+
1002
+ for ( NSInteger i = 0; i < _lineCount; ++i )
1003
+ {
1004
+ if ( _lineHeights[i] > _lineHeights[longest] )
1005
+ {
1006
+ longest = i;
1007
+ }
1008
+ }
1009
+
1010
+ return longest;
1011
+ }
1012
+
1013
+ - (NSInteger)getShortestLine
1014
+ {
1015
+ if ( 0 == _total )
1016
+ {
1017
+ return _lineCount + 1;
1018
+ }
1019
+
1020
+ NSInteger shortest = 0;
1021
+
1022
+ for ( NSInteger i = 0; i < _lineCount; ++i )
1023
+ {
1024
+ if ( _lineHeights[i] < _lineHeights[shortest] )
1025
+ {
1026
+ shortest = i;
1027
+ }
1028
+ }
1029
+
1030
+ return shortest;
1031
+ }
1032
+
1033
+ - (void)releaseAllViews
1034
+ {
1035
+ if ( _items )
1036
+ {
1037
+ for ( BeeUIScrollItem * item in _items )
1038
+ {
1039
+ [item.view removeFromSuperview];
1040
+ item.view = nil;
1041
+ }
1042
+
1043
+ [_items removeAllObjects];
1044
+ }
1045
+
1046
+ // if ( _reuseQueue )
1047
+ // {
1048
+ // [_reuseQueue removeAllObjects];
1049
+ // }
1050
+ }
1051
+
1052
+ - (void)releaseViewsBefore:(NSInteger)index
1053
+ {
1054
+ }
1055
+
1056
+ - (void)releaseViewsAfter:(NSInteger)index
1057
+ {
1058
+ }
1059
+
1060
+ - (void)showHeaderLoader:(BOOL)flag animated:(BOOL)animated
1061
+ {
1062
+ if ( nil == _headerLoader )
1063
+ {
1064
+ _headerLoader = [[BeeUIPullLoader alloc] initWithFrame:CGRectZero];
1065
+ _headerLoader.hidden = YES;
1066
+ _headerLoader.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
1067
+
1068
+ if ( _direction == self.DIRECTION_HORIZONTAL )
1069
+ {
1070
+ _headerLoader.transform = CGAffineTransformMakeRotation( M_PI / 2.0f );
1071
+ }
1072
+ else
1073
+ {
1074
+ _headerLoader.transform = CGAffineTransformIdentity;
1075
+ }
1076
+
1077
+ [self addSubview:_headerLoader];
1078
+ [self bringSubviewToFront:_headerLoader];
1079
+ }
1080
+
1081
+ if ( flag )
1082
+ {
1083
+ _headerLoader.hidden = NO;
1084
+ }
1085
+ else
1086
+ {
1087
+ _headerLoader.hidden = YES;
1088
+ }
1089
+
1090
+ [self syncPullPositions];
1091
+ [self syncPullInsets];
1092
+ }
1093
+
1094
+ - (void)showFooterLoader:(BOOL)flag animated:(BOOL)animated
1095
+ {
1096
+ if ( nil == _footerLoader )
1097
+ {
1098
+ _footerLoader = [[BeeUIPullLoader alloc] initWithFrame:CGRectZero];
1099
+ _footerLoader.hidden = YES;
1100
+ _footerLoader.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
1101
+
1102
+ if ( _direction == self.DIRECTION_HORIZONTAL )
1103
+ {
1104
+ _headerLoader.transform = CGAffineTransformMakeRotation( M_PI / 2.0f * 3.0f );
1105
+ }
1106
+ else
1107
+ {
1108
+ _headerLoader.transform = CGAffineTransformMakeRotation( M_PI );
1109
+ }
1110
+
1111
+ [self addSubview:_footerLoader];
1112
+ [self bringSubviewToFront:_footerLoader];
1113
+ }
1114
+
1115
+ if ( flag )
1116
+ {
1117
+ _footerLoader.hidden = NO;
1118
+ }
1119
+ else
1120
+ {
1121
+ _footerLoader.hidden = YES;
1122
+ }
1123
+
1124
+ [self syncPullPositions];
1125
+ [self syncPullInsets];
1126
+ }
1127
+
1128
+ - (void)setHeaderLoading:(BOOL)en
1129
+ {
1130
+ if ( _headerLoader )
1131
+ {
1132
+ if ( en )
1133
+ {
1134
+ if ( BeeUIPullLoader.STATE_LOADING != _headerLoader.state )
1135
+ {
1136
+ [_headerLoader changeState:BeeUIPullLoader.STATE_LOADING animated:YES];
1137
+
1138
+ [UIView beginAnimations:nil context:NULL];
1139
+ [UIView setAnimationDuration:0.3f];
1140
+ [UIView setAnimationBeginsFromCurrentState:YES];
1141
+ [self syncPullInsets];
1142
+ [UIView commitAnimations];
1143
+ }
1144
+ }
1145
+ else
1146
+ {
1147
+ if ( BeeUIPullLoader.STATE_NORMAL != _headerLoader.state )
1148
+ {
1149
+ [_headerLoader changeState:BeeUIPullLoader.STATE_NORMAL animated:YES];
1150
+
1151
+ [UIView beginAnimations:nil context:NULL];
1152
+ [UIView setAnimationDuration:0.3f];
1153
+ [UIView setAnimationBeginsFromCurrentState:YES];
1154
+ [self syncPullInsets];
1155
+ [UIView commitAnimations];
1156
+ }
1157
+ }
1158
+ }
1159
+ }
1160
+
1161
+ - (void)setFooterLoading:(BOOL)en
1162
+ {
1163
+ if ( _footerLoader )
1164
+ {
1165
+ if ( en )
1166
+ {
1167
+ if ( BeeUIPullLoader.STATE_LOADING != _footerLoader.state )
1168
+ {
1169
+ [_footerLoader changeState:BeeUIPullLoader.STATE_LOADING animated:YES];
1170
+
1171
+ [UIView beginAnimations:nil context:NULL];
1172
+ [UIView setAnimationDuration:0.3f];
1173
+ [UIView setAnimationBeginsFromCurrentState:YES];
1174
+ [self syncPullInsets];
1175
+ [UIView commitAnimations];
1176
+ }
1177
+ }
1178
+ else
1179
+ {
1180
+ if ( BeeUIPullLoader.STATE_NORMAL != _footerLoader.state )
1181
+ {
1182
+ [_footerLoader changeState:BeeUIPullLoader.STATE_NORMAL animated:YES];
1183
+
1184
+ [UIView beginAnimations:nil context:NULL];
1185
+ [UIView setAnimationDuration:0.3f];
1186
+ [UIView setAnimationBeginsFromCurrentState:YES];
1187
+ [self syncPullInsets];
1188
+ [UIView commitAnimations];
1189
+ }
1190
+ }
1191
+ }
1192
+ }
1193
+
1194
+ - (void)syncPullPositions
1195
+ {
1196
+ if ( _headerLoader )
1197
+ {
1198
+ CGRect pullFrame;
1199
+
1200
+ if ( _direction == self.DIRECTION_HORIZONTAL )
1201
+ {
1202
+ pullFrame.origin.x = -PULL_LOADER_SIZE - _baseInsets.left;
1203
+ pullFrame.origin.y = 0.0f;
1204
+ pullFrame.size.width = PULL_LOADER_SIZE;
1205
+ pullFrame.size.height = self.bounds.size.height;
1206
+ }
1207
+ else
1208
+ {
1209
+ pullFrame.origin.x = 0.0f;
1210
+ pullFrame.origin.y = -PULL_LOADER_SIZE - _baseInsets.top;
1211
+ pullFrame.size.width = self.bounds.size.width;
1212
+ pullFrame.size.height = PULL_LOADER_SIZE;
1213
+ }
1214
+
1215
+ _headerLoader.frame = pullFrame;
1216
+
1217
+ CC( @"headerLoader, frame = (%f,%f,%f,%f), insets = (%f,%f,%f,%f)",
1218
+ _headerLoader.frame.origin.x, _headerLoader.frame.origin.y,
1219
+ _headerLoader.frame.size.width, _headerLoader.frame.size.height,
1220
+ self.contentInset.top, self.contentInset.left,
1221
+ self.contentInset.bottom, self.contentInset.right
1222
+ );
1223
+ }
1224
+
1225
+ if ( _footerLoader )
1226
+ {
1227
+ CGRect pullFrame;
1228
+
1229
+ if ( _direction == self.DIRECTION_HORIZONTAL )
1230
+ {
1231
+ pullFrame.origin.x = _baseInsets.left + _baseInsets.right + self.contentSize.width;
1232
+ pullFrame.origin.y = 0.0f;
1233
+ pullFrame.size.width = PULL_LOADER_SIZE;
1234
+ pullFrame.size.height = self.bounds.size.height;
1235
+ }
1236
+ else
1237
+ {
1238
+ pullFrame.origin.x = 0.0f;
1239
+ pullFrame.origin.y = _baseInsets.top + _baseInsets.bottom + self.contentSize.height;
1240
+ pullFrame.size.width = self.bounds.size.width;
1241
+ pullFrame.size.height = PULL_LOADER_SIZE;
1242
+ }
1243
+
1244
+ _footerLoader.frame = pullFrame;
1245
+ }
1246
+ }
1247
+
1248
+ - (void)syncPullInsets
1249
+ {
1250
+ UIEdgeInsets insets = _baseInsets;
1251
+
1252
+ if ( _headerLoader )
1253
+ {
1254
+ if ( BeeUIPullLoader.STATE_LOADING == _headerLoader.state )
1255
+ {
1256
+ if ( _direction == self.DIRECTION_HORIZONTAL )
1257
+ {
1258
+ insets.left += _headerLoader.bounds.size.width;
1259
+ }
1260
+ else
1261
+ {
1262
+ insets.top += _headerLoader.bounds.size.height;
1263
+ }
1264
+ }
1265
+
1266
+ CC( @"headerLoader, frame = (%f,%f,%f,%f), insets = (%f,%f,%f,%f)",
1267
+ _headerLoader.frame.origin.x, _headerLoader.frame.origin.y,
1268
+ _headerLoader.frame.size.width, _headerLoader.frame.size.height,
1269
+ self.contentInset.top, self.contentInset.left,
1270
+ self.contentInset.bottom, self.contentInset.right
1271
+ );
1272
+ }
1273
+
1274
+ if ( _footerLoader )
1275
+ {
1276
+ if ( BeeUIPullLoader.STATE_LOADING == _footerLoader.state )
1277
+ {
1278
+ if ( _direction == self.DIRECTION_HORIZONTAL )
1279
+ {
1280
+ insets.right += _footerLoader.bounds.size.width;
1281
+ }
1282
+ else
1283
+ {
1284
+ insets.bottom += _footerLoader.bounds.size.height;
1285
+ }
1286
+ }
1287
+ }
1288
+
1289
+ self.contentInset = insets;
1290
+ }
1291
+
1292
+ #pragma mark -
1293
+ #pragma mark BeeUIScrollViewDelegate
1294
+
1295
+ - (NSInteger)numberOfLinesInScrollView:(BeeUIScrollView *)scrollView
1296
+ {
1297
+ return 0;
1298
+ }
1299
+
1300
+ - (NSInteger)numberOfViewsInScrollView:(BeeUIScrollView *)scrollView
1301
+ {
1302
+ return 0;
1303
+ }
1304
+
1305
+ - (UIView *)scrollView:(BeeUIScrollView *)scrollView viewForIndex:(NSInteger)index scale:(CGFloat)scale
1306
+ {
1307
+ return nil;
1308
+ }
1309
+
1310
+ - (CGSize)scrollView:(BeeUIScrollView *)scrollView sizeForIndex:(NSInteger)index
1311
+ {
1312
+ return CGSizeZero;
1313
+ }
1314
+
1315
+ #pragma mark -
1316
+ #pragma mark UIScrollViewDelegate
1317
+
1318
+ - (void)scrollViewDidScroll:(UIScrollView *)scrollView
1319
+ {
1320
+ if ( scrollView.dragging )
1321
+ {
1322
+ // header loader
1323
+ if ( NO == _headerLoader.hidden && BeeUIPullLoader.STATE_LOADING != _headerLoader.state )
1324
+ {
1325
+ if ( _direction == self.DIRECTION_HORIZONTAL )
1326
+ {
1327
+ CGFloat offset = scrollView.contentOffset.x;
1328
+ CGFloat boundX = -(_baseInsets.left + _headerLoader.bounds.size.width);
1329
+
1330
+ if ( offset < boundX )
1331
+ {
1332
+ if ( BeeUIPullLoader.STATE_PULLING != _headerLoader.state )
1333
+ {
1334
+ [_headerLoader changeState:BeeUIPullLoader.STATE_PULLING animated:YES];
1335
+ }
1336
+ }
1337
+ else if ( offset < 0.0f )
1338
+ {
1339
+ if ( BeeUIPullLoader.STATE_NORMAL != _headerLoader.state )
1340
+ {
1341
+ [_headerLoader changeState:BeeUIPullLoader.STATE_NORMAL animated:YES];
1342
+ }
1343
+ }
1344
+ }
1345
+ else
1346
+ {
1347
+ CGFloat offset = scrollView.contentOffset.y;
1348
+ CGFloat boundY = -(_baseInsets.top + _headerLoader.bounds.size.height);
1349
+
1350
+ if ( offset < boundY )
1351
+ {
1352
+ if ( BeeUIPullLoader.STATE_PULLING != _headerLoader.state )
1353
+ {
1354
+ [_headerLoader changeState:BeeUIPullLoader.STATE_PULLING animated:YES];
1355
+ }
1356
+ }
1357
+ else if ( offset < 0.0f )
1358
+ {
1359
+ if ( BeeUIPullLoader.STATE_NORMAL != _headerLoader.state )
1360
+ {
1361
+ [_headerLoader changeState:BeeUIPullLoader.STATE_NORMAL animated:YES];
1362
+ }
1363
+ }
1364
+ }
1365
+ }
1366
+
1367
+ // TODO: footer loader
1368
+ }
1369
+
1370
+ if ( _shouldNotify )
1371
+ {
1372
+ [self sendUISignal:BeeUIScrollView.DID_SCROLL];
1373
+ }
1374
+
1375
+ [self syncPositions];
1376
+ [self syncPullPositions];
1377
+ }
1378
+
1379
+ - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
1380
+ {
1381
+ [self syncPositions];
1382
+ [self syncPullPositions];
1383
+ }
1384
+
1385
+ - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
1386
+ {
1387
+ if ( decelerate )
1388
+ {
1389
+ // header loader
1390
+ if ( NO == _headerLoader.hidden && BeeUIPullLoader.STATE_LOADING != _headerLoader.state )
1391
+ {
1392
+ if ( _direction == self.DIRECTION_HORIZONTAL )
1393
+ {
1394
+ CGFloat offset = scrollView.contentOffset.x;
1395
+ CGFloat boundY = -(_baseInsets.left + _headerLoader.bounds.size.width);
1396
+
1397
+ if ( offset <= boundY )
1398
+ {
1399
+ if ( BeeUIPullLoader.STATE_LOADING != _headerLoader.state )
1400
+ {
1401
+ [_headerLoader changeState:BeeUIPullLoader.STATE_LOADING animated:YES];
1402
+
1403
+ [self sendUISignal:self.HEADER_REFRESH];
1404
+ }
1405
+ }
1406
+ else
1407
+ {
1408
+ if ( BeeUIPullLoader.STATE_NORMAL != _headerLoader.state )
1409
+ {
1410
+ [_headerLoader changeState:BeeUIPullLoader.STATE_NORMAL animated:YES];
1411
+ }
1412
+ }
1413
+ }
1414
+ else
1415
+ {
1416
+ CGFloat offset = scrollView.contentOffset.y;
1417
+ CGFloat boundY = -(_baseInsets.top + _headerLoader.bounds.size.height);
1418
+
1419
+ if ( offset <= boundY )
1420
+ {
1421
+ if ( BeeUIPullLoader.STATE_LOADING != _headerLoader.state )
1422
+ {
1423
+ [_headerLoader changeState:BeeUIPullLoader.STATE_LOADING animated:YES];
1424
+
1425
+ [self sendUISignal:self.HEADER_REFRESH];
1426
+ }
1427
+ }
1428
+ else
1429
+ {
1430
+ if ( BeeUIPullLoader.STATE_NORMAL != _headerLoader.state )
1431
+ {
1432
+ [_headerLoader changeState:BeeUIPullLoader.STATE_NORMAL animated:YES];
1433
+ }
1434
+ }
1435
+ }
1436
+
1437
+ [UIView beginAnimations:nil context:NULL];
1438
+ [UIView setAnimationDuration:0.3f];
1439
+ [UIView setAnimationBeginsFromCurrentState:YES];
1440
+
1441
+ CC( @"pulled" );
1442
+
1443
+ [self syncPullPositions];
1444
+ [self syncPullInsets];
1445
+
1446
+ [UIView commitAnimations];
1447
+ }
1448
+
1449
+ // TODO: footer loader
1450
+ }
1451
+
1452
+ if ( _shouldNotify )
1453
+ {
1454
+ [self sendUISignal:BeeUIScrollView.DID_DRAG];
1455
+ [self sendUISignal:BeeUIScrollView.DID_STOP];
1456
+ }
1457
+
1458
+ [self syncPositions];
1459
+ [self syncPullPositions];
1460
+ }
1461
+
1462
+ - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView
1463
+ {
1464
+ [self syncPositions];
1465
+ [self syncPullPositions];
1466
+ }
1467
+
1468
+ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
1469
+ {
1470
+ if ( _shouldNotify )
1471
+ {
1472
+ [self sendUISignal:BeeUIScrollView.DID_STOP];
1473
+ }
1474
+
1475
+ [self syncPositions];
1476
+ [self syncPullPositions];
1477
+ }
1478
+
1479
+ - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
1480
+ {
1481
+ [self syncPositions];
1482
+ [self syncPullPositions];
1483
+ }
1484
+
1485
+ @end
1486
+
1487
+ #endif // #if (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)