- Welcome migrated to ReducerProtocol - snapshot test fixed
This commit is contained in:
parent
53011ff4c8
commit
410de3bfa2
|
@ -8,6 +8,7 @@ typealias AppViewStore = ViewStore<AppState, AppAction>
|
||||||
|
|
||||||
typealias AnyRecoveryPhraseDisplayReducer = AnyReducer<RecoveryPhraseDisplayReducer.State, RecoveryPhraseDisplayReducer.Action, AppEnvironment>
|
typealias AnyRecoveryPhraseDisplayReducer = AnyReducer<RecoveryPhraseDisplayReducer.State, RecoveryPhraseDisplayReducer.Action, AppEnvironment>
|
||||||
typealias AnyRecoveryPhraseValidationFlowReducer = AnyReducer<RecoveryPhraseValidationFlowReducer.State, RecoveryPhraseValidationFlowReducer.Action, AppEnvironment>
|
typealias AnyRecoveryPhraseValidationFlowReducer = AnyReducer<RecoveryPhraseValidationFlowReducer.State, RecoveryPhraseValidationFlowReducer.Action, AppEnvironment>
|
||||||
|
typealias AnyWelcomeReducer = AnyReducer<WelcomeReducer.State, WelcomeReducer.Action, AppEnvironment>
|
||||||
|
|
||||||
// MARK: - State
|
// MARK: - State
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ struct AppState: Equatable {
|
||||||
var internalRoute: Route = .welcome
|
var internalRoute: Route = .welcome
|
||||||
var sandboxState: SandboxState
|
var sandboxState: SandboxState
|
||||||
var storedWallet: StoredWallet?
|
var storedWallet: StoredWallet?
|
||||||
var welcomeState: WelcomeState
|
var welcomeState: WelcomeReducer.State
|
||||||
|
|
||||||
var route: Route {
|
var route: Route {
|
||||||
get { internalRoute }
|
get { internalRoute }
|
||||||
|
@ -61,7 +62,7 @@ enum AppAction: Equatable {
|
||||||
case respondToWalletInitializationState(InitializationState)
|
case respondToWalletInitializationState(InitializationState)
|
||||||
case sandbox(SandboxAction)
|
case sandbox(SandboxAction)
|
||||||
case updateRoute(AppState.Route)
|
case updateRoute(AppState.Route)
|
||||||
case welcome(WelcomeAction)
|
case welcome(WelcomeReducer.Action)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Environment
|
// MARK: - Environment
|
||||||
|
@ -416,10 +417,13 @@ extension AppReducer {
|
||||||
environment: { _ in SandboxEnvironment() }
|
environment: { _ in SandboxEnvironment() }
|
||||||
)
|
)
|
||||||
|
|
||||||
private static let welcomeReducer: AppReducer = WelcomeReducer.default.pullback(
|
private static let welcomeReducer: AppReducer = AnyWelcomeReducer { _ in
|
||||||
|
WelcomeReducer()
|
||||||
|
}
|
||||||
|
.pullback(
|
||||||
state: \AppState.welcomeState,
|
state: \AppState.welcomeState,
|
||||||
action: /AppAction.welcome,
|
action: /AppAction.welcome,
|
||||||
environment: { _ in WelcomeEnvironment() }
|
environment: { $0 }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,28 +8,16 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
import ComposableArchitecture
|
import ComposableArchitecture
|
||||||
|
|
||||||
typealias WelcomeReducer = Reducer<WelcomeState, WelcomeAction, WelcomeEnvironment>
|
typealias WelcomeStore = Store<WelcomeReducer.State, WelcomeReducer.Action>
|
||||||
typealias WelcomeStore = Store<WelcomeState, WelcomeAction>
|
|
||||||
typealias WelcomeViewStore = ViewStore<WelcomeState, WelcomeAction>
|
|
||||||
|
|
||||||
// MARK: - State
|
struct WelcomeReducer: ReducerProtocol {
|
||||||
|
struct State: Equatable {}
|
||||||
|
|
||||||
struct WelcomeState: Equatable {}
|
enum Action: Equatable {
|
||||||
|
case debugMenuStartup
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Action
|
func reduce(into state: inout State, action: Action) -> ComposableArchitecture.EffectTask<Action> {
|
||||||
|
|
||||||
enum WelcomeAction: Equatable {
|
|
||||||
case debugMenuStartup
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Environment
|
|
||||||
|
|
||||||
struct WelcomeEnvironment { }
|
|
||||||
|
|
||||||
// MARK: - Reducer
|
|
||||||
|
|
||||||
extension WelcomeReducer {
|
|
||||||
static let `default` = WelcomeReducer { _, _, _ in
|
|
||||||
return .none
|
return .none
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,13 +27,12 @@ extension WelcomeReducer {
|
||||||
extension WelcomeStore {
|
extension WelcomeStore {
|
||||||
static var demo = WelcomeStore(
|
static var demo = WelcomeStore(
|
||||||
initialState: .placeholder,
|
initialState: .placeholder,
|
||||||
reducer: .default,
|
reducer: WelcomeReducer()
|
||||||
environment: WelcomeEnvironment()
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Placeholders
|
// MARK: - Placeholders
|
||||||
|
|
||||||
extension WelcomeState {
|
extension WelcomeReducer.State {
|
||||||
static let placeholder = WelcomeState()
|
static let placeholder = WelcomeReducer.State()
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,7 @@ class WelcomeSnapshotTests: XCTestCase {
|
||||||
func testWelcomeSnapshot() throws {
|
func testWelcomeSnapshot() throws {
|
||||||
let store = Store(
|
let store = Store(
|
||||||
initialState: .placeholder,
|
initialState: .placeholder,
|
||||||
reducer: WelcomeReducer.default,
|
reducer: WelcomeReducer()
|
||||||
environment: WelcomeEnvironment()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
addAttachments(WelcomeView(store: store))
|
addAttachments(WelcomeView(store: store))
|
||||||
|
|
Loading…
Reference in New Issue