@@ -85,8 +85,8 @@ private(set) lazy var pagination: AdvancedListPagination<AnyView, AnyView> = {
8585
8686### 📁 Move and 🗑️ delete items
8787
88- You can define which actions your list should support through the ` onMoveAction ` and ` onDeleteAction ` initializer parameters .
89- ** Per default the move and delete functions are disabled if you skip the parameters .**
88+ To enable the move or delete function just use the related ` onMove ` or ` onDelete ` view modifier .
89+ ** Per default the functions are disabled if you don't add the view modifiers .**
9090
9191``` swift
9292import AdvancedList
@@ -95,18 +95,20 @@ import AdvancedList
9595
9696AdvancedList (yourData, content : { item in
9797 Text (" Item" )
98- }, listState : $listState, onMoveAction : { (indexSet, index) in
99- // do something
100- }, onDeleteAction : { indexSet in
101- // do something
102- }, emptyStateView : {
98+ }, listState : $listState, emptyStateView : {
10399 Text (" No data" )
104100}, errorStateView : { error in
105101 Text (error.localizedDescription )
106102 .lineLimit (nil )
107103}, loadingStateView : {
108104 Text (" Loading ..." )
109105}, pagination : .noPagination )
106+ .onMove { (indexSet, index) in
107+ // move me
108+ }
109+ .onDelete { indexSet in
110+ // delete me
111+ }
110112```
111113
112114### 🎛️ Filtering
@@ -217,3 +219,69 @@ AdvancedList(yourData, content: { item in
217219 Text (" Loading ..." )
218220}, pagination : .noPagination )
219221```
222+
223+ ## Migration 3.0 -> 4.0
224+
225+ Thanks to a hint from @SpectralDragon I could refactor the ` onMove ` and ` onDelete ` functionality to view modifiers.
226+
227+ ** Before:**
228+ ``` swift
229+ import AdvancedList
230+
231+ @State private var listState: ListState = .items
232+
233+ AdvancedList (yourData, content : { item in
234+ Text (" Item" )
235+ }, listState : $listState, onMoveAction : { (indexSet, index) in
236+ // move me
237+ }, onDeleteAction : { indexSet in
238+ // delete me
239+ }, emptyStateView : {
240+ Text (" No data" )
241+ }, errorStateView : { error in
242+ VStack {
243+ Text (error.localizedDescription )
244+ .lineLimit (nil )
245+
246+ Button (action : {
247+ // do something
248+ }) {
249+ Text (" Retry" )
250+ }
251+ }
252+ }, loadingStateView : {
253+ Text (" Loading ..." )
254+ }, pagination : .noPagination )
255+ ```
256+
257+ ** After:**
258+ ``` swift
259+ import AdvancedList
260+
261+ @State private var listState: ListState = .items
262+
263+ AdvancedList (yourData, content : { item in
264+ Text (" Item" )
265+ }, listState : $listState, emptyStateView : {
266+ Text (" No data" )
267+ }, errorStateView : { error in
268+ VStack {
269+ Text (error.localizedDescription )
270+ .lineLimit (nil )
271+
272+ Button (action : {
273+ // do something
274+ }) {
275+ Text (" Retry" )
276+ }
277+ }
278+ }, loadingStateView : {
279+ Text (" Loading ..." )
280+ }, pagination : .noPagination )
281+ .onMove { (indexSet, index) in
282+ // move me
283+ }
284+ .onDelete { indexSet in
285+ // delete me
286+ }
287+ ```
0 commit comments