Skip to content

Commit

Permalink
Propagated up the ability to pass in a call back block so that it may be
Browse files Browse the repository at this point in the history
passed in from all methods.
Renamed customTypeString to customTypeName.
Added some showNotificationWithTitle methods to complement existing
showNotificationInViewController methods.
Applied xcode indentation formatting to Rmessage.
  • Loading branch information
Adonis committed Feb 14, 2016
1 parent d33a319 commit 650d0c0
Show file tree
Hide file tree
Showing 6 changed files with 295 additions and 153 deletions.
185 changes: 95 additions & 90 deletions Example/DemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,53 +28,58 @@ - (void)viewDidLoad
- (IBAction)didTapError:(id)sender
{
[RMessage showNotificationWithTitle:NSLocalizedString(@"Something failed", nil)
subtitle:NSLocalizedString(@"The internet connection seems to be down. Please check it!", nil)
type:RMessageTypeError
customTypeString:nil];
subtitle:NSLocalizedString(@"The internet connection seems to be down. Please check it!", nil)
type:RMessageTypeError
customTypeName:nil
callback:nil];
}

- (IBAction)didTapWarning:(id)sender
{
[RMessage showNotificationWithTitle:NSLocalizedString(@"Some random warning", nil)
subtitle:NSLocalizedString(@"Look out! Something is happening there!", nil)
type:RMessageTypeWarning
customTypeString:nil];
subtitle:NSLocalizedString(@"Look out! Something is happening there!", nil)
type:RMessageTypeWarning
customTypeName:nil
callback:nil];
}

- (IBAction)didTapMessage:(id)sender
{
[RMessage showNotificationWithTitle:NSLocalizedString(@"Tell the user something", nil)
subtitle:NSLocalizedString(@"This is some neutral notification!", nil)
type:RMessageTypeNormal
customTypeString:nil];
subtitle:NSLocalizedString(@"This is some neutral notification!", nil)
type:RMessageTypeNormal
customTypeName:nil
callback:nil];
}

- (IBAction)didTapSuccess:(id)sender
{
[RMessage showNotificationWithTitle:NSLocalizedString(@"Success", nil)
subtitle:NSLocalizedString(@"Some task was successfully completed!", nil)
type:RMessageTypeSuccess
customTypeString:nil];
subtitle:NSLocalizedString(@"Some task was successfully completed!", nil)
type:RMessageTypeSuccess
customTypeName:nil
callback:nil];
}

- (IBAction)didTapButton:(id)sender
{
[RMessage showNotificationInViewController:self
title:NSLocalizedString(@"New version available", nil)
subtitle:NSLocalizedString(@"Please update our app. We would be very thankful", nil)
iconImage:nil
type:RMessageTypeNormal
customTypeString:nil
duration:RMessageDurationAutomatic
callback:nil
buttonTitle:NSLocalizedString(@"Update", nil)
buttonCallback:^{
[RMessage showNotificationWithTitle:NSLocalizedString(@"Thanks for updating", nil)
type:RMessageTypeSuccess
customTypeString:nil];
}
atPosition:RMessagePositionTop
canBeDismissedByUser:YES];
title:NSLocalizedString(@"New version available", nil)
subtitle:NSLocalizedString(@"Please update our app. We would be very thankful", nil)
iconImage:nil
type:RMessageTypeNormal
customTypeName:nil
duration:RMessageDurationAutomatic
callback:nil
buttonTitle:NSLocalizedString(@"Update", nil)
buttonCallback:^{
[RMessage showNotificationWithTitle:NSLocalizedString(@"Thanks for updating", nil)
type:RMessageTypeSuccess
customTypeName:nil
callback:nil];
}
atPosition:RMessagePositionTop
canBeDismissedByUser:YES];
}

