appjam 0.1.8.8 → 0.1.8.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. data/README.md +22 -62
  2. data/lib/appjam/generators/gist.yml +1 -1
  3. data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/project.pbxproj +1166 -482
  4. data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/project.xcworkspace/xcuserdata/eiffel.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  5. data/lib/appjam/generators/templates/blank/EiffelApplication/EiffelApplication-Prefix.pch.tt +26 -0
  6. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/AwesomeMenu.h +52 -0
  7. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/AwesomeMenu.m +412 -0
  8. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/AwesomeMenuItem.h +44 -0
  9. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/AwesomeMenuItem.m +97 -0
  10. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/bg-addbutton-highlighted.png +0 -0
  11. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/bg-addbutton-highlighted@2x.png +0 -0
  12. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/bg-addbutton.png +0 -0
  13. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/bg-addbutton@2x.png +0 -0
  14. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/bg-menuitem-highlighted.png +0 -0
  15. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/bg-menuitem-highlighted@2x.png +0 -0
  16. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/bg-menuitem.png +0 -0
  17. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/bg-menuitem@2x.png +0 -0
  18. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/icon-plus-highlighted.png +0 -0
  19. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/icon-plus-highlighted@2x.png +0 -0
  20. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/icon-plus.png +0 -0
  21. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/icon-plus@2x.png +0 -0
  22. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/icon-star.png +0 -0
  23. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/AwesomeMenu/Images/icon-star@2x.png +0 -0
  24. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/CMPopTipView/CMPopTipView.h +167 -0
  25. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/CMPopTipView/CMPopTipView.m +639 -0
  26. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/FXLabel/FXLabel.h +97 -0
  27. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/FXLabel/FXLabel.m +1080 -0
  28. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/MBProgressHUD/MBProgressHUD.h +451 -0
  29. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/MBProgressHUD/MBProgressHUD.m +865 -0
  30. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/FacingView.h +42 -0
  31. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/FacingView.m +56 -0
  32. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/FoldView.h +90 -0
  33. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/FoldView.m +316 -0
  34. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/MultiFoldView.h +104 -0
  35. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/MultiFoldView.m +516 -0
  36. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldConstants.h +49 -0
  37. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldNavigationController.h +18 -0
  38. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldNavigationController.m +88 -0
  39. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldResources.bundle/swipe_guide_left.png +0 -0
  40. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldResources.bundle/swipe_guide_left@2x.png +0 -0
  41. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldResources.bundle/swipe_guide_right.png +0 -0
  42. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldResources.bundle/swipe_guide_right@2x.png +0 -0
  43. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldSwipeHintView.h +25 -0
  44. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldSwipeHintView.m +76 -0
  45. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldView.h +131 -0
  46. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/PaperFoldView.m +941 -0
  47. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/Resources/swipe_guide.psd +0 -0
  48. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/Resources/swipe_guide2.psd +0 -0
  49. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/ShadowView.h +46 -0
  50. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/ShadowView.m +82 -0
  51. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/TouchThroughUIView.h +39 -0
  52. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/TouchThroughUIView.m +72 -0
  53. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/UIView+Screenshot.h +42 -0
  54. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/PaperFold/UIView+Screenshot.m +100 -0
  55. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/NSBubbleData.h +34 -0
  56. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/NSBubbleData.m +140 -0
  57. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/UIBubbleHeaderTableViewCell.h +17 -0
  58. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/UIBubbleHeaderTableViewCell.m +57 -0
  59. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/UIBubbleTableView.h +30 -0
  60. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/UIBubbleTableView.m +233 -0
  61. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/UIBubbleTableViewCell.h +19 -0
  62. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/UIBubbleTableViewCell.m +122 -0
  63. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/UIBubbleTableViewDataSource.h +24 -0
  64. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/UIBubbleTypingTableViewCell.h +20 -0
  65. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/UIBubbleTypingTableViewCell.m +56 -0
  66. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/images/bubbleMine.png +0 -0
  67. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/images/bubbleMine@2x.png +0 -0
  68. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/images/bubbleSomeone.png +0 -0
  69. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/images/bubbleSomeone@2x.png +0 -0
  70. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/images/missingAvatar.png +0 -0
  71. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/images/missingAvatar@2x.png +0 -0
  72. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/images/typingMine.png +0 -0
  73. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/images/typingMine@2x.png +0 -0
  74. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/images/typingSomeone.png +0 -0
  75. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIBubbleTableView/images/typingSomeone@2x.png +0 -0
  76. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIGlossyButton/UIGlossyButton.h +124 -0
  77. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIGlossyButton/UIGlossyButton.m +545 -0
  78. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIGlossyButton/UIView+LayerEffects.h +22 -0
  79. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/UIGlossyButton/UIView+LayerEffects.m +32 -0
  80. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFIncrementalStore/AFIncrementalStore.h +344 -0
  81. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFIncrementalStore/AFIncrementalStore.m +848 -0
  82. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFIncrementalStore/AFRESTClient.h +135 -0
  83. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFIncrementalStore/AFRESTClient.m +441 -0
  84. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/InflectorKit/NSString+InflectorKit.h +40 -0
  85. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/InflectorKit/NSString+InflectorKit.m +36 -0
  86. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/InflectorKit/TTTStringInflector.h +76 -0
  87. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/InflectorKit/TTTStringInflector.m +270 -0
  88. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/MKAnnotationView+WebCache.h +95 -0
  89. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/MKAnnotationView+WebCache.m +78 -0
  90. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDImageCache.h +144 -0
  91. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDImageCache.m +311 -0
  92. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageCompat.h +40 -0
  93. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageCompat.m +54 -0
  94. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageDecoder.h +18 -0
  95. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageDecoder.m +70 -0
  96. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageDownloader.h +102 -0
  97. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageDownloader.m +226 -0
  98. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageDownloaderOperation.h +25 -0
  99. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageDownloaderOperation.m +339 -0
  100. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageManager.h +167 -0
  101. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageManager.m +244 -0
  102. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImageOperation.h +15 -0
  103. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImagePrefetcher.h +58 -0
  104. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/SDWebImagePrefetcher.m +127 -0
  105. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/UIButton+WebCache.h +173 -0
  106. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/UIButton+WebCache.m +129 -0
  107. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/UIImageView+WebCache.h +140 -0
  108. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/SDWebImage/UIImageView+WebCache.m +84 -0
  109. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CPAnimationSequence/CPAnimationProgram.h +28 -0
  110. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CPAnimationSequence/CPAnimationSequence.h +28 -0
  111. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CPAnimationSequence/CPAnimationStep.h +49 -0
  112. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CPAnimationSequence/private/CPAnimationProgram.m +100 -0
  113. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CPAnimationSequence/private/CPAnimationSequence.m +85 -0
  114. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CPAnimationSequence/private/CPAnimationStep.m +122 -0
  115. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaAsyncSocket/GCDAsyncSocket.h +1074 -0
  116. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaAsyncSocket/GCDAsyncSocket.m +7430 -0
  117. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Categories/DDData.h +14 -0
  118. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Categories/DDData.m +158 -0
  119. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Categories/DDNumber.h +12 -0
  120. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Categories/DDNumber.m +88 -0
  121. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Categories/DDRange.h +56 -0
  122. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Categories/DDRange.m +104 -0
  123. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/HTTPAuthenticationRequest.h +45 -0
  124. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/HTTPAuthenticationRequest.m +195 -0
  125. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/HTTPConnection.h +119 -0
  126. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/HTTPConnection.m +2708 -0
  127. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/HTTPLogging.h +136 -0
  128. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/HTTPMessage.h +48 -0
  129. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/HTTPMessage.m +113 -0
  130. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/HTTPResponse.h +149 -0
  131. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/HTTPServer.h +205 -0
  132. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/HTTPServer.m +772 -0
  133. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Mime/MultipartFormDataParser.h +65 -0
  134. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Mime/MultipartFormDataParser.m +529 -0
  135. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Mime/MultipartMessageHeader.h +33 -0
  136. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Mime/MultipartMessageHeader.m +86 -0
  137. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Mime/MultipartMessageHeaderField.h +23 -0
  138. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Mime/MultipartMessageHeaderField.m +211 -0
  139. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPAsyncFileResponse.h +75 -0
  140. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPAsyncFileResponse.m +405 -0
  141. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPDataResponse.h +13 -0
  142. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPDataResponse.m +79 -0
  143. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPDynamicFileResponse.h +52 -0
  144. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPDynamicFileResponse.m +292 -0
  145. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPErrorResponse.h +9 -0
  146. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPErrorResponse.m +38 -0
  147. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPFileResponse.h +25 -0
  148. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPFileResponse.m +237 -0
  149. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPRedirectResponse.h +12 -0
  150. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/Responses/HTTPRedirectResponse.m +73 -0
  151. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/WebSocket.h +105 -0
  152. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Core/WebSocket.m +791 -0
  153. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Extensions/WebDAV/DAVConnection.h +7 -0
  154. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Extensions/WebDAV/DAVConnection.m +160 -0
  155. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Extensions/WebDAV/DAVResponse.h +11 -0
  156. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Extensions/WebDAV/DAVResponse.m +372 -0
  157. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Extensions/WebDAV/DELETEResponse.h +7 -0
  158. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Extensions/WebDAV/DELETEResponse.m +49 -0
  159. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Extensions/WebDAV/PUTResponse.h +8 -0
  160. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/CocoaHTTPServer/Extensions/WebDAV/PUTResponse.m +69 -0
  161. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/hpple/TFHpple.h +54 -0
  162. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/hpple/TFHpple.m +102 -0
  163. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/hpple/TFHppleElement.h +103 -0
  164. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/hpple/TFHppleElement.m +200 -0
  165. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/hpple/XPathQuery.h +10 -0
  166. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/hpple/XPathQuery.m +197 -0
  167. data/lib/appjam/version.rb +1 -1
  168. metadata +164 -3
