Skip to content

Commit

Permalink
more updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrandonw committed Apr 8, 2024
1 parent 6479c12 commit 1f09da3
Show file tree
Hide file tree
Showing 7 changed files with 294 additions and 310 deletions.
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ if ProcessInfo.processInfo.environment["TEST_SERVER"] == nil {
name: "DailyChallengeHelpers",
dependencies: [
"ApiClient",
"ClientModels",
"SharedModels",
.product(name: "ComposableArchitecture", package: "swift-composable-architecture"),
]
Expand Down
15 changes: 1 addition & 14 deletions Sources/AppFeature/AppView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,7 @@ public struct AppReducer {

case .dailyChallengeReport:
state.destination = nil
state.home.destination = .dailyChallenge(
DailyChallengeReducer.State(
inProgressDailyChallengeUnlimited: state.$savedGames.dailyChallengeUnlimited
)
)
state.home.destination = .dailyChallenge(DailyChallengeReducer.State())
}
}

Expand Down Expand Up @@ -233,15 +229,6 @@ public struct AppReducer {
state.destination = .game(Game.State(inProgressGame: inProgressGame))
return .none

case let .home(.dailyChallengeResponse(.success(dailyChallenges))):
if dailyChallenges.unlimited?.dailyChallenge.id
!= state.savedGames.dailyChallengeUnlimited?.gameContext.dailyChallenge
{
state.savedGames.dailyChallengeUnlimited = nil
return .none
}
return .none

case .home(.howToPlayButtonTapped):
state.destination = .onboarding(Onboarding.State(presentationStyle: .help))
return .none
Expand Down
23 changes: 9 additions & 14 deletions Sources/DailyChallengeFeature/DailyChallengeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,18 @@ public struct DailyChallengeReducer {
public var dailyChallenges: [FetchTodaysDailyChallengeResponse]
@Presents public var destination: Destination.State?
public var gameModeIsLoading: GameMode?
@Shared public var inProgressDailyChallengeUnlimited: InProgressGame?
@Shared(.savedGames) public var savedGames = SavedGamesState()
public var userNotificationSettings: UserNotificationClient.Notification.Settings?

public init(
dailyChallenges: [FetchTodaysDailyChallengeResponse] = [],
destination: Destination.State? = nil,
gameModeIsLoading: GameMode? = nil,
inProgressDailyChallengeUnlimited: Shared<InProgressGame?>,
userNotificationSettings: UserNotificationClient.Notification.Settings? = nil
) {
self.dailyChallenges = dailyChallenges
self.destination = destination
self.gameModeIsLoading = gameModeIsLoading
self._inProgressDailyChallengeUnlimited = inProgressDailyChallengeUnlimited
self.userNotificationSettings = userNotificationSettings
}

Expand Down Expand Up @@ -107,7 +105,7 @@ public struct DailyChallengeReducer {
isPlayable = !challenge.yourResult.started
case .unlimited:
isPlayable =
!challenge.yourResult.started || state.inProgressDailyChallengeUnlimited != nil
!challenge.yourResult.started || state.savedGames.dailyChallengeUnlimited != nil
}

guard isPlayable
Expand Down Expand Up @@ -256,7 +254,7 @@ public struct DailyChallengeView: View {
var unlimitedState: ButtonState {
.init(
fetchedResponse: store.dailyChallenges.unlimited,
inProgressGame: store.inProgressDailyChallengeUnlimited
inProgressGame: store.savedGames.dailyChallengeUnlimited
)
}

Expand Down Expand Up @@ -457,18 +455,15 @@ private struct RingEffect: GeometryEffect {

struct DailyChallengeView_Previews: PreviewProvider {
static var previews: some View {
@Shared(.savedGames) var savedGames = SavedGamesState()
let _ = savedGames.dailyChallengeUnlimited = update(.mock) {
$0?.moves = [.highScoringMove]
}

Preview {
NavigationView {
DailyChallengeView(
store: .init(
initialState: DailyChallengeReducer.State(
inProgressDailyChallengeUnlimited: Shared(
update(.mock) {
$0?.moves = [.highScoringMove]
}
)
)
) {
store: .init(initialState: DailyChallengeReducer.State()) {
DailyChallengeReducer()
} withDependencies: {
$0.userNotifications.getNotificationSettings = {
Expand Down
10 changes: 6 additions & 4 deletions Sources/HomeFeature/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,17 @@ public struct Home {

case .dailyChallengeButtonTapped:
state.destination = .dailyChallenge(
DailyChallengeReducer.State(
dailyChallenges: state.dailyChallenges ?? [],
inProgressDailyChallengeUnlimited: state.$savedGames.dailyChallengeUnlimited
)
DailyChallengeReducer.State(dailyChallenges: state.dailyChallenges ?? [])
)
return .none

case let .dailyChallengeResponse(.success(dailyChallenges)):
state.dailyChallenges = dailyChallenges
if dailyChallenges.unlimited?.dailyChallenge.id
!= state.savedGames.dailyChallengeUnlimited?.gameContext.dailyChallenge
{
state.savedGames.dailyChallengeUnlimited = nil
}
return .none

case .dailyChallengeResponse(.failure):
Expand Down
1 change: 0 additions & 1 deletion Sources/SoloFeature/SoloView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public struct SoloView: View {
}
.adaptivePadding(.vertical)
.screenEdgePadding(.horizontal)
// .task { await store.send(.task).finish() }
.navigationStyle(
backgroundColor: self.colorScheme == .dark ? .isowordsBlack : .solo,
foregroundColor: self.colorScheme == .dark ? .solo : .isowordsBlack,
Expand Down

0 comments on commit 1f09da3

Please sign in to comment.