Skip to content

Instantly share code, notes, and snippets.

@KhayalSuleymani
Created October 16, 2024 12:38
Show Gist options
  • Save KhayalSuleymani/f5c0bd61d0230d4aa490ba503cfd16c3 to your computer and use it in GitHub Desktop.
Save KhayalSuleymani/f5c0bd61d0230d4aa490ba503cfd16c3 to your computer and use it in GitHub Desktop.
import Common
class PasscodeViewItem: ViewItem<PasscodeState>, ImageConvertable, TextsStyleConvertable, PasscodeDelegate {
// MARK: ImageConvertable & TextsStyleConvertable
private(set) var texts: [TextStyle]
private(set) var image: Image
override init(_ state: PasscodeState) {
self.texts = [
.passcodev2(state: state),
.passcodev3(state: state)
]
self.image = state.image
super.init(state)
}
// MARK: PasscodeDelegate
func onEnter(passcode: String) {
switch data {
case .empty:
move(to: .passcode(.set(passcode)))
case .set(let code):
move(to: .passcode(.again(code)))
case .again(let code), .refresh(let code):
if code == passcode {
BiometricAuthenticator
.authenticateWithPasscode(reason: code) { _ in
move(to: .dashboard(.set(code)))
}
}
}
}
func onBiometric() {
onEnter(passcode: keychainService.get(.passcode)))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment