Git Product home page Git Product logo

notificationview's Introduction

NotificationView

CI Status Version License Platform Swift 5.0

Introduce

You can easily implement iOS Basic Notification screens. There is a default theme and a dark theme. You can attach an image to the Notification screen with only the UIImageView. You can adjust the disappearance time. You can get a delegate or callback for the visible and disappearing states. You can get delegates and callbacks for tap.

Theme Multiple
Custom Duration
Rotate



Screen

- iPhoneSE iPhone8Plus
Vertical demo demo
Horizontal demo demo
- iPhoneX iPad
Vertical demo demo
Horizontal demo demo

Theme

default dark
demo demo

Type

custom1 custom2
demo demo



Requirements

NotificationView written in Swift 5.0. Compatible with iOS 8.0+

Installation

Versioning notes

Version 0.2.1 introduces Swift 5.0 support

Version 0.2.0 introduces Swift 4.2 support

Version 0.1.1 introduces Swift 4.0 support

Cocoapods

NotificationView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'NotificationView'

Swift Package Manager

To integrate NotificationView via SPM into your Xcode 11 project specify it in Project > Swift Packages:

https://github.com/pikachu987/NotificationView

Usage

import NotificationView

DefaultNotification

let notificationView = NotificationView.default
notificationView.title = title
notificationView.subtitle = subtitle
notificationView.body = body
notificationView.image = image
notificationView.show()

MultipleNotification

let notificationView = NotificationView()
notificationView.title = title
notificationView.subtitle = subtitle
notificationView.body = body
notificationView.image = image
notificationView.show()

done!




Property

NotificationView

//Theme for NotificationView. There are dark mode and default mode and custom mode.
notificationView.theme

//The title of the NotificationView.
notificationView.title

//The subtitle of the NotificationView.
notificationView.subtitle

//The body of the NotificationView.
notificationView.body

//The image of the NotificationView.
notificationView.image

//The background color of the NotificationView.
notificationView.backgroundColor

//It is a dictionary that can contain any data.
notificationView.param

//The identifier for the NotificationView.
notificationView.identifier

//The time until the NotificationView is shown and then disappears.
notificationView.hideDuration

//An UIImageView that displays the AppIcon image.
notificationView.iconImageView

//An UILabel that displays the AppName text.
notificationView.appNameLabel

//An UILabel that displays the Date text.
notificationView.dateLabel

//An UILabel that displays the Title text.
notificationView.titleLabel

//An UILabel that displays the Subtitle text.
notificationView.subtitleLabel

//An UILabel that displays the Body text.
notificationView.bodyLabel

//An UIImageView that displays the Image.
notificationView.imageView



Method

NotificationView Show

notificationView.show()

notificationView.show { (state) in
    print("callback: \(state)")
}

notificationView.showAfter(0.1)

notificationView.showAfter(0.1) { (state) in
    print("callback: \(state)")
}

NotificationView Hide

notificationView.hide()

notificationView.hideAfter(0.1)



Delegate

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let notificationView = NotificationView()
        notificationView.delegate = self
    }
}

extension ViewController: NotificationViewDelegate {

    /**
    Called when NotificationView is willAppear.
    - Parameters:
    - notificationView: NotificationView
    */
    func notificationViewWillAppear(_ notificationView: NotificationView) {
        print("delegate: notificationViewWillAppear")
    }

    /**
    Called when NotificationView is didAppear.
    - Parameters:
    - notificationView: NotificationView
    */
    func notificationViewDidAppear(_ notificationView: NotificationView) {
        print("delegate: notificationViewDidAppear")
    }

    /**
    Called when NotificationView is willDisappear.
    - Parameters:
    - notificationView: NotificationView
    */
    func notificationViewWillDisappear(_ notificationView: NotificationView) {
        print("delegate: notificationViewWillDisappear")
    }

    /**
    Called when NotificationView is didDisappear.
    - Parameters:
    - notificationView: NotificationView
    */
    func notificationViewDidDisappear(_ notificationView: NotificationView) {   
        print("delegate: notificationViewDidDisappear")
    }

    /**
    Called when the NotificationView is touched.
    - Parameters:
    - notificationView: NotificationView
    */
    func notificationViewDidTap(_ notificationView: NotificationView) {
        print("delegate: notificationViewDidTap")
    }
}

Custom

let notificationView = NotificationView()
notificationView.title = title
notificationView.subtitle = subtitle
notificationView.body = body
notificationView.image = image

notificationView.theme = .custom
notificationView.backgroundColor = .red
notificationView.appNameLabel.textColor = .blue
notificationView.dateLabel.textColor = .blue
notificationView.titleLabel.textColor = .blue
notificationView.subtitleLabel.textColor = .blue
notificationView.bodyLabel.textColor = .blue

notificationView.show()



Author

pikachu987, [email protected]

License

NotificationView is available under the MIT license. See the LICENSE file for more info.

notificationview's People

Contributors

pikachu987 avatar

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.