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
)
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.
- Select
File
/Swift Packages
/Add Package Dependency…
from the menu. - Paste
https://github.com/sbertix/DropView.git
. - Follow the steps.
- 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.
DropView allows you to present alerts just like sheet
s and fullScreenCover
s.
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)
}
}
}
}
Massive thanks to anyone contributing to omaralbeik/Drops for the inspiration.