2021-11-09 03:59:03 -08:00
|
|
|
//
|
|
|
|
// OnboardingFooterView.swift
|
|
|
|
// secant-testnet
|
|
|
|
//
|
|
|
|
// Created by Adam Stener on 11/18/21.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
import ComposableArchitecture
|
|
|
|
|
|
|
|
struct OnboardingFooterView: View {
|
|
|
|
let store: Store<OnboardingState, OnboardingAction>
|
|
|
|
let animationDuration: CGFloat = 0.8
|
|
|
|
|
|
|
|
var body: some View {
|
2022-02-21 12:17:49 -08:00
|
|
|
WithViewStore(self.store) { viewStore in
|
|
|
|
VStack(spacing: 5) {
|
|
|
|
Spacer()
|
|
|
|
|
|
|
|
if viewStore.isFinalStep {
|
2022-02-25 04:27:50 -08:00
|
|
|
Button("onboarding.button.newWallet") {
|
2022-02-21 12:17:49 -08:00
|
|
|
withAnimation(.easeInOut(duration: animationDuration)) {
|
|
|
|
viewStore.send(.createNewWallet)
|
|
|
|
}
|
|
|
|
}
|
2022-03-01 00:12:50 -08:00
|
|
|
.activeButtonStyle
|
2022-02-23 09:32:54 -08:00
|
|
|
.onboardingFooterButtonLayout()
|
2021-11-09 03:59:03 -08:00
|
|
|
|
2022-02-25 04:27:50 -08:00
|
|
|
Button("onboarding.button.importWallet") {
|
2022-02-21 12:17:49 -08:00
|
|
|
withAnimation(.easeInOut(duration: animationDuration)) {
|
2022-03-01 00:12:50 -08:00
|
|
|
viewStore.send(.importExistingWallet)
|
2021-11-09 03:59:03 -08:00
|
|
|
}
|
2022-02-21 12:17:49 -08:00
|
|
|
}
|
|
|
|
.secondaryButtonStyle
|
2022-02-23 09:32:54 -08:00
|
|
|
.onboardingFooterButtonLayout()
|
2022-02-21 12:17:49 -08:00
|
|
|
} else {
|
|
|
|
Button("Next") {
|
|
|
|
withAnimation(.easeInOut(duration: animationDuration)) {
|
|
|
|
viewStore.send(.next)
|
2021-11-09 03:59:03 -08:00
|
|
|
}
|
|
|
|
}
|
2022-02-21 12:17:49 -08:00
|
|
|
.primaryButtonStyle
|
2022-02-23 09:32:54 -08:00
|
|
|
.onboardingFooterButtonLayout()
|
2021-11-09 03:59:03 -08:00
|
|
|
|
|
|
|
ProgressView(
|
2022-02-23 09:32:54 -08:00
|
|
|
String(format: "%02d", viewStore.index + 1),
|
2021-11-09 03:59:03 -08:00
|
|
|
value: Double(viewStore.index + 1),
|
|
|
|
total: Double(viewStore.steps.count)
|
|
|
|
)
|
2022-02-23 09:32:54 -08:00
|
|
|
.onboardingProgressStyle
|
|
|
|
.padding(.horizontal, 30)
|
|
|
|
.padding(.vertical, 20)
|
2021-11-09 03:59:03 -08:00
|
|
|
}
|
|
|
|
}
|
2022-03-01 00:12:50 -08:00
|
|
|
.navigationLinkEmpty(
|
|
|
|
isActive: viewStore.bindingForRoute(.importExistingWallet),
|
|
|
|
destination: {
|
|
|
|
ImportWalletView(
|
|
|
|
store: store.scope(
|
|
|
|
state: \.importWalletState,
|
|
|
|
action: OnboardingAction.importWallet
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
)
|
2021-11-09 03:59:03 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-23 09:32:54 -08:00
|
|
|
// swiftlint:disable:next private_over_fileprivate strict_fileprivate
|
|
|
|
fileprivate struct OnboardingFooterButtonLayout: ViewModifier {
|
2022-02-21 12:17:49 -08:00
|
|
|
func body(content: Content) -> some View {
|
|
|
|
content
|
|
|
|
.frame(height: 60)
|
|
|
|
.padding(.horizontal, 28)
|
|
|
|
.transition(.opacity)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension View {
|
2022-02-23 09:32:54 -08:00
|
|
|
func onboardingFooterButtonLayout() -> some View {
|
2022-02-21 12:17:49 -08:00
|
|
|
modifier(OnboardingFooterButtonLayout())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-09 03:59:03 -08:00
|
|
|
struct OnboardingFooterView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
let store = Store<OnboardingState, OnboardingAction>(
|
2022-03-01 00:12:50 -08:00
|
|
|
initialState: OnboardingState(
|
|
|
|
index: 3,
|
|
|
|
importWalletState: .placeholder
|
|
|
|
),
|
2021-11-09 03:59:03 -08:00
|
|
|
reducer: OnboardingReducer.default,
|
|
|
|
environment: ()
|
|
|
|
)
|
|
|
|
|
|
|
|
Group {
|
|
|
|
OnboardingFooterView(store: store)
|
2022-02-21 12:17:49 -08:00
|
|
|
.applyScreenBackground()
|
|
|
|
.preferredColorScheme(.light)
|
|
|
|
.previewDevice("iPhone 13 Pro Max")
|
|
|
|
|
|
|
|
OnboardingFooterView(store: store)
|
|
|
|
.applyScreenBackground()
|
2021-11-09 03:59:03 -08:00
|
|
|
.preferredColorScheme(.dark)
|
|
|
|
.previewDevice("iPhone 13 Pro Max")
|
|
|
|
|
|
|
|
OnboardingFooterView(store: store)
|
2022-02-21 12:17:49 -08:00
|
|
|
.applyScreenBackground()
|
2021-11-09 03:59:03 -08:00
|
|
|
.preferredColorScheme(.dark)
|
|
|
|
.previewDevice("iPhone 13 mini")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|