Connect Phrase Display to validation
This commit is contained in:
parent
a7fab173c0
commit
5647b7d7e0
|
@ -1,15 +1,17 @@
|
|||
import ComposableArchitecture
|
||||
|
||||
struct AppState: Equatable {
|
||||
enum Route {
|
||||
enum Route: Equatable {
|
||||
case startup
|
||||
case onboarding
|
||||
case home
|
||||
case phraseValidation
|
||||
case phraseDisplay
|
||||
}
|
||||
var homeState: HomeState
|
||||
var onboardingState: OnboardingState
|
||||
var phraseValidationState: RecoveryPhraseValidationState
|
||||
var phraseDisplayState: RecoveryPhraseDisplayState
|
||||
var route: Route = .startup
|
||||
}
|
||||
|
||||
|
@ -17,6 +19,7 @@ enum AppAction: Equatable {
|
|||
case updateRoute(AppState.Route)
|
||||
case home(HomeAction)
|
||||
case onboarding(OnboardingAction)
|
||||
case phraseDisplay(RecoveryPhraseDisplayAction)
|
||||
case phraseValidation(RecoveryPhraseValidationAction)
|
||||
}
|
||||
|
||||
|
@ -33,7 +36,8 @@ extension AppReducer {
|
|||
routeReducer,
|
||||
homeReducer,
|
||||
onboardingReducer,
|
||||
phraseValidationReducer.debug()
|
||||
phraseValidationReducer.debug(),
|
||||
phraseDisplayReducer.debug()
|
||||
]
|
||||
)
|
||||
|
||||
|
@ -43,8 +47,14 @@ extension AppReducer {
|
|||
state.route = route
|
||||
case .home(.reset):
|
||||
state.route = .startup
|
||||
case .onboarding(.createNewWallet), .phraseValidation(.proceedToHome):
|
||||
case .onboarding(.createNewWallet),
|
||||
.phraseValidation(.proceedToHome):
|
||||
state.route = .home
|
||||
case .phraseValidation(.displayBackedUpPhrase),
|
||||
.phraseDisplay(.createPhrase):
|
||||
state.route = .phraseDisplay
|
||||
case .phraseDisplay(.finishedPressed):
|
||||
state.route = .phraseValidation
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
@ -68,6 +78,12 @@ extension AppReducer {
|
|||
action: /AppAction.phraseValidation,
|
||||
environment: { _ in BackupPhraseEnvironment.demo }
|
||||
)
|
||||
|
||||
private static let phraseDisplayReducer: AppReducer = RecoveryPhraseDisplayReducer.default.pullback(
|
||||
state: \AppState.phraseDisplayState,
|
||||
action: /AppAction.phraseDisplay,
|
||||
environment: { _ in BackupPhraseEnvironment.demo }
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - AppStore
|
||||
|
@ -91,7 +107,10 @@ extension AppState {
|
|||
.init(
|
||||
homeState: .placeholder,
|
||||
onboardingState: .init(),
|
||||
phraseValidationState: RecoveryPhraseValidationState.placeholder
|
||||
phraseValidationState: RecoveryPhraseValidationState.placeholder,
|
||||
phraseDisplayState: RecoveryPhraseDisplayState(
|
||||
phrase: RecoveryPhrase.placeholder
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ struct AppView: View {
|
|||
)
|
||||
}
|
||||
.navigationViewStyle(StackNavigationViewStyle())
|
||||
|
||||
case .onboarding:
|
||||
OnboardingScreen(
|
||||
store: store.scope(
|
||||
|
@ -25,10 +26,12 @@ struct AppView: View {
|
|||
action: AppAction.onboarding
|
||||
)
|
||||
)
|
||||
|
||||
case .startup:
|
||||
ZStack(alignment: .topTrailing) {
|
||||
StartupView(sendAction: viewStore.send)
|
||||
}
|
||||
|
||||
case .phraseValidation:
|
||||
NavigationView {
|
||||
RecoveryPhraseBackupValidationView(
|
||||
|
@ -50,6 +53,16 @@ struct AppView: View {
|
|||
})
|
||||
.navigationViewStyle(StackNavigationViewStyle())
|
||||
}
|
||||
|
||||
case .phraseDisplay:
|
||||
NavigationView {
|
||||
RecoveryPhraseDisplayView(
|
||||
store: store.scope(
|
||||
state: \.phraseDisplayState,
|
||||
action: AppAction.phraseDisplay
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,6 +85,10 @@ private struct StartupView: View {
|
|||
Button("Go To Phrase Validation Demo") {
|
||||
sendAction(.updateRoute(.phraseValidation))
|
||||
}
|
||||
|
||||
Button("Go To Phrase Display Demo") {
|
||||
sendAction(.updateRoute(.phraseDisplay))
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationBarTitle("Startup")
|
||||
|
|
|
@ -202,6 +202,7 @@ enum RecoveryPhraseValidationAction: Equatable {
|
|||
case succeed
|
||||
case fail
|
||||
case proceedToHome
|
||||
case displayBackedUpPhrase
|
||||
}
|
||||
|
||||
typealias RecoveryPhraseValidationReducer = Reducer<RecoveryPhraseValidationState, RecoveryPhraseValidationAction, BackupPhraseEnvironment>
|
||||
|
@ -233,11 +234,16 @@ extension RecoveryPhraseValidationReducer {
|
|||
case .fail:
|
||||
state.route = .failure
|
||||
return .none
|
||||
|
||||
case .updateRoute(let route):
|
||||
state.route = route
|
||||
return .none
|
||||
|
||||
case .proceedToHome:
|
||||
return .none
|
||||
|
||||
case .displayBackedUpPhrase:
|
||||
return .none
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ struct ValidationSuccededView: View {
|
|||
VStack(spacing: 10) {
|
||||
Text("Success!")
|
||||
.font(.custom(FontFamily.Rubik.regular.name, size: 36))
|
||||
|
||||
Text("Place that backup somewhere safe and venture forth in security.")
|
||||
.font(.custom(FontFamily.Rubik.regular.name, size: 17))
|
||||
.multilineTextAlignment(.center)
|
||||
|
@ -52,7 +53,7 @@ struct ValidationSuccededView: View {
|
|||
)
|
||||
|
||||
Button(
|
||||
action: { () },
|
||||
action: { viewStore.send(.displayBackedUpPhrase, animation: .easeIn(duration: 1)) },
|
||||
label: { Text("Show me my phrase again") }
|
||||
)
|
||||
.secondaryButtonStyle
|
||||
|
|
Loading…
Reference in New Issue