JDStatusBarNotification.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. //
  2. // JDStatusBarNotification.h
  3. //
  4. // Based on KGStatusBar by Kevin Gibbon
  5. //
  6. // Created by Markus Emrich on 10/28/13.
  7. // Copyright 2013 Markus Emrich. All rights reserved.
  8. //
  9. #import <UIKit/UIKit.h>
  10. #import "JDStatusBarStyle.h"
  11. #import "JDStatusBarView.h"
  12. /**
  13. * A block that is used to define the appearance of a notification.
  14. * A JDStatusBarStyle instance defines the notification appeareance.
  15. *
  16. * @param style The current default JDStatusBarStyle instance.
  17. *
  18. * @return The modified JDStatusBarStyle instance.
  19. */
  20. typedef JDStatusBarStyle*(^JDPrepareStyleBlock)(JDStatusBarStyle *style);
  21. /**
  22. * This class is a singletion which is used to present notifications
  23. * on top of the status bar. To present a notification, use one of the
  24. * given class methods.
  25. */
  26. @interface JDStatusBarNotification : NSObject
  27. #pragma mark Presentation
  28. /**
  29. * Show a notification. It won't hide automatically,
  30. * you have to dimiss it on your own.
  31. *
  32. * @param status The message to display
  33. *
  34. * @return The presented notification view for further customization
  35. */
  36. + (JDStatusBarView*)showWithStatus:(NSString *)status;
  37. /**
  38. * Show a notification with a specific style. It won't
  39. * hide automatically, you have to dimiss it on your own.
  40. *
  41. * @param status The message to display
  42. * @param styleName The name of the style. You can use any JDStatusBarStyle constant
  43. * (JDStatusBarStyleDefault, etc.), or a custom style identifier, after you added a
  44. * custom style. If this is nil, the default style will be used.
  45. *
  46. * @return The presented notification view for further customization
  47. */
  48. + (JDStatusBarView*)showWithStatus:(NSString *)status
  49. styleName:(NSString*)styleName;
  50. /**
  51. * Same as showWithStatus:, but the notification will
  52. * automatically dismiss after the given timeInterval.
  53. *
  54. * @param status The message to display
  55. * @param timeInterval The duration, how long the notification
  56. * is displayed. (Including the animation duration)
  57. *
  58. * @return The presented notification view for further customization
  59. */
  60. + (JDStatusBarView*)showWithStatus:(NSString *)status
  61. dismissAfter:(NSTimeInterval)timeInterval;
  62. /**
  63. * Same as showWithStatus:styleName:, but the notification
  64. * will automatically dismiss after the given timeInterval.
  65. *
  66. * @param status The message to display
  67. * @param timeInterval The duration, how long the notification
  68. * is displayed. (Including the animation duration)
  69. * @param styleName The name of the style. You can use any JDStatusBarStyle constant
  70. * (JDStatusBarStyleDefault, etc.), or a custom style identifier, after you added a
  71. * custom style. If this is nil, the default style will be used.
  72. *
  73. * @return The presented notification view for further customization
  74. */
  75. + (JDStatusBarView*)showWithStatus:(NSString *)status
  76. dismissAfter:(NSTimeInterval)timeInterval
  77. styleName:(NSString*)styleName;
  78. #pragma mark Dismissal
  79. /**
  80. * Calls dismissAnimated: with animated set to YES
  81. */
  82. + (void)dismiss;
  83. /**
  84. * Dismisses any currently displayed notification immediately
  85. *
  86. * @param animated If this is YES, the animation style used
  87. * for presentation will also be used for the dismissal.
  88. */
  89. + (void)dismissAnimated:(BOOL)animated;
  90. /**
  91. * Same as dismissAnimated:, but you can specify a delay,
  92. * so the notification wont be dismissed immediately
  93. *
  94. * @param delay The delay, how long the notification should stay visible
  95. */
  96. + (void)dismissAfter:(NSTimeInterval)delay;
  97. #pragma mark Styles
  98. /**
  99. * This changes the default style, which is always used
  100. * when a method without styleName is used for presentation, or
  101. * styleName is nil, or no style is found with this name.
  102. *
  103. * @param prepareBlock A block, which has a JDStatusBarStyle instance as
  104. * parameter. This instance can be modified to suit your needs. You need
  105. * to return the modified style again.
  106. */
  107. + (void)setDefaultStyle:(JDPrepareStyleBlock)prepareBlock;
  108. /**
  109. * Adds a custom style, which than can be used
  110. * in the presentation methods.
  111. *
  112. * @param identifier The identifier, which will
  113. * later be used to reference the configured style.
  114. * @param prepareBlock A block, which has a JDStatusBarStyle instance as
  115. * parameter. This instance can be modified to suit your needs. You need
  116. * to return the modified style again.
  117. *
  118. * @return Returns the given identifier, so it can
  119. * be directly used as styleName parameter.
  120. */
  121. + (NSString*)addStyleNamed:(NSString*)identifier
  122. prepare:(JDPrepareStyleBlock)prepareBlock;
  123. #pragma mark progress & activity
  124. /**
  125. * Show the progress below the label.
  126. *
  127. * @param progress Relative progress from 0.0 to 1.0
  128. */
  129. + (void)showProgress:(CGFloat)progress;
  130. /**
  131. * Shows an activity indicator in front of the notification text
  132. *
  133. * @param show Use this flag to show or hide the activity indicator
  134. * @param style Sets the style of the activity indicator
  135. */
  136. + (void)showActivityIndicator:(BOOL)show
  137. indicatorStyle:(UIActivityIndicatorViewStyle)style;
  138. #pragma mark state
  139. /**
  140. * This method tests, if a notification is currently displayed.
  141. *
  142. * @return YES, if a notification is currently displayed. Otherwise NO.
  143. */
  144. + (BOOL)isVisible;
  145. @end