From dc90ac3ffff212cde6d0f785b1fa647009c28bf4 Mon Sep 17 00:00:00 2001 From: Luke Durrant Date: Wed, 10 Dec 2014 17:35:51 +1100 Subject: [PATCH 1/9] First Tag implementation --- Example/TSMessages/TSDemoViewController.m | 11 ++ Pod/Classes/TSMessage.h | 54 +++++++++ Pod/Classes/TSMessage.m | 139 ++++++++++++++++++---- Pod/Classes/TSMessageView.h | 43 +++++-- Pod/Classes/TSMessageView.m | 17 +++ 5 files changed, 230 insertions(+), 34 deletions(-) diff --git a/Example/TSMessages/TSDemoViewController.m b/Example/TSMessages/TSDemoViewController.m index 1460a5ad..3d4d2548 100755 --- a/Example/TSMessages/TSDemoViewController.m +++ b/Example/TSMessages/TSDemoViewController.m @@ -44,6 +44,17 @@ - (IBAction)didTapMessage:(id)sender type:TSMessageNotificationTypeMessage]; } + +- (IBAction)didTapEndlessMessage:(id)sender +{ + [TSMessage showEndlessNotificationWithTag:NSLocalizedString(@"Tell the user something", nil) + subtitle:NSLocalizedString(@"This is some neutral notification it wont disappear unless you tell it to!", nil) + type:TSMessageNotificationTypeMessage + tag:10]; + +} + + - (IBAction)didTapSuccess:(id)sender { [TSMessage showNotificationWithTitle:NSLocalizedString(@"Success", nil) diff --git a/Pod/Classes/TSMessage.h b/Pod/Classes/TSMessage.h index d7f0f46e..2b70c5f1 100755 --- a/Pod/Classes/TSMessage.h +++ b/Pod/Classes/TSMessage.h @@ -89,6 +89,20 @@ typedef NS_ENUM(NSInteger,TSMessageNotificationDuration) { subtitle:(NSString *)subtitle type:(TSMessageNotificationType)type; +/** Shows an endless notification message + @param title The title of the notification view + @param subtitle The text that is displayed underneath the title + @param type The notification type (Message, Warning, Error, Success) + */ ++ (TSMessageView*)showEndlessNotification:(NSString *)title + subtitle:(NSString *)subtitle + type:(TSMessageNotificationType)type; + ++ (TSMessageView*)showEndlessNotificationWithTag:(NSString *)title + subtitle:(NSString *)subtitle + type:(TSMessageNotificationType)type + tag:(NSInteger)tag; + /** Shows a notification message in a specific view controller @param viewController The view controller to show the notification in. You can use +setDefaultViewController: to set the the default one instead @@ -101,6 +115,18 @@ typedef NS_ENUM(NSInteger,TSMessageNotificationDuration) { subtitle:(NSString *)subtitle type:(TSMessageNotificationType)type; +/** Shows an endless notification message in a specific view controller + @param viewController The view controller to show the notification in. + You can use +setDefaultViewController: to set the the default one instead + @param title The title of the notification view + @param subtitle The text that is displayed underneath the title + @param type The notification type (Message, Warning, Error, Success) + */ ++ (TSMessageView*)showEndlessNotificationInViewController:(UIViewController *)viewController + title:(NSString *)title + subtitle:(NSString *)subtitle + type:(TSMessageNotificationType)type; + /** Shows a notification message in a specific view controller with a specific duration @param viewController The view controller to show the notification in. You can use +setDefaultViewController: to set the the default one instead @@ -115,6 +141,7 @@ typedef NS_ENUM(NSInteger,TSMessageNotificationDuration) { type:(TSMessageNotificationType)type duration:(NSTimeInterval)duration; + /** Shows a notification message in a specific view controller with a specific duration @param viewController The view controller to show the notification in. You can use +setDefaultViewController: to set the the default one instead @@ -158,6 +185,33 @@ typedef NS_ENUM(NSInteger,TSMessageNotificationDuration) { atPosition:(TSMessageNotificationPosition)messagePosition canBeDismissedByUser:(BOOL)dismissingEnabled; +/** Shows a notification message with a tag in a specific view controller + @param viewController The view controller to show the notification in. + @param title The title of the notification view + @param subtitle The message that is displayed underneath the title (optional) + @param tag The message that is displayed underneath the title (optional) + @param image A custom icon image (optional) + @param type The notification type (Message, Warning, Error, Success) + @param duration The duration of the notification being displayed + @param callback The block that should be executed, when the user tapped on the message + @param buttonTitle The title for button (optional) + @param buttonCallback The block that should be executed, when the user tapped on the button + @param messagePosition The position of the message on the screen + @param dismissingEnabled Should the message be dismissed when the user taps/swipes it + */ ++ (TSMessageView*)showNotificationWithTagInViewController:(UIViewController *)viewController + title:(NSString *)title + subtitle:(NSString *)subtitle + tag:(NSInteger)tag + image:(UIImage *)image + type:(TSMessageNotificationType)type + duration:(NSTimeInterval)duration + callback:(void (^)())callback + buttonTitle:(NSString *)buttonTitle + buttonCallback:(void (^)())buttonCallback + atPosition:(TSMessageNotificationPosition)messagePosition + canBeDismissedByUser:(BOOL)dismissingEnabled; + /** Fades out the currently displayed notification. If another notification is in the queue, the next one will be displayed automatically @return YES if the currently displayed notification was successfully dismissed. NO if no notification diff --git a/Pod/Classes/TSMessage.m b/Pod/Classes/TSMessage.m index 5c4d530b..939cc36a 100755 --- a/Pod/Classes/TSMessage.m +++ b/Pod/Classes/TSMessage.m @@ -62,6 +62,29 @@ + (void)showNotificationWithTitle:(NSString *)title type:type]; } ++ (TSMessageView*)showEndlessNotification:(NSString *)title + subtitle:(NSString *)subtitle + type:(TSMessageNotificationType)type +{ + return [self showEndlessNotificationInViewController:[self defaultViewController] + title:title + subtitle:subtitle + tag:-1 + type:type]; +} + ++ (TSMessageView*)showEndlessNotificationWithTag:(NSString *)title + subtitle:(NSString *)subtitle + type:(TSMessageNotificationType)type + tag:(NSInteger)tag +{ + return [self showEndlessNotificationInViewController:[self defaultViewController] + title:title + subtitle:subtitle + tag:tag + type:type]; +} + + (void)showNotificationInViewController:(UIViewController *)viewController title:(NSString *)title subtitle:(NSString *)subtitle @@ -119,32 +142,83 @@ + (void)showNotificationInViewController:(UIViewController *)viewController canBeDismissedByUser:YES]; } ++ (TSMessageView*)showEndlessNotificationInViewController:(UIViewController *)viewController + title:(NSString *)title + subtitle:(NSString *)subtitle + tag:(NSInteger)tag + type:(TSMessageNotificationType)type +{ + return [TSMessage showNotificationWithTagInViewController:viewController + title:title + subtitle:subtitle + tag:tag + image:nil + type:type + duration:TSMessageNotificationDurationAutomatic + callback:nil + buttonTitle:nil + buttonCallback:nil + atPosition:TSMessageNotificationPositionTop + canBeDismissedByUser:YES]; + +} + ++ (TSMessageView*)showNotificationWithTagInViewController:(UIViewController *)viewController + title:(NSString *)title + subtitle:(NSString *)subtitle + tag:(NSInteger)tag + image:(UIImage *)image + type:(TSMessageNotificationType)type + duration:(NSTimeInterval)duration + callback:(void (^)())callback + buttonTitle:(NSString *)buttonTitle + buttonCallback:(void (^)())buttonCallback + atPosition:(TSMessageNotificationPosition)messagePosition + canBeDismissedByUser:(BOOL)dismissingEnabled +{ + // Create the TSMessageView + TSMessageView *v = [[TSMessageView alloc] initWithTag:title + subtitle:subtitle + tag:tag + image:image + type:type + duration:duration + inViewController:viewController + callback:callback + buttonTitle:buttonTitle + buttonCallback:buttonCallback + atPosition:messagePosition + canBeDismissedByUser:dismissingEnabled]; + [self prepareNotificationToBeShown:v]; + + return v; +} + (void)showNotificationInViewController:(UIViewController *)viewController - title:(NSString *)title - subtitle:(NSString *)subtitle - image:(UIImage *)image - type:(TSMessageNotificationType)type - duration:(NSTimeInterval)duration - callback:(void (^)())callback - buttonTitle:(NSString *)buttonTitle - buttonCallback:(void (^)())buttonCallback - atPosition:(TSMessageNotificationPosition)messagePosition - canBeDismissedByUser:(BOOL)dismissingEnabled + title:(NSString *)title + subtitle:(NSString *)subtitle + image:(UIImage *)image + type:(TSMessageNotificationType)type + duration:(NSTimeInterval)duration + callback:(void (^)())callback + buttonTitle:(NSString *)buttonTitle + buttonCallback:(void (^)())buttonCallback + atPosition:(TSMessageNotificationPosition)messagePosition + canBeDismissedByUser:(BOOL)dismissingEnabled { - // Create the TSMessageView - TSMessageView *v = [[TSMessageView alloc] initWithTitle:title - subtitle:subtitle - image:image - type:type - duration:duration - inViewController:viewController - callback:callback - buttonTitle:buttonTitle - buttonCallback:buttonCallback - atPosition:messagePosition - canBeDismissedByUser:dismissingEnabled]; - [self prepareNotificationToBeShown:v]; + // Create the TSMessageView + TSMessageView *v = [[TSMessageView alloc] initWithTitle:title + subtitle:subtitle + image:image + type:type + duration:duration + inViewController:viewController + callback:callback + buttonTitle:buttonTitle + buttonCallback:buttonCallback + atPosition:messagePosition + canBeDismissedByUser:dismissingEnabled]; + [self prepareNotificationToBeShown:v]; } @@ -152,7 +226,7 @@ + (void)prepareNotificationToBeShown:(TSMessageView *)messageView { NSString *title = messageView.title; NSString *subtitle = messageView.subtitle; - + for (TSMessageView *n in [TSMessage sharedMessage].messages) { if (([n.title isEqualToString:title] || (!n.title && !title)) && ([n.subtitle isEqualToString:subtitle] || (!n.subtitle && !subtitle))) @@ -160,9 +234,9 @@ + (void)prepareNotificationToBeShown:(TSMessageView *)messageView return; // avoid showing the same messages twice in a row } } - + [[TSMessage sharedMessage].messages addObject:messageView]; - + if (!notificationActive) { [[TSMessage sharedMessage] fadeInCurrentNotification]; @@ -375,6 +449,19 @@ - (void)fadeOutNotification:(TSMessageView *)currentView animationFinishedBlock: }]; } ++ (void)dismissNotificationsWithTag:(NSInteger)tag +{ + NSArray *messages = [TSMessage queuedMessages]; + + for(TSMessageView *messageView in messages) + { + if(messageView.tag == tag) + { + [[TSMessage sharedMessage] fadeOutNotification:messageView]; + } + } +} + + (BOOL)dismissActiveNotification { return [self dismissActiveNotificationWithCompletion:nil]; diff --git a/Pod/Classes/TSMessageView.h b/Pod/Classes/TSMessageView.h index c578e7b2..8c6cade9 100755 --- a/Pod/Classes/TSMessageView.h +++ b/Pod/Classes/TSMessageView.h @@ -34,6 +34,7 @@ /** Is the message currenlty fully displayed? Is set as soon as the message is really fully visible */ @property (nonatomic, assign) BOOL messageIsFullyDisplayed; + /** Inits the notification view. Do not call this from outside this library. @param title The title of the notification view @param subtitle The subtitle of the notification view (optional) @@ -48,15 +49,41 @@ @param dismissingEnabled Should this message be dismissed when the user taps/swipes it? */ - (id)initWithTitle:(NSString *)title - subtitle:(NSString *)subtitle - image:(UIImage *)image - type:(TSMessageNotificationType)notificationType - duration:(CGFloat)duration + subtitle:(NSString *)subtitle + image:(UIImage *)image + type:(TSMessageNotificationType)notificationType + duration:(CGFloat)duration + inViewController:(UIViewController *)viewController + callback:(void (^)())callback + buttonTitle:(NSString *)buttonTitle + buttonCallback:(void (^)())buttonCallback + atPosition:(TSMessageNotificationPosition)position +canBeDismissedByUser:(BOOL)dismissingEnabled; + +/** Inits the notification view. Do not call this from outside this library. + @param title The title of the notification view + @param subtitle The subtitle of the notification view (optional) + @param image A custom icon image (optional) + @param notificationType The type (color) of the notification view + @param duration The duration this notification should be displayed (optional) + @param viewController The view controller this message should be displayed in + @param callback The block that should be executed, when the user tapped on the message + @param buttonTitle The title for button (optional) + @param buttonCallback The block that should be executed, when the user tapped on the button + @param position The position of the message on the screen + @param dismissingEnabled Should this message be dismissed when the user taps/swipes it? + */ +- (id)initWithTag:(NSString *)title + subtitle:(NSString *)subtitle + tag:(NSInteger)tag + image:(UIImage *)image + type:(TSMessageNotificationType)notificationType + duration:(CGFloat)duration inViewController:(UIViewController *)viewController - callback:(void (^)())callback - buttonTitle:(NSString *)buttonTitle - buttonCallback:(void (^)())buttonCallback - atPosition:(TSMessageNotificationPosition)position + callback:(void (^)())callback + buttonTitle:(NSString *)buttonTitle + buttonCallback:(void (^)())buttonCallback + atPosition:(TSMessageNotificationPosition)position canBeDismissedByUser:(BOOL)dismissingEnabled; /** Fades out this notification view */ diff --git a/Pod/Classes/TSMessageView.m b/Pod/Classes/TSMessageView.m index 9214f0bc..79987cf2 100755 --- a/Pod/Classes/TSMessageView.m +++ b/Pod/Classes/TSMessageView.m @@ -100,7 +100,23 @@ - (CGFloat)padding } - (id)initWithTitle:(NSString *)title + subtitle:(NSString *)subtitle + image:(UIImage *)image + type:(TSMessageNotificationType)notificationType + duration:(CGFloat)duration + inViewController:(UIViewController *)viewController + callback:(void (^)())callback + buttonTitle:(NSString *)buttonTitle + buttonCallback:(void (^)())buttonCallback + atPosition:(TSMessageNotificationPosition)position +canBeDismissedByUser:(BOOL)dismissingEnabled +{ + return [self initWithTag:title subtitle:subtitle tag:-1 image:image type:notificationType duration:duration inViewController:viewController callback:callback buttonTitle:buttonTitle buttonCallback:buttonCallback atPosition:position canBeDismissedByUser:dismissingEnabled]; +} + +- (id)initWithTag:(NSString *)title subtitle:(NSString *)subtitle + tag:(NSInteger)tag image:(UIImage *)image type:(TSMessageNotificationType)notificationType duration:(CGFloat)duration @@ -117,6 +133,7 @@ - (id)initWithTitle:(NSString *)title { _title = title; _subtitle = subtitle; + [self setTag:tag]; _buttonTitle = buttonTitle; _duration = duration; _viewController = viewController; From e7e003f965f3201e312dce5f11afff3e1f74dcf9 Mon Sep 17 00:00:00 2001 From: Luke Durrant Date: Wed, 10 Dec 2014 17:43:45 +1100 Subject: [PATCH 2/9] More convient methods --- Pod/Classes/TSMessage.h | 2 +- Pod/Classes/TSMessage.m | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Pod/Classes/TSMessage.h b/Pod/Classes/TSMessage.h index 2b70c5f1..9c8c8d83 100755 --- a/Pod/Classes/TSMessage.h +++ b/Pod/Classes/TSMessage.h @@ -98,7 +98,7 @@ typedef NS_ENUM(NSInteger,TSMessageNotificationDuration) { subtitle:(NSString *)subtitle type:(TSMessageNotificationType)type; -+ (TSMessageView*)showEndlessNotificationWithTag:(NSString *)title ++ (void)showEndlessNotificationWithTag:(NSString *)title subtitle:(NSString *)subtitle type:(TSMessageNotificationType)type tag:(NSInteger)tag; diff --git a/Pod/Classes/TSMessage.m b/Pod/Classes/TSMessage.m index 939cc36a..5466f3be 100755 --- a/Pod/Classes/TSMessage.m +++ b/Pod/Classes/TSMessage.m @@ -72,13 +72,12 @@ + (TSMessageView*)showEndlessNotification:(NSString *)title tag:-1 type:type]; } - -+ (TSMessageView*)showEndlessNotificationWithTag:(NSString *)title ++ (void)showEndlessNotificationWithTag:(NSString *)title subtitle:(NSString *)subtitle type:(TSMessageNotificationType)type tag:(NSInteger)tag { - return [self showEndlessNotificationInViewController:[self defaultViewController] + [self showEndlessNotificationInViewController:[self defaultViewController] title:title subtitle:subtitle tag:tag From 545e0273ab148bbcc3bec2aeb5572a436119f665 Mon Sep 17 00:00:00 2001 From: Luke Durrant Date: Wed, 10 Dec 2014 17:46:58 +1100 Subject: [PATCH 3/9] Dismiss with tag header update --- Pod/Classes/TSMessage.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Pod/Classes/TSMessage.h b/Pod/Classes/TSMessage.h index 9c8c8d83..b3e1407c 100755 --- a/Pod/Classes/TSMessage.h +++ b/Pod/Classes/TSMessage.h @@ -219,6 +219,8 @@ typedef NS_ENUM(NSInteger,TSMessageNotificationDuration) { */ + (BOOL)dismissActiveNotification; ++ (void)dismissNotificationsWithTag:(NSInteger)tag; + /** Fades out the currently displayed notification with a completion block after the animation has finished. If another notification is in the queue, the next one will be displayed automatically @return YES if the currently displayed notification was successfully dismissed. NO if no notification From b270f35cf4023e4d0bc3643a0e4f79fc1514ba1e Mon Sep 17 00:00:00 2001 From: Luke Durrant Date: Wed, 10 Dec 2014 17:56:11 +1100 Subject: [PATCH 4/9] correct duration on endless notification --- Pod/Classes/TSMessage.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pod/Classes/TSMessage.m b/Pod/Classes/TSMessage.m index 5466f3be..c94b5fd5 100755 --- a/Pod/Classes/TSMessage.m +++ b/Pod/Classes/TSMessage.m @@ -153,7 +153,7 @@ + (TSMessageView*)showEndlessNotificationInViewController:(UIViewController *)vi tag:tag image:nil type:type - duration:TSMessageNotificationDurationAutomatic + duration:TSMessageNotificationDurationEndless callback:nil buttonTitle:nil buttonCallback:nil From 858678bbb2ab0d7a293674dc65c4c2044ad9313d Mon Sep 17 00:00:00 2001 From: Luke Durrant Date: Thu, 11 Dec 2014 16:04:52 +1100 Subject: [PATCH 5/9] showEndlessNotification with title --- Pod/Classes/TSMessage.h | 11 ++++++++--- Pod/Classes/TSMessage.m | 25 +++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/Pod/Classes/TSMessage.h b/Pod/Classes/TSMessage.h index b3e1407c..e01c125d 100755 --- a/Pod/Classes/TSMessage.h +++ b/Pod/Classes/TSMessage.h @@ -77,8 +77,9 @@ typedef NS_ENUM(NSInteger,TSMessageNotificationDuration) { @param message The title of the notification view @param type The notification type (Message, Warning, Error, Success) */ -+ (void)showNotificationWithTitle:(NSString *)message - type:(TSMessageNotificationType)type; ++ (void)showNotificationWithTitle:(NSString *)message type:(TSMessageNotificationType)type; + ++(void)showEndlessNotificationWithTitle:(NSString *)message type:(TSMessageNotificationType)type; /** Shows a notification message @param title The title of the notification view @@ -89,12 +90,16 @@ typedef NS_ENUM(NSInteger,TSMessageNotificationDuration) { subtitle:(NSString *)subtitle type:(TSMessageNotificationType)type; ++(void)showEndlessNotification:(NSString *)title + subtitle:(NSString *)subtitle + type:(TSMessageNotificationType)type; + /** Shows an endless notification message @param title The title of the notification view @param subtitle The text that is displayed underneath the title @param type The notification type (Message, Warning, Error, Success) */ -+ (TSMessageView*)showEndlessNotification:(NSString *)title ++(void)showEndlessNotification:(NSString *)title subtitle:(NSString *)subtitle type:(TSMessageNotificationType)type; diff --git a/Pod/Classes/TSMessage.m b/Pod/Classes/TSMessage.m index c94b5fd5..a28f6c67 100755 --- a/Pod/Classes/TSMessage.m +++ b/Pod/Classes/TSMessage.m @@ -52,6 +52,16 @@ + (void)showNotificationWithTitle:(NSString *)title type:type]; } ++ (void)showEndlessNotification:(NSString *)title + type:(TSMessageNotificationType)type +{ + [self showEndlessNotificationInViewController:[self defaultViewController] + title:title + subtitle:nil + tag:-1 + type:type]; +} + + (void)showNotificationWithTitle:(NSString *)title subtitle:(NSString *)subtitle type:(TSMessageNotificationType)type @@ -62,16 +72,17 @@ + (void)showNotificationWithTitle:(NSString *)title type:type]; } -+ (TSMessageView*)showEndlessNotification:(NSString *)title ++(void)showEndlessNotification:(NSString *)title subtitle:(NSString *)subtitle type:(TSMessageNotificationType)type { - return [self showEndlessNotificationInViewController:[self defaultViewController] + [self showEndlessNotificationInViewController:[self defaultViewController] title:title subtitle:subtitle tag:-1 type:type]; } + + (void)showEndlessNotificationWithTag:(NSString *)title subtitle:(NSString *)subtitle type:(TSMessageNotificationType)type @@ -141,6 +152,16 @@ + (void)showNotificationInViewController:(UIViewController *)viewController canBeDismissedByUser:YES]; } + ++ (TSMessageView*)showEndlessNotificationInViewController:(UIViewController *)viewController + title:(NSString *)title + subtitle:(NSString *)subtitle + type:(TSMessageNotificationType)type +{ + return [TSMessage showEndlessNotificationInViewController:viewController title:title subtitle:subtitle tag:-1 type:type]; +} + + + (TSMessageView*)showEndlessNotificationInViewController:(UIViewController *)viewController title:(NSString *)title subtitle:(NSString *)subtitle From 492d432814d340e9b9a427f877689eee4ac488e8 Mon Sep 17 00:00:00 2001 From: Luke Durrant Date: Thu, 11 Dec 2014 16:10:11 +1100 Subject: [PATCH 6/9] + (void)showEndlessNotificationWithTitle:(NSString *)title type:(TSMessageNotificationType)type --- Pod/Classes/TSMessage.h | 7 ++++--- Pod/Classes/TSMessage.m | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Pod/Classes/TSMessage.h b/Pod/Classes/TSMessage.h index e01c125d..4d90b51d 100755 --- a/Pod/Classes/TSMessage.h +++ b/Pod/Classes/TSMessage.h @@ -79,7 +79,8 @@ typedef NS_ENUM(NSInteger,TSMessageNotificationDuration) { */ + (void)showNotificationWithTitle:(NSString *)message type:(TSMessageNotificationType)type; -+(void)showEndlessNotificationWithTitle:(NSString *)message type:(TSMessageNotificationType)type; + ++ (void)showEndlessNotificationWithTitle:(NSString *)message type:(TSMessageNotificationType)type; /** Shows a notification message @param title The title of the notification view @@ -90,7 +91,7 @@ typedef NS_ENUM(NSInteger,TSMessageNotificationDuration) { subtitle:(NSString *)subtitle type:(TSMessageNotificationType)type; -+(void)showEndlessNotification:(NSString *)title ++ (void)showEndlessNotification:(NSString *)title subtitle:(NSString *)subtitle type:(TSMessageNotificationType)type; @@ -103,7 +104,7 @@ typedef NS_ENUM(NSInteger,TSMessageNotificationDuration) { subtitle:(NSString *)subtitle type:(TSMessageNotificationType)type; -+ (void)showEndlessNotificationWithTag:(NSString *)title ++(void)showEndlessNotificationWithTag:(NSString *)title subtitle:(NSString *)subtitle type:(TSMessageNotificationType)type tag:(NSInteger)tag; diff --git a/Pod/Classes/TSMessage.m b/Pod/Classes/TSMessage.m index a28f6c67..9a1aed5a 100755 --- a/Pod/Classes/TSMessage.m +++ b/Pod/Classes/TSMessage.m @@ -52,7 +52,7 @@ + (void)showNotificationWithTitle:(NSString *)title type:type]; } -+ (void)showEndlessNotification:(NSString *)title ++ (void)showEndlessNotificationWithTitle:(NSString *)title type:(TSMessageNotificationType)type { [self showEndlessNotificationInViewController:[self defaultViewController] From 4ce7a786bcc185a4d68c443300bd86eb303be6ab Mon Sep 17 00:00:00 2001 From: Luke Durrant Date: Fri, 15 May 2015 11:13:54 +1000 Subject: [PATCH 7/9] ability to centreIconImage or not --- Pod/Classes/TSMessageView.h | 2 ++ Pod/Classes/TSMessageView.m | 43 +++++++++++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/Pod/Classes/TSMessageView.h b/Pod/Classes/TSMessageView.h index 8c6cade9..f85c76bb 100755 --- a/Pod/Classes/TSMessageView.h +++ b/Pod/Classes/TSMessageView.h @@ -34,6 +34,8 @@ /** Is the message currenlty fully displayed? Is set as soon as the message is really fully visible */ @property (nonatomic, assign) BOOL messageIsFullyDisplayed; +@property (nonatomic, assign) BOOL centerIconImage; + /** Inits the notification view. Do not call this from outside this library. @param title The title of the notification view diff --git a/Pod/Classes/TSMessageView.m b/Pod/Classes/TSMessageView.m index 79987cf2..4888e391 100755 --- a/Pod/Classes/TSMessageView.m +++ b/Pod/Classes/TSMessageView.m @@ -205,10 +205,17 @@ - (id)initWithTag:(NSString *)title UIColor *fontColor = [UIColor colorWithHexString:[current valueForKey:@"textColor"] alpha:1.0]; - - self.textSpaceLeft = 2 * padding; - if (image) self.textSpaceLeft += image.size.width + 2 * padding; - + if(self.centerIconImage) + { + self.textSpaceLeft = 2 * padding; + if (image) self.textSpaceLeft += image.size.width + 2 * padding; + } + else + { + self.textSpaceLeft = padding; + if (image) self.textSpaceLeft += image.size.width + padding; + } + // Set up title label _titleLabel = [[UILabel alloc] init]; [self.titleLabel setText:title]; @@ -259,13 +266,24 @@ - (id)initWithTag:(NSString *)title if (image) { _iconImageView = [[UIImageView alloc] initWithImage:image]; - self.iconImageView.frame = CGRectMake(padding * 2, - padding, + if(self.centerIconImage) + { + self.iconImageView.frame = CGRectMake(padding * 2, + padding, image.size.width, image.size.height); + } + else + { + self.iconImageView.frame = CGRectMake(20, + 18, + image.size.width, + image.size.height); + } + [self addSubview:self.iconImageView]; } - + // Set up button (if set) if ([buttonTitle length]) { @@ -416,11 +434,18 @@ - (CGFloat)updateHeightOfMessageView else { // z-align - self.iconImageView.center = CGPointMake([self.iconImageView center].x, + if(self.centerIconImage) + { + self.iconImageView.center = CGPointMake([self.iconImageView center].x, round(currentHeight / 2.0)); + } + else + { + self.iconImageView.frame = CGRectMake(20, 18, self.frame.size.width, self.frame.size.height); + } } } - + // z-align button self.button.center = CGPointMake([self.button center].x, round(currentHeight / 2.0)); From 041ac1dda163d8476131d1fe6328ba0be7e4da93 Mon Sep 17 00:00:00 2001 From: Luke Durrant Date: Fri, 15 May 2015 11:25:19 +1000 Subject: [PATCH 8/9] don't stretch the image --- Pod/Classes/TSMessageView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pod/Classes/TSMessageView.m b/Pod/Classes/TSMessageView.m index 24a6b06e..41f49ef3 100755 --- a/Pod/Classes/TSMessageView.m +++ b/Pod/Classes/TSMessageView.m @@ -525,7 +525,7 @@ - (CGFloat)updateHeightOfMessageView } else { - self.iconImageView.frame = CGRectMake(20, 18, self.frame.size.width, self.frame.size.height); + self.iconImageView.frame = CGRectMake(20, 18, self.iconImageView.frame.size.width, self.iconImageView.frame.size.height); } } } From 82376f21d9dd693d208e763924088b7a5fa692a3 Mon Sep 17 00:00:00 2001 From: Luke Durrant Date: Fri, 15 May 2015 11:31:37 +1000 Subject: [PATCH 9/9] Min padding keep it inline with title TSMessageViewMinimumPadding --- Pod/Classes/TSMessageView.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Pod/Classes/TSMessageView.m b/Pod/Classes/TSMessageView.m index 41f49ef3..49522181 100755 --- a/Pod/Classes/TSMessageView.m +++ b/Pod/Classes/TSMessageView.m @@ -360,7 +360,7 @@ - (id)initWithTag:(NSString *)title else { self.iconImageView.frame = CGRectMake(20, - 18, + TSMessageViewMinimumPadding, image.size.width, image.size.height); } @@ -525,7 +525,7 @@ - (CGFloat)updateHeightOfMessageView } else { - self.iconImageView.frame = CGRectMake(20, 18, self.iconImageView.frame.size.width, self.iconImageView.frame.size.height); + self.iconImageView.frame = CGRectMake(20, TSMessageViewMinimumPadding, self.iconImageView.frame.size.width, self.iconImageView.frame.size.height); } } }