Skip to content

Instantly share code, notes, and snippets.

@KhayalSuleymani
Last active October 16, 2024 14:31
Show Gist options
  • Save KhayalSuleymani/3ac6a96343b75eb03b586a22ad8898ae to your computer and use it in GitHub Desktop.
Save KhayalSuleymani/3ac6a96343b75eb03b586a22ad8898ae to your computer and use it in GitHub Desktop.
import Common
class PasscodeView: ViewController<PasscodeViewItem, View> {
@IBOutlet weak var v1: Button! /// logo image view
@IBOutlet weak var v2: Label! /// logo title label
@IBOutlet weak var v3: Label! /// logo subtitle label
@IBOutlet weak var v4: Passcode! /// passcode fill view
@IBOutlet weak var v5: Button! /// biometric button
@IBOutlet weak var v6: Button! /// delete button
@IBOutlet var vs: [Button]! /// all numbers buttons
convenience init () {
self.init(nibName: "Passcode(v)", bundle: .bundle)
}
override func render(state: ViewState<PasscodeViewItem>) {
switch state {
case let .loaded(m):
viewDidLoad()
v1.configure(.style(.imaged(m.image)))
v2.configure(.style(m.texts[0]))
v3.configure(.style(m.texts[1]))
v5.onTap(handler: m.onBiometric)
v6.onTap(handler: v4.deleteBackward)
vs.forEach { v in
v.onTap(handler: weaks {
$0.v4.insertText(v.text)
})
}
case _:
super.render(state: state)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment