Skip to content

Commit

Permalink
Fix a bunch of deprecation warnings. (#181)
Browse files Browse the repository at this point in the history
* Fix a bunch of deprecation warnings.

* wip
  • Loading branch information
mbrandonw committed Jun 20, 2023
1 parent 63f1c31 commit 5ef99f5
Show file tree
Hide file tree
Showing 42 changed files with 110 additions and 98 deletions.
5 changes: 3 additions & 2 deletions Sources/AppFeature/AppView.swift
Expand Up @@ -342,7 +342,7 @@ public struct AppView: View {

public init(store: StoreOf<AppReducer>) {
self.store = store
self.viewStore = ViewStore(self.store.scope(state: ViewState.init))
self.viewStore = ViewStore(self.store.scope(state: ViewState.init, action: { $0 }))
}

public var body: some View {
Expand All @@ -368,7 +368,8 @@ public struct AppView: View {
)
)
}
}
},
action: { $0 }
),
then: { gameAndSettingsStore in
GameFeatureView(
Expand Down
2 changes: 1 addition & 1 deletion Sources/ChangelogFeature/ChangelogView.swift
Expand Up @@ -122,7 +122,7 @@ public struct ChangelogView: View {
}

public var body: some View {
WithViewStore(self.store.scope(state: ViewState.init)) { viewStore in
WithViewStore(self.store.scope(state: ViewState.init, action: { $0 })) { viewStore in
ScrollView {
VStack(alignment: .leading) {
if viewStore.isUpdateButtonVisible {
Expand Down
7 changes: 4 additions & 3 deletions Sources/CubeCore/CubeNode.swift
Expand Up @@ -71,20 +71,21 @@ public class CubeNode: SCNNode {
letterGeometry: SCNGeometry,
store: Store<ViewState, Never>
) {
func absurd<A>(_: Never) -> A {}
self.viewStore = ViewStore(store)

self.index = self.viewStore.index
self.leftPlaneNode = CubeFaceNode(
letterGeometry: letterGeometry,
store: store.scope(state: \.left)
store: store.scope(state: \.left, action: absurd)
)
self.rightPlaneNode = CubeFaceNode(
letterGeometry: letterGeometry,
store: store.scope(state: \.right)
store: store.scope(state: \.right, action: absurd)
)
self.topPlaneNode = CubeFaceNode(
letterGeometry: letterGeometry,
store: store.scope(state: \.top)
store: store.scope(state: \.top, action: absurd)
)

super.init()
Expand Down
2 changes: 1 addition & 1 deletion Sources/CubeCore/CubeSceneView.swift
Expand Up @@ -146,8 +146,8 @@ public class CubeSceneView: SCNView, UIGestureRecognizerDelegate {
let cube = CubeNode(
letterGeometry: letterGeometry,
store: store
.scope(state: \.cubes[index], action: { $0 })
.actionless
.scope(state: \.cubes[index])
)
cube.scale = SCNVector3(x: 1 / 3, y: 1 / 3, z: 1 / 3)
self.gameCubeNode.addChildNode(cube)
Expand Down
14 changes: 8 additions & 6 deletions Sources/CubePreview/CubePreviewView.swift
Expand Up @@ -69,7 +69,7 @@ public struct CubePreview: ReducerProtocol {
public var body: some ReducerProtocol<State, Action> {
BindingReducer()
Reduce { state, action in
enum SelectionID {}
enum CancelID { case selection }

switch action {
case .binding:
Expand All @@ -90,7 +90,7 @@ public struct CubePreview: ReducerProtocol {
case .removedCube:
break
}
return .cancel(id: SelectionID.self)
return .cancel(id: CancelID.selection)

case .task:
return .run { [move = state.moves[state.moveIndex]] send in
Expand Down Expand Up @@ -145,7 +145,7 @@ public struct CubePreview: ReducerProtocol {
break
}
}
.cancellable(id: SelectionID.self)
.cancellable(id: CancelID.selection)
}
}
.haptics(
Expand Down Expand Up @@ -185,7 +185,7 @@ public struct CubePreviewView: View {

public init(store: StoreOf<CubePreview>) {
self.store = store
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(state:)))
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(state:), action: { $0 }))
}

public var body: some View {
Expand Down Expand Up @@ -229,15 +229,17 @@ public struct CubePreviewView: View {
? nil
: BloomBackground(
size: proxy.size,
store: self.store.actionless
store: self.store
.scope(
state: { _ in
BloomBackground.ViewState(
bloomCount: self.viewStore.selectedWordString.count,
word: self.viewStore.selectedWordString
)
}
},
action: { $0 }
)
.actionless
)
)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/DailyChallengeFeature/CalendarView.swift
Expand Up @@ -69,7 +69,7 @@ struct CalendarView: View {
store: StoreOf<DailyChallengeResults>
) {
self.store = store
self.viewStore = ViewStore(store.scope(state: ViewState.init(state:)))
self.viewStore = ViewStore(store.scope(state: ViewState.init(state:), action: { $0 }))
}

var body: some View {
Expand Down
4 changes: 2 additions & 2 deletions Sources/DailyChallengeFeature/DailyChallengeResults.swift
Expand Up @@ -66,7 +66,7 @@ public struct DailyChallengeResults: ReducerProtocol {
state.history = nil
}

enum CancelID {}
enum CancelID { case fetch }
return .task { [gameMode = state.leaderboardResults.gameMode] in
await .fetchHistoryResponse(
TaskResult {
Expand All @@ -77,7 +77,7 @@ public struct DailyChallengeResults: ReducerProtocol {
}
)
}
.cancellable(id: CancelID.self, cancelInFlight: true)
.cancellable(id: CancelID.fetch, cancelInFlight: true)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/DailyChallengeFeature/DailyChallengeView.swift
Expand Up @@ -294,7 +294,7 @@ public struct DailyChallengeView: View {

public init(store: StoreOf<DailyChallengeReducer>) {
self.store = store
self.viewStore = ViewStore(self.store.scope(state: ViewState.init))
self.viewStore = ViewStore(self.store.scope(state: ViewState.init, action: { $0 }))
}

public var body: some View {
Expand Down Expand Up @@ -390,7 +390,7 @@ public struct DailyChallengeView: View {
.background(self.colorScheme == .dark ? Color.dailyChallenge : .isowordsBlack)
}
.task { await self.viewStore.send(.task).finish() }
.alert(self.store.scope(state: \.alert), dismiss: .dismissAlert)
.alert(self.store.scope(state: \.alert, action: { $0 }), dismiss: .dismissAlert)
.navigationStyle(
backgroundColor: self.colorScheme == .dark ? .isowordsBlack : .dailyChallenge,
foregroundColor: self.colorScheme == .dark ? .dailyChallenge : .isowordsBlack,
Expand Down
4 changes: 2 additions & 2 deletions Sources/DemoFeature/Demo.swift
Expand Up @@ -154,11 +154,11 @@ public struct DemoView: View {
store: StoreOf<Demo>
) {
self.store = store
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(state:)))
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(state:), action: { $0 }))
}

public var body: some View {
SwitchStore(self.store.scope(state: \.step)) {
SwitchStore(self.store.scope(state: \.step, action: { $0 })) {
CaseLet(
state: /Demo.State.Step.onboarding,
action: Demo.Action.onboarding,
Expand Down
10 changes: 5 additions & 5 deletions Sources/GameCore/SoundsCore.swift
Expand Up @@ -16,13 +16,13 @@ private struct GameSounds<Base: ReducerProtocol<Game.State, Game.Action>>: Reduc

let base: Base

enum CubeShakingID {}
enum CancelID { case cubeShaking }

var body: some ReducerProtocol<Game.State, Game.Action> {
self.core
.onChange(of: { $0.gameOver == nil }) { _, _, _ in
.fireAndForget {
Task.cancel(id: CubeShakingID.self)
Task.cancel(id: CancelID.cubeShaking)
for music in AudioPlayerClient.Sound.allMusic where music != .gameOverMusicLoop {
await self.audioPlayer.stop(music)
}
Expand Down Expand Up @@ -59,7 +59,7 @@ private struct GameSounds<Base: ReducerProtocol<Game.State, Game.Action>>: Reduc
guard !selectedWord.isEmpty
else {
state.cubeStartedShakingAt = nil
return .cancel(id: CubeShakingID.self)
return .cancel(id: CancelID.cubeShaking)
}

let previousWord = state.cubes.string(from: previousSelection)
Expand All @@ -84,11 +84,11 @@ private struct GameSounds<Base: ReducerProtocol<Game.State, Game.Action>>: Reduc
await self.audioPlayer.play(.cubeShake)
}
}
.cancellable(id: CubeShakingID.self)
.cancellable(id: CancelID.cubeShaking)

} else {
state.cubeStartedShakingAt = nil
return .cancel(id: CubeShakingID.self)
return .cancel(id: CancelID.cubeShaking)
}
}
.onChange(of: \.moves.last) { lastMove, state, _ in
Expand Down
4 changes: 2 additions & 2 deletions Sources/GameCore/Views/GameFooterView.swift
Expand Up @@ -25,7 +25,7 @@ public struct GameFooterView: View {
self.isAnimationReduced = isAnimationReduced
self.isLeftToRight = isLeftToRight
self.store = store
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(state:)))
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(state:), action: { $0 }))
}

public var body: some View {
Expand Down Expand Up @@ -64,7 +64,7 @@ public struct WordListView: View {
) {
self.isLeftToRight = isLeftToRight
self.store = store
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(state:)))
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(state:), action: { $0 }))
}

struct SpacerId: Hashable {}
Expand Down
4 changes: 2 additions & 2 deletions Sources/GameCore/Views/GameHeaderView.swift
Expand Up @@ -21,7 +21,7 @@ struct GameHeaderView: View {
store: StoreOf<Game>
) {
self.store = store
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(state:)))
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(state:), action: { $0 }))
}

var body: some View {
Expand Down Expand Up @@ -67,7 +67,7 @@ struct ScoreView: View {
store: StoreOf<Game>
) {
self.store = store
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(state:)))
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(state:), action: { $0 }))
}

var body: some View {
Expand Down
2 changes: 1 addition & 1 deletion Sources/GameCore/Views/GameNavView.swift
Expand Up @@ -21,7 +21,7 @@ struct GameNavView: View {
store: StoreOf<Game>
) {
self.store = store
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(state:)))
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(state:), action: { $0 }))
}

var body: some View {
Expand Down
10 changes: 6 additions & 4 deletions Sources/GameCore/Views/GameView.swift
Expand Up @@ -43,7 +43,7 @@ public struct GameView<Content>: View where Content: View {
self.content = content
self.isAnimationReduced = isAnimationReduced
self.store = store
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(state:)))
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(state:), action: { $0 }))
}

public var body: some View {
Expand Down Expand Up @@ -158,22 +158,24 @@ public struct GameView<Content>: View where Content: View {
? nil
: BloomBackground(
size: proxy.size,
store: self.store.actionless
store: self.store
.scope(
state: {
BloomBackground.ViewState(
bloomCount: $0.selectedWord.count,
word: $0.selectedWordString
)
}
},
action: { $0 }
)
.actionless
)
)
.background(
Color(self.colorScheme == .dark ? .hex(0x111111) : .white)
.ignoresSafeArea()
)
.bottomMenu(self.store.scope(state: \.bottomMenu))
.bottomMenu(self.store.scope(state: \.bottomMenu, action: { $0 }))
.alert(
self.store.scope(state: \.alert, action: Game.Action.alert),
dismiss: .dismiss
Expand Down
2 changes: 1 addition & 1 deletion Sources/GameCore/Views/PlayersAndScoresView.swift
Expand Up @@ -35,7 +35,7 @@ struct PlayersAndScoresView: View {
store: StoreOf<Game>
) {
self.store = store
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(state:)))
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(state:), action: { $0 }))
}

