FUIBasicAuthenticationScreen
open class FUIBasicAuthenticationScreen : FUIWelcomeController
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 lable 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
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
-
The headline title label to display the title of this screen. The default text of this lable is
Authentication
from the localized strings files.Declaration
Swift
@IBOutlet weak public private(set) var headlineLabel: UILabel!
-
The detail message lable to display the message of this screen. The default text of this lable is
Please provide your username and password to authenticate.
from the localized strings files.Declaration
Swift
@IBOutlet weak public private(set) var detailLabel: UILabel!
-
The field for inputting the username.
The default placeholder string is
username
from the localized strings files. Developer could customized the placeholder string similar to the following:basicAuthController.usernameInputView.emailTextField.placeholder = "enter username"
Declaration
Swift
@IBOutlet weak public private(set) var usernameInputView: FUIEmailInputView!
-
The field for inputting the password.
The default placeholder string is
password
from the localized strings files. Developer could customized the placeholder string similar to the following:basicAuthController.passwordInputView.emailTextField.placeholder = "enter password"
Declaration
Swift
@IBOutlet weak public private(set) var passwordInputView: FUIEmailInputView!
-
The sign in button. The default button title is
Sign In
from the localized strings files.Declaration
Swift
@IBOutlet weak public private(set) var primaryActionButton: FUIOnboardingButton!
-
The
FUIBasicAuthenticationDelegate
for thisFUIBasicAuthenticationScreen
.Declaration
Swift
public weak var delegate: FUIBasicAuthenticationDelegate?
-
The message displayed on the banner when verifying the message. The default text of this lable is
Verifying Information…
from the localized strings files.Declaration
Swift
public var verifyingMessage: String?
-
The custom error message when failed to sign in. If this property is not set, the default error message is
Incorrect credentials. Try again.
from the localized strings files.Declaration
Swift
public var signInErrorMessage: String?
-
Creates a
FUIBasicAuthenticationScreen
object from storyboard.Declaration
Swift
public class func createInstanceFromStoryboard() -> (navigationController: UINavigationController, basicAuthenticationScreen: FUIBasicAuthenticationScreen)
Return Value
A tuple of
UINavigationController
andFUIBasicAuthenticationScreen
objects.