Git Product home page Git Product logo

notificationview's Introduction

NotificationView

Easy to use and customizable messages/notifications for iOS applications.

Example

How To Get Started

Carthage

Specify "NotificationView" in your Cartfile:

github "teambition/NotificationView"

Usage

Style

Four default icon styles available, and custom icon is supported certainly.

enum NotificationViewStyle {
    case success
    case error
    case message
    case warning
    case custom(UIImage?)
}

Position

enum NotificationViewPosition {
    case top
    case bottom
    case navBar(UINavigationController)
}

For position navBar, an UINavigationController instance is needed for displaying the notification.

Accessory Type

enum NotificationViewAccessoryType {
    case none
    case disclosureIndicator(() -> ())
    case custom(UIView)
}

For accessory type disclosureIndicator, a disclosure indicator will be displayed in the right side of the notification, which indicates that tapping the notification triggers an action associated with the value of the accessoryType property.

For accessory type custom, the given associated view will be used for the right accessory view of notification.

Show Notification

static func showNotification(at position: NotificationViewPosition = default, style: NotificationViewStyle, title: String?, subtitle: String?, accessoryType: NotificationViewAccessoryType = default) { }

static func showSuccess(at position: NotificationViewPosition = default, title: String?, subtitle: String?, accessoryType: NotificationViewAccessoryType = default) { }

static func showError(at position: NotificationViewPosition = default, title: String?, subtitle: String?, accessoryType: NotificationViewAccessoryType = default) { }

static func showMessage(at position: NotificationViewPosition = default, title: String?, subtitle: String?, accessoryType: NotificationViewAccessoryType = default) { }

static func showWarning(at position: NotificationViewPosition = default, title: String?, subtitle: String?, accessoryType: NotificationViewAccessoryType = default) { }

For position navBar, there is a convenient way to show notification, you can call these functions of UINavigationController:

extension UINavigationController {
    func showNotification(style: NotificationViewStyle, title: String?, subtitle: String?, accessoryType: NotificationViewAccessoryType = default) { }

    func showSuccess(title: String?, subtitle: String?, accessoryType: NotificationViewAccessoryType = default) { }

    func showError(title: String?, subtitle: String?, accessoryType: NotificationViewAccessoryType = default) { }

    func showMessage(title: String?, subtitle: String?, accessoryType: NotificationViewAccessoryType = default) { }

    func showWarning(title: String?, subtitle: String?, accessoryType: NotificationViewAccessoryType = default) { }
}

Implement the delegate if needed

func shouldShowNotificationView(_ notificationView: NotificationView) -> Bool {
    // default is true
}

func willShowNotificationView(_ notificationView: NotificationView) {
    // do something
}

func didShowNotificationView(_ notificationView: NotificationView) {
    // do something
}

func shouldDismissNotificationView(_ notificationView: NotificationView) -> Bool {
    // default is true
}

func willDismissNotificationView(_ notificationView: NotificationView) {
    // do something
}

func didDismissNotificationView(_ notificationView: NotificationView) {
    // do something
}

Minimum Requirement

iOS 8.0

Release Notes

License

NotificationView is released under the MIT license. See LICENSE for details.

More Info

Have a question? Please open an issue!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.