Permalink
Browse files

Add source code for CoconutKit 2.0

  • Loading branch information...
1 parent 031b1be commit 08436d2218fd7b89bb45af6efe375482d92e04de @defagos committed Nov 16, 2012
Showing with 27,506 additions and 3 deletions.
  1. +8 −0 CoconutKit-Prefix.pch
  2. BIN CoconutKit-resources.bundle/ButtonBarArrowLeft.png
  3. BIN CoconutKit-resources.bundle/ButtonBarArrowLeft@2x.png
  4. BIN CoconutKit-resources.bundle/ButtonBarArrowRight.png
  5. BIN CoconutKit-resources.bundle/ButtonBarArrowRight@2x.png
  6. BIN CoconutKit-resources.bundle/ButtonBarRefresh.png
  7. BIN CoconutKit-resources.bundle/ButtonBarRefresh@2x.png
  8. BIN CoconutKit-resources.bundle/CursorDefaultPointer.png
  9. BIN CoconutKit-resources.bundle/HLSWebViewController.nib
  10. BIN CoconutKit-resources.bundle/Info.plist
  11. BIN CoconutKit-resources.bundle/SearchFieldIcon.png
  12. BIN CoconutKit-resources.bundle/SearchFieldIcon@2x.png
  13. BIN CoconutKit-resources.bundle/de.lproj/Localizable.strings
  14. BIN CoconutKit-resources.bundle/en.lproj/Localizable.strings
  15. BIN CoconutKit-resources.bundle/es.lproj/Localizable.strings
  16. BIN CoconutKit-resources.bundle/fr.lproj/Localizable.strings
  17. BIN CoconutKit-resources.bundle/it.lproj/Localizable.strings
  18. BIN CoconutKit-resources.bundle/ja.lproj/Localizable.strings
  19. BIN CoconutKit-resources.bundle/ko.lproj/Localizable.strings
  20. +7 −0 LICENSE
  21. +37 −0 PublicHeaders/CALayer+HLSExtensions.h
  22. +21 −0 PublicHeaders/CAMediaTimingFunction+HLSExtensions.h
  23. +90 −0 PublicHeaders/CoconutKit.h
  24. +106 −0 PublicHeaders/HLSActionSheet.h
  25. +288 −0 PublicHeaders/HLSAnimation.h
  26. +51 −0 PublicHeaders/HLSAnimationStep.h
  27. +25 −0 PublicHeaders/HLSApplicationPreloader.h
  28. +116 −0 PublicHeaders/HLSAssert.h
  29. +46 −0 PublicHeaders/HLSAutorotation.h
  30. +464 −0 PublicHeaders/HLSContainerStack.h
  31. +50 −0 PublicHeaders/HLSConverters.h
  32. +147 −0 PublicHeaders/HLSCursor.h
  33. +64 −0 PublicHeaders/HLSError.h
  34. +98 −0 PublicHeaders/HLSExpandingSearchBar.h
  35. +57 −0 PublicHeaders/HLSFloat.h
  36. +53 −0 PublicHeaders/HLSKeyboardInformation.h
  37. +43 −0 PublicHeaders/HLSLabel.h
  38. +119 −0 PublicHeaders/HLSLayerAnimation.h
  39. +55 −0 PublicHeaders/HLSLayerAnimationStep.h
  40. +97 −0 PublicHeaders/HLSLogger.h
  41. +25 −0 PublicHeaders/HLSManagedObjectCopying.h
  42. +158 −0 PublicHeaders/HLSModelManager.h
  43. +54 −0 PublicHeaders/HLSNibView.h
  44. +128 −0 PublicHeaders/HLSNotifications.h
  45. +19 −0 PublicHeaders/HLSObjectAnimation.h
  46. +80 −0 PublicHeaders/HLSOptionalFeatures.h
  47. +55 −0 PublicHeaders/HLSPlaceholderInsetSegue.h
  48. +229 −0 PublicHeaders/HLSPlaceholderViewController.h
  49. +31 −0 PublicHeaders/HLSRuntime.h
  50. +146 −0 PublicHeaders/HLSSlideshow.h
  51. +330 −0 PublicHeaders/HLSStackController.h
  52. +50 −0 PublicHeaders/HLSStackPushSegue.h
  53. +19 −0 PublicHeaders/HLSSubtitleTableViewCell.h
  54. +84 −0 PublicHeaders/HLSTableSearchDisplayViewController.h
  55. +107 −0 PublicHeaders/HLSTableViewCell.h
  56. +140 −0 PublicHeaders/HLSTask.h
  57. +149 −0 PublicHeaders/HLSTaskGroup.h
  58. +138 −0 PublicHeaders/HLSTaskManager.h
  59. +42 −0 PublicHeaders/HLSTaskOperation+Protected.h
  60. +41 −0 PublicHeaders/HLSTaskOperation.h
  61. +69 −0 PublicHeaders/HLSTextField.h
  62. +460 −0 PublicHeaders/HLSTransition.h
  63. +28 −0 PublicHeaders/HLSUserInterfaceLock.h
  64. +20 −0 PublicHeaders/HLSValidable.h
  65. +22 −0 PublicHeaders/HLSValidators.h
  66. +19 −0 PublicHeaders/HLSValue1TableViewCell.h
  67. +19 −0 PublicHeaders/HLSValue2TableViewCell.h
  68. +38 −0 PublicHeaders/HLSVector.h
  69. +60 −0 PublicHeaders/HLSViewAnimation.h
  70. +44 −0 PublicHeaders/HLSViewAnimationStep.h
  71. +103 −0 PublicHeaders/HLSViewController.h
  72. +59 −0 PublicHeaders/HLSWebViewController.h
  73. +83 −0 PublicHeaders/HLSWizardViewController.h
  74. +29 −0 PublicHeaders/NSArray+HLSExtensions.h
  75. +70 −0 PublicHeaders/NSBundle+HLSDynamicLocalization.h
  76. +23 −0 PublicHeaders/NSBundle+HLSExtensions.h
  77. +184 −0 PublicHeaders/NSCalendar+HLSExtensions.h
  78. +51 −0 PublicHeaders/NSData+HLSExtensions.h
  79. +19 −0 PublicHeaders/NSDate+HLSExtensions.h
  80. +18 −0 PublicHeaders/NSDateFormatter+HLSExtensions.h
  81. +35 −0 PublicHeaders/NSDictionary+HLSExtensions.h
  82. +38 −0 PublicHeaders/NSError+HLSExtensions.h
  83. +87 −0 PublicHeaders/NSManagedObject+HLSExtensions.h
  84. +131 −0 PublicHeaders/NSManagedObject+HLSValidation.h
  85. +27 −0 PublicHeaders/NSObject+HLSExtensions.h
  86. +118 −0 PublicHeaders/NSString+HLSExtensions.h
  87. +77 −0 PublicHeaders/NSTimeZone+HLSExtensions.h
  88. +18 −0 PublicHeaders/UIActionSheet+HLSExtensions.h
  89. +35 −0 PublicHeaders/UIColor+HLSExtensions.h
  90. +20 −0 PublicHeaders/UIControl+HLSExclusiveTouch.h
  91. +27 −0 PublicHeaders/UIImage+HLSExtensions.h
  92. +75 −0 PublicHeaders/UILabel+HLSDynamicLocalization.h
  93. +16 −0 PublicHeaders/UINavigationBar+HLSExtensions.h
  94. +29 −0 PublicHeaders/UINavigationController+HLSExtensions.h
  95. +16 −0 PublicHeaders/UIPopoverController+HLSExtensions.h
  96. +39 −0 PublicHeaders/UIScrollView+HLSExtensions.h
  97. +28 −0 PublicHeaders/UISplitViewController+HLSExtensions.h
  98. +28 −0 PublicHeaders/UITabBarController+HLSExtensions.h
  99. +16 −0 PublicHeaders/UITextField+HLSExtensions.h
  100. +107 −0 PublicHeaders/UITextField+HLSValidation.h
  101. +16 −0 PublicHeaders/UITextView+HLSExtensions.h
  102. +16 −0 PublicHeaders/UIToolbar+HLSExtensions.h
  103. +30 −0 PublicHeaders/UIView+HLSExtensions.h
  104. +120 −0 PublicHeaders/UIViewController+HLSExtensions.h
  105. +29 −0 PublicHeaders/UIWebView+HLSExtensions.h
  106. +2 −3 README.md
  107. +623 −0 Sources/Animation/HLSAnimation.m
  108. +66 −0 Sources/Animation/HLSAnimationStep+Friend.h
  109. +112 −0 Sources/Animation/HLSAnimationStep+Protected.h
  110. +305 −0 Sources/Animation/HLSAnimationStep.m
  111. +45 −0 Sources/Animation/HLSLayerAnimation+Friend.h
  112. +352 −0 Sources/Animation/HLSLayerAnimation.m
  113. +397 −0 Sources/Animation/HLSLayerAnimationStep.m
  114. +20 −0 Sources/Animation/HLSObjectAnimation+Friend.h
  115. +36 −0 Sources/Animation/HLSObjectAnimation.m
  116. +25 −0 Sources/Animation/HLSViewAnimation+Friend.h
  117. +141 −0 Sources/Animation/HLSViewAnimation.m
  118. +203 −0 Sources/Animation/HLSViewAnimationStep.m
  119. +135 −0 Sources/Core/CALayer+HLSExtensions.m
  120. +47 −0 Sources/Core/CAMediaTimingFunction+HLSExtensions.m
  121. +172 −0 Sources/Core/HLSApplicationPreloader.m
  122. +85 −0 Sources/Core/HLSAssert.m
  123. +170 −0 Sources/Core/HLSConverters.m
  124. +129 −0 Sources/Core/HLSError.m
  125. +73 −0 Sources/Core/HLSFloat.m
  126. +107 −0 Sources/Core/HLSKeyboardInformation.m
  127. +354 −0 Sources/Core/HLSNotifications.m
  128. +36 −0 Sources/Core/HLSRuntime.m
  129. +65 −0 Sources/Core/HLSUserInterfaceLock.m
  130. +35 −0 Sources/Core/HLSValidators.m
  131. +54 −0 Sources/Core/HLSVector.m
  132. +58 −0 Sources/Core/HLSZeroingWeakRef.h
  133. +161 −0 Sources/Core/HLSZeroingWeakRef.m
  134. +60 −0 Sources/Core/NSArray+HLSExtensions.m
  135. +242 −0 Sources/Core/NSBundle+HLSDynamicLocalization.m
  136. +35 −0 Sources/Core/NSBundle+HLSExtensions.m
  137. +470 −0 Sources/Core/NSCalendar+HLSExtensions.m
  138. +72 −0 Sources/Core/NSData+HLSExtensions.m
  139. +74 −0 Sources/Core/NSDate+HLSExtensions.m
  140. +41 −0 Sources/Core/NSDateFormatter+HLSExtensions.m
  141. +46 −0 Sources/Core/NSDictionary+HLSExtensions.m
  142. +64 −0 Sources/Core/NSError+HLSExtensions.m
  143. +21 −0 Sources/Core/NSMutableArray+HLSExtensions.h
  144. +27 −0 Sources/Core/NSMutableArray+HLSExtensions.m
  145. +47 −0 Sources/Core/NSObject+HLSExtensions.m
  146. +16 −0 Sources/Core/NSSet+HLSExtensions.h
  147. +19 −0 Sources/Core/NSSet+HLSExtensions.m
  148. +165 −0 Sources/Core/NSString+HLSExtensions.m
  149. +83 −0 Sources/Core/NSTimeZone+HLSExtensions.m
  150. +13 −0 Sources/Core/NSURLRequest+HLSExtensions.h
  151. +41 −0 Sources/Core/NSURLRequest+HLSExtensions.m
  152. +68 −0 Sources/Core/UIColor+HLSExtensions.m
  153. +63 −0 Sources/Core/UIControl+HLSExclusiveTouch.m
  154. +58 −0 Sources/Core/UIImage+HLSExtensions.m
  155. +58 −0 Sources/CoreData/HLSManagedTextFieldValidator.h
  156. +255 −0 Sources/CoreData/HLSManagedTextFieldValidator.m
  157. +358 −0 Sources/CoreData/HLSModelManager.m
  158. +214 −0 Sources/CoreData/NSManagedObject+HLSExtensions.m
  159. +519 −0 Sources/CoreData/NSManagedObject+HLSValidation.m
  160. +171 −0 Sources/Logging/HLSLogger.m
  161. +40 −0 Sources/Task/HLSTask+Friend.h
  162. +190 −0 Sources/Task/HLSTask.m
  163. +45 −0 Sources/Task/HLSTaskGroup+Friend.h
  164. +370 −0 Sources/Task/HLSTaskGroup.m
  165. +28 −0 Sources/Task/HLSTaskManager+Friend.h
  166. +559 −0 Sources/Task/HLSTaskManager.m
  167. +293 −0 Sources/Task/HLSTaskOperation.m
  168. +27 −0 Sources/View/HLSActionSheet+Friend.h
  169. +246 −0 Sources/View/HLSActionSheet.m
  170. +598 −0 Sources/View/HLSCursor.m
  171. +481 −0 Sources/View/HLSExpandingSearchBar.m
  172. +93 −0 Sources/View/HLSLabel.m
  173. +62 −0 Sources/View/HLSLabelLocalizationInfo.h
  174. +276 −0 Sources/View/HLSLabelLocalizationInfo.m
  175. +91 −0 Sources/View/HLSNibView.m
  176. +857 −0 Sources/View/HLSSlideshow.m
  177. +20 −0 Sources/View/HLSSubtitleTableViewCell.m
  178. +17 −0 Sources/View/HLSTableViewCell+Protected.h
  179. +165 −0 Sources/View/HLSTableViewCell.m
  180. +390 −0 Sources/View/HLSTextField.m
  181. +37 −0 Sources/View/HLSTextFieldInternalDelegate.h
  182. +137 −0 Sources/View/HLSTextFieldInternalDelegate.m
  183. +31 −0 Sources/View/HLSTextFieldTouchDetector.h
  184. +75 −0 Sources/View/HLSTextFieldTouchDetector.m
  185. +20 −0 Sources/View/HLSValue1TableViewCell.m
  186. +20 −0 Sources/View/HLSValue2TableViewCell.m
  187. +105 −0 Sources/View/UIActionSheet+HLSExtensions.m
  188. +20 −0 Sources/View/UIBarButtonItem+HLSActionSheet.h
  189. +84 −0 Sources/View/UIBarButtonItem+HLSActionSheet.m
  190. +263 −0 Sources/View/UILabel+HLSDynamicLocalization.m
  191. +132 −0 Sources/View/UINavigationBar+HLSExtensions.m
  192. +16 −0 Sources/View/UINavigationController+HLSActionSheet.h
  193. +41 −0 Sources/View/UINavigationController+HLSActionSheet.m
  194. +145 −0 Sources/View/UIScrollView+HLSExtensions.m
  195. +58 −0 Sources/View/UITextField+HLSExtensions.m
  196. +219 −0 Sources/View/UITextField+HLSValidation.m
  197. +65 −0 Sources/View/UITextView+HLSExtensions.m
  198. +62 −0 Sources/View/UIToolbar+HLSExtensions.m
  199. +47 −0 Sources/View/UIView+HLSExtensions.m
  200. +98 −0 Sources/View/UIWebView+HLSExtensions.m
  201. +28 −0 Sources/ViewControllers/HLSAutorotationCompatibility.h
  202. +179 −0 Sources/ViewControllers/HLSContainerContent.h
  203. +592 −0 Sources/ViewControllers/HLSContainerContent.m
  204. +58 −0 Sources/ViewControllers/HLSContainerGroupView.h
  205. +122 −0 Sources/ViewControllers/HLSContainerGroupView.m
  206. +1,213 −0 Sources/ViewControllers/HLSContainerStack.m
  207. +146 −0 Sources/ViewControllers/HLSContainerStackView.h
  208. +149 −0 Sources/ViewControllers/HLSContainerStackView.m
  209. +81 −0 Sources/ViewControllers/HLSPlaceholderInsetSegue.m
  210. +437 −0 Sources/ViewControllers/HLSPlaceholderViewController.m
  211. +449 −0 Sources/ViewControllers/HLSStackController.m
  212. +76 −0 Sources/ViewControllers/HLSStackPushSegue.m
  213. +208 −0 Sources/ViewControllers/HLSTableSearchDisplayViewController.m
  214. +1,425 −0 Sources/ViewControllers/HLSTransition.m
  215. +224 −0 Sources/ViewControllers/HLSViewController.m
  216. +297 −0 Sources/ViewControllers/HLSWebViewController.m
  217. +305 −0 Sources/ViewControllers/HLSWizardViewController.m
  218. +166 −0 Sources/ViewControllers/UINavigationController+HLSExtensions.m
  219. +88 −0 Sources/ViewControllers/UIPopoverController+HLSExtensions.m
  220. +147 −0 Sources/ViewControllers/UISplitViewController+HLSExtensions.m
  221. +147 −0 Sources/ViewControllers/UITabBarController+HLSExtensions.m
  222. +475 −0 Sources/ViewControllers/UIViewController+HLSExtensions.m
