Swiftpack.co - Bonney/MBUtilities as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Bonney.
Bonney/MBUtilities 1.1.0
My personal grab-bag of Swift and SwiftUI goodies.
⭐️ 0
🕓 2 weeks ago
iOS macOS watchOS
.package(url: "https://github.com/Bonney/MBUtilities.git", from: "1.1.0")


Personal collection of handy Swift and SwiftUI utilities, extensions, and custom views.

Big-old gigantic WIP.

SwiftUI Views


Combines a SwiftUI Toggle with an onChange event. Allows for a Toggle to fire off additional actions when it's State changes.

@State private var allowNotifications: Bool = false

// Standard Toggle behavior, binding to a Boolean
ActionToggle(isOn: $allowNotifications) {
	Text("Allow App to Send Notifications")
} action: { (newValue: Bool) in
	someController.notificationPreferenceDidChange(to: newValue)

This is functionally identical to this:

Toggle(isOn: $allowNotifications) {
	Text("Allow App to Send Notifications")
.onChange(of: isOn) { (newValue) in
	someController.notificationPreferenceDidChange(to: newValue)


Say you need a Button somewhere in your UI that specifically for showing a detail sheet. Maybe it's a "Compose" button, or the navigation bar item for to show your Preferences sheet.

Typically, I end up doing this: storing the State and Sheet presentation logic inside the view that hosts the Button itself.

@State private var showSheet: Bool = false

var body: some View {
    List(...) {
        // ...
        Button("Show Detail Sheet") {
    .sheet(isPresented: $showSheet) {

The worst part about this? It makes it hard to pull these types of Buttons out to standalone Views – which SwiftUI very much wants you to do! What if we want a common, re-usable Button, used to display a specific modal sheet, that can be placed anywhere in our app?


public struct SheetButton: View {
    // ...
    public var body: some View {
        Button(role: .none) {
        } label: {
        .sheet(isPresented: $showSheet) {

SheetButton {
    Text("New Message")
} sheetContent: {


Stars: 0
Last commit: 16 hours ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

2 weeks ago

Bump to target 2022 OS releases (iOS 16, watchOS 9, macOS Ventura).

Adds some SwiftUI views!

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