项目作者: omaralbeik

项目描述 :
A µFramework for showing alerts like the one used when copying from pasteboard or connecting Apple pencil
高级语言: Swift
项目地址: git://github.com/omaralbeik/Drops.git
创建时间: 2021-04-27T08:52:16Z
项目社区:https://github.com/omaralbeik/Drops

开源协议:MIT License

下载


Drops 💧

A µFramework for showing alerts like the one used when copying from pasteboard or connecting Apple pencil.

Demo


CI
codecov

Features

  • iOS 13+
  • Can be used in SwiftUI and UIKit applications
  • Light/Dark modes
  • Interactive dismissal
  • Queue to show consecutive drops
  • Support dynamic font sizing
  • Support announcing title and subtitle via VoiceOver
  • Show from top or bottom of screen

Usage

  1. Create a drop:
  1. let drop: Drop = "Title Only"
  1. let drop = Drop(title: "Title Only")
  1. let drop = Drop(title: "Title", subtitle: "Subtitle")
  1. let drop = Drop(title: "Title", subtitle: "Subtitle", duration: 5.0)
  1. let drop = Drop(
  2. title: "Title",
  3. subtitle: "Subtitle",
  4. icon: UIImage(systemName: "star.fill"),
  5. action: .init {
  6. print("Drop tapped")
  7. Drops.hideCurrent()
  8. },
  9. position: .bottom,
  10. duration: 5.0,
  11. accessibility: "Alert: Title, Subtitle"
  12. )
  1. Show it:
  1. Drops.show("Title")
  1. Drops.show(drop)
SwiftUI
  1. import SwiftUI
  2. import Drops
  3. struct ContentView: View {
  4. var body: some View {
  5. Button("Show Drop") {
  6. Drops.show(drop)
  7. }
  8. }
  9. }
UIKit
  1. import UIKit
  2. import Drops
  3. class ViewController: UIViewController {
  4. let drops = Drops(delayBetweenDrops: 1.0)
  5. func showDrop() {
  6. drops.show(drop)
  7. }
  8. }

Read the docs for more usage options.


Example Projects

  • Run the SwiftUIExample target to see how Drops works in SwiftUI applications.
  • Run the UIKitExample target to see how Drops works in UIKit applications.

Example


Installation

Swift Package Manager

The Swift Package Manager is a tool for managing the distribution of Swift code.

  1. Add the following to your Package.swift file:
  1. dependencies: [
  2. .package(url: "https://github.com/omaralbeik/Drops.git", from: "1.7.0")
  3. ]
  1. Build your project:
  1. $ swift build

CocoaPods

To integrate Drops into your Xcode project using CocoaPods, specify it in your Podfile:

  1. pod 'Drops', :git => 'https://github.com/omaralbeik/Drops.git', :tag => '1.7.0'

Carthage

To integrate Drops into your Xcode project using Carthage, specify it in your Cartfile:

  1. github "omaralbeik/Drops" ~> 1.7.0

Manually

Add the Sources folder to your Xcode project.


Thanks

Special thanks to SwiftKickMobile team for creating SwiftMessages, this project was heavily inspired by their work.


License

Drops is released under the MIT license. See LICENSE for more information.