49 lines
1.5 KiB
Swift
49 lines
1.5 KiB
Swift
//
|
|
// AddKeystoneHWWalletCoordFlowCoordinator.swift
|
|
// Zashi
|
|
//
|
|
// Created by Lukáš Korba on 2025-03-19.
|
|
//
|
|
|
|
import ComposableArchitecture
|
|
import Generated
|
|
import AudioServices
|
|
|
|
// Path
|
|
import AddKeystoneHWWallet
|
|
import Scan
|
|
|
|
extension AddKeystoneHWWalletCoordFlow {
|
|
public func coordinatorReduce() -> Reduce<AddKeystoneHWWalletCoordFlow.State, AddKeystoneHWWalletCoordFlow.Action> {
|
|
Reduce { state, action in
|
|
switch action {
|
|
|
|
// MARK: - Scan
|
|
|
|
case .path(.element(id: _, action: .scan(.foundAccounts(let account)))):
|
|
var addKeystoneHWWalletState = AddKeystoneHWWallet.State.initial
|
|
addKeystoneHWWalletState.zcashAccounts = account
|
|
state.path.append(.accountHWWalletSelection(addKeystoneHWWalletState))
|
|
audioServices.systemSoundVibrate()
|
|
return .none
|
|
|
|
case .path(.element(id: _, action: .scan(.cancelTapped))):
|
|
let _ = state.path.popLast()
|
|
return .none
|
|
|
|
// MARK: - Self
|
|
|
|
case .addKeystoneHWWallet(.readyToScanTapped):
|
|
var scanState = Scan.State.initial
|
|
scanState.checkers = [.keystoneScanChecker]
|
|
scanState.instructions = L10n.Keystone.scanInfo
|
|
scanState.forceLibraryToHide = true
|
|
state.path.append(.scan(scanState))
|
|
return .none
|
|
|
|
default: return .none
|
|
}
|
|
}
|
|
}
|
|
}
|