Skip to content

Commit

Permalink
Merge pull request #16 from crelies/dev
Browse files Browse the repository at this point in the history
Updated listState documentation and added migration info
  • Loading branch information
Chris authored Apr 20, 2021
2 parents 99b0313 + 8c80624 commit 8309de4
Showing 1 changed file with 64 additions and 4 deletions.
68 changes: 64 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import AdvancedList

AdvancedList(yourData, content: { item in
Text("Item")
}, listState: $listState, emptyStateView: {
}, listState: listState, emptyStateView: {
Text("No data")
}, errorStateView: { error in
Text(error.localizedDescription)
Expand Down Expand Up @@ -53,7 +53,7 @@ AdvancedList(yourData, listView: { rows in
}
}, content: { item in
Text("Item")
}, listState: $listState, emptyStateView: {
}, listState: listState, emptyStateView: {
Text("No data")
}, errorStateView: { error in
Text(error.localizedDescription)
Expand Down Expand Up @@ -112,7 +112,7 @@ import AdvancedList

AdvancedList(yourData, content: { item in
Text("Item")
}, listState: $listState, emptyStateView: {
}, listState: listState, emptyStateView: {
Text("No data")
}, errorStateView: { error in
Text(error.localizedDescription)
Expand Down Expand Up @@ -143,7 +143,7 @@ import AdvancedList

AdvancedList(yourData, content: { item in
Text("Item")
}, listState: $listState, emptyStateView: {
}, listState: listState, emptyStateView: {
Text("No data")
}, errorStateView: { error in
VStack {
Expand Down Expand Up @@ -417,3 +417,63 @@ AdvancedList(yourData, content: { item in
})
```
</details>

<details>
<summary>Migration 6.0 -> 7.0</summary>

I replaced the unnecessary listState `Binding` and replaced it with a simple value parameter.

**Before:**

```swift
import AdvancedList

@State private var listState: ListState = .items

AdvancedList(yourData, content: { item in
Text("Item")
}, listState: $listState, emptyStateView: {
Text("No data")
}, errorStateView: { error in
VStack {
Text(error.localizedDescription)
.lineLimit(nil)

Button(action: {
// do something
}) {
Text("Retry")
}
}
}, loadingStateView: {
Text("Loading ...")
}, pagination: .noPagination)
```

**After:**

```swift
import AdvancedList

@State private var listState: ListState = .items

AdvancedList(yourData, content: { item in
Text("Item")
}, listState: listState, emptyStateView: {
Text("No data")
}, errorStateView: { error in
VStack {
Text(error.localizedDescription)
.lineLimit(nil)

Button(action: {
// do something
}) {
Text("Retry")
}
}
}, loadingStateView: {
Text("Loading ...")
}, pagination: .noPagination)
```
</details>

0 comments on commit 8309de4

Please sign in to comment.