Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lawrencebensaid/blissfulbinding
Make you SwiftUI coding experience more joyful with an extended Binding class
https://github.com/lawrencebensaid/blissfulbinding
Last synced: 16 days ago
JSON representation
Make you SwiftUI coding experience more joyful with an extended Binding class
- Host: GitHub
- URL: https://github.com/lawrencebensaid/blissfulbinding
- Owner: lawrencebensaid
- Created: 2022-03-25T19:28:43.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-07T11:40:14.000Z (almost 3 years ago)
- Last Synced: 2023-03-09T16:35:54.412Z (almost 2 years ago)
- Language: Swift
- Homepage:
- Size: 4.88 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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.```swift
import BlissfulBindingstruct 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.
```swift
import BlissfulBindingstruct MyView: View {
@Binding var message: String?
var body: some View {
Text("Hello, World!")
.sheet(isPresented: .notNil($message)) {
Text(message ?? "")
}
}}
```