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
This package provides a wrapper view around the **SwiftUI**`List view` which adds **pagination** (through my [ListPagination package](https://github.com/crelies/ListPagination)) and an **empty**, **error** and **loading state** including a corresponding view.
8
8
9
-
## Installation
9
+
## 📦 Installation
10
10
11
11
Add this Swift package in Xcode using its Github repository url. (File > Swift Packages > Add Package Dependency...)
12
12
13
-
## How to use
13
+
## 🚀 How to use
14
14
15
15
You control the view through an instance of `ListService`. The service manages the current state and the items of the list.
16
-
Use it to append, update or remove items and to modify the state of the list. The view listens to the service and updates itself if needed.
16
+
Use it to append, update or remove items and to modify the state of the list. The `AdvancedList`view listens to the service and updates itself if needed.
The `Pagination` is implemented as a class (conforming to `ObservableObject`) so the `AdvancedList` can observe it.
21
41
It has three different states: `error`, `idle` and `loading`. If the `state` of the `Pagination` changes the `AdvancedList` updates itself to show or hide the state related view (`ErrorView` for state `.error(Error)` or `LoadingView` for state `.loading`, `.idle` will display nothing). Update the `state` if you start loading (`.loading`), stop loading ( `.idle`) or if an error occurred (`.error(Error)`) so the `AdvancedList` can render the appropriate view.
@@ -34,12 +54,71 @@ The `thresholdItemPagination` expects an offset parameter (number of items befor
34
54
35
55
**Skip pagination setup by using `.noPagination`.**
You can define which actions your list should support through the `supportedListActions` property of your `ListService` instance.
91
+
Choose between `delete`, `move`, `moveAndDelete` and `none`. **The default is `none`.**
92
+
93
+
```swift
94
+
let listService =ListService()
95
+
listService.supportedListActions= .moveAndDelete(onMove: { indexSet, index in
96
+
// move me
97
+
}, onDelete: { indexSet in
98
+
// please delete me
99
+
})
100
+
```
101
+
102
+
### 🎛️ Filtering
103
+
104
+
The `AdvancedList` supports filtering (**disabled by default**). You only have to set the closure `excludeItem: (AnyListItem) -> Bool)` on your `ListService` instance.
105
+
`AnyListItem` gives you access to the item (`Any`). **Keep in mind that you have to cast this item to your custom type!**
0 commit comments