- (IBAction)didTapToggleNavigationBar:(id)sender
Expand All @@ -97,17 +102,17 @@ - (IBAction)didTapToggleWantsFullscreen:(id)sender
- (IBAction)didTapCustomImage:(id)sender
{
[RMessage showNotificationInViewController:self
title:NSLocalizedString(@"Custom image", nil)
subtitle:NSLocalizedString(@"This uses an image you can define", nil)
iconImage:[UIImage imageNamed:@"NotificationButtonBackground.png"]
type:RMessageTypeNormal
customTypeString:nil
duration:RMessageDurationAutomatic
callback:nil
buttonTitle:nil
buttonCallback:nil
atPosition:RMessagePositionTop
canBeDismissedByUser:YES];
title:NSLocalizedString(@"Custom image", nil)
subtitle:NSLocalizedString(@"This uses an image you can define", nil)
iconImage:[UIImage imageNamed:@"NotificationButtonBackground.png"]
type:RMessageTypeNormal
customTypeName:nil
duration:RMessageDurationAutomatic
callback:nil
buttonTitle:nil
buttonCallback:nil
atPosition:RMessagePositionTop
canBeDismissedByUser:YES];
}

- (IBAction)didTapDismissCurrentMessage:(id)sender
Expand All @@ -118,67 +123,69 @@ - (IBAction)didTapDismissCurrentMessage:(id)sender
- (IBAction)didTapEndless:(id)sender
{
[RMessage showNotificationInViewController:self
title:NSLocalizedString(@"Endless", nil)
subtitle:NSLocalizedString(@"This message can not be dismissed and will not be hidden automatically. Tap the 'Dismiss' button to dismiss the currently shown message", nil)
iconImage:nil
type:RMessageTypeSuccess
customTypeString:nil
duration:RMessageDurationEndless
callback:nil
buttonTitle:nil
buttonCallback:nil
atPosition:RMessagePositionTop
canBeDismissedByUser:NO];
title:NSLocalizedString(@"Endless", nil)
subtitle:NSLocalizedString(@"This message can not be dismissed and will not be hidden automatically. Tap the 'Dismiss' button to dismiss the currently shown message", nil)
iconImage:nil
type:RMessageTypeSuccess
customTypeName:nil
duration:RMessageDurationEndless
callback:nil
buttonTitle:nil
buttonCallback:nil
atPosition:RMessagePositionTop
canBeDismissedByUser:NO];
}

- (IBAction)didTapLong:(id)sender
{
[RMessage showNotificationInViewController:self
title:NSLocalizedString(@"Long", nil)
subtitle:NSLocalizedString(@"This message is displayed 10 seconds instead of the calculated value", nil)
iconImage:nil
type:RMessageTypeWarning
customTypeString:nil
duration:10.0
callback:nil
buttonTitle:nil
buttonCallback:nil
atPosition:RMessagePositionTop
canBeDismissedByUser:YES];
title:NSLocalizedString(@"Long", nil)
subtitle:NSLocalizedString(@"This message is displayed 10 seconds instead of the calculated value", nil)
iconImage:nil
type:RMessageTypeWarning
customTypeName:nil
duration:10.0
callback:nil
buttonTitle:nil
buttonCallback:nil
atPosition:RMessagePositionTop
canBeDismissedByUser:YES];
}

- (IBAction)didTapBottom:(id)sender
{
[RMessage showNotificationInViewController:self
title:NSLocalizedString(@"Hu!", nil)
subtitle:NSLocalizedString(@"I'm down here :)", nil)
iconImage:nil
type:RMessageTypeSuccess
customTypeString:nil
duration:RMessageDurationAutomatic
callback:nil
buttonTitle:nil
buttonCallback:nil
atPosition:RMessagePositionBottom
canBeDismissedByUser:YES];
title:NSLocalizedString(@"Hu!", nil)
subtitle:NSLocalizedString(@"I'm down here :)", nil)
iconImage:nil
type:RMessageTypeSuccess
customTypeName:nil
duration:RMessageDurationAutomatic
callback:nil
buttonTitle:nil
buttonCallback:nil
atPosition:RMessagePositionBottom
canBeDismissedByUser:YES];
}

- (IBAction)didTapText:(id)sender
{
[RMessage showNotificationWithTitle:NSLocalizedString(@"With 'Text' I meant a long text, so here it is", nil)
subtitle:NSLocalizedString(@"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus.At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus", nil)
type:RMessageTypeWarning
customTypeString:nil];
subtitle:NSLocalizedString(@"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus.At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus", nil)
type:RMessageTypeWarning
customTypeName:nil
callback:nil];
}

- (IBAction)didTapCustomDesign:(id)sender
{
// this is an example on how to apply a custom design
[RMessage addDesignsFromFileWithName:@"AlternativeDesigns" inBundle:[NSBundle mainBundle]];
[RMessage showNotificationWithTitle:NSLocalizedString(@"Added custom design file", nil)
subtitle:NSLocalizedString(@"This background is blue while the subtitles are white. Yes this is still an alternate error design :)", nil)
type:RMessageTypeCustom
customTypeString:@"alternate-error"];
subtitle:NSLocalizedString(@"This background is blue while the subtitles are white. Yes this is still an alternate error design :)", nil)
type:RMessageTypeCustom
customTypeName:@"alternate-error"
callback:nil];
}


Expand All @@ -189,21 +196,19 @@ - (IBAction)didTapNavBarOverlay:(id)sender
}

[RMessage showNotificationInViewController:self.navigationController
title:NSLocalizedString(@"Whoa!", nil)
subtitle:NSLocalizedString(@"Over the Navigation Bar!", nil)
iconImage:nil
type:RMessageTypeSuccess
customTypeString:nil
duration:RMessageDurationAutomatic
callback:nil
buttonTitle:nil
buttonCallback:nil
atPosition:RMessagePositionNavBarOverlay
canBeDismissedByUser:YES];
title:NSLocalizedString(@"Whoa!", nil)
subtitle:NSLocalizedString(@"Over the Navigation Bar!", nil)
iconImage:nil
type:RMessageTypeSuccess
customTypeName:nil
duration:RMessageDurationAutomatic
callback:nil
buttonTitle:nil
buttonCallback:nil
atPosition:RMessagePositionNavBarOverlay
canBeDismissedByUser:YES];
}



//- (CGFloat)messageLocationOfMessageView:(RMessageView *)messageView
//{
// return 44.0; // any calculation here
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ To show notifications use the following code:
[RMessage showNotificationWithTitle:@"Your Title"
subtitle:@"A description"
type:RMessageTypeError
customTypeString:nil];
customTypeName:nil
callback:nil];


// Add a button inside the message
Expand All @@ -72,7 +73,7 @@ To show notifications use the following code:
subtitle:@"Please update the app"
image:nil
type:RMessageTypeNormal
customTypeString:nil
customTypeName:nil
duration:RMessageDurationAutomatic
callback:nil
buttonTitle:@"Update"
Expand All @@ -88,7 +89,8 @@ To show notifications use the following code:
[RMessage showNotificationWithTitle:@"Your Title"
subtitle:@"A description"
type:RMessageTypeCustom
customTypeString:@"alternate-error"];
customTypeName:@"alternate-error"
callback:nil];
```
You can define a default view controller in which the notifications should be displayed:
Expand Down Expand Up @@ -141,7 +143,7 @@ The following properties can be set when creating a new notification:
* **type**: The notification type (Message, Warning, Error, Success, Custom)
* **duration**: The duration the notification should be displayed
* **callback**: The block that should be executed, when the user dismissed the message by tapping on it or swiping it to the top.
* **customTypeString**: When using a custom design that you have added specify the key to use from your design, otherwise set to nil if not using a custom design.
* **customTypeName**: When using a custom design that you have added specify the key to use from your design, otherwise set to nil if not using a custom design.

Except the title and the notification type, all of the listed values are optional

Expand Down
Loading

0 comments on commit 650d0c0

Please sign in to comment.