View
@@ -0,0 +1,8 @@
+#ifdef __OBJC__
+ #import <Foundation/Foundation.h>
+ #import <CoreData/CoreData.h>
+ #import <CoreGraphics/CoreGraphics.h>
+ #import <QuartzCore/QuartzCore.h>
+ #import <UIKit/UIKit.h>
+ #import <MessageUI/MessageUI.h>
+#endif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
@@ -0,0 +1,7 @@
+Copyright (c) 2011-2012 hortis le studio, Samuel Défago
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,37 @@
+//
+// CALayer+HLSExtensions.h
+// CoconutKit
+//
+// Created by Samuel Défago on 8/23/12.
+// Copyright (c) 2012 Hortis. All rights reserved.
+//
+
+@interface CALayer (HLSExtensions)
+
+/**
+ * This method removes all animations added to a CALayer and to all layers in its sublayer hierarchy
+ * (the usual -removeAllAnimations only removes the animations attached to a layer, not to its sublayers)
+ */
+- (void)removeAllAnimationsRecursively;
+
+/**
+ * Pause all animations attached to a layer. Does nothing if the layer was already paused
+ */
+- (void)pauseAllAnimations;
+
+/**
+ * Resume animations attached to a layer. Does nothing if the layer was not paused
+ */
+- (void)resumeAllAnimations;
+
+/**
+ * Return YES iff layer animations have been paused
+ */
+- (BOOL)isPaused;
+
+/**
+ * Return the layer and all its sublayers flattened as a UIImage
+ */
+- (UIImage *)flattenedImage;
+
+@end
@@ -0,0 +1,21 @@
+//
+// CAMediaTimingFunction+HLSExtensions.h
+// CoconutKit
+//
+// Created by Samuel Défago on 8/23/12.
+// Copyright (c) 2012 Hortis. All rights reserved.
+//
+
+@interface CAMediaTimingFunction (HLSExtensions)
+
+/**
+ * Return the inverse function, i.e. the one which must be played when playing an animation backwards
+ */
+- (CAMediaTimingFunction *)inverseFunction;
+
+/**
+ * Return the control points as a human-readable string
+ */
+- (NSString *)controlPointsString;
+
+@end
View
@@ -0,0 +1,90 @@
+ #import <Foundation/Foundation.h>
+ #import <CoreData/CoreData.h>
+ #import <CoreGraphics/CoreGraphics.h>
+ #import <QuartzCore/QuartzCore.h>
+ #import <UIKit/UIKit.h>
+ #import <MessageUI/MessageUI.h>
+#import "CALayer+HLSExtensions.h"
+#import "CAMediaTimingFunction+HLSExtensions.h"
+#import "HLSActionSheet.h"
+#import "HLSAnimation.h"
+#import "HLSAnimationStep.h"
+#import "HLSApplicationPreloader.h"
+#import "HLSAssert.h"
+#import "HLSAutorotation.h"
+#import "HLSContainerStack.h"
+#import "HLSConverters.h"
+#import "HLSCursor.h"
+#import "HLSError.h"
+#import "HLSExpandingSearchBar.h"
+#import "HLSFloat.h"
+#import "HLSKeyboardInformation.h"
+#import "HLSLabel.h"
+#import "HLSLayerAnimation.h"
+#import "HLSLayerAnimationStep.h"
+#import "HLSLogger.h"
+#import "HLSManagedObjectCopying.h"
+#import "HLSModelManager.h"
+#import "HLSNibView.h"
+#import "HLSNotifications.h"
+#import "HLSObjectAnimation.h"
+#import "HLSOptionalFeatures.h"
+#import "HLSPlaceholderInsetSegue.h"
+#import "HLSPlaceholderViewController.h"
+#import "HLSRuntime.h"
+#import "HLSSlideshow.h"
+#import "HLSStackController.h"
+#import "HLSStackPushSegue.h"
+#import "HLSSubtitleTableViewCell.h"
+#import "HLSTableSearchDisplayViewController.h"
+#import "HLSTableViewCell.h"
+#import "HLSTask.h"
+#import "HLSTaskGroup.h"
+#import "HLSTaskManager.h"
+#import "HLSTaskOperation.h"
+#import "HLSTaskOperation+Protected.h"
+#import "HLSTextField.h"
+#import "HLSTransition.h"
+#import "HLSUserInterfaceLock.h"
+#import "HLSValidable.h"
+#import "HLSValidators.h"
+#import "HLSValue1TableViewCell.h"
+#import "HLSValue2TableViewCell.h"
+#import "HLSVector.h"
+#import "HLSViewAnimation.h"
+#import "HLSViewAnimationStep.h"
+#import "HLSViewController.h"
+#import "HLSWebViewController.h"
+#import "HLSWizardViewController.h"
+#import "NSArray+HLSExtensions.h"
+#import "NSBundle+HLSExtensions.h"
+#import "NSBundle+HLSDynamicLocalization.h"
+#import "NSCalendar+HLSExtensions.h"
+#import "NSData+HLSExtensions.h"
+#import "NSDate+HLSExtensions.h"
+#import "NSDateFormatter+HLSExtensions.h"
+#import "NSDictionary+HLSExtensions.h"
+#import "NSError+HLSExtensions.h"
+#import "NSManagedObject+HLSExtensions.h"
+#import "NSManagedObject+HLSValidation.h"
+#import "NSObject+HLSExtensions.h"
+#import "NSString+HLSExtensions.h"
+#import "NSTimeZone+HLSExtensions.h"
+#import "UIActionSheet+HLSExtensions.h"
+#import "UIColor+HLSExtensions.h"
+#import "UIControl+HLSExclusiveTouch.h"
+#import "UIImage+HLSExtensions.h"
+#import "UILabel+HLSDynamicLocalization.h"
+#import "UINavigationBar+HLSExtensions.h"
+#import "UINavigationController+HLSExtensions.h"
+#import "UIPopoverController+HLSExtensions.h"
+#import "UIScrollView+HLSExtensions.h"
+#import "UISplitViewController+HLSExtensions.h"
+#import "UITabBarController+HLSExtensions.h"
+#import "UITextField+HLSExtensions.h"
+#import "UITextField+HLSValidation.h"
+#import "UITextView+HLSExtensions.h"
+#import "UIToolbar+HLSExtensions.h"
+#import "UIView+HLSExtensions.h"
+#import "UIViewController+HLSExtensions.h"
+#import "UIWebView+HLSExtensions.h"
@@ -0,0 +1,106 @@
+//
+// HLSActionSheet.h
+// CoconutKit
+//
+// Created by Samuel Défago on 24.08.11.
+// Copyright 2011 Hortis. All rights reserved.
+//
+
+/**
+ * The built-in UIActionSheet is rather inconvenient when action buttons are enabled or not depending on
+ * some context. Imagine for example a menu letting you take a picture using the camera, or choose one
+ * from your library. If either one is unavailable for some reason, the corresponding option should not
+ * be displayed in the menu. In such cases it is rather inconvenient for the delegate to implement the
+ * -actionSheet:clickedButtonAtIndex: protocol method, since the index it receives does not always correspond
+ * to the same action depending on which actions buttons were actually available.
+ *
+ * Moreover, UIActionSheet has a strange behavior on the iPad: When an action sheet is shown, it usually
+ * can be dismissed when the user taps outside it. The only exception is when the action sheet is shown
+ * from a bar button item: In such cases, all toolbar buttons (in the same toolbar) remain active, including
+ * of course the one which shows the action sheet. Tapping outside an action sheet therefore does not
+ * dismiss it if the tap occurs in the same toolbar which the button showing it belongs to. In such cases,
+ * additional code has to be written by clients so that the behavior stays correct, which means:
+ * - avoiding the user to be able to stack up action sheets by repeatedly tapping the same bar button item
+ * - tapping a bar button while another one is displaying an action sheet must dismiss the action sheet
+ * - dismissing the action sheet when navigating back in a navigation controller
+ *
+ * The HLSActionSheet class solves all the above issues. When creating an action sheet, you add buttons to
+ * it, attaching targets and actions as you would for a button. This makes it easy to keep your code well
+ * organized. Moreover, correct behavior with bar buttons is ensured.
+ *
+ * To create and display an HLSActionSheet object, proceed as follows:
+ * - initialize the object using the -init method (the designated intializer inherited from
+ * UIActionSheet cannot be used anymore)
+ * - further customize the action sheet using the properties inherited from UIActionSheet (if
+ * needed). The destructiveButtonIndex and cancelButtonIndex properties have been overridden
+ * and do nothing anymore
+ * - add the buttons in the order you want them displayed on screen, using the add... methods
+ * Then display the HLSActionSheet using the -show... methods inherited from UIActionSheet.
+ *
+ * Wherever you used a UIActionSheet, you can replace it with an HLSActionSheet with little effort.
+ * HLSActionSheet is not strictly a drop-in replacement for UIActionSheet, but almost. In general,
+ * all you have to do is replacing the
+ * -initWithTitle:delegate:cancelButtonTitle:destructiveButtonTitle:otherButtonTitles:
+ * call used to initialize a UIActionSheet with a call to init, followed by calls to the three
+ * add methods of HLSActionSheet.
+ *
+ * Remarks:
+ * - You can still have a delegate if you want. It will catch the exact same events as if you had used
+ * a built-in UIActionSheet. This is useful for menus letting you choose a value from a set of elements
+ * (e.g. a set of languages given by the system)
+ * - iPad: If you tap outside the pop-up, the protocol methods
+ * -actionSheet:clickedButtonAtIndex:
+ * -actionSheet:willDismissWithButtonIndex:
+ * -actionSheet:didDismissWithButtonIndex:
+ * are called, each one receiving -1 as button index. This is the same as for UIActionSheet, but I
+ * found it useful to have it documented somewhere.
+ *
+ * Designated initializer: -init
+ */
+@interface HLSActionSheet : UIActionSheet {
+@private
+ NSArray *m_targets;
+ NSArray *m_actions;
+ id<UIActionSheetDelegate> m_realDelegate;
+}
+
+/**
+ * Add a standard button at the end of the current button list, with a specific target and action.
+ * The index of the added button is returned. Target and option are optional.
+ * Only one such button can be added, the function returns the index of the existing one if called
+ * more than once.
+ *
+ * The signature of action must be - (void)methodName:(id)sender (sender is the action sheet)
+ * or - (void)methodName
+ *
+ * This method does nothing on the iPad
+ */
+- (NSInteger)addCancelButtonWithTitle:(NSString *)cancelButtonTitle
+ target:(id)target
+ action:(SEL)action;
+
+/**
+ * Add a destructive button at the end of the current button list, with a specific target and action.
+ * The index of the added button is returned. Target and option are optional.
+ * Only one such button can be added, the function returns the index of the existing one if called
+ * more than once.
+ *
+ * The signature of action must be - (void)methodName:(id)sender (sender is the action sheet)
+ * or - (void)methodName
+ */
+- (NSInteger)addDestructiveButtonWithTitle:(NSString *)destructiveButtonTitle
+ target:(id)target
+ action:(SEL)action;
+
+/**
+ * Add a standard button at the end of the current button list, with a specific target and action.
+ * The index of the added button is returned. Target and option are optional.
+ *
+ * The signature of action must be - (void)methodName:(id)sender (sender is the action sheet)
+ * or - (void)methodName
+ */
+- (NSInteger)addButtonWithTitle:(NSString *)title
+ target:(id)target
+ action:(SEL)action;
+
+@end
Oops, something went wrong.

0 comments on commit 08436d2

Please sign in to comment.