Git Product home page Git Product logo

spalert's Introduction

SPAlert

Popup from Apple Music & Feedback in AppStore. Contains Done, Heart, Error and other presets. Support Dark Mode. I clone Apple's alerts as much as possible. You can find this alerts in AppStore after feedback and after added song to library in Apple Music.

And other

If you like the project, do not forget to put star ★ and follow me on GitHub. To help project, see Сooperation section.

Check example usage in app Debts - Spending tracker for iOS and macOS. You can buy source code this apps in my store for iOS developers:

xcode-shop.com https://github.com/ivanvorobei

Navigate

Requirements

Swift 4.2 & 5.0. Ready for use on iOS 10+

Installation

CocoaPods:

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate SPAlert into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'SPAlert'

Swift Package Manager

The Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

To integrate SPAlert into your Xcode project using Xcode 11, specify it in File > Swift Packages > Add:

https://github.com/ivanvorobei/SPAlert

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate SPAlert into your Xcode project using Carthage, specify it in your Cartfile:

github "ivanvorobei/SPAlert"

Manually

If you prefer not to use any of dependency managers, you can integrate SPAlert into your project manually. Put Source/SPAlert folder in your Xcode project. Make sure to enable Copy items if needed and Create groups.

Quick Start

For best experience, I recommend call alerts by SPAlert. These functions are updated regularly and show as Apple way. I focus on presets:

SPAlert.present(title: "Added to Library", preset: .done)

If you want use custom image, use func:

SPAlert.present(title: "Love", message: "We'll recommend more like this in For You", image: UIImage(named: "Heart")!)

For show simple text message, use:

SPAlert.present(message: "Empty UITextField")

Usage

Sometimes it may require deep customization. In this section, I will show you what you can do.

Duration

To change the time that the SPAlert will be shown, use property duration:

let alertView = SPAlertView(title: "Added to Library", message: nil, preset: SPAlertPreset.done)
alertView.duration = 3
alertView.present()

Dark Mode

Dark Mode no need additional configuration. As soon as the user change the interface to dark, all alerts will appear dark.

For check state of user appearance I am use traitCollection:

if self.traitCollection.userInterfaceStyle == .dark {
    return true
}

It available since iOS 12, for early using always Light Mode.

Layout

Here you can change the sizes and spaces:

alertView.layout.topSpace = 18
alertView.layout.iconHeight = 25

For more properties see class.

Dismiss by Tap

If you click on the alert, it will disappear ahead of time. This can be disabled:

alertView.dismissByTap = false

Haptic

If you use presets, the vibro-response will be start automatically. For customize this, you need set property haptic:

alertView.haptic = .success

For disable haptic, set it to .none.

Corner Radius

I use a corner radius like an Apple. If you need to change it, see the property cornerRadius:

alertView.layer.cornerRadius = 40

Сooperation

The development of this project is completely free. If you can make a contribution, it will help development. Here list of task what need do:

  • Fix mistakes in this Readme and docs. My English so bad. Good create pull request.
  • Add docs in source files. Description of public methods and parametrs.
  • Help me translate my app Debts - Spending tracker for other languages.

License

SPAlert is released under the MIT license. Check LICENSE.md for details.

spalert's People

Contributors

tijme avatar erjanmx avatar leeceny avatar lohenyumnam avatar

Watchers

James Cloos avatar  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.