DropView is a SwiftUI-based library to display alerts inspired by the Apple Pencil and pasteboard stock ones.
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 greater, we expect the need for alternative solutions to fade quickly.
DropView allows you to present alerts just like sheets and fullScreenCovers.
Just call .drop($drop) on any View.
Example
import SwiftUI
import DropView
struct YourView: View {
/// An optional `Drop` binding.
@State var drop: Drop?
/// The current posiiton.
@State var alignmentValue: Int = 0
/// Autohides after a given amount of seconds.
@State var seconds: TimeInterval = 2
/// The vertical alignment.
private var alignment: VerticalAlignment {
switch alignmentValue {
case 1: return .center
case 2: return .bottom
default: return .top
}
}
/// The underlying view.
var body: some View {
VStack(spacing: 8) {
Slider(value: $seconds, in: 2...10)
.padding(.horizontal)
Picker("Alignment", selection: $alignmentValue) {
Text("Top").tag(0)
Text("Center").tag(1)
Text("Bottom").tag(2)
}
Button(action: {
drop = .init(title: "DropView",
subtitle: "github.com/sbertix/DropView",
icon: Image(systemName: "hand.wave.fill").resizable(),
action: Image(systemName: "star.circle.fill").resizable())
}) {
Text("Present").bold()
}
Button(action: {
drop = nil
}) {
Text("Hide").foregroundColor(.red)
}
}
.drop($drop, hidingAfter: seconds, alignment: alignment)
}
}
Massive thanks to anyone contributing to omaralbeik/Drops for the inspiration.
