Giter Club home page Giter Club logo

nativepopup's Introduction

NativePopup

platforms GitHub license Carthage compatible Language: Swift

NativePopup is clone of Apple iOS AppStore review feedback popup.

NativePopup clones native popup's design and behavior(animation and user interaction). And you can use custom image and emoji in addition to bad/good icons.

Compared with Apple original popups.

NativePopup Original
NativePopup Done Original Done
NativePopup Good Original Good

Examples

Good/Bad

Good Bad
good bad

Custom Image/Emoji

Custom Image Emoji
custome image bad

Usage

Very simple to use NativePopup🐢

// Good
NativePopup.show(image: Preset.Feedback.good,
                 title: "Helpful",
                 message: "Thanks for your feedback.")
// Bad
NativePopup.show(image: Preset.Feedback.bad,
                 title: "Not Helpful",
                 message: "Thanks for your feedback.")
// Custom Image
NativePopup.show(image: UIImage(named: "love")!,
                 title: "参考にγͺった",
                 message: "γƒ•γ‚£γƒΌγƒ‰γƒγƒƒγ‚―γ‚’γ‚γ‚ŠγŒγ¨γ†\nγ”γ–γ„γΎγ—γŸγ€‚")
// Emoji
NativePopup.show(image: Character("🐢"),
                 title: "γ‚€γƒƒγƒŒ",
                 message: "η΅΅ζ–‡ε­—ε―ΎεΏœγ—γŸγƒ―γƒ³")
// Title only
NativePopup.show(image: Preset.Feedback.good,
                 title: "Empty Message πŸ—‘",
                 message: nil)
// Custom duration (default duration is 1.5 seconds)
NativePopup.show(image: Character("πŸ”Ÿ"),
                    title: "10 seconds",
                    message: "Long durationπŸ™‡",
                    duration: 10)
// Like Apple Music
NativePopup.show(image: Preset.Feedback.done,
                 title: "Added to Library",
                 message: nil,
                 initialEffectType: .fadeIn)

image accepts ImageConvertible protocol.

public enum Image {
    case image(UIImage)
    case emoji(Character)

    func validate() {
        switch self {
        case .image(let image):
            assert(image.size.width == image.size.height, "Aspect ratio should be 1:1.")
        case .emoji:
            // MEMO: should check?
            break
        }
    }
}

public protocol ImageConvertible {
    var npImage: Image { get }
}

UIImage and Character conforms to ImageConvertible by default.

extension UIImage: ImageConvertible {
    public var npImage: Image { return .image(self) }
}

extension Character: ImageConvertible {
    public var npImage: Image { return .emoji(self) }
}

You can define custom preset image as below.

extension NativePopup {
    public struct Preset {
        private init() {}
        public enum Feedback: String, ImageConvertible {
            case
            good,
            bad

            public var npImage: Image {
                return .image(UIImage.init(nativePopupNamed: "feedback_\(rawValue)"))
            }
        }
    }
}

Image size should be 112 x 112.

Installation

You can install by Carthage or add NativePopup sources manually.

Add this to Cartfile

github "mono0926/NativePopup"
$ carthage update

nativepopup's People

Contributors

mono0926 avatar

Watchers

Denis Murphy 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.