Skip to content

Commit 8b4189a

Browse files
committed
Update readme with latest features
1 parent b075f18 commit 8b4189a

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ PredicateView(predicate: $predicate, rowTemplates: [
8383
- [x] Type safety
8484
- [x] Built-in support for optionals and nested expressions
8585
- [x] Rich representations for supported data types
86+
- [x] SwiftData support
87+
- [x] Support for custom controls for row templates
8688

8789
## Not Features
8890

@@ -92,6 +94,30 @@ As an experimental control, `PredicateView` does not support the following capab
9294
- [ ] A rich text experience using text attachments
9395
- [ ] Support for all built-in `PredicateExpression`s
9496

97+
## Advanced Capabilities
98+
99+
### Custom Predicate Views
100+
101+
The `CustomExpressionView` protocol allows you to build custom expression views for key paths not covered by the standard set of built-in expressions. For example, when working with CloudKit in SwiftData, you may choose to implement a custom picker for your enums and dynamically convert them to raw values for their representation in the model layer.
102+
103+
A custom predicate expression may be used as a row template just like any of the standard ones:
104+
105+
```swift
106+
PredicateView(predicate: predicate, rowTemplates: [
107+
.init(keyPath: \.title, title: "Title"),
108+
.init(keyPath: \.creationDate, title: "Creation date"),
109+
.init(keyPath: \.modificationDate, title: "Modification date"),
110+
// Custom expression view:
111+
.init(StatusExpressionView.self),
112+
])
113+
```
114+
115+
See the sample project for additional details.
116+
117+
### Decoding Predicates
118+
119+
`PredicateView` supports taking `Predicate`s as input and populating the control from them. This makes it convenient to store user-built predicates in a database and subsequently allowing your users to modify them. Most built-in expression view types support decoding. Custom expressions may choose to opt into the decoding capability by implementing a single method. The decoding support is opt-in and *not* all-or-nothing. You may elect some expression views to not allow decoding, in which case they will not be populated when the control is instantiated using a non-trivial `Predicate` instance. Conformance is independent, so this decision does not affect other custom expression views or any of the built-in ones.
120+
95121
## Compatibility
96122

97-
Compatibility matches that of the [Swift predicates](https://forums.swift.org/t/pitch-swift-predicates/62000) feature; namely macOS 14.0+, iOS 17.0+, watchOS 10.0+.
123+
Compatibility matches that of the [Swift predicates](https://forums.swift.org/t/pitch-swift-predicates/62000) feature; namely macOS 14.0+, iOS 17.0+, watchOS 10.0+, visionOS 1.0+.

0 commit comments

Comments
 (0)