var body: some View {
Expand Down
8 changes: 4 additions & 4 deletions Sources/GameCore/Views/WordSubmitButton.swift
Expand Up @@ -60,7 +60,7 @@ public struct WordSubmitButtonFeature: ReducerProtocol {
@Dependency(\.audioPlayer.play) var playSound

public func reduce(into state: inout State, action: Action) -> EffectTask<Action> {
enum SubmitButtonPressedDelayID {}
enum CancelID { case submitButtonPressedDelay }

guard state.isYourTurn
else { return .none }
Expand Down Expand Up @@ -106,7 +106,7 @@ public struct WordSubmitButtonFeature: ReducerProtocol {
try await self.mainQueue.sleep(for: 0.5)
return .delayedSubmitButtonPressed
}
.cancellable(id: SubmitButtonPressedDelayID.self, cancelInFlight: true)
.cancellable(id: CancelID.submitButtonPressedDelay, cancelInFlight: true)

case .submitButtonReleased:
guard state.isTurnBasedMatch
Expand All @@ -117,7 +117,7 @@ public struct WordSubmitButtonFeature: ReducerProtocol {
state.wordSubmitButton.isSubmitButtonPressed = false

return .run { [areReactionsOpen = state.wordSubmitButton.areReactionsOpen] send in
Task.cancel(id: SubmitButtonPressedDelayID.self)
Task.cancel(id: CancelID.submitButtonPressedDelay)
guard !wasClosing && !areReactionsOpen
else { return }
await send(.delegate(.confirmSubmit(reaction: nil)))
Expand Down Expand Up @@ -161,7 +161,7 @@ public struct WordSubmitButton: View {
Spacer()

ZStack {
ReactionsView(store: self.store.scope(state: \.wordSubmitButton))
ReactionsView(store: self.store.scope(state: \.wordSubmitButton, action: { $0 }))

Button(action: {
self.viewStore.send(.submitButtonTapped, animation: .default)
Expand Down
6 changes: 3 additions & 3 deletions Sources/GameFeature/GameFeatureView.swift
Expand Up @@ -16,10 +16,10 @@ public struct GameFeatureView<Content>: View where Content: View {

public var body: some View {
IfLetStore(
self.store.scope(state: \.game),
self.store.scope(state: \.game, action: { $0 }),
then: { store in
WithViewStore(
self.store.scope(state: \.settings.userSettings.enableReducedAnimation)
self.store.scope(state: \.settings.userSettings.enableReducedAnimation, action: { $0 })
) { viewStore in
GameView(
content: self.content,
Expand All @@ -31,7 +31,7 @@ public struct GameFeatureView<Content>: View where Content: View {
)
.background(Color.adaptiveWhite)
.background(
WithViewStore(self.store.scope(state: { $0.game?.isSettingsPresented ?? false })) {
WithViewStore(self.store.scope(state: { $0.game?.isSettingsPresented ?? false }, action: { $0 })) {
viewStore in
// NB: If an .alert/.sheet modifier is used on a child view while the parent view is also
// using an .alert/.sheet modifier, then the child view’s alert/sheet will never appear:
Expand Down
2 changes: 1 addition & 1 deletion Sources/GameOverFeature/GameOverView.swift
Expand Up @@ -424,7 +424,7 @@ public struct GameOverView: View {

public init(store: StoreOf<GameOver>) {
self.store = store
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(state:)))
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(state:), action: { $0 }))
}

public var body: some View {
Expand Down
2 changes: 1 addition & 1 deletion Sources/HomeFeature/DailyChallengeHeaderView.swift
Expand Up @@ -23,7 +23,7 @@ struct DailyChallengeHeaderView: View {

init(store: StoreOf<Home>) {
self.store = store
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(homeState:)))
self.viewStore = ViewStore(self.store.scope(state: ViewState.init(homeState:), action: { $0 }))
}

var body: some View {
Expand Down
2 changes: 1 addition & 1 deletion Sources/HomeFeature/Home.swift
Expand Up @@ -501,7 +501,7 @@ public struct HomeView: View {

public init(store: StoreOf<Home>) {
self.store = store
self.viewStore = ViewStore(store.scope(state: ViewState.init))
self.viewStore = ViewStore(store.scope(state: ViewState.init, action: { $0 }))
}

public var body: some View {
Expand Down

0 comments on commit 5ef99f5

Please sign in to comment.