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

Overview

Drops 💧

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

Demo


CI codecov

Features

  • iOS 10+
  • 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:
let drop: Drop = "Title Only"
let drop = Drop(title: "Title Only")
let drop = Drop(title: "Title", subtitle: "Subtitle")
let drop = Drop(title: "Title", subtitle: "Subtitle", duration: 5.0)
let drop = Drop(
    title: "Title",
    subtitle: "Subtitle",
    icon: UIImage(systemName: "star.fill"),
    action: .init {
        print("Drop tapped")
        Drops.hideCurrent()
    },
    position: .bottom,
    duration: 5.0,
    accessibility: "Alert: Title, Subtitle"
)
  1. Show it:
Drops.show("Title")
Drops.show(drop)
SwiftUI
import SwiftUI
import Drops

struct ContentView: View {
    var body: some View {
        Button("Show Drop") {
            Drops.show(drop)
        }
    }
}
UIKit
import UIKit
import Drops

class ViewController: UIViewController {
    let drops = Drops(delayBetweenDrops: 1.0)

    func showDrop() {
        drops.show(drop)
    }
}

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:
dependencies: [
    .package(url: "https://github.com/omaralbeik/Drops.git", from: "1.2.1")
]
  1. Build your project:
$ swift build

CocoaPods

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

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

Carthage

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

github "omaralbeik/Drops" ~> 1.2

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.

