Skip to content

Commit

Permalink
TCA Navigation (#185)
Browse files Browse the repository at this point in the history
* Use built-in Reducer.onChange

* wip

* wip

* update stats

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* fix

* wip

* Settings Dependency + Navigation Finesse (#186)

* Beginnings of the UserSettingsClient.

* extracted UserSettingsClient to its own library

* Decoupled haptics settings from some features.

* Stopped threading isAnimationReduced state through multple features and fixed tests.

* Stopped threading isAnimationReduced to leaderboard.

* Moved daily challenge settings into UserSettings.

* Moved enableNotifications to UserSettings.

* Moved developer settings to app storage.

* Game feature has its own settings, haven't deleted home settings yet.

* Removed GameFeature

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Fixed some runtime warnings.

* wip

* Flatten nag banner domains, remove old settings from home

* wip

* wip

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
  • Loading branch information
stephencelis and mbrandonw committed Aug 23, 2023
1 parent d683f23 commit 34e28fa
Show file tree
Hide file tree
Showing 131 changed files with 4,233 additions and 4,964 deletions.
11 changes: 5 additions & 6 deletions App/AppClip/AppClipApp.swift
Expand Up @@ -16,13 +16,12 @@ struct AppClipApp: App {
var body: some Scene {
WindowGroup {
DemoView(
store: Store(
initialState: Demo.State()
) {
store: Store(initialState: Demo.State()) {
Demo()
.dependency(\.apiClient, .appClip)
.dependency(\.audioPlayer, .live(bundles: [AppClipAudioLibrary.bundle]))
.dependency(\.dictionary, .file())
} withDependencies: {
$0.apiClient = .appClip
$0.audioPlayer = .live(bundles: [AppClipAudioLibrary.bundle])
$0.dictionary = .file()
}
)
}
Expand Down
5 changes: 2 additions & 3 deletions App/Previews/CubeCorePreview/CubeCorePreviewApp.swift
Expand Up @@ -11,16 +11,15 @@ struct CubeCorePreviewApp: App {
store: Store(
initialState: CubeSceneView.ViewState(
cubes: .mock,
enableGyroMotion: false,
isOnLowPowerMode: false,
nub: nil,
playedWords: [],
selectedFaceCount: 0,
selectedWordIsValid: false,
selectedWordString: "",
settings: .init(showSceneStatistics: true)
selectedWordString: ""
)
) {

}
)
}
Expand Down
8 changes: 3 additions & 5 deletions App/Previews/CubePreviewPreview/CubePreviewPreviewApp.swift
Expand Up @@ -19,8 +19,6 @@ struct CubePreviewPreviewApp: App {
store: Store(
initialState: CubePreview.State(
cubes: .mock,
isAnimationReduced: false,
isHapticsEnabled: true,
isOnLowPowerMode: false,
moveIndex: 0,
moves: [
Expand Down Expand Up @@ -56,12 +54,12 @@ struct CubePreviewPreviewApp: App {
),
])
)
],
settings: .init()
]
)
) {
CubePreview()
.dependency(\.audioPlayer, .noop)
} withDependencies: {
$0.audioPlayer = .noop
}
)
}
Expand Down
66 changes: 31 additions & 35 deletions App/Previews/GameOverPreview/GameOverPreviewApp.swift
Expand Up @@ -39,44 +39,39 @@ extension StoreOf<GameOver> {
)
) {
GameOver()
.dependency(
\.apiClient,
update(.noop) {
$0.override(
routeCase: (/ServerRoute.Api.Route.games)
.appending(path: /ServerRoute.Api.Route.Games.submit),
withResponse: { _ in
try await OK(
SubmitGameResponse.solo(
.init(
ranks: [
.allTime: .init(outOf: 152122, rank: 3828),
.lastDay: .init(outOf: 512, rank: 79),
.lastWeek: .init(outOf: 1603, rank: 605),
]
)
)
} withDependencies: {
$0.apiClient = update(.noop) {
$0.override(
routeCase: (/ServerRoute.Api.Route.games)
.appending(path: /ServerRoute.Api.Route.Games.submit),
withResponse: { _ in
try await OK(
SubmitGameResponse.solo(
.init(
ranks: [
.allTime: .init(outOf: 152122, rank: 3828),
.lastDay: .init(outOf: 512, rank: 79),
.lastWeek: .init(outOf: 1603, rank: 605),
]
)
}
)
)
}
)
.dependency(\.audioPlayer, .noop)
.dependency(
\.database,
.autoMigratingLive(
path: FileManager.default
.urls(for: .documentDirectory, in: .userDomainMask)
.first!
.appendingPathComponent("co.pointfree.Isowords")
.appendingPathComponent("Isowords.sqlite3")
)
)
.dependency(\.fileClient, .noop)
.dependency(\.remoteNotifications, .noop)
.dependency(\.serverConfig, .noop)
.dependency(\.userDefaults.boolForKey) { _ in false }
.dependency(\.userNotifications, .noop)
}
$0.audioPlayer = .noop
$0.database = .autoMigratingLive(
path: FileManager.default
.urls(for: .documentDirectory, in: .userDomainMask)
.first!
.appendingPathComponent("co.pointfree.Isowords")
.appendingPathComponent("Isowords.sqlite3")
)
$0.fileClient = .noop
$0.remoteNotifications = .noop
$0.serverConfig = .noop
$0.userDefaults.boolForKey = { _ in false }
$0.userNotifications = .noop
}
}

Expand All @@ -99,7 +94,8 @@ extension StoreOf<GameOver> {
)
) {
GameOver()
.dependency(\.context, .preview)
} withDependencies: {
$0.context = .preview
}
}
}
72 changes: 34 additions & 38 deletions App/Previews/HomeFeaturePreview/HomeFeaturePreviewApp.swift
Expand Up @@ -17,47 +17,43 @@ struct HomeFeaturePreviewApp: App {
WindowGroup {
NavigationView {
HomeView(
store: Store(
initialState: Home.State()
) {
store: Store(initialState: Home.State()) {
Home()
.dependency(
\.apiClient,
update(.noop) {
$0.authenticate = { _ in .init(appleReceipt: nil, player: .blob) }
$0.override(
route: .dailyChallenge(.today(language: .en)),
withResponse: {
try await OK([
FetchTodaysDailyChallengeResponse(
dailyChallenge: .init(
endsAt: .init(),
gameMode: .timed,
id: .init(rawValue: UUID()),
language: .en
),
yourResult: .init(
outOf: .random(in: 2000...4000),
rank: 10,
score: 3_000
)
)
])
}
)
} withDependencies: {
$0.apiClient = update(.noop) {
$0.authenticate = { _ in .init(appleReceipt: nil, player: .blob) }
$0.override(
route: .dailyChallenge(.today(language: .en)),
withResponse: {
try await OK([
FetchTodaysDailyChallengeResponse(
dailyChallenge: .init(
endsAt: .init(),
gameMode: .timed,
id: .init(rawValue: UUID()),
language: .en
),
yourResult: .init(
outOf: .random(in: 2000...4000),
rank: 10,
score: 3_000
)
)
])
}
)
.dependency(\.applicationClient, .noop)
.dependency(\.audioPlayer, .noop)
.dependency(\.build, .noop)
.dependency(\.database, .inMemory)
.dependency(\.deviceId, .noop)
.dependency(\.gameCenter, .noop)
.dependency(\.remoteNotifications, .noop)
.dependency(\.serverConfig, .noop)
.dependency(\.storeKit, .noop)
.dependency(\.userDefaults, .noop)
.dependency(\.userNotifications, .noop)
}
$0.applicationClient = .noop
$0.audioPlayer = .noop
$0.build = .noop
$0.database = .inMemory
$0.deviceId = .noop
$0.gameCenter = .noop
$0.remoteNotifications = .noop
$0.serverConfig = .noop
$0.storeKit = .noop
$0.userDefaults = .noop
$0.userNotifications = .noop
}
)
}
Expand Down
13 changes: 6 additions & 7 deletions App/Previews/LeaderboardsPreview/LeaderboardsPreviewApp.swift
Expand Up @@ -55,14 +55,13 @@ struct LeaderboardsPreviewApp: App {

return WindowGroup {
LeaderboardView(
store: .init(
initialState: Leaderboard.State(isHapticsEnabled: false, settings: .init())
) {
store: Store(initialState: Leaderboard.State()) {
Leaderboard()
.dependency(\.apiClient, apiClient)
.dependency(\.audioPlayer, .noop)
.dependency(\.feedbackGenerator, .noop)
.dependency(\.lowPowerMode, .false)
} withDependencies: {
$0.apiClient = apiClient
$0.audioPlayer = .noop
$0.feedbackGenerator = .noop
$0.lowPowerMode = .false
}
)
}
Expand Down
11 changes: 4 additions & 7 deletions App/Previews/OnboardingPreview/OnboardingPreviewApp.swift
Expand Up @@ -15,14 +15,11 @@ struct OnboardingPreviewApp: App {
var body: some Scene {
WindowGroup {
OnboardingView(
store: Store(
initialState: Onboarding.State(presentationStyle: .firstLaunch)
) {
store: Store(initialState: Onboarding.State(presentationStyle: .firstLaunch)) {
Onboarding()
.dependency(
\.audioPlayer, .live(bundles: [AppClipAudioLibrary.bundle, AppAudioLibrary.bundle])
)
.dependency(\.userDefaults, .noop)
} withDependencies: {
$0.audioPlayer = .live(bundles: [AppClipAudioLibrary.bundle, AppAudioLibrary.bundle])
$0.userDefaults = .noop
}
)
}
Expand Down
15 changes: 7 additions & 8 deletions App/Previews/SettingsPreview/SettingsPreviewApp.swift
Expand Up @@ -20,15 +20,14 @@ struct SettingsPreviewApp: App {
WindowGroup {
NavigationView {
SettingsView(
store: .init(
initialState: Settings.State()
) {
store: .init(initialState: Settings.State()) {
Settings()
.dependency(\.apiClient, .noop)
.dependency(\.audioPlayer, .noop)
.dependency(\.build, .noop)
.dependency(\.database, .noop)
.dependency(\.serverConfig, .live(fetch: { .init() }))
} withDependencies: {
$0.apiClient = .noop
$0.audioPlayer = .noop
$0.build = .noop
$0.database = .noop
$0.serverConfig = .live(fetch: { .init() })
},
navPresentationStyle: .modal
)
Expand Down
49 changes: 21 additions & 28 deletions App/Previews/TrailerPreview/TrailerPreviewApp.swift
Expand Up @@ -15,35 +15,28 @@ struct TrailerPreviewApp: App {
var body: some Scene {
WindowGroup {
TrailerView(
store: .init(
initialState: Trailer.State()
) {
store: .init(initialState: Trailer.State()) {
Trailer()
.dependency(
\.audioPlayer,
.live(bundles: [
AppAudioLibrary.bundle,
AppClipAudioLibrary.bundle,
])
)
.dependency(
\.dictionary,
.init(
contains: { string, _ in
[
"SAY", "HELLO", "TO", "ISOWORDS",
"A", "NEW", "WORD", "SEARCH", "GAME",
"FOR", "YOUR", "PHONE",
"COMING", "NEXT", "YEAR",
]
.contains(string.uppercased())
},
load: { _ in true },
lookup: { _, _ in nil },
randomCubes: { _ in .mock },
unload: { _ in }
)
)
} withDependencies: {
$0.audioPlayer = .live(bundles: [
AppAudioLibrary.bundle,
AppClipAudioLibrary.bundle,
])
$0.dictionary = .init(
contains: { string, _ in
[
"SAY", "HELLO", "TO", "ISOWORDS",
"A", "NEW", "WORD", "SEARCH", "GAME",
"FOR", "YOUR", "PHONE",
"COMING", "NEXT", "YEAR",
]
.contains(string.uppercased())
},
load: { _ in true },
lookup: { _, _ in nil },
randomCubes: { _ in .mock },
unload: { _ in }
)
}
)
.statusBar(hidden: true)
Expand Down
Expand Up @@ -13,11 +13,10 @@ struct UpgradeInterstitialPreviewApp: App {
var body: some Scene {
WindowGroup {
UpgradeInterstitialView(
store: Store(
initialState: UpgradeInterstitial.State()
) {
store: Store(initialState: UpgradeInterstitial.State()) {
UpgradeInterstitial()
.dependency(\.serverConfig, .noop)
} withDependencies: {
$0.serverConfig = .noop
}
)
}
Expand Down

0 comments on commit 34e28fa

Please sign in to comment.