Swiftpack.co - danielsaidi/SystemNotification as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by danielsaidi.
danielsaidi/SystemNotification 0.7.0
SystemNotification is a SwiftUI library that lets you mimic the native iOS system notification. It supports extensive styling, custom views and can be used on all major Apple platforms.
⭐️ 198
🕓 10 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/danielsaidi/SystemNotification.git", from: "0.7.0")

SystemNotification Logo

Version Swift 5.6 Swift UI MIT License Twitter: @danielsaidi Mastodon: @danielsaidi@mastodon.social

About SystemNotification

SystemNotification is a SwiftUI library that lets you mimic the native iOS system notification that for instance is presented when you toggle silent mode on and off, connect your AirPods etc.

The result can look like this, or completely different:

SystemNotification supports extensive styling and customizations, custom views and can be used on all major Apple platforms.

Installation

SystemNotification can be installed with the Swift Package Manager:

https://github.com/danielsaidi/SystemNotification.git

or with CocoaPods

pod SystemNotification

If you prefer to not have external dependencies, you can also just copy the source code into your app.

Supported Platforms

SystemNotification supports iOS 14, macOS 11, tvOS 14 and watchOS 7.

Getting started

The online documentation has a getting started guide guide to help you get started with SystemNotification.

SystemNotification supports both state- and context-based notifications. Context-based notifications work similar to sheet, alert and fullScreenModal, but use an observable SystemNotificationContext instead of state:

struct MyView: View {

    @StateObject 
    private var notification = SystemNotificationContext()

    var body: some View {
        List {
            Button("Show notification", action: showNotification)
            Button("Show orange notification", action: showCustomNotification)
        }.systemNotification(notification)
    }
    
    func showNotification() {
        notification.present {
            SystemNotificationMessage(
                icon: Image(systemName: "􀋚"),
                title: Text("Silent mode"),
                text: Text("Off"),
                style: .init(iconColor: .red)
            )
        }
    }
    
    func showCustomNotification() {
        notification.present(
            configuration: .init(backgroundColor: .orange)
        ) {
            VStack {
                Text("Custom notification").font(.headline)
                Divider()
                Text("SystemNotification supports using any views you like as notification messages.")
            }
            .foregroundColor(.white)
            .padding()
        }
    }
}

The context-based approach lets you use the same context in your entire application, with a single view modifier being applied to a single view hierarchy.

For more information, please see the online documentation and getting started guide.

Documentation

The online documentation has articles, code examples etc. that let you overview the various parts of the library.

Demo Application

The demo app lets you explore the library on iOS and macOS. To try it out, just open and run the Demo project.

Support

You can sponsor this project on GitHub Sponsors or get in touch for paid support.

Contact

Feel free to reach out if you have questions or if you want to contribute in any way:

License

SystemNotification is available under the MIT license. See the LICENSE file for more info.

GitHub

link
Stars: 198
Last commit: 3 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

10 weeks ago

This version splits up SystemNotificationConfiguration in a configuration and style type.

Due to changes in the SystemNotificationMessage capabilities, the LocalizedStringKey support has been deprecated.

Also, since SystemNotification aims to be a pure SwiftUI project, the SystemNotificationUIKitOverlay has been deprecated. Please let me know if you really need it, and I'll re-add it to the library.

✨ New features

  • SystemNotificationMessage now supports a custom icon view.
  • SystemNotificationStyle is a new type that's extracted from SystemNotificationConfiguration.

💡 Behavior changes

  • SystemNotification no longer uses async size bindings to apply the corner radius.

🗑 Deprecated

  • SystemNotificationConfiguration moves all styles to SystemNotificationStyle.
  • SystemNotificationMessage has deprecated its LocalizedString initializer.
  • SystemNotificationMessageConfiguration is renamed to SystemNotificationMessageStyle.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics