45 lines
1.2 KiB
Swift
45 lines
1.2 KiB
Swift
//
|
|
// WalletPinViewModel.swift
|
|
// Malinka
|
|
//
|
|
// Created by Juraldinio on 1/15/23.
|
|
// Copyright © 2023 NUT.Tech. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
open class WalletPinViewModel {
|
|
|
|
typealias ValidationHandler = (String) -> Bool
|
|
typealias BiometricHandler = () -> Void
|
|
typealias CheckBiometricHandler = (Bool) -> Void
|
|
|
|
func dismissController(_ controller: WalletPinController) {
|
|
controller.dismiss(animated: true, completion: nil)
|
|
}
|
|
|
|
func updatePassword(_ password: String, using controller: WalletPinController) {
|
|
try? Accounts().update(password: password)
|
|
}
|
|
|
|
func validatePinSuccess(from controller: WalletPinController) {
|
|
DispatchQueue.main.async {
|
|
controller.dismiss(animated: false)
|
|
}
|
|
}
|
|
|
|
func clearAccountData(from controller: WalletPinController) {
|
|
Account.reset()
|
|
}
|
|
|
|
var validatePin: ValidationHandler?
|
|
var submitBiometric: BiometricHandler?
|
|
|
|
var isBiometricksEnabled: Bool { Account.Service.isBiometricksEnabled }
|
|
|
|
func checkBiometrics(completion: @escaping CheckBiometricHandler) {
|
|
Account.Service.checkBiometricks(completion)
|
|
}
|
|
|
|
}
|