[+] Create function to prompt the user to enter the pin

This commit is contained in:
Hykilpikonna
2021-01-24 20:32:34 -05:00
parent 7f2a34a99d
commit e8da4650db
+24
View File
@@ -165,6 +165,30 @@ extension UIViewController
a.dismiss { self.msg("An error occurred", message) }
}
}
/**
Asks the user to enter a pin
*/
func enterPin(_ title: String = "Enter Pin", _ message: String = "Please enter your family pin.", _ then: @escaping (String) -> Void)
{
// Create alert
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert)
// Add next button
alert.addAction(UIAlertAction(title: "Next", style: UIAlertAction.Style.default) { it in
let t = alert.textFields![0] as UITextField
then(t.text!)
})
// Add pin text field
alert.addTextField(configurationHandler: { (t: UITextField!) in
t.placeholder = "Enter Pin"
t.isSecureTextEntry = true
})
// Present alert
self.present(alert, animated: true, completion: nil)
}
}