Basic Authentication¶
FUIBasicAuthenticationScreen
¶
open class FUIBasicAuthenticationScreen: FUIWelcomeController, FUIBlurNavigationBarViewController
This FUIBasicAuthenticationScreen
is an UIViewController
to display the screen to prompt
user to enter username and password to do basic authentication.
It has a headline label and a detail label to display the title and a detail message for this screen. There are two input fields for user input username and password. And one primary action button. The button will be enabled when both the username and password are not empty.
There is also a cancel button on the navigation bar for user to cancel the basic authentication process.
Developer should implement FUIBasicAuthenticationDelegate
and set it to the
delegate
property to handle user responses.
func presentDynamicAuthenticationScreen() {
let controllers = FUIBasicAuthenticationScreen.createInstanceFromStoryboard()
let basicAuthController = controllers.basicAuthenticationScreen
basicAuthController.loadViewIfNeeded()
basicAuthController.delegate = self
self.navigationController?.present(controllers.navigationController, animated: true, completion: nil)
}
func didSignIn(_ controller: FUIBasicAuthenticationScreen, username: String, password: String, completion: @escaping ((_ errorMessage: String?) -> Void)) {
var signInErrorMessage: String? = nil
// Send username and password to server for verification here
// Simulate callback from verification process
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
// This is for testing purposes only.
if !self.signInOk || username == password {
signInErrorMessage = "Sign In Failed"
}
completion(signInErrorMessage)
if signInErrorMessage == nil {
controller.dismiss(animated: true, completion: nil)
}
}
}
func didCancel(_ controller: FUIBasicAuthenticationScreen) {
print("User Cancelled Basic Authentication")
controller.dismiss(animated: true, completion: nil)
}
Theming¶
```swift fdlFUIBasicAuthenticationScreen_headlineLabel { font-size: 28; font-name: thinSystem; font-color: @primary1; }
fdlFUIBasicAuthenticationScreen_detailLabel { font-style: body; font-color: @primary1; }
fdlFUIBasicAuthenticationScreen_primaryActionButton { font-style: callout; font-color: @primary6; corner-radius: 8; background-color-normal: @tintColorDark; background-color-highlighted: @backgroundGradientTop;
background-color-disabled: @line; font-color-disabled: #28666666; /*primary2 with 0.4 alpha; "28" is the hex value of 20% for alpha; "666666" is primary2