@@ -0,0 +1,49 @@
1
+ //
2
+ // PaperFoldConstants.h
3
+ // PaperFold
4
+ //
5
+ // Created by honcheng on 25/8/12.
6
+ // Copyright (c) 2012 honcheng@gmail.com. All rights reserved.
7
+ //
8
+
9
+ #ifndef PaperFold_PaperFoldConstants_h
10
+ #define PaperFold_PaperFoldConstants_h
11
+
12
+ #define FOLDVIEW_TAG 1000
13
+ #define kLeftViewUnfoldThreshold 0.3
14
+ #define kRightViewUnfoldThreshold 0.3
15
+ #define kTopViewUnfoldThreshold 0.3
16
+ #define kBottomViewUnfoldThreshold 0.3
17
+ #define kEdgeScrollWidth 40.0
18
+
19
+ typedef enum
20
+ {
21
+ FoldStateClosed = 0,
22
+ FoldStateOpened = 1,
23
+ FoldStateTransition = 2
24
+ } FoldState;
25
+
26
+ typedef enum
27
+ {
28
+ FoldDirectionHorizontalRightToLeft = 0,
29
+ FoldDirectionHorizontalLeftToRight = 1,
30
+ FoldDirectionVertical = 2,
31
+ } FoldDirection;
32
+
33
+ typedef enum
34
+ {
35
+ PaperFoldStateDefault = 0,
36
+ PaperFoldStateLeftUnfolded = 1,
37
+ PaperFoldStateRightUnfolded = 2,
38
+ PaperFoldStateTopUnfolded = 3,
39
+ PaperFoldStateBottomUnfolded = 4,
40
+ PaperFoldStateTransition = 5
41
+ } PaperFoldState;
42
+
43
+ typedef enum
44
+ {
45
+ PaperFoldInitialPanDirectionHorizontal = 0,
46
+ PaperFoldInitialPanDirectionVertical = 1,
47
+ } PaperFoldInitialPanDirection;
48
+
49
+ #endif
@@ -0,0 +1,18 @@
1
+ //
2
+ // PaperFoldNavigationController.h
3
+ // PaperFold-ContainmentView
4
+ //
5
+ // Created by honcheng on 10/8/12.
6
+ // Copyright (c) 2012 honcheng. All rights reserved.
7
+ //
8
+
9
+ #import <UIKit/UIKit.h>
10
+ #import "PaperFoldView.h"
11
+
12
+ @interface PaperFoldNavigationController : UIViewController <PaperFoldViewDelegate>
13
+ @property (nonatomic, strong) UIViewController *rootViewController, *leftViewController, *rightViewController;
14
+ @property (nonatomic, strong) PaperFoldView *paperFoldView;
15
+ - (id)initWithRootViewController:(UIViewController*)rootViewController;
16
+ - (void)setLeftViewController:(UIViewController *)leftViewController width:(float)width;
17
+ - (void)setRightViewController:(UIViewController*)rightViewController width:(float)width rightViewFoldCount:(int)rightViewFoldCount rightViewPullFactor:(float)rightViewPullFactor;
18
+ @end
@@ -0,0 +1,88 @@
1
+ //
2
+ // PaperFoldNavigationController.m
3
+ // PaperFold-ContainmentView
4
+ //
5
+ // Created by honcheng on 10/8/12.
6
+ // Copyright (c) 2012 honcheng. All rights reserved.
7
+ //
8
+
9
+ #import "PaperFoldNavigationController.h"
10
+
11
+ @interface PaperFoldNavigationController ()
12
+
13
+ @end
14
+
15
+ @implementation PaperFoldNavigationController
16
+
17
+ - (id)initWithRootViewController:(UIViewController*)rootViewController
18
+ {
19
+ self = [super init];
20
+ if (self) {
21
+
22
+ [self.view setAutoresizesSubviews:YES];
23
+
24
+ _paperFoldView = [[PaperFoldView alloc] initWithFrame:CGRectMake(0,0,[self.view bounds].size.width,[self.view bounds].size.height)];
25
+ [self.view addSubview:_paperFoldView];
26
+ [_paperFoldView setDelegate:self];
27
+ [_paperFoldView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
28
+
29
+ _rootViewController = rootViewController;
30
+ [_rootViewController.view setFrame:CGRectMake(0,0,[self.view bounds].size.width,[self.view bounds].size.height)];
31
+ [_rootViewController.view setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
32
+ [_paperFoldView setCenterContentView:_rootViewController.view];
33
+ }
34
+ return self;
35
+ }
36
+
37
+ - (void)setRightViewController:(UIViewController*)rightViewController width:(float)width rightViewFoldCount:(int)rightViewFoldCount rightViewPullFactor:(float)rightViewPullFactor
38
+ {
39
+ _rightViewController = rightViewController;
40
+
41
+ [self.rightViewController.view setFrame:CGRectMake(0,0,width,[self.view bounds].size.height)];
42
+ [self.paperFoldView setRightFoldContentView:self.rightViewController.view foldCount:rightViewFoldCount pullFactor:rightViewFoldCount];
43
+ }
44
+
45
+ - (void)setLeftViewController:(UIViewController *)leftViewController width:(float)width
46
+ {
47
+ _leftViewController = leftViewController;
48
+
49
+ [self.leftViewController.view setFrame:CGRectMake(0,0,width,[self.view bounds].size.height)];
50
+ [self.paperFoldView setLeftFoldContentView:self.leftViewController.view foldCount:3 pullFactor:0.9];
51
+ }
52
+
53
+ - (void)paperFoldView:(id)paperFoldView didFoldAutomatically:(BOOL)automated toState:(PaperFoldState)paperFoldState
54
+ {
55
+ if (paperFoldState==PaperFoldStateDefault)
56
+ {
57
+ if (self.leftViewController) {
58
+ [self.leftViewController viewWillDisappear:YES];
59
+ [self.leftViewController viewDidDisappear:YES];
60
+ }
61
+
62
+ if (self.rightViewController) {
63
+ [self.rightViewController viewWillDisappear:YES];
64
+ [self.rightViewController viewDidDisappear:YES];
65
+ }
66
+
67
+ [self.rootViewController viewWillAppear:YES];
68
+ [self.rootViewController viewDidAppear:YES];
69
+ }
70
+ else if (paperFoldState==PaperFoldStateLeftUnfolded)
71
+ {
72
+ [self.rootViewController viewWillDisappear:YES];
73
+ [self.rootViewController viewDidDisappear:YES];
74
+
75
+ [self.leftViewController viewWillAppear:YES];
76
+ [self.leftViewController viewDidAppear:YES];
77
+ }
78
+ else if (paperFoldState==PaperFoldStateRightUnfolded)
79
+ {
80
+ [self.rootViewController viewWillDisappear:YES];
81
+ [self.rootViewController viewDidDisappear:YES];
82
+
83
+ [self.rightViewController viewWillAppear:YES];
84
+ [self.rightViewController viewDidAppear:YES];
85
+ }
86
+ }
87
+
88
+ @end
@@ -0,0 +1,25 @@
1
+ //
2
+ // PaperFoldSwipeHintView.h
3
+ // SGBusArrivals
4
+ //
5
+ // Created by honcheng on 13/10/12.
6
+ //
7
+ //
8
+
9
+ #import <UIKit/UIKit.h>
10
+
11
+ typedef enum
12
+ {
13
+ PaperFoldSwipeHintViewModeSwipeLeft = 0,
14
+ PaperFoldSwipeHintViewModeSwipeRight = 1,
15
+ } PaperFoldSwipeHintViewMode;
16
+
17
+ @interface PaperFoldSwipeHintView : UIView
18
+ @property (nonatomic, strong) UIImageView *imageView;
19
+ @property (nonatomic, assign) PaperFoldSwipeHintViewMode mode;
20
+ - (id)initWithPaperFoldSwipeHintViewMode:(PaperFoldSwipeHintViewMode)mode;
21
+ - (void)showInView:(UIView*)view;
22
+ + (void)hidePaperFoldHintViewInView:(UIView*)view;
23
+
24
+
25
+ @end
@@ -0,0 +1,76 @@
1
+ //
2
+ // PaperFoldSwipeHintView.m
3
+ // SGBusArrivals
4
+ //
5
+ // Created by honcheng on 13/10/12.
6
+ //
7
+ //
8
+
9
+ #import "PaperFoldSwipeHintView.h"
10
+
11
+ @implementation PaperFoldSwipeHintView
12
+
13
+ #define TAG_VIEW 2090
14
+
15
+ - (id)initWithPaperFoldSwipeHintViewMode:(PaperFoldSwipeHintViewMode)mode
16
+ {
17
+ self = [super initWithFrame:CGRectZero];
18
+ if (self) {
19
+ _mode = mode;
20
+
21
+ UIImage *image = nil;
22
+ if (_mode==PaperFoldSwipeHintViewModeSwipeLeft)
23
+ {
24
+ image = [UIImage imageNamed:@"PaperFoldResources.bundle/swipe_guide_left.png"];
25
+ }
26
+ else if (_mode==PaperFoldSwipeHintViewModeSwipeRight)
27
+ {
28
+ image = [UIImage imageNamed:@"PaperFoldResources.bundle/swipe_guide_right.png"];
29
+ }
30
+ _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,image.size.width,image.size.height)];
31
+ [self addSubview:_imageView];
32
+ [_imageView setImage:image];
33
+ [self setUserInteractionEnabled:NO];
34
+
35
+ [self setTag:TAG_VIEW];
36
+ }
37
+ return self;
38
+ }
39
+
40
+ - (void)showInView:(UIView*)view
41
+ {
42
+ // remove any existing view if available
43
+ if ([view viewWithTag:TAG_VIEW]) [[view viewWithTag:TAG_VIEW] removeFromSuperview];
44
+
45
+ [self setFrame:view.frame];
46
+
47
+ CGRect imageViewFrame = [self.imageView frame];
48
+ imageViewFrame.origin.x = (view.frame.size.width-imageViewFrame.size.width)/2;
49
+ imageViewFrame.origin.y = (view.frame.size.height-imageViewFrame.size.height)/2;
50
+ [self.imageView setFrame:imageViewFrame];
51
+
52
+ [view addSubview:self];
53
+
54
+ [self setAlpha:0.0];
55
+ [UIView animateWithDuration:0.2 animations:^{
56
+ [self setAlpha:1.0];
57
+ }];
58
+ }
59
+
60
+ - (void)hide
61
+ {
62
+ [self setAlpha:1.0];
63
+ [UIView animateWithDuration:0.2 animations:^{
64
+ [self setAlpha:0.0];
65
+ } completion:^(BOOL finished) {
66
+ [self removeFromSuperview];
67
+ }];
68
+ }
69
+
70
+ + (void)hidePaperFoldHintViewInView:(UIView*)view
71
+ {
72
+ PaperFoldSwipeHintView *hintView = (PaperFoldSwipeHintView*)[view viewWithTag:TAG_VIEW];
73
+ [hintView hide];
74
+ }
75
+
76
+ @end
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Copyright (c) 2012 Muh Hon Cheng
3
+ * Created by honcheng on 6/2/12.
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files (the
7
+ * "Software"), to deal in the Software without restriction, including
8
+ * without limitation the rights to use, copy, modify, merge, publish,
9
+ * distribute, sublicense, and/or sell copies of the Software, and to
10
+ * permit persons to whom the Software is furnished to do so, subject
11
+ * to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT
17
+ * WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR
20
+ * PURPOSE AND NONINFRINGEMENT. IN NO EVENT
21
+ * SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR
25
+ * IN CONNECTION WITH THE SOFTWARE OR
26
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
+ *
28
+ * @author Muh Hon Cheng <honcheng@gmail.com>
29
+ * @copyright 2012 Muh Hon Cheng
30
+ * @version
31
+ *
32
+ */
33
+
34
+
35
+ #import <UIKit/UIKit.h>
36
+ #import "FacingView.h"
37
+ #import "FoldView.h"
38
+ #import "MultiFoldView.h"
39
+ #import "TouchThroughUIView.h"
40
+
41
+ typedef void (^CompletionBlock)();
42
+
43
+ @protocol PaperFoldViewDelegate <NSObject>
44
+ @optional
45
+ // callback when paper fold transition state changes
46
+ // does not callback when action is cancelled
47
+ - (void)paperFoldView:(id)paperFoldView didFoldAutomatically:(BOOL)automated toState:(PaperFoldState)paperFoldState;
48
+ // callback when paper fold view is offset
49
+ - (void)paperFoldView:(id)paperFoldView viewDidOffset:(CGPoint)offset;
50
+ @end
51
+
52
+ @interface PaperFoldView : UIView <MultiFoldViewDelegate, UIGestureRecognizerDelegate>
53
+
54
+ // main content view
55
+ @property (nonatomic, strong) TouchThroughUIView *contentView;
56
+ // timer to animate folds after gesture ended
57
+ // manual animation with NSTimer is required to sync the offset of the contentView, with the folding of views
58
+ @property (nonatomic, strong) NSTimer *animationTimer;
59
+ // the fold view on the left and bottom
60
+ @property (nonatomic, strong) FoldView *bottomFoldView;
61
+ // the fold view on the left
62
+ @property (nonatomic, strong) MultiFoldView *leftFoldView;
63
+ // the multiple fold view on the right
64
+ @property (nonatomic, strong) MultiFoldView *rightFoldView;
65
+ // the multiple fold view on the top
66
+ @property (nonatomic, strong) MultiFoldView *topFoldView;
67
+ // state of the current fold
68
+ @property (nonatomic, assign) PaperFoldState state, lastState;
69
+ // enable and disable dragging
70
+ @property (nonatomic, assign) BOOL enableLeftFoldDragging, enableRightFoldDragging, enableTopFoldDragging, enableBottomFoldDragging;
71
+ @property (nonatomic, assign) BOOL enableHorizontalEdgeDragging;
72
+ // indicate if the fold was triggered by finger panning, or set state
73
+ @property (nonatomic, assign) BOOL isAutomatedFolding;
74
+ @property (nonatomic, assign) id<PaperFoldViewDelegate> delegate;
75
+ // the initial panning direction
76
+ @property (nonatomic, assign) PaperFoldInitialPanDirection paperFoldInitialPanDirection;
77
+ // optimized screenshot follows the scale of the screen
78
+ // non-optimized is always the non-retina image
79
+ @property (nonatomic, assign) BOOL useOptimizedScreenshot;
80
+ // restrict the dragging gesture recogniser to a certain UIRect of this view. Useful to restrict
81
+ // dragging to, say, a navigation bar.
82
+ @property (nonatomic, assign) CGRect restrictedDraggingRect;
83
+ // divider lines
84
+ // these are exposed so that it is possible to hide the lines
85
+ // especially when views have rounded corners
86
+ @property (nonatomic, weak) UIView *leftDividerLine;
87
+ @property (nonatomic, weak) UIView *rightDividerLine;
88
+ @property (nonatomic, weak) UIView *topDividerLine;
89
+ @property (nonatomic, weak) UIView *bottomDividerLine;
90
+
91
+ // animate folding and unfolding when sent the offset of contentView
92
+ // offset are either sent from pan gesture recognizer, or manual animation done with NSTimer after gesture ended
93
+ - (void)animateWithContentOffset:(CGPoint)point panned:(BOOL)panned;
94
+
95
+ // set the right fold content view
96
+ // and the right fold container view
97
+ // with the number of folds and pull factor
98
+ - (void)setRightFoldContentView:(UIView*)view foldCount:(int)rightViewFoldCount pullFactor:(float)rightViewPullFactor;
99
+
100
+ // set the top fold content view
101
+ // and the top fold container view
102
+ // with the number of folds and pull factor
103
+ - (void)setTopFoldContentView:(UIView*)view topViewFoldCount:(int)topViewFoldCount topViewPullFactor:(float)topViewPullFactor;
104
+
105
+ // set the left fold content view
106
+ // and set the left fold container view frame
107
+ - (void)setLeftFoldContentView:(UIView*)view foldCount:(int)leftViewFoldCount pullFactor:(float)leftViewPullFactor;
108
+
109
+ // set the bottom fold content view
110
+ // and set the bottom fold container view frame
111
+ - (void)setBottomFoldContentView:(UIView*)view;
112
+
113
+ - (void)setCenterContentView:(UIView*)view;
114
+
115
+ // unfold the left and right view
116
+ - (void)setPaperFoldState:(PaperFoldState)state;
117
+ - (void)setPaperFoldState:(PaperFoldState)state animated:(BOOL)animated;
118
+ - (void)setPaperFoldState:(PaperFoldState)state
119
+ animated:(BOOL)animated
120
+ completion:(CompletionBlock)completion;
121
+
122
+ // deprecate methods
123
+ // use setPaperFoldState: instead
124
+ - (void)unfoldLeftView __attribute__((deprecated));
125
+ - (void)unfoldRightView __attribute__((deprecated));
126
+ - (void)restoreToCenter __attribute__((deprecated));
127
+ // set fold views
128
+ - (void)setLeftFoldContentView:(UIView*)view __attribute__((deprecated));
129
+ - (void)setRightFoldContentView:(UIView*)view rightViewFoldCount:(int)rightViewFoldCount rightViewPullFactor:(float)rightViewPullFactor __attribute__((deprecated));;
130
+
131
+ @end
@@ -0,0 +1,941 @@
1
+ /**
2
+ * Copyright (c) 2012 Muh Hon Cheng
3
+ * Created by honcheng on 6/2/12.
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files (the
7
+ * "Software"), to deal in the Software without restriction, including
8
+ * without limitation the rights to use, copy, modify, merge, publish,
9
+ * distribute, sublicense, and/or sell copies of the Software, and to
10
+ * permit persons to whom the Software is furnished to do so, subject
11
+ * to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT
17
+ * WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR
20
+ * PURPOSE AND NONINFRINGEMENT. IN NO EVENT
21
+ * SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR
25
+ * IN CONNECTION WITH THE SOFTWARE OR
26
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
+ *
28
+ * @author Muh Hon Cheng <honcheng@gmail.com>
29
+ * @copyright 2012 Muh Hon Cheng
30
+ * @version
31
+ *
32
+ */
33
+
34
+
35
+ #import "PaperFoldView.h"
36
+ #import <QuartzCore/QuartzCore.h>
37
+
38
+
39
+ @interface PaperFoldView ()
40
+
41
+ @property (nonatomic, copy) CompletionBlock completionBlock;
42
+ @property (nonatomic, strong) UIPanGestureRecognizer *panGestureRecognizer;
43
+
44
+ // indicate if the divider line should be visible
45
+ @property (nonatomic, assign) BOOL showDividerLines;
46
+
47
+ - (void)onContentViewPannedHorizontally:(UIPanGestureRecognizer*)gesture;
48
+ - (void)onContentViewPannedVertically:(UIPanGestureRecognizer*)gesture;
49
+ @end
50
+
51
+ @implementation PaperFoldView
52
+
53
+ - (id)initWithFrame:(CGRect)frame
54
+ {
55
+ self = [super initWithFrame:frame];
56
+ if (self)
57
+ {
58
+ [self initialize];
59
+ }
60
+ return self;
61
+ }
62
+
63
+ - (void)awakeFromNib
64
+ {
65
+ [self initialize];
66
+ }
67
+
68
+ - (void)initialize
69
+ {
70
+ _useOptimizedScreenshot = YES;
71
+
72
+ [self setBackgroundColor:[UIColor darkGrayColor]];
73
+ [self setAutoresizesSubviews:YES];
74
+ [self setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
75
+
76
+ _contentView = [[TouchThroughUIView alloc] initWithFrame:CGRectMake(0,0,self.frame.size.width,self.frame.size.height)];
77
+ [_contentView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
78
+ [self addSubview:_contentView];
79
+ [_contentView setBackgroundColor:[UIColor whiteColor]];
80
+ [_contentView setAutoresizesSubviews:YES];
81
+
82
+ UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(onContentViewPanned:)];
83
+ panGestureRecognizer.delegate = self;
84
+ [_contentView addGestureRecognizer:panGestureRecognizer];
85
+ [panGestureRecognizer setDelegate:self];
86
+
87
+ _state = PaperFoldStateDefault;
88
+ _lastState = _state;
89
+ _enableRightFoldDragging = NO;
90
+ _enableLeftFoldDragging = NO;
91
+ _enableBottomFoldDragging = NO;
92
+ _enableTopFoldDragging = NO;
93
+ _restrictedDraggingRect = CGRectNull;
94
+ _showDividerLines = NO;
95
+ }
96
+
97
+ - (void)setFrame:(CGRect)frame
98
+ {
99
+ [super setFrame:frame];
100
+
101
+ CGRect leftFoldViewFrame = self.leftFoldView.frame;
102
+ leftFoldViewFrame.size.height = frame.size.height;
103
+ [self.leftFoldView setFrame:leftFoldViewFrame];
104
+
105
+ CGRect rightFoldViewFrame = self.rightFoldView.frame;
106
+ rightFoldViewFrame.size.height = frame.size.height;
107
+ [self.rightFoldView setFrame:rightFoldViewFrame];
108
+ }
109
+
110
+ - (void)setCenterContentView:(UIView*)view
111
+ {
112
+ [view setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
113
+ [self.contentView addSubview:view];
114
+ }
115
+
116
+ // this method is deprecated
117
+ - (void)setLeftFoldContentView:(UIView*)view
118
+ {
119
+ [self setLeftFoldContentView:view foldCount:1 pullFactor:0.9];
120
+ }
121
+
122
+ - (void)setLeftFoldContentView:(UIView*)view foldCount:(int)leftViewFoldCount pullFactor:(float)leftViewPullFactor
123
+ {
124
+ if (self.leftFoldView) [self.leftFoldView removeFromSuperview];
125
+ self.leftFoldView = [[MultiFoldView alloc] initWithFrame:CGRectMake(0,0,view.frame.size.width,self.frame.size.height) foldDirection:FoldDirectionHorizontalLeftToRight folds:leftViewFoldCount pullFactor:leftViewPullFactor];
126
+ [self.leftFoldView setDelegate:self];
127
+ [self.leftFoldView setUseOptimizedScreenshot:self.useOptimizedScreenshot];
128
+ [self.leftFoldView setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
129
+ [self insertSubview:self.leftFoldView belowSubview:self.contentView];
130
+ [self.leftFoldView setContent:view];
131
+ [self.leftFoldView setHidden:YES];
132
+ //[self.leftFoldView setAutoresizingMask:UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleHeight];
133
+ //[view setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
134
+ [view setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
135
+
136
+ UIView *line = [[UIView alloc] initWithFrame:CGRectMake(-1,0,1,self.frame.size.height)];
137
+ [line setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
138
+ [self.contentView addSubview:line];
139
+ [line setBackgroundColor:[UIColor colorWithWhite:0.9 alpha:0.5]];
140
+ line.alpha = 0;
141
+ self.leftDividerLine = line;
142
+
143
+ self.enableLeftFoldDragging = YES;
144
+ }
145
+
146
+ - (void)setBottomFoldContentView:(UIView*)view
147
+ {
148
+ if (self.bottomFoldView) [self.bottomFoldView removeFromSuperview];
149
+
150
+ self.bottomFoldView = [[FoldView alloc] initWithFrame:CGRectMake(0,self.frame.size.height-view.frame.size.height,view.frame.size.width,view.frame.size.height) foldDirection:FoldDirectionVertical];
151
+ [self.bottomFoldView setUseOptimizedScreenshot:self.useOptimizedScreenshot];
152
+ [self.bottomFoldView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
153
+ [self insertSubview:self.bottomFoldView belowSubview:self.contentView];
154
+ [self.bottomFoldView setContent:view];
155
+ [self.bottomFoldView setHidden:YES];
156
+ [view setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
157
+
158
+ UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0,self.frame.size.height,self.frame.size.width,1)];
159
+ [line setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
160
+ [self.contentView addSubview:line];
161
+ [line setBackgroundColor:[UIColor colorWithWhite:0.9 alpha:0.5]];
162
+ line.alpha = 0;
163
+ self.bottomDividerLine = line;
164
+
165
+ self.enableBottomFoldDragging = YES;
166
+ }
167
+
168
+ - (void)setRightFoldContentView:(UIView*)view foldCount:(int)rightViewFoldCount pullFactor:(float)rightViewPullFactor
169
+ {
170
+ self.rightFoldView = [[MultiFoldView alloc] initWithFrame:CGRectMake(self.frame.size.width,0,view.frame.size.width,self.frame.size.height) foldDirection:FoldDirectionHorizontalRightToLeft folds:rightViewFoldCount pullFactor:rightViewPullFactor];
171
+ [self.rightFoldView setDelegate:self];
172
+ [self.rightFoldView setUseOptimizedScreenshot:self.useOptimizedScreenshot];
173
+ [self.rightFoldView setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleHeight];
174
+ [self.contentView insertSubview:self.rightFoldView atIndex:0];
175
+ [self.rightFoldView setContent:view];
176
+ [self.rightFoldView setHidden:YES];
177
+ [view setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
178
+
179
+ UIView *line = [[UIView alloc] initWithFrame:CGRectMake(self.contentView.frame.size.width,0,1,self.frame.size.height)];
180
+ [line setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
181
+ [self.contentView addSubview:line];
182
+ [line setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleHeight];
183
+ [line setBackgroundColor:[UIColor colorWithWhite:0.9 alpha:0.5]];
184
+ line.alpha = 0;
185
+ self.rightDividerLine = line;
186
+
187
+ self.enableRightFoldDragging = YES;
188
+ }
189
+
190
+ // this method is deprecated
191
+ - (void)setRightFoldContentView:(UIView*)view rightViewFoldCount:(int)rightViewFoldCount rightViewPullFactor:(float)rightViewPullFactor
192
+ {
193
+ [self setRightFoldContentView:view foldCount:rightViewFoldCount pullFactor:rightViewPullFactor];
194
+ }
195
+
196
+ - (void)setTopFoldContentView:(UIView*)view topViewFoldCount:(int)topViewFoldCount topViewPullFactor:(float)topViewPullFactor
197
+ {
198
+ self.topFoldView = [[MultiFoldView alloc] initWithFrame:CGRectMake(0,-1*view.frame.size.height,view.frame.size.width,view.frame.size.height) foldDirection:FoldDirectionVertical folds:topViewFoldCount pullFactor:topViewPullFactor];
199
+ [self.topFoldView setDelegate:self];
200
+ [self.topFoldView setUseOptimizedScreenshot:self.useOptimizedScreenshot];
201
+ [self.topFoldView setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleHeight];
202
+ [self.contentView insertSubview:self.topFoldView atIndex:0];
203
+ [self.topFoldView setContent:view];
204
+ [self.topFoldView setHidden:YES];
205
+ [view setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
206
+
207
+ UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0,-1,self.contentView.frame.size.width,1)];
208
+ [line setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
209
+ [self.contentView addSubview:line];
210
+ [line setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleHeight];
211
+ [line setBackgroundColor:[UIColor colorWithWhite:0.9 alpha:0.5]];
212
+ line.alpha = 0;
213
+ self.topDividerLine = line;
214
+
215
+ self.enableTopFoldDragging = YES;
216
+ }
217
+
218
+ - (void)onContentViewPanned:(UIPanGestureRecognizer*)gesture
219
+ {
220
+ // cancel gesture if another animation has not finished yet
221
+ if ([self.animationTimer isValid]) return;
222
+
223
+ BOOL isVoiceOverRunning = UIAccessibilityIsVoiceOverRunning();
224
+
225
+ if ([gesture state]==UIGestureRecognizerStateBegan)
226
+ {
227
+ // show the divider while dragging
228
+ [self setShowDividerLines:YES animated:YES];
229
+
230
+ CGPoint velocity = [gesture velocityInView:self];
231
+ if ( abs(velocity.x) > abs(velocity.y))
232
+ {
233
+ if (self.state==PaperFoldStateDefault)
234
+ {
235
+ self.paperFoldInitialPanDirection = PaperFoldInitialPanDirectionHorizontal;
236
+
237
+ if (isVoiceOverRunning)
238
+ {
239
+ if (velocity.x>0)
240
+ {
241
+ [self setPaperFoldState:PaperFoldStateLeftUnfolded animated:YES];
242
+ }
243
+ else if (velocity.x<0)
244
+ {
245
+ [self setPaperFoldState:PaperFoldStateRightUnfolded animated:YES];
246
+ }
247
+ }
248
+ }
249
+ else
250
+ {
251
+ if (isVoiceOverRunning)
252
+ {
253
+ [self setPaperFoldState:PaperFoldStateDefault animated:YES];
254
+ }
255
+ if (self.enableHorizontalEdgeDragging)
256
+ {
257
+ CGPoint location = [gesture locationInView:self.contentView];
258
+ if (location.x < kEdgeScrollWidth || location.x > (self.contentView.frame.size.width-kEdgeScrollWidth))
259
+ {
260
+ self.paperFoldInitialPanDirection = PaperFoldInitialPanDirectionHorizontal;
261
+ }
262
+ else self.paperFoldInitialPanDirection = PaperFoldInitialPanDirectionVertical;
263
+ }
264
+ else self.paperFoldInitialPanDirection = PaperFoldInitialPanDirectionHorizontal;
265
+ }
266
+ }
267
+ else
268
+ {
269
+ if (self.state==PaperFoldStateDefault)
270
+ {
271
+ self.paperFoldInitialPanDirection = PaperFoldInitialPanDirectionVertical;
272
+ }
273
+ }
274
+ }
275
+ else if (!isVoiceOverRunning)
276
+ {
277
+ if (self.paperFoldInitialPanDirection==PaperFoldInitialPanDirectionHorizontal)
278
+ {
279
+ [self onContentViewPannedHorizontally:gesture];
280
+ }
281
+ else
282
+ {
283
+ [self onContentViewPannedVertically:gesture];
284
+ }
285
+
286
+ if (gesture.state != UIGestureRecognizerStateChanged) {
287
+ // hide the divider line
288
+ [self setShowDividerLines:NO animated:YES];
289
+ }
290
+ }
291
+ }
292
+
293
+ - (void)onContentViewPannedVertically:(UIPanGestureRecognizer*)gesture
294
+ {
295
+ [self.rightFoldView setHidden:YES];
296
+ [self.leftFoldView setHidden:YES];
297
+ [self.bottomFoldView setHidden:NO];
298
+ [self.topFoldView setHidden:NO];
299
+
300
+ CGPoint point = [gesture translationInView:self];
301
+ if ([gesture state]==UIGestureRecognizerStateChanged)
302
+ {
303
+ if (_state==PaperFoldStateDefault)
304
+ {
305
+ // animate folding when panned
306
+ [self animateWithContentOffset:point panned:YES];
307
+ }
308
+ else if (_state==PaperFoldStateBottomUnfolded)
309
+ {
310
+ CGPoint adjustedPoint = CGPointMake(point.x, point.y - self.bottomFoldView.frame.size.height);
311
+ [self animateWithContentOffset:adjustedPoint panned:YES];
312
+ }
313
+ else if (_state==PaperFoldStateTopUnfolded)
314
+ {
315
+ CGPoint adjustedPoint = CGPointMake(point.x, point.y + self.topFoldView.frame.size.height);
316
+ [self animateWithContentOffset:adjustedPoint panned:YES];
317
+ }
318
+
319
+ }
320
+ else if ([gesture state]==UIGestureRecognizerStateEnded || [gesture state]==UIGestureRecognizerStateCancelled)
321
+ {
322
+ float y = point.y;
323
+ if (y<=0.0) // offset to the top
324
+ {
325
+ if ( (-y>=kBottomViewUnfoldThreshold*self.bottomFoldView.frame.size.height && _state==PaperFoldStateDefault) || -1*[self.contentView frame].origin.y==self.bottomFoldView.frame.size.height)
326
+ {
327
+ if (self.enableBottomFoldDragging)
328
+ {
329
+ // if offset more than threshold, open fully
330
+ self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(unfoldBottomView:) userInfo:nil repeats:YES];
331
+ return;
332
+ }
333
+ }
334
+
335
+ }
336
+ else if (y>0)
337
+ {
338
+ if ((y>=kTopViewUnfoldThreshold*self.topFoldView.frame.size.height && _state==PaperFoldStateDefault) || [self.contentView frame].origin.y==self.topFoldView.frame.size.height)
339
+ {
340
+ if (self.enableTopFoldDragging)
341
+ {
342
+ // if offset more than threshold, open fully
343
+ self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(unfoldTopView:) userInfo:nil repeats:YES];
344
+ return;
345
+ }
346
+ }
347
+ }
348
+
349
+ // after panning completes
350
+ // if offset does not exceed threshold
351
+ // use NSTimer to create manual animation to restore view
352
+
353
+ //[self setPaperFoldState:PaperFoldStateDefault];
354
+ self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(restoreView:) userInfo:nil repeats:YES];
355
+
356
+
357
+ }
358
+ }
359
+
360
+ - (void)onContentViewPannedHorizontally:(UIPanGestureRecognizer*)gesture
361
+ {
362
+ [self.rightFoldView setHidden:NO];
363
+ [self.leftFoldView setHidden:NO];
364
+ [self.bottomFoldView setHidden:YES];
365
+ [self.topFoldView setHidden:YES];
366
+
367
+ CGPoint point = [gesture translationInView:self];
368
+ if ([gesture state]==UIGestureRecognizerStateChanged)
369
+ {
370
+ if (_state==PaperFoldStateDefault)
371
+ {
372
+ // animate folding when panned
373
+ [self animateWithContentOffset:point panned:YES];
374
+ }
375
+ else if (_state==PaperFoldStateLeftUnfolded)
376
+ {
377
+ CGPoint adjustedPoint = CGPointMake(point.x + self.leftFoldView.frame.size.width, point.y);
378
+ [self animateWithContentOffset:adjustedPoint panned:YES];
379
+ }
380
+ else if (_state==PaperFoldStateRightUnfolded)
381
+ {
382
+ CGPoint adjustedPoint = CGPointMake(point.x - self.rightFoldView.frame.size.width, point.y);
383
+ [self animateWithContentOffset:adjustedPoint panned:YES];
384
+ }
385
+ }
386
+ else if ([gesture state]==UIGestureRecognizerStateEnded || [gesture state]==UIGestureRecognizerStateCancelled)
387
+ {
388
+ float x = point.x;
389
+ if (x>=0.0) // offset to the right
390
+ {
391
+ if ( (x>=kLeftViewUnfoldThreshold*self.leftFoldView.frame.size.width && _state==PaperFoldStateDefault) || [self.contentView frame].origin.x==self.leftFoldView.frame.size.width)
392
+ {
393
+ if (self.enableLeftFoldDragging)
394
+ {
395
+ // if offset more than threshold, open fully
396
+ self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(unfoldLeftView:) userInfo:nil repeats:YES];
397
+ return;
398
+ }
399
+ }
400
+ }
401
+ else if (x<0)
402
+ {
403
+ if ((x<=-kRightViewUnfoldThreshold*self.rightFoldView.frame.size.width && _state==PaperFoldStateDefault) || [self.contentView frame].origin.x==-self.rightFoldView.frame.size.width)
404
+ {
405
+ if (self.enableRightFoldDragging)
406
+ {
407
+ // if offset more than threshold, open fully
408
+ self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(unfoldRightView:) userInfo:nil repeats:YES];
409
+ return;
410
+ }
411
+ }
412
+ }
413
+
414
+ // after panning completes
415
+ // if offset does not exceed threshold
416
+ // use NSTimer to create manual animation to restore view
417
+ self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(restoreView:) userInfo:nil repeats:YES];
418
+
419
+ //self.paperFoldInitialPanDirection = PaperFoldInitialPanDirectionNone;
420
+ }
421
+ }
422
+
423
+ - (void)animateWithContentOffset:(CGPoint)point panned:(BOOL)panned
424
+ {
425
+ if (self.paperFoldInitialPanDirection==PaperFoldInitialPanDirectionHorizontal)
426
+ {
427
+ float x = point.x;
428
+ // if offset to the right, show the left view
429
+ // if offset to the left, show the right multi-fold view
430
+
431
+ if (self.state!=self.lastState) self.lastState = self.state;
432
+
433
+ if (x>0.0)
434
+ {
435
+ if (self.enableLeftFoldDragging || !panned)
436
+ {
437
+ // set the limit of the right offset
438
+ if (x>=self.leftFoldView.frame.size.width)
439
+ {
440
+ if (self.lastState != PaperFoldStateLeftUnfolded) {
441
+ [self finishForState:PaperFoldStateLeftUnfolded];
442
+ }
443
+ self.lastState = self.state;
444
+ self.state = PaperFoldStateLeftUnfolded;
445
+ x = self.leftFoldView.frame.size.width;
446
+ }
447
+ [self.contentView setTransform:CGAffineTransformMakeTranslation(x, 0)];
448
+ //[self.leftFoldView unfoldWithParentOffset:-1*x];
449
+ [self.leftFoldView unfoldWithParentOffset:x];
450
+
451
+ if ([self.delegate respondsToSelector:@selector(paperFoldView:viewDidOffset:)])
452
+ {
453
+ [self.delegate paperFoldView:self viewDidOffset:CGPointMake(x,0)];
454
+ }
455
+ }
456
+ }
457
+ else if (x<0.0)
458
+ {
459
+ if (self.enableRightFoldDragging || !panned)
460
+ {
461
+ // set the limit of the left offset
462
+ // original x value not changed, to be sent to multi-fold view
463
+ float x1 = x;
464
+ if (x1<=-self.rightFoldView.frame.size.width)
465
+ {
466
+ if (self.lastState != PaperFoldStateRightUnfolded) {
467
+ [self finishForState:PaperFoldStateRightUnfolded];
468
+ }
469
+ self.lastState = self.state;
470
+ self.state = PaperFoldStateRightUnfolded;
471
+ x1 = -self.rightFoldView.frame.size.width;
472
+ }
473
+ [self.contentView setTransform:CGAffineTransformMakeTranslation(x1, 0)];
474
+ [self.rightFoldView unfoldWithParentOffset:x];
475
+
476
+ if ([self.delegate respondsToSelector:@selector(paperFoldView:viewDidOffset:)])
477
+ {
478
+ [self.delegate paperFoldView:self viewDidOffset:CGPointMake(x,0)];
479
+ }
480
+ }
481
+ }
482
+ else
483
+ {
484
+ [self.contentView setTransform:CGAffineTransformMakeTranslation(0, 0)];
485
+ [self.leftFoldView unfoldWithParentOffset:-1*x];
486
+ [self.rightFoldView unfoldWithParentOffset:x];
487
+ self.state = PaperFoldStateDefault;
488
+
489
+ if ([self.delegate respondsToSelector:@selector(paperFoldView:viewDidOffset:)])
490
+ {
491
+ [self.delegate paperFoldView:self viewDidOffset:CGPointMake(x,0)];
492
+ }
493
+ }
494
+ }
495
+ else if (self.paperFoldInitialPanDirection==PaperFoldInitialPanDirectionVertical)
496
+ {
497
+ float y = point.y;
498
+ // if offset to the top, show the bottom view
499
+ // if offset to the bottom, show the top multi-fold view
500
+
501
+ if (self.state!=self.lastState) self.lastState = self.state;
502
+
503
+ if (y<0.0)
504
+ {
505
+ if (self.enableBottomFoldDragging || !panned)
506
+ {
507
+ // set the limit of the top offset
508
+ if (-y>=self.bottomFoldView.frame.size.height)
509
+ {
510
+ self.lastState = self.state;
511
+ self.state = PaperFoldStateBottomUnfolded;
512
+ y = -self.bottomFoldView.frame.size.height;
513
+ }
514
+ [self.contentView setTransform:CGAffineTransformMakeTranslation(0, y)];
515
+ [self.bottomFoldView unfoldWithParentOffset:y];
516
+
517
+ if ([self.delegate respondsToSelector:@selector(paperFoldView:viewDidOffset:)])
518
+ {
519
+ [self.delegate paperFoldView:self viewDidOffset:CGPointMake(0,y)];
520
+ }
521
+ }
522
+ }
523
+ else if (y>0.0)
524
+ {
525
+ if (self.enableTopFoldDragging || !panned)
526
+ {
527
+ // set the limit of the bottom offset
528
+ // original y value not changed, to be sent to multi-fold view
529
+ float y1 = y;
530
+ if (y1>=self.topFoldView.frame.size.height)
531
+ {
532
+ self.lastState = self.state;
533
+ self.state = PaperFoldStateTopUnfolded;
534
+ y1 = self.topFoldView.frame.size.height;
535
+ }
536
+ [self.contentView setTransform:CGAffineTransformMakeTranslation(0, y1)];
537
+ [self.topFoldView unfoldWithParentOffset:y];
538
+
539
+ if ([self.delegate respondsToSelector:@selector(paperFoldView:viewDidOffset:)])
540
+ {
541
+ [self.delegate paperFoldView:self viewDidOffset:CGPointMake(0,y)];
542
+ }
543
+ }
544
+ }
545
+ else
546
+ {
547
+
548
+ [self.contentView setTransform:CGAffineTransformMakeTranslation(0, 0)];
549
+ [self.bottomFoldView unfoldWithParentOffset:y];
550
+ [self.topFoldView unfoldWithParentOffset:y];
551
+ self.state = PaperFoldStateDefault;
552
+
553
+ if ([self.delegate respondsToSelector:@selector(paperFoldView:viewDidOffset:)])
554
+ {
555
+ [self.delegate paperFoldView:self viewDidOffset:CGPointMake(0,y)];
556
+ }
557
+ }
558
+ }
559
+
560
+ }
561
+
562
+ - (void)unfoldBottomView:(NSTimer*)timer
563
+ {
564
+ [self.topFoldView setHidden:NO];
565
+ [self.bottomFoldView setHidden:NO];
566
+ [self.leftFoldView setHidden:YES];
567
+ [self.rightFoldView setHidden:YES];
568
+
569
+ self.paperFoldInitialPanDirection=PaperFoldInitialPanDirectionVertical;
570
+
571
+ CGAffineTransform transform = [self.contentView transform];
572
+ float y = transform.ty - (self.bottomFoldView.frame.size.height+transform.ty)/4;
573
+ transform = CGAffineTransformMakeTranslation(0, y);
574
+ [self.contentView setTransform:transform];
575
+
576
+ if (-y>=self.bottomFoldView.frame.size.height-2)
577
+ {
578
+ [timer invalidate];
579
+ transform = CGAffineTransformMakeTranslation(0,-1*self.bottomFoldView.frame.size.height);
580
+ [self.contentView setTransform:transform];
581
+
582
+ if (self.lastState != PaperFoldStateBottomUnfolded) {
583
+ [self finishForState:PaperFoldStateBottomUnfolded];
584
+ }
585
+ }
586
+
587
+ // use the x value to animate folding
588
+ [self animateWithContentOffset:CGPointMake(0, self.contentView.frame.origin.y) panned:NO];
589
+ }
590
+
591
+ // unfold the left view
592
+ - (void)unfoldLeftView:(NSTimer*)timer
593
+ {
594
+ [self.topFoldView setHidden:YES];
595
+ [self.bottomFoldView setHidden:YES];
596
+ [self.leftFoldView setHidden:NO];
597
+ [self.rightFoldView setHidden:NO];
598
+
599
+ CGAffineTransform transform = [self.contentView transform];
600
+ float x = transform.tx + (self.leftFoldView.frame.size.width-transform.tx)/4;
601
+ transform = CGAffineTransformMakeTranslation(x, 0);
602
+ [self.contentView setTransform:transform];
603
+ if (x>=self.leftFoldView.frame.size.width-2)
604
+ {
605
+ [timer invalidate];
606
+ transform = CGAffineTransformMakeTranslation(self.leftFoldView.frame.size.width, 0);
607
+ [self.contentView setTransform:transform];
608
+
609
+ // if (self.lastState!=PaperFoldStateLeftUnfolded && [self.delegate respondsToSelector:@selector(paperFoldView:didFoldAutomatically:toState:)])
610
+ // {
611
+ // [self.delegate paperFoldView:self didFoldAutomatically:self.isAutomatedFolding toState:PaperFoldStateLeftUnfolded];
612
+ // }
613
+ // [self setIsAutomatedFolding:NO];
614
+ }
615
+
616
+ // use the x value to animate folding
617
+ [self animateWithContentOffset:CGPointMake(self.contentView.frame.origin.x, 0) panned:NO];
618
+ }
619
+
620
+ // unfold the top view
621
+ - (void)unfoldTopView:(NSTimer*)timer
622
+ {
623
+ [self.topFoldView setHidden:NO];
624
+ [self.bottomFoldView setHidden:NO];
625
+ [self.leftFoldView setHidden:YES];
626
+ [self.rightFoldView setHidden:YES];
627
+
628
+ self.paperFoldInitialPanDirection=PaperFoldInitialPanDirectionVertical;
629
+
630
+ CGAffineTransform transform = [self.contentView transform];
631
+ float y = transform.ty + (self.topFoldView.frame.size.height-transform.ty)/8;
632
+ transform = CGAffineTransformMakeTranslation(0, y);
633
+ [self.contentView setTransform:transform];
634
+
635
+ if (y>=self.topFoldView.frame.size.height-5)
636
+ {
637
+ [timer invalidate];
638
+ transform = CGAffineTransformMakeTranslation(0,self.topFoldView.frame.size.height);
639
+ [self.contentView setTransform:transform];
640
+
641
+ if (self.lastState != PaperFoldStateTopUnfolded) {
642
+ [self finishForState:PaperFoldStateTopUnfolded];
643
+ }
644
+ }
645
+
646
+ // use the x value to animate folding
647
+ [self animateWithContentOffset:CGPointMake(0,self.contentView.frame.origin.y) panned:NO];
648
+ }
649
+
650
+ // unfold the right view
651
+ - (void)unfoldRightView:(NSTimer*)timer
652
+ {
653
+ [self.topFoldView setHidden:YES];
654
+ [self.bottomFoldView setHidden:YES];
655
+ [self.leftFoldView setHidden:NO];
656
+ [self.rightFoldView setHidden:NO];
657
+
658
+ CGAffineTransform transform = [self.contentView transform];
659
+ float x = transform.tx - (transform.tx+self.rightFoldView.frame.size.width)/8;
660
+ transform = CGAffineTransformMakeTranslation(x, 0);
661
+ [self.contentView setTransform:transform];
662
+
663
+ if (x<=-self.rightFoldView.frame.size.width+5)
664
+ {
665
+ [timer invalidate];
666
+ transform = CGAffineTransformMakeTranslation(-self.rightFoldView.frame.size.width, 0);
667
+ [self.contentView setTransform:transform];
668
+ }
669
+
670
+ // use the x value to animate folding
671
+ [self animateWithContentOffset:CGPointMake(self.contentView.frame.origin.x, 0) panned:NO];
672
+ }
673
+
674
+ // restore contentView back to original position
675
+ - (void)restoreView:(NSTimer*)timer
676
+ {
677
+ if (self.paperFoldInitialPanDirection==PaperFoldInitialPanDirectionHorizontal)
678
+ {
679
+ CGAffineTransform transform = [self.contentView transform];
680
+ // restoring the x position 3/4 of the last x translation
681
+ float x = transform.tx/4*3;
682
+ transform = CGAffineTransformMakeTranslation(x, 0);
683
+ [self.contentView setTransform:transform];
684
+
685
+ // if -5<x<5, stop timer animation
686
+ if ((x>=0 && x<5) || (x<=0 && x>-5))
687
+ {
688
+ [timer invalidate];
689
+ transform = CGAffineTransformMakeTranslation(0, 0);
690
+ [self.contentView setTransform:transform];
691
+ [self animateWithContentOffset:CGPointMake(0, 0) panned:NO];
692
+
693
+ if (self.lastState != PaperFoldStateDefault) {
694
+ [self finishForState:PaperFoldStateDefault];
695
+ }
696
+ self.state = PaperFoldStateDefault;
697
+ }
698
+ else
699
+ {
700
+ // use the x value to animate folding
701
+ [self animateWithContentOffset:CGPointMake(self.contentView.frame.origin.x, 0) panned:NO];
702
+ }
703
+ }
704
+ else if (self.paperFoldInitialPanDirection==PaperFoldInitialPanDirectionVertical)
705
+ {
706
+ CGAffineTransform transform = [self.contentView transform];
707
+ // restoring the y position 3/4 of the last y translation
708
+ float y = transform.ty/4*3;
709
+ transform = CGAffineTransformMakeTranslation(0, y);
710
+ [self.contentView setTransform:transform];
711
+
712
+ // if -5<x<5, stop timer animation
713
+ if ((y>=0 && y<5) || (y<=0 && y>-5))
714
+ {
715
+ [timer invalidate];
716
+ transform = CGAffineTransformMakeTranslation(0, 0);
717
+ [self.contentView setTransform:transform];
718
+ [self animateWithContentOffset:CGPointMake(0, 0) panned:NO];
719
+
720
+ if (self.lastState != PaperFoldStateDefault) {
721
+ [self finishForState:PaperFoldStateDefault];
722
+ }
723
+ self.state = PaperFoldStateDefault;
724
+
725
+ }
726
+ else
727
+ {
728
+ // use the x value to animate folding
729
+ [self animateWithContentOffset:CGPointMake(0,self.contentView.frame.origin.y) panned:NO];
730
+ }
731
+ }
732
+ }
733
+
734
+ - (void)setPaperFoldState:(PaperFoldState)state animated:(BOOL)animated
735
+ {
736
+ if (animated)
737
+ {
738
+ [self setPaperFoldState:state];
739
+ }
740
+ else
741
+ {
742
+ [self.topFoldView setHidden:YES];
743
+ [self.bottomFoldView setHidden:YES];
744
+ [self.leftFoldView setHidden:YES];
745
+ [self.rightFoldView setHidden:YES];
746
+
747
+ if (state==PaperFoldStateDefault)
748
+ {
749
+ CGAffineTransform transform = transform = CGAffineTransformMakeTranslation(0, 0);
750
+ [self.contentView setTransform:transform];
751
+
752
+ if (self.lastState != PaperFoldStateDefault) {
753
+ [self finishForState:PaperFoldStateDefault];
754
+ }
755
+ }
756
+ else if (state==PaperFoldStateLeftUnfolded)
757
+ {
758
+ [self.leftFoldView setHidden:NO];
759
+
760
+ CGAffineTransform transform = CGAffineTransformMakeTranslation(self.leftFoldView.frame.size.width, 0);
761
+ [self.contentView setTransform:transform];
762
+ [self.leftFoldView unfoldWithoutAnimation];
763
+
764
+ if (self.lastState != PaperFoldStateLeftUnfolded) {
765
+ [self finishForState:PaperFoldStateLeftUnfolded];
766
+ }
767
+ }
768
+ else if (state==PaperFoldStateRightUnfolded)
769
+ {
770
+ [self.rightFoldView setHidden:NO];
771
+
772
+ CGAffineTransform transform = CGAffineTransformMakeTranslation(-self.rightFoldView.frame.size.width, 0);
773
+ [self.contentView setTransform:transform];
774
+ [self.rightFoldView unfoldWithoutAnimation];
775
+
776
+ if (self.lastState != PaperFoldStateRightUnfolded) {
777
+ [self finishForState:PaperFoldStateRightUnfolded];
778
+ }
779
+ }
780
+ self.state = state;
781
+ }
782
+ }
783
+
784
+ - (void)setPaperFoldState:(PaperFoldState)state
785
+ {
786
+ [self setIsAutomatedFolding:YES];
787
+ if (state==PaperFoldStateDefault)
788
+ {
789
+ self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(restoreView:) userInfo:nil repeats:YES];
790
+ }
791
+ else if (state==PaperFoldStateLeftUnfolded)
792
+ {
793
+ self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(unfoldLeftView:) userInfo:nil repeats:YES];
794
+ }
795
+ else if (state==PaperFoldStateRightUnfolded)
796
+ {
797
+ self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(unfoldRightView:) userInfo:nil repeats:YES];
798
+ }
799
+ else if (state==PaperFoldStateTopUnfolded)
800
+ {
801
+ self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(unfoldTopView:) userInfo:nil repeats:YES];
802
+ }
803
+ else if (state==PaperFoldStateBottomUnfolded)
804
+ {
805
+ self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(unfoldBottomView:) userInfo:nil repeats:YES];
806
+ }
807
+ }
808
+
809
+ - (void)setPaperFoldState:(PaperFoldState)state
810
+ animated:(BOOL)animated
811
+ completion:(void (^)())completion
812
+ {
813
+ self.completionBlock = completion;
814
+ [self setPaperFoldState:state animated:animated];
815
+ }
816
+
817
+
818
+ - (void)unfoldLeftView
819
+ {
820
+ [self setPaperFoldState:PaperFoldStateLeftUnfolded];
821
+ }
822
+
823
+ - (void)unfoldRightView
824
+ {
825
+ [self setPaperFoldState:PaperFoldStateRightUnfolded];
826
+ }
827
+
828
+ - (void)restoreToCenter
829
+ {
830
+ [self setPaperFoldState:PaperFoldStateDefault];
831
+ }
832
+
833
+ - (void)finishForState:(PaperFoldState)state
834
+ {
835
+ [self setShowDividerLines:NO animated:YES];
836
+
837
+ // we prefer executing the completion block, otherwise we notify the delegate
838
+ if (self.completionBlock != nil) {
839
+ self.completionBlock();
840
+ self.completionBlock = nil;
841
+
842
+ } else if ([self.delegate respondsToSelector:@selector(paperFoldView:didFoldAutomatically:toState:)]) {
843
+ [self.delegate paperFoldView:self
844
+ didFoldAutomatically:self.isAutomatedFolding
845
+ toState:state];
846
+ }
847
+
848
+ // no more animations
849
+ [self setIsAutomatedFolding:NO];
850
+ }
851
+
852
+
853
+
854
+ - (void)setShowDividerLines:(BOOL)showDividerLines
855
+ {
856
+ [self setShowDividerLines:showDividerLines animated:NO];
857
+ }
858
+
859
+ - (void)setShowDividerLines:(BOOL)showDividerLines animated:(BOOL)animated
860
+ {
861
+ if (_showDividerLines == showDividerLines)
862
+ return;
863
+
864
+ _showDividerLines = showDividerLines;
865
+ CGFloat alpha = showDividerLines ? 1 : 0;
866
+ [UIView animateWithDuration:animated ? 0.25 : 0
867
+ animations:
868
+ ^{
869
+ self.leftDividerLine.alpha = alpha;
870
+ self.topDividerLine.alpha = alpha;
871
+ self.rightDividerLine.alpha = alpha;
872
+ self.bottomDividerLine.alpha = alpha;
873
+ }];
874
+ }
875
+
876
+ #pragma mark - MultiFoldView delegate
877
+
878
+ - (CGFloat)displacementOfMultiFoldView:(id)multiFoldView
879
+ {
880
+ if (multiFoldView==self.rightFoldView)
881
+ {
882
+ return [self.contentView frame].origin.x;
883
+ }
884
+ else if (multiFoldView==self.leftFoldView)
885
+ {
886
+ return -1*[self.contentView frame].origin.x;
887
+ }
888
+ else if (multiFoldView==self.topFoldView)
889
+ {
890
+ if ([self.contentView isKindOfClass:[UIScrollView class]])
891
+ {
892
+ return -1*[(UIScrollView*)self.contentView contentOffset].y;
893
+ }
894
+ else
895
+ {
896
+ return self.contentView.frame.origin.y;
897
+ }
898
+ }
899
+ else if (multiFoldView==self.bottomFoldView)
900
+ {
901
+ if ([self.contentView isKindOfClass:[UIScrollView class]])
902
+ {
903
+ return -1*[(UIScrollView*)self.contentView contentOffset].y;
904
+ }
905
+ else
906
+ {
907
+ return self.contentView.frame.origin.y;
908
+ }
909
+ }
910
+ return 0.0;
911
+ }
912
+
913
+ #pragma mark - Gesture recogniser delegate
914
+
915
+ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
916
+ {
917
+ if (self.enableHorizontalEdgeDragging)
918
+ {
919
+ CGPoint location = [gestureRecognizer locationInView:self.contentView];
920
+ if (location.x < kEdgeScrollWidth || location.x > (self.contentView.frame.size.width-kEdgeScrollWidth))
921
+ {
922
+
923
+ return NO;
924
+ }
925
+ else return YES;
926
+ }
927
+ else return NO;
928
+ }
929
+
930
+ - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
931
+ {
932
+ // only allow panning if we didn't restrict it to start at a certain rect
933
+ if (NO == CGRectIsNull(self.restrictedDraggingRect)
934
+ && NO == CGRectContainsPoint(self.restrictedDraggingRect, [gestureRecognizer locationInView:self])) {
935
+ return NO;
936
+ } else {
937
+ return YES;
938
+ }
939
+ }
940
+
941
+ @end