Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: swift
osx_image: xcode11.3
osx_image: xcode12
script:
- swift package generate-xcodeproj
- xcodebuild clean test -destination 'name=iPhone 8' -scheme AdvancedList-Package -enableCodeCoverage YES -derivedDataPath .build/derivedData -quiet
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.1
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AdvancedList

[![Swift 5](https://img.shields.io/badge/swift-5-green.svg?longCache=true&style=flat-square)](https://developer.apple.com/swift)
[![Swift 5.3](https://img.shields.io/badge/swift-5.3-green.svg?longCache=true&style=flat-square)](https://developer.apple.com/swift)
[![Platforms](https://img.shields.io/badge/platform-iOS%20%7C%20macOS%20%7C%20tvOS-lightgrey.svg?longCache=true&style=flat-square)](https://www.apple.com)
[![Current version](https://img.shields.io/github/v/tag/crelies/AdvancedList?longCache=true&style=flat-square)](https://github.com/crelies/AdvancedList)
[![Build status](https://travis-ci.com/crelies/AdvancedList.svg?token=THnaziKxRFFz1nKcsPgz&branch=dev)](https://travis-ci.com/crelies/AdvancedList)
Expand Down Expand Up @@ -148,7 +148,10 @@ AdvancedList(yourData, content: { item in

For more examples take a look at [AdvancedList-SwiftUI](https://github.com/crelies/AdvancedList-SwiftUI).

## Migration 2.x -> 3.0
## Migration

<details>
<summary>Migration 2.x -> 3.0</summary>

The `AdvancedList` was dramatically simplified and is now more like the `List` and `ForEach` SwiftUI views.

Expand All @@ -158,6 +161,7 @@ The `AdvancedList` was dramatically simplified and is now more like the `List` a
4. **Move and delete:** Instead of setting `AdvancedListActions` on your list service just pass a `onMoveAction` and/or `onDeleteAction` block to the initializer

**Before:**

```swift
import AdvancedList

Expand Down Expand Up @@ -193,6 +197,7 @@ listService.listState = .items
```

**After:**

```swift
import AdvancedList

Expand Down Expand Up @@ -221,12 +226,15 @@ AdvancedList(yourData, content: { item in
Text("Loading ...")
}, pagination: .noPagination)
```
</details>

## Migration 3.0 -> 4.0
<details>
<summary>Migration 3.0 -> 4.0</summary>

Thanks to a hint from @SpectralDragon I could refactor the `onMove` and `onDelete` functionality to view modifiers.

**Before:**

```swift
import AdvancedList

Expand Down Expand Up @@ -257,6 +265,7 @@ AdvancedList(yourData, content: { item in
```

**After:**

```swift
import AdvancedList

Expand Down Expand Up @@ -287,3 +296,4 @@ AdvancedList(yourData, content: { item in
// delete me
}
```
</details>
11 changes: 5 additions & 6 deletions Sources/AdvancedList/public/Views/AdvancedList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public struct AdvancedList<Data: RandomAccessCollection, Content: View, EmptySta
extension AdvancedList {
public var body: some View {
Group {
if listState.wrappedValue == .items {
switch listState.wrappedValue {
case .items:
if !data.isEmpty {
VStack {
getListView()
Expand All @@ -53,12 +54,10 @@ extension AdvancedList {
} else {
emptyStateView()
}
} else if listState.wrappedValue == .loading {
case .loading:
loadingStateView()
} else {
listState.wrappedValue.error.map {
errorStateView($0)
}
case let .error(error):
errorStateView(error)
}
}
}
Expand Down