Skip to content

A SwiftUI library to display Apple Pencil and Pasteboard-like alerts on iOS.

Notifications You must be signed in to change notification settings

sbertix/DropView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Notification


DropView is a SwiftUI-based library to display alerts inspired by the Apple Pencil and pasteboard stock ones.


What are some features I can expect from this library?

  • Dark mode
  • Interactive dismissal
  • Dynamic font sizing
  • Accessibility support
  • Custom positioning (.top, .bottom and .center)

Status

Swift iOS macOS tvOS watchOS
checks GitHub release (latest by date)

You can find all changelogs directly under every release.

What's next?

Milestones and issues are the best way to keep updated with active developement.

Feel free to contribute by sending a pull request. Just remember to refer to our guidelines and Code of Conduct beforehand.

Installation

Swift Package Manager (Xcode 11 and above)

  1. Select File/Swift Packages/Add Package Dependency… from the menu.
  2. Paste https://github.com/sbertix/DropView.git.
  3. Follow the steps.
  4. Add DropView.

Why not CocoaPods, or Carthage, or blank?

Supporting multiple dependency managers makes maintaining a library exponentially more complicated and time consuming.
Furthermore, with the integration of the Swift Package Manager in Xcode 11 and above, we expect the need for alternative solutions to fade quickly.

Usage

DropView allows you to present alerts just like sheets and fullScreenCovers.

Example

import SwiftUI

import DropView

struct DropViewContainer: View {
    /// Whether it's presenting the drop view or not.
    @State var isPresented: Bool = false
    /// The time interval before it auto-dismisses.
    @State var seconds: TimeInterval = 2

    /// The underlying view.
    var body: some View {
        Form {
            Slider(value: $seconds, in: 2...10) { Text("Seconds before it auto-dismisses") }
                .padding(.horizontal)
            
            ControlGroup {
                Button {
                    isPresented = true
                } label: {
                    Text("Present")
                }
                Button(role: .destructive) {
                    isPresented = false
                } label: {
                    Text("Dismiss")
                }
            }
        }
        .drop(isPresented: $isPresented, alignment: .bottom, dismissingAfter: seconds) {
            DropView(
                title: "DropView",
                subtitle: "github.com/sbertix/DropView"
            ) {
                Image(systemName: "hand.wave.fill")
                    .imageScale(.large)
                    .font(.headline)
                    .foregroundColor(.secondary)
            } trailing: {
                Image(systemName: "star.circle.fill")
                    .resizable()
                    .frame(width: 40, height: 40)
                    .foregroundColor(.accentColor)
            }
        }
    }
}

Special thanks

Massive thanks to anyone contributing to omaralbeik/Drops for the inspiration.