You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-3Lines changed: 33 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,33 @@ This repo is an experiment on designing and implementing a cross-platform SwiftU
16
16
17
17
A `PredicateView` can be initialized using a binding to a [`Predicate`](https://developer.apple.com/documentation/foundation/predicate) and a collection of row templates. Note: it purposefully uses the same terminology for row templates as `NSPredicateEditor`.
18
18
19
+
`PredicateView` has built-in support for common primitive and compound Swift types, including `Bool`, `String`, `Numeric`, `CaseIterable`, and `RawRepresentable`. It uses appropriate customized UI controls for each one, such as menus for enums, segmented controls for booleans, and steppers for numeric data.
20
+
21
+
You construct a `PredicateView` by providing a `Binding` to a `Predicate` over your model type. You then provide a collection of row templates, which define the set of properties the user will be able to filter through. Each template must contain a `KeyPath` in your model type, as well as a user-friendly title.
22
+
23
+
As the user makes changes to the predicate using the `PredicateView` UI, the value of the predicate will update. If your model instance conforms to `Sequence`, you can easily filter it using the predicate by calling the Swift standard library `filter(_:)` method. Note that it is a good practice to opt into updating the filtered-down representation of the model live as the user interacts with the `PredicateView` UI, instead of requiring the user to interact with an additional control, such as an explicit Search button.
24
+
25
+
### Optionals
26
+
27
+
`PredicateView` has built-in support for optionals of all supported types. If a given row template uses an optional `KeyPath`, the user will be able to filter over the existence or non-existence of values, in addition to the values themselves.
28
+
29
+
### Collections
30
+
31
+
You can provide nested row templates for `Collection` backed data, which will allow the user to customize their query even more, filtering over containment or filtering elements that satisfy all of the conditions.
0 commit comments