Comments
  • Provide a customisation of maximum number of lines for title and subtitle

    Provide a customisation of maximum number of lines for title and subtitle

    Hi! I find your library very powerful and like it much more than SPIndicator. And I'd find it very nice to have a possibility to show Drops with multiline text. So this PR adds two properties to Drop struct to control numberOfLines of title and subtitle UILabels.

    enhancement 
    opened by ky1vstar 4
  • Xcode 13: 'shared' is unavailable in application extensions for iOS

    Xcode 13: 'shared' is unavailable in application extensions for iOS

    Due to a change in the latest Xcode beta, this no longer compiles as a SwiftPM dependency, even for a target that is not an extension. https://forums.swift.org/t/set-application-extension-api-only-on-a-spm-package/39333/8

    It appears @available(iOSApplicationExtension, unavailable) now needs to be added in WindowViewController:44.

    Error

    SourcePackages/checkouts/Drops/Sources/WindowViewController.swift:44:45: 'shared' is unavailable in application extensions for iOS: Use view controller based solutions where appropriate instead.

    opened by fourbytes 4
  • Unhandled `Info.plist` when importing with SPM

    Unhandled `Info.plist` when importing with SPM

    Hey @omaralbeik,

    amazing job with this library 💪

    I've found an issue when using Drops with the SPM:

    Screen Shot 2021-05-11 at 19 45 58

    Possible fixes would be moving the Info.plist out of the Sources folder – as it's only used in the test-wrapper app, or explicitly excluding it from Package.swift target. I'd push a PR but I'm not really sure which approach you'd rather follow 😅

    opened by sbertix 4
  • Prevent PassthroughWindow from overriding status bar style

    Prevent PassthroughWindow from overriding status bar style

    Hi! When presenting Drop above view controller that has preferredStatusBarStyle set to .lightContent there is a bug. Status bar turns to black while Drop is presented, and turn back to expected color (white) when dismissed. This PR fix this behaviour using UIWindow's private API override. There are several open radars related to this, but none of them is fixed. This fix is totally safe and we are using it in App Store without any issues for three years now.

    opened by ky1vstar 2
  • Present `Drop`s

    Present `Drop`s "everywhere"

    Hey @omaralbeik,

    is there any plan atm for supporting presenting DropViews at any level of the view hierarchy? I feel like it would make a lot of sense to decouple the actual presentation from the all WindowViewController "magic", especially for a better SwiftUI support, as it would allow to use Drops in a declarative way.

    /// An optional `Drop` binding.
    @State var drop: Drop?
    
    // Something along the lines of…
    var body: some View {
       Text("A random text")
          .frame(maxWidth: .infinity, maxHeight: .infinity)
          .drop($drop)
    }
    

    With a definition allowing for a Drops parameter, so that it could still reuse the same code, or even better, imho, just considering delayBetweenDrops (as the whole Binding thing would most likely deprecate the current queue system), or nothing at all (letting SwiftUI animation deal with that).

    public extension View {
       /// Present a `Drop` view.
       ///
       /// - parameters:
       ///   - drop: An optional `Drop` binding. 
       ///   - drops: Some valid `Drops`. Defaults to `.shared`.
       /// - returns: Some `View`.
       drop(_ drop: Binding<Drop?>, with drops: Drops = .shared) -> some View {
          […]
       }
    
       // … OR …
    
       /// Present a `Drop` view.
       ///
       /// - parameters:
       ///   - drop: An optional `Drop` binding. 
       ///   - delayBetweenDrops: Some valid `TimeInterval`. Defaults to `0.5`.
       /// - returns: Some `View`.
       drop(_ drop: Binding<Drop?>, delayedBy delayBetweenDrops: TimeInterval = 0.5) -> some View {
          […]
       }
    }
    

    Of course this would require Drop to at least conform to Identifiable (either directly — unlikely due to the current deployment target, or just as an analogy), which would also give the user the ability to cancel any queued presenter "for free", using the imperative Drops (when dealing with UIKit directly).

    /// Hide some drops.
    /// - Parameter drops: `Drop`s to hide.
    /// - Note: 
    ///    This is really just some "concept code". 
    ///    I tried to make it efficient instead of concise, 
    ///    but it's very much a draft.
    public func hide<C: Collection>(_ drops: C) where C.Element == Drop {
        var identifiers = Set(drops.map(\.id))
        var shouldHideCurrent = false
        dispatchQueue.sync {
            queue.removeAll {
                let isRemoving = identifiers.remove($0.drop.id) != nil
                if !shouldHideCurrent { shouldHideCurrent = isRemoving && current?.drop.id == $0.drop.id }
                return isRemoving
            }
            guard shouldHideCurrent else { return }
            hideCurrent()
        }
    }
    
    opened by sbertix 2
  • Dark/Light mode control

    Dark/Light mode control

    I prefer to have overlays like this show in the opposite color scheme than the current one in use - this is to make sure it stands out against the background of the normal app views. So, feature request!

    opened by vectorstofinal 1
  • Customisation

    Customisation

    Hello and thank you for creating this! Is it possible for further customisation? Eg. using it for error messages (think on having a red background color etc)

    wontfix 
    opened by danipralea 1
  • Unable to see large text

    Unable to see large text

    When subtitle is long text the text size is too small that it is unable to be seen, when text is large drop size should be increased instead of decreasing the font size please check this. uploadingImage

    invalid 
    opened by rahulvermaJW 1
  • release: v1.3.0

    release: v1.3.0

    • Fix a bug where showing a drop was not respecting the current status bar style
    • Mark the library unavailable for app extensions
    • Fix an accessibility bug where labels font size was not adjusting
    opened by omaralbeik 1
  • Add `willShow` notification to `Drop` presentation

    Add `willShow` notification to `Drop` presentation

    Hi! This PR adds optional willShow parameter to Drops.show(_:) method to notify user that Drop is about to appear. I.e. it can be used to provide haptic feedback like it is done in SPIndicator, but since Drops are automatically enqueued, now it's impossible to say when you should send such feedback.

    enhancement 
    opened by ky1vstar 1
  • Make hiding speed of bottom drop the same as top

    Make hiding speed of bottom drop the same as top

    Thanks for creating great project.

    I found that hiding speed of drops is too fast when position is .bottom. This PR makes hiding speed of bottom drops the same as top. Please close this PR if the current behavior is intentional.

    | before | after | top (for reference) | | --- | --- | --- | | 2022-10-18 14 28 51 | 2022-10-18 14 30 09 | 2022-10-18 14 29 19 |

    bug 
    opened by maiyama18 0
