Skip to content

TDNotificationPanel is a drop in class that displays a notification panel.

License

Notifications You must be signed in to change notification settings

skywinder/TDNotificationPanel

 
 

Repository files navigation

Build Status

TDNotificationPanel

TDNotificationPanel is a drop in class that displays a notification which can contain a title, subtitle, icon, progress bar or activity indicator.

Requirements

TDNotificationPanel has been tested on iOS 6+ and requires ARC. It depends on the following Apple frameworks:

  • Foundation.framework
  • UIKit.framework
  • CoreGraphics.framework

Adding TDNotificationPanel To Your Project

CocoaPods

CocoaPods is the recommended way to add TDNotificationPanel to your project.

  1. Add a pod entry for TDNotificationPanel to your Podfile pod 'TDNotificationPanel', '~> 0.5.1'.
  2. Install the pod(s) by running pod install.
  3. Include TDNotificationPanel wherever you need it with #import "TDNotificationPanel.h".

Source Files

Add the following files located in TDNotificationPanel directory to your project. Then include TDNotificationPanel wherever you need it with #import "TDNotificationPanel.h".

Usage

There are 3 different notification types these are:

  • TDNotificationTypeError
  • TDNotificationTypeMessage
  • TDNotificationTypeSuccess

There are 3 different notification modes these are:

  • TDNotificationModeActivityIndicator
  • TDNotificationModeProgressBar
  • TDNotificationModeText

Please note when using TDNotificationModeActivityIndicator and TDNotificationModeProgressBar the notification type TDNotificationTypeMessage will be used.

To display a notification panel use the following method:

[TDNotificationPanel showNotificationInView:self.view
                                      title:@"Notification Title"
                                   subtitle:@"Notification Subtitle"
                                       type:TDNotificationTypeError
                                       mode:TDNotificationModeText
                                dismissible:YES
                             hideAfterDelay:3];

If you need to run a long task with a progress bar use the following method:

TDNotificationPanel *panel = [[TDNotificationPanel alloc] initWithView:self.view
                                                                 title:@"Posting Message"
                                                              subtitle:nil
                                                                  type:TDNotificationTypeMessage
                                                                  mode:TDNotificationModeProgressBar
                                                           dismissible:NO];
[[self view] addSubview:panel];
[panel show];

[self longRunningTaskWithProgress:^(float)progress {
    [panel setProgress:progress];
} completion:^{
	[panel hideAfterDelay:3];
}];

Completion Handler

A completion handler can be set and will be called when the notification is dismissed.

[TDNotificationPanel showNotificationInView:self.view
                                      title:@"Notification Title"
                                   subtitle:@"Notification Subtitle"
                                       type:TDNotificationTypeError
                                       mode:TDNotificationModeText
                                dismissible:YES
                             hideAfterDelay:3
                          completionHandler:^{
                                     NSLog(@"Completion Handler");
                          ];

Queue

All notifications are added to a queue and displayed sequentially.

[TDNotificationPanel showNotificationInView:self.view
                                      title:@"Notification 1"
                                   subtitle:@"Notification 1 Subtitle"
                                       type:TDNotificationTypeError
                                       mode:TDNotificationModeText
                                dismissible:YES
                             hideAfterDelay:3];
                             
[TDNotificationPanel showNotificationInView:self.view
                                      title:@"Notification 2 Title"
                                   subtitle:@"Notification 2 Subtitle"
                                       type:TDNotificationTypeSuccess
                                       mode:TDNotificationModeText
                                dismissible:YES
                             hideAfterDelay:3];

License

TDNotificationPanel is distributed under the MIT License.

Changelog

Changelog can be viewed here.

About

TDNotificationPanel is a drop in class that displays a notification panel.

Resources

License

Stars

Watchers

Forks

Packages