master
  1//
  2//  TSMessage.h
  3//  Toursprung
  4//
  5//  Created by Felix Krause on 24.08.12.
  6//  Copyright (c) 2012 Toursprung. All rights reserved.
  7//
  8
  9#import <UIKit/UIKit.h>
 10
 11typedef enum {
 12    TSMessageNotificationTypeMessage = 0,
 13    TSMessageNotificationTypeWarning,
 14    TSMessageNotificationTypeError,
 15    TSMessageNotificationTypeSuccess
 16} TSMessageNotificationType;
 17
 18typedef enum {
 19    TSMessageNotificationPositionTop = 0,
 20    TSMessageNotificationPositionBottom
 21} TSMessageNotificationPosition;
 22
 23/** This enum can be passed to the duration parameter */
 24typedef enum {
 25    TSMessageNotificationDurationAutomatic = 0,
 26    TSMessageNotificationDurationEndless = -1 // The notification is displayed until the user dismissed it or it is dismissed by calling dismissActiveNotification
 27} TSMessageNotificationDuration;
 28
 29
 30@interface TSMessage : NSObject
 31
 32+ (instancetype)sharedMessage;
 33
 34/** Indicates whether a notification is currently active. */
 35+ (BOOL)isNotificationActive;
 36
 37/** Shows a notification message 
 38 @param message The title of the notification view
 39 @param type The notification type (Message, Warning, Error, Success)
 40 */
 41+ (void)showNotificationWithMessage:(NSString *)message
 42                           withType:(TSMessageNotificationType)type;
 43
 44/** Shows a notification message
 45 @param title The title of the notification view
 46 @param message The message that is displayed underneath the title
 47 @param type The notification type (Message, Warning, Error, Success)
 48 */
 49+ (void)showNotificationWithTitle:(NSString *)title
 50                      withMessage:(NSString *)message
 51                         withType:(TSMessageNotificationType)type;
 52
 53/** Shows a notification message in a specific view controller
 54 @param viewController The view controller to show the notification in.
 55 @param title The title of the notification view
 56 @param message The message that is displayed underneath the title
 57 @param type The notification type (Message, Warning, Error, Success)
 58 */
 59+ (void)showNotificationInViewController:(UIViewController *)viewController
 60                               withTitle:(NSString *)title
 61                             withMessage:(NSString *)message
 62                                withType:(TSMessageNotificationType)type;
 63
 64/** Shows a notification message in a specific view controller
 65 @param viewController The view controller to show the notification in.
 66 @param title The title of the notification view
 67 @param message The message that is displayed underneath the title
 68 @param type The notification type (Message, Warning, Error, Success)
 69 @param duration The duration of the notification being displayed
 70 */
 71+ (void)showNotificationInViewController:(UIViewController *)viewController
 72                               withTitle:(NSString *)title
 73                             withMessage:(NSString *)message
 74                                withType:(TSMessageNotificationType)type
 75                            withDuration:(NSTimeInterval)duration;
 76
 77/** Shows a notification message in a specific view controller
 78 @param viewController The view controller to show the notification in.
 79 @param title The title of the notification view
 80 @param message The message that is displayed underneath the title
 81 @param type The notification type (Message, Warning, Error, Success)
 82 @param duration The duration of the notification being displayed
 83 @param callback The block that should be executed, when the user tapped on the message
 84 */
 85+ (void)showNotificationInViewController:(UIViewController *)viewController
 86                               withTitle:(NSString *)title
 87                             withMessage:(NSString *)message
 88                                withType:(TSMessageNotificationType)type
 89                            withDuration:(NSTimeInterval)duration
 90                            withCallback:(void (^)())callback;
 91
 92/** Shows a notification message in a specific view controller
 93 @param viewController The view controller to show the notification in.
 94 @param title The title of the notification view
 95 @param message The message that is displayed underneath the title
 96 @param type The notification type (Message, Warning, Error, Success)
 97 @param duration The duration of the notification being displayed
 98 @param callback The block that should be executed, when the user tapped on the message
 99 @param position The position of the message on the screen
100 */
101+ (void)showNotificationInViewController:(UIViewController *)viewController
102                               withTitle:(NSString *)title
103                             withMessage:(NSString *)message
104                                withType:(TSMessageNotificationType)type
105                            withDuration:(NSTimeInterval)duration
106                            withCallback:(void (^)())callback
107                              atPosition:(TSMessageNotificationPosition)messagePosition;
108
109/** Shows a notification message in a specific view controller
110 @param viewController The view controller to show the notification in.
111 @param title The title of the notification view
112 @param message The message that is displayed underneath the title
113 @param type The notification type (Message, Warning, Error, Success)
114 @param duration The duration of the notification being displayed
115 @param callback The block that should be executed, when the user tapped on the message
116 @param buttonTitle The title for button (optional)
117 @param buttonCallback The block that should be executed, when the user tapped on the button
118 @param position The position of the message on the screen
119 @param dismissingEnabled Should the message be dismissed when the user taps/swipes it
120 */
121+ (void)showNotificationInViewController:(UIViewController *)viewController
122                               withTitle:(NSString *)title
123                             withMessage:(NSString *)message
124                                withType:(TSMessageNotificationType)type
125                            withDuration:(NSTimeInterval)duration
126                            withCallback:(void (^)())callback
127                         withButtonTitle:(NSString *)buttonTitle
128                      withButtonCallback:(void (^)())buttonCallback
129                              atPosition:(TSMessageNotificationPosition)messagePosition
130                     canBeDismisedByUser:(BOOL)dismissingEnabled;
131
132
133/** Fades out the currently displayed notification. If another notification is in the queue,
134 the next one will be displayed automatically 
135 @return YES if the currently displayed notification could be hidden. NO if no notification 
136 was currently displayed.
137 */
138+ (BOOL)dismissActiveNotification;
139
140
141
142/** Shows a predefined error message, that is displayed, when this action requires an internet connection */
143+ (void)showInternetError;
144
145/** Shows a predefined error message, that is displayed, when this action requires location services */
146+ (void)showLocationError;
147
148
149
150
151/** Implement this in subclass to set a default view controller */
152+ (UIViewController *)defaultViewController;
153
154/** Can be implemented differently in subclass. Is used to define the top position from which the notification flies in from */
155+ (CGFloat)navigationbarBottomOfViewController:(UIViewController *)viewController;
156
157@end