Skip to content

Commit 3fae989

Browse files
mluisbrownstephencelisnspavlombrandonw
authored
Sync latest changes from swift-composable-architecture (#33)
* Fix Binding animations (#338) * Replace deprecated optional with optional() (#339) * Only include actions in TestStore debug output (#342) * Add `Scene` conformance to `WithViewStore` (#336) * Add SceneWithViewStore for accessing stores in scenes This would allow accessing `ViewStore` instances from a `body` definition of a type conforming to `Scene`. It could be useful for conditional rendering of scenes or sending actions from scene commands. Here's an example: ```swift import ComposableArchitecture import SwiftUI @main struct CommandsApp: App { private let store = Store( initialState: RootState(), reducer: rootReducer, environment: .live(rootEnvironment) ) var body: some Scene { SceneWithViewStore(store) { viewStore in WindowGroup { WorkspaceView() }.commands { CommandGroup(after: CommandGroupPlacement.newItem) { Button("Open...") { viewStore.send(.open) }.keyboardShortcut("o", modifiers: [.command]) } } } } } ``` * Avoid building SceneWithViewStore with old Xcode * Separate Catalina and Big Sur jobs This allows testing APIs that are only available on Big Sur * Unify `WithViewStore` and `SceneWithViewStore` * Format and coverage * Update Reducer.swift (#332) * Remove LocationManager and MotionManager examples from README (#319) * Fix Tests (#343) * Fix tests * fix * Direct people to GH discussions instead of Swift forums (#348) * Direct people to GH discussions instead of Swift forums How do you feel about this? * Update README.md Co-authored-by: Stephen Celis <[email protected]> * Update README.md Co-authored-by: Stephen Celis <[email protected]> * Update issue template to mention GH discussions. (#358) * Add TextState (for AlertState, ActionSheetState, etc.) (#359) * Use SwiftUI.Text with {Alert,ActionSheet}State Fix #293, #318. * Use public interface * Availability * TextState * Note * Simplify * Update LocalizedStringTests.swift * Fix warnings * Fix docs * Fix availability annotations. * Re-publicize `AlertState.Button.type` (#361) * Re-publicize `AlertState.Button.type` * Update Alert.swift * Simplify UIKit list case study (#365) Suggestion from @ryanbooker: pointfreeco/swift-composable-architecture#351 * Disable Big Sur tests - too flaky right now. * - Use Xcode 12.3 for CI - Remove #if nesting in WithViewStore.swift * Fix typo. Co-authored-by: Stephen Celis <[email protected]> Co-authored-by: Jans Pavlovs <[email protected]> Co-authored-by: Brandon Williams <[email protected]>
1 parent 33f667a commit 3fae989

37 files changed

+1063
-622
lines changed

.github/ISSUE_TEMPLATE/question.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ assignees: ''
77

88
---
99

10-
The Composable Architecture uses GitHub issues for bugs. For more general discussion and help, please use [the Swift forum](https://forums.swift.org/c/related-projects/swift-composable-architecture) first.
10+
The Composable Architecture uses GitHub issues for bugs. For more general discussion and help, please use [GitHub Discussions](https://github.com/pointfreeco/swift-composable-architecture/discussions) or [the Swift forum](https://forums.swift.org/c/related-projects/swift-composable-architecture) first.

.github/workflows/ci.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,33 @@ on:
1010

1111
jobs:
1212
library:
13-
runs-on: macOS-latest
13+
runs-on: macos-10.15
1414
strategy:
1515
matrix:
1616
xcode:
1717
- 11.7
18-
- 12.0
18+
- 12.3
1919
steps:
2020
- uses: actions/checkout@v2
2121
- name: Select Xcode ${{ matrix.xcode }}
2222
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
2323
- name: Run tests
2424
run: make test
2525

26+
# NB: GitHub's Big Sur instances are super flaky. We should revisit later.
27+
# bigsur-tests:
28+
# runs-on: macos-11.0
29+
# strategy:
30+
# matrix:
31+
# xcode:
32+
# - 12.3
33+
# steps:
34+
# - uses: actions/checkout@v2
35+
# - name: Select Xcode ${{ matrix.xcode }}
36+
# run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
37+
# - name: Run tests
38+
# run: make test
39+
2640
swiftpm-linux:
2741
name: SwiftPM Linux
2842
runs-on: ubuntu-18.04

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-AlertsAndActionSheets.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ let alertAndSheetReducer = Reducer<
4444
switch action {
4545
case .actionSheetButtonTapped:
4646
state.actionSheet = .init(
47-
title: "Action sheet",
48-
message: "This is an action sheet.",
47+
title: .init("Action sheet"),
48+
message: .init("This is an action sheet."),
4949
buttons: [
5050
.cancel(),
51-
.default("Increment", send: .incrementButtonTapped),
52-
.default("Decrement", send: .decrementButtonTapped),
51+
.default(.init("Increment"), send: .incrementButtonTapped),
52+
.default(.init("Decrement"), send: .decrementButtonTapped),
5353
]
5454
)
5555
return .none
@@ -63,10 +63,10 @@ let alertAndSheetReducer = Reducer<
6363

6464
case .alertButtonTapped:
6565
state.alert = .init(
66-
title: "Alert!",
67-
message: "This is an alert",
66+
title: .init("Alert!"),
67+
message: .init("This is an alert"),
6868
primaryButton: .cancel(),
69-
secondaryButton: .default("Increment", send: .incrementButtonTapped)
69+
secondaryButton: .default(.init("Increment"), send: .incrementButtonTapped)
7070
)
7171
return .none
7272

@@ -78,12 +78,12 @@ let alertAndSheetReducer = Reducer<
7878
return .none
7979

8080
case .decrementButtonTapped:
81-
state.alert = .init(title: "Decremented!")
81+
state.alert = .init(title: .init("Decremented!"))
8282
state.count -= 1
8383
return .none
8484

8585
case .incrementButtonTapped:
86-
state.alert = .init(title: "Incremented!")
86+
state.alert = .init(title: .init("Incremented!"))
8787
state.count += 1
8888
return .none
8989
}

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-SharedState.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ let sharedStateCounterReducer = Reducer<
107107
case .isPrimeButtonTapped:
108108
state.alert = .init(
109109
title: isPrime(state.count)
110-
? "👍 The number \(state.count) is prime!"
111-
: "👎 The number \(state.count) is not prime :("
110+
? .init("👍 The number \(state.count) is prime!")
111+
: .init("👎 The number \(state.count) is not prime :(")
112112
)
113113
return .none
114114
}

Examples/CaseStudies/SwiftUICaseStudies/02-Effects-WebSocket.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ let webSocketReducer = Reducer<WebSocketState, WebSocketAction, WebSocketEnviron
106106

107107
case let .sendResponse(error):
108108
if error != nil {
109-
state.alert = .init(title: "Could not send socket message. Try again.")
109+
state.alert = .init(title: .init("Could not send socket message. Try again."))
110110
}
111111
return .none
112112

@@ -118,7 +118,7 @@ let webSocketReducer = Reducer<WebSocketState, WebSocketAction, WebSocketEnviron
118118
let .webSocket(.didCompleteWithError(error)):
119119
state.connectivityState = .disconnected
120120
if error != nil {
121-
state.alert = .init(title: "Disconnected from socket for some reason. Try again.")
121+
state.alert = .init(title: .init("Disconnected from socket for some reason. Try again."))
122122
}
123123
return .cancel(id: WebSocketId())
124124

Examples/CaseStudies/SwiftUICaseStudies/03-Effects-SystemEnvironment.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ let multipleDependenciesReducer = Reducer<
5050
.delay(1, on: environment.mainQueue())
5151

5252
case .alertDelayReceived:
53-
state.alert = .init(title: "Here's an alert after a delay!")
53+
state.alert = .init(title: .init("Here's an alert after a delay!"))
5454
return .none
5555

5656
case .alertDismissed:

Examples/CaseStudies/SwiftUICaseStudies/04-HigherOrderReducers-ResuableOfflineDownloads/DownloadComponent.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,19 @@ extension Reducer {
119119
}
120120

121121
private let deleteAlert = AlertState(
122-
title: "Do you want to delete this map from your offline storage?",
123-
primaryButton: .destructive("Delete", send: .deleteButtonTapped),
122+
title: .init("Do you want to delete this map from your offline storage?"),
123+
primaryButton: .destructive(.init("Delete"), send: .deleteButtonTapped),
124124
secondaryButton: nevermindButton
125125
)
126126

127127
private let cancelAlert = AlertState(
128-
title: "Do you want to cancel downloading this map?",
129-
primaryButton: .destructive("Cancel", send: .cancelButtonTapped),
128+
title: .init("Do you want to cancel downloading this map?"),
129+
primaryButton: .destructive(.init("Cancel"), send: .cancelButtonTapped),
130130
secondaryButton: nevermindButton
131131
)
132132

133133
let nevermindButton = AlertState<DownloadComponentAction.AlertAction>.Button
134-
.default("Nevermind", send: .nevermindButtonTapped)
134+
.default(.init("Nevermind"), send: .nevermindButtonTapped)
135135

136136
struct DownloadComponent<ID: Equatable>: View {
137137
let store: Store<DownloadComponentState<ID>, DownloadComponentAction>

Examples/CaseStudies/SwiftUICaseStudies/04-HigherOrderReducers-ReusableFavoriting.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ extension Reducer {
7979
.cancellable(id: FavoriteCancelId(id: state.id), cancelInFlight: true)
8080

8181
case let .response(.failure(error)):
82-
state.alert = .init(title: .init(error.localizedDescription))
82+
state.alert = .init(title: TextState(error.localizedDescription))
8383
return .none
8484

8585
case let .response(.success(isFavorite)):

Examples/CaseStudies/SwiftUICaseStudiesTests/01-GettingStarted-AlertsAndActionSheetsTests.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ class AlertsAndActionSheetsTests: XCTestCase {
1616
store.assert(
1717
.send(.alertButtonTapped) {
1818
$0.alert = .init(
19-
title: "Alert!",
20-
message: "This is an alert",
19+
title: .init("Alert!"),
20+
message: .init("This is an alert"),
2121
primaryButton: .cancel(),
22-
secondaryButton: .default("Increment", send: .incrementButtonTapped)
22+
secondaryButton: .default(.init("Increment"), send: .incrementButtonTapped)
2323
)
2424
},
2525
.send(.incrementButtonTapped) {
26-
$0.alert = .init(title: "Incremented!")
26+
$0.alert = .init(title: .init("Incremented!"))
2727
$0.count = 1
2828
},
2929
.send(.alertDismissed) {
@@ -42,17 +42,17 @@ class AlertsAndActionSheetsTests: XCTestCase {
4242
store.assert(
4343
.send(.actionSheetButtonTapped) {
4444
$0.actionSheet = .init(
45-
title: "Action sheet",
46-
message: "This is an action sheet.",
45+
title: .init("Action sheet"),
46+
message: .init("This is an action sheet."),
4747
buttons: [
4848
.cancel(),
49-
.default("Increment", send: .incrementButtonTapped),
50-
.default("Decrement", send: .decrementButtonTapped),
49+
.default(.init("Increment"), send: .incrementButtonTapped),
50+
.default(.init("Decrement"), send: .decrementButtonTapped),
5151
]
5252
)
5353
},
5454
.send(.incrementButtonTapped) {
55-
$0.alert = .init(title: "Incremented!")
55+
$0.alert = .init(title: .init("Incremented!"))
5656
$0.count = 1
5757
},
5858
.send(.actionSheetDismissed) {

Examples/CaseStudies/SwiftUICaseStudiesTests/01-GettingStarted-SharedStateTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class SharedStateTests: XCTestCase {
8080
store.assert(
8181
.send(.isPrimeButtonTapped) {
8282
$0.alert = .init(
83-
title: "👍 The number \($0.count) is prime!"
83+
title: .init("👍 The number \($0.count) is prime!")
8484
)
8585
},
8686
.send(.alertDismissed) {
@@ -100,7 +100,7 @@ class SharedStateTests: XCTestCase {
100100
store.assert(
101101
.send(.isPrimeButtonTapped) {
102102
$0.alert = .init(
103-
title: "👎 The number \($0.count) is not prime :("
103+
title: .init("👎 The number \($0.count) is not prime :(")
104104
)
105105
},
106106
.send(.alertDismissed) {

0 commit comments

Comments
 (0)