BlissfulBinding

1.1.0

Make you SwiftUI coding experience more joyful with an extended Binding class
lawrencebensaid/BlissfulBinding

What's New

BlissfulBinding v1.1.0

2022-04-07T11:40:14Z

Changes

  • Added macOS compatibility (#1)

BlissfulBinding

SwiftUI provides a Binding class, which can sometimes be hard to work with when you are dealing with optionals. BlissfulBinding extends SwiftUI's Binding class with some features allowing you to work with these optionals more easily:.

Introducing the Coalescing Operator ??

A familiar operator to Swift. BlissfulBinding allows you to use this operator with SwiftUI's Binding. This is useful because a lot of SwiftUI modifiers expect unwrapped variables.

import BlissfulBinding

struct MyView: View {

    @Binding var present: Bool?

    var body: some View {
        Text("Hello, World!")
            .sheet(isPresented: $present ?? false) {
                Text("Hi!")
            }
    }

}

Introducing .notNil function

This allows you to convert an Optional Binding variable to a Boolean Binding variable.

import BlissfulBinding

struct MyView: View {

    @Binding var message: String?

    var body: some View {
        Text("Hello, World!")
            .sheet(isPresented: .notNil($message)) {
                Text(message ?? "")
            }
    }

}

Description

  • Swift Tools 5.5.0
View More Packages from this Author

Dependencies

  • None
Last updated: Wed Oct 30 2024 18:20:59 GMT-0900 (Hawaii-Aleutian Daylight Time)