Skip to content

Commit 147a211

Browse files
author
Chris
authored
Merge pull request #9 from crelies/dev
Swift 5.3, Make use of function builder enhancements
2 parents 85bfad4 + f7d73f2 commit 147a211

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: swift
2-
osx_image: xcode11.3
2+
osx_image: xcode12
33
script:
44
- swift package generate-xcodeproj
55
- xcodebuild clean test -destination 'name=iPhone 8' -scheme AdvancedList-Package -enableCodeCoverage YES -derivedDataPath .build/derivedData -quiet

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.1
1+
// swift-tools-version:5.3
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# AdvancedList
22

3-
[![Swift 5](https://img.shields.io/badge/swift-5-green.svg?longCache=true&style=flat-square)](https://developer.apple.com/swift)
3+
[![Swift 5.3](https://img.shields.io/badge/swift-5.3-green.svg?longCache=true&style=flat-square)](https://developer.apple.com/swift)
44
[![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)
55
[![Current version](https://img.shields.io/github/v/tag/crelies/AdvancedList?longCache=true&style=flat-square)](https://github.com/crelies/AdvancedList)
66
[![Build status](https://travis-ci.com/crelies/AdvancedList.svg?token=THnaziKxRFFz1nKcsPgz&branch=dev)](https://travis-ci.com/crelies/AdvancedList)
@@ -148,7 +148,10 @@ AdvancedList(yourData, content: { item in
148148

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

151-
## Migration 2.x -> 3.0
151+
## Migration
152+
153+
<details>
154+
<summary>Migration 2.x -> 3.0</summary>
152155

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

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

160163
**Before:**
164+
161165
```swift
162166
import AdvancedList
163167

@@ -193,6 +197,7 @@ listService.listState = .items
193197
```
194198

195199
**After:**
200+
196201
```swift
197202
import AdvancedList
198203

@@ -221,12 +226,15 @@ AdvancedList(yourData, content: { item in
221226
Text("Loading ...")
222227
}, pagination: .noPagination)
223228
```
229+
</details>
224230

225-
## Migration 3.0 -> 4.0
231+
<details>
232+
<summary>Migration 3.0 -> 4.0</summary>
226233

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

229236
**Before:**
237+
230238
```swift
231239
import AdvancedList
232240

@@ -257,6 +265,7 @@ AdvancedList(yourData, content: { item in
257265
```
258266

259267
**After:**
268+
260269
```swift
261270
import AdvancedList
262271

@@ -287,3 +296,4 @@ AdvancedList(yourData, content: { item in
287296
// delete me
288297
}
289298
```
299+
</details>

Sources/AdvancedList/public/Views/AdvancedList.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ public struct AdvancedList<Data: RandomAccessCollection, Content: View, EmptySta
4141
extension AdvancedList {
4242
public var body: some View {
4343
Group {
44-
if listState.wrappedValue == .items {
44+
switch listState.wrappedValue {
45+
case .items:
4546
if !data.isEmpty {
4647
VStack {
4748
getListView()
@@ -53,12 +54,10 @@ extension AdvancedList {
5354
} else {
5455
emptyStateView()
5556
}
56-
} else if listState.wrappedValue == .loading {
57+
case .loading:
5758
loadingStateView()
58-
} else {
59-
listState.wrappedValue.error.map {
60-
errorStateView($0)
61-
}
59+
case let .error(error):
60+
errorStateView(error)
6261
}
6362
}
6463
}

0 commit comments

Comments
 (0)