Releases(1.6.1)
  • 1.6.1(Oct 18, 2022)

    What's Changed

    • Make hiding speed of bottom drop the same as top by @maiyama18 in https://github.com/omaralbeik/Drops/pull/41

    New Contributors

    • @maiyama18 made their first contribution in https://github.com/omaralbeik/Drops/pull/41

    Full Changelog: https://github.com/omaralbeik/Drops/compare/1.6.0...1.6.1

    Source code(tar.gz)
    Source code(zip)
  • 1.6.0(Oct 7, 2022)

    What's Changed

    • Increase test coverage by @omaralbeik in https://github.com/omaralbeik/Drops/pull/35
    • Reduce image size and prevent macOS app crash by @1998code in https://github.com/omaralbeik/Drops/pull/39
    • Update test apps to support Mac Catalyst by @omaralbeik in https://github.com/omaralbeik/Drops/pull/40

    New Contributors

    • @1998code made their first contribution in https://github.com/omaralbeik/Drops/pull/39

    Full Changelog: https://github.com/omaralbeik/Drops/compare/1.5.0...1.6.0

    Source code(tar.gz)
    Source code(zip)
  • 1.5.0(Jul 16, 2022)

    What's Changed

    • Fix Drop position in multi window environment by @ky1vstar in https://github.com/omaralbeik/Drops/pull/30
    • Bump deployment target to iOS13 + code cleanup in https://github.com/omaralbeik/Drops/pull/34

    Full Changelog: https://github.com/omaralbeik/Drops/compare/1.4.0...1.5.0

    Source code(tar.gz)
    Source code(zip)
  • 1.4.0(Oct 13, 2021)

    Change Log

    Added

    • Added a customisation of maximum number of lines for title and subtitle #23
    • Added new willShowDrop, didShowDrop, willDismissDrop, and didDismissDrop handlers #24 #29

    Great thanks to @ky1vstar for their contributions 👏

    Source code(tar.gz)
    Source code(zip)
  • 1.3.0(Sep 11, 2021)

    Change Log

    Fixed

    • Fixed a bug where showing a drop was not respecting the current status bar style #22
    • Marked the library unavailable for app extensions #20
    • Fixed an accessibility bug where labels font size was not adjusting #25

    Great thanks to @fourbytes, @ky1vstar, and @thierrybucco for their contributions 👏

    Source code(tar.gz)
    Source code(zip)
  • 1.2.1(May 21, 2021)

  • 1.2.0(May 14, 2021)

    Change Log

    Added

    • Drop now conforms to ExpressibleByStringLiteral to allow more natural code like:
    Drops.show("Message")
    
    • New Drop.Accessibility struct to customize VoiceOver message for a drop
    • Drop.Duration now conforms to ExpressibleByFloatLiteral to allow more natural code like:
    let drop = Drop(title: "Title", subtitle: "Subtitle", duration: 5.0)
    

    Changed

    • Label colors now change to darker colors when "Increase Contrast" is turned on in System's settings.
    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(May 12, 2021)

  • 1.0.1(May 11, 2021)

Owner
Omar Albeik
It’s not a bug – it’s an undocumented feature!
Omar Albeik
Display Apple system-like self-hiding status alerts. It is well suited for notifying user without interrupting user flow in iOS-like way.

StatusAlert is being sponsored by the following tool; please help to support us by takin a look and signing up to a free trial. Dependency managers Fe

Yehor Miroshnychenko 841 Dec 6, 2022
Bursts 🔥 A Funny Framework is showing alerts, Have been Adapting Swift and SwiftUI

Bursts ?? A Funny Framework is showing alerts, Have been Adapting Swift and SwiftUI Features iOS 10+ Can be used in UIKit and SwiftUI applications Lig

Jovins 11 Apr 22, 2022
Create Apple-like alerts & toasts using SwiftUI

AlertToast-SwiftUI Present Apple-like alert & toast in SwiftUI ?? Example ?? Overview Currently in SwiftUI, the only way to inform the user about some

Elai Zuberman 1.1k Dec 29, 2022
ActionBee is a programmable pasteboard action trigger.

ActionBee ActionBee is a programmable pasteboard action trigger. Preview Video It can be used to clean your URL in text. To see code or import this mo

Derek Jones 2 Aug 24, 2022
Easily create different alerts in SwiftUI

AlertWizard ????‍♂️ This package lets you easily create different alerts in SwiftUI with the call of a single function. As this is my first package th

null 3 Jun 3, 2021
iOS tweak to display toasts for Low Power alerts and charging

Electrode iOS tweak to display toasts for Low Power alerts and charging. Localization Want to help translate Electrode to your language? Sumbit a pull

null 8 Sep 7, 2022
It is a highly configurable iOS library which allows easy styling with built in styles as well as extra header and footer views so that you can make extremely unique alerts and action sheets.

 CFAlertViewController CFAlertViewController is a library that helps you display and customise Alerts, Action Sheets, and Notifications on iPad and i

Crowdfire Inc. 1.1k Dec 18, 2022
Advance animated alerts for iOS written in Swift

LIHAlert LIHAlert provides animated banners for iOS. Updated to Swift 3 Demo Project The LIHAlert workspace contains a demo project, also used for dev

null 37 Dec 9, 2022
🚨Use the iPhone X Notch to display alerts. 🚨

NotchyAlert Prerequisites Xcode 9.x Swift 4.x iPhone X Simulator/Device Demo Installation Cocoapods To install NotchyAlert using Cocoapods, add the fo

Sofiane Beors 70 Nov 20, 2022
BeautyAlert - BeautyAlert provides alerts with custom shapes, colors, buttons

BeautyAlert helps you can easily design by determining the color, shape, and sha

chacha 17 Sep 8, 2022
zekunyan 608 Dec 30, 2022
SwiftEntryKit is a presentation library for iOS. It can be used to easily display overlays within your iOS apps.

SwiftEntryKit ?? Donations can be made here. Table of Contents Overview Features Example Project Example Project Installation Presets Playground Requi

Daniel Huri 6.1k Jan 4, 2023
A customizable, full-feature, lightweight iOS framework to be used instead of UIAlertController.

A customizable, full-feature, lightweight iOS framework to be used instead of UIAlertController.

Ali Samaiee 11 Jun 6, 2022
Simple Alert View written in Swift, which can be used as a UIAlertController. (AlertController/AlertView/ActionSheet)

DOAlertController Simple Alert View written in Swift, which can be used as a UIAlertController replacement. It supports from iOS7! It is simple and ea

Daiki Okumura 406 Sep 5, 2022
Bottom Sheet component is widely used in Joom application

Bottom Sheet Bottom Sheet component is widely used in Joom application Installation Swift Package Manager Swift Package Manager is a tool for managing

Joom 101 Dec 29, 2022
This is an iOS control for selecting a date using UIDatePicker in an UIAlertController like manner

RMDateSelectionViewController This framework allows you to select a date by presenting an action sheet. In addition, it allows you to add actions arro

Roland Moers 1.2k Dec 13, 2022
Animated alert library like Swarm app.

TKSwarmAlert Animation Tool for Alert like Swarm app. ScreenShot Installation CocoaPods You can use CocoaPods to install TKSwarmAlert by adding it to

Takuya Okamoto 581 Dec 2, 2022
This is an iOS control for presenting any UIView in an UIAlertController like manner

RMActionController This framework allows you to present just any view as an action sheet. In addition, it allows you to add actions around the present

Roland Moers 542 Dec 5, 2022
Swift library to manage in app notification in swift language, like WhatsApp, Telegram, Frind, ecc.

InAppNotify - Manage in App notifications During develop of my app Frind, I needed to manage in app notifications like whatsapp or telegram, but i did

Luca Becchetti 438 Nov 20, 2022