FUIBasicAuthenticationScreen

@MainActor
open class FUIBasicAuthenticationScreen : FUIWelcomeController, FUISolidNavigationBarProtocol, UIScrollViewDelegate
extension FUIBasicAuthenticationScreen: UITextFieldDelegate

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

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 label is “Authentication” from the localized strings files.

    Declaration

    Swift

    @IBOutlet
    @MainActor
    weak public private(set) var headlineLabel: UILabel! { get }
  • The detail message label to display the message of this screen. The default text of this label is “Please provide your username and password to authenticate.” from the localized strings files.

    Declaration

    Swift

    @IBOutlet
    @MainActor
    weak public private(set) var detailLabel: UILabel! { get }
  • The field for inputting the username.

    The default placeholder string is “username” from the localized strings files. Developer could customize the placeholder string similar to the following:

    basicAuthController.usernameInputView.emailTextField.placeholder = "enter username"
    

    Declaration

    Swift

    @IBOutlet
    @MainActor
    weak public private(set) var usernameInputView: FUIEmailInputView! { get }
  • The field for inputting the password.

    The default placeholder string is “password” from the localized strings files. Developer could customize the placeholder string similar to the following:

    basicAuthController.passwordInputView.emailTextField.placeholder = "enter password"
    

    Declaration

    Swift

    @IBOutlet
    @MainActor
    weak public private(set) var passwordInputView: FUIEmailInputView! { get }
  • The sign in button. The default button title is “Sign In” from the localized strings files.

    Declaration

    Swift

    @IBOutlet
    @MainActor
    weak public private(set) var primaryActionButton: FUIOnboardingButton! { get }
  • The FUIBasicAuthenticationDelegate for this FUIBasicAuthenticationScreen.

    Declaration

    Swift

    @MainActor
    public weak var delegate: FUIBasicAuthenticationDelegate?
  • The message displayed on the banner when verifying the message. The default text of this label is “Verifying Information…” from the localized strings files.

    Declaration

    Swift

    @MainActor
    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

    @MainActor
    public var signInErrorMessage: String?
  • Illustration message. The application has the capability to configure the FUIIllustratedMessage by specifying the title, body, and detailImageView. These attributes are used to display the branding image, title, and description of the application respectively. When utilizing the illustratedMessage feature and setting showsIllustratedMessage to true, the headlineLabel and detailLabel will automatically be hidden.

    Declaration

    Swift

    @MainActor
    public private(set) lazy var illustratedMessage: FUIIllustratedMessage { get set }
  • A boolean flag, showsIllustratedMessage, determines whether the illustration message is displayed.

    When showsIllustratedMessage is set to true, the illustratedMessage will be shown, and the headlineLabel and detailLabel will be hidden. Conversely, when showsIllustratedMessage is set to false, the headlineLabel and detailLabel will be displayed, and the illustratedMessage will be hidden.

    The default setting for showsIllustratedMessage is false.

    Declaration

    Swift

    @MainActor
    public var showsIllustratedMessage: Bool { get set }
  • Creates a FUIBasicAuthenticationScreen object from storyboard.

    Declaration

    Swift

    @MainActor
    public class func createInstanceFromStoryboard() -> (navigationController: UINavigationController, basicAuthenticationScreen: FUIBasicAuthenticationScreen)

    Return Value

    A tuple of UINavigationController and FUIBasicAuthenticationScreen objects.

  • Undocumented

    Declaration

    Swift

    @MainActor
    public func scrollViewDidScroll(_ scrollView: UIScrollView)