FUIDynamicAuthenticationScreen
open class FUIDynamicAuthenticationScreen : FUIWelcomeController
The FUIDynamicAuthenticationScreen
is an UIViewController
to display the screen to
prompt user to enter information needed for authentication.
It has a message lable and a number of the input fields for user to enter information needed.
The input fields are configured using the informationFields
property.
There is a ‘Cancel’ button on the navigation bar for user to cancel the authentication process.
There is also a ‘Done’ button on the navigation bar for user to submit the information. The Done
button is disabled until all the input fields are not empty.
Developer should implement FUIDynamicAuthenticationDelegate
and set it to the
delegate
property to handle user responses.
var dynamicAuthenticationScreen: FUIDynamicAuthenticationScreen?
var completionBlock: ((_ errorMessage: String?) -> Void)?
func presentDynamicAuthenticationScreen() {
let controllers = FUIDynamicAuthenticationScreen.createInstanceFromStoryboard()
let dynamicAuthController = controllers.dynamicAuthenticationScreen
dynamicAuthController.informationFields = [
FUIAuthenticationInformationField(placeholder: "username", isSecureText: false, informationString: "Admin"),
FUIAuthenticationInformationField(placeholder: "password", isSecureText: true, informationString: nil),
FUIAuthenticationInformationField(placeholder: "url", isSecureText: false, informationString: nil),
FUIAuthenticationInformationField(placeholder: "test field", isSecureText: false, informationString: nil)
]
dynamicAuthController.delegate = self
self.navigationController?.present(controllers.navigationController, animated: true, completion: nil)
}
func verify(_ controller: FUIDynamicAuthenticationScreen, informationStrings: [String], completion: @escaping ((_ errorMessage: String?) -> Void)) {
dynamicAuthenticationScreen = controller
completionBlock = completion
// Send information to server for verification here
// Simulate callback from verification process
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
self.verificationDone()
}
}
func verificationDone() {
completionBlock?(verificationErrorMessage)
if verificationErrorMessage == nil {
dynamicAuthenticationScreen?.dismiss(animated: true, completion: nil)
}
}
func didCancel(_ controller: FUIBasicAuthenticationScreen) {
print("User Cancelled Basic Authentication")
controller.dismiss(animated: true, completion: nil)
}
Theming
fdlFUIDynamicAuthenticationScreen_detailLabel {
font-color: @primary1;
}
fdlFUIDynamicAuthenticationScreen_cancelButton {
background-tint-color: @tintColorDark;
}
fdlFUIDynamicAuthenticationScreen_doneButton {
background-tint-color: @tintColorDark;
}
fdlFUIDynamicAuthenticationScreen_messageBannerTitleLabel {
font-color: @primary7;
}
fdlFUIDynamicAuthenticationScreen_messageBannerDividerTop {
background-color: @line;
}
fdlFUIDynamicAuthenticationScreen_errorMessageBannerTitleLabel {
font-color: @negative;
}
fdlFUIDynamicAuthenticationScreen_errorMessageBannerDividerTop {
background-color: @negative;
}
Attention
The delegate object with type FUIDynamicAuthenticationDelegate
is declared as a weak reference. So on deallocation it will be automatically set to nil. To keep it alive as expected, developer should retain the delegate object during its whole execution scope.
-
The detail message lable to display the message of this screen. The default text of this lable is
Please provide the information below to start the activation process.
from the localized strings files.Declaration
Swift
@IBOutlet weak public private(set) var detailLabel: UILabel!
-
Developer should provide this property for configuring the input fields.
Declaration
Swift
public var informationFields: [FUIAuthenticationInformationField]?
-
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
FUIDynamicAuthenticationDelegate
instance to verify information user entered.Declaration
Swift
public weak var delegate: FUIDynamicAuthenticationDelegate?
-
Creates a
FUIDynamicAuthenticationScreen
object from storyboard.Declaration
Swift
public class func createInstanceFromStoryboard() -> (navigationController: UINavigationController, dynamicAuthenticationScreen: FUIDynamicAuthenticationScreen)
Return Value
A tuple of
UINavigationController
andFUIDynamicAuthenticationScreen
objects.