EnterpriseDS Documentation

Structure DSUIText​Field

@available(iOS 13.0, tvOS 13.0, *)
public struct DSUITextField: View  

An Enterprise-styled text entry element for use in SwiftUI views. It provides a placeholder label, helper text that sits below it that educates the user on what text to enter, and DSInputMask and DSValidationRule rules which will determine user input format and display errors when validations failed.

The field defaults to single-line, but if isMultiline is set to true the field will grow vertically as text is entered and space is required.

Use the DSInputMask framework to control text input based on the type of data being entered. There are many built-in rules to use or you can implement your own.

Use the DSValidationRule framework to add one or more validation checks. There are many built-in rules to use or you can implement your own.

Since this component can shrink and grow vertically to accommodate its contents, it's recommended that the DSTextField be embedded in a ScrollView that makes it easy for its contents to resize smoothly vertically. The component internally uses the DSTextFieldDelegate method textFieldDidLayout which gets called when the size changes.

Initialize and set parameters as needed.

DSUITextField(text: $step1Config.groupNumber,
    labelText: "Group Number",
    helperText: "Up to 5 characters, typing will stop",
    isMultiline: true, inputMask: DSMaxTextLengthInputMask(maxTextLength: 5),
    validationRules: [DSRequiredTextValidationRule(message: "This Text is required")],
    isValid: $step1Config.isGroupNumberTextValid,
    customizeTextEntry: customizeTextEntry,
    customizeTextField: customizeTextField,
    customizeTextView: customizeTextView)
DSUITextField DSUITextField View View DSUITextField->View

Conforms To

View

Initializers

init(text:​prefix​Text:​label​Text:​helper​Text:​is​Multiline:​is​Secure​Text:​shows​Show​Hide​Button​With​Secure​Text:​input​Mask:​raw​Text:​validation​Rules:​is​Valid:​clear​Button​Mode:​shared​Background​Color:​customize​Text​Entry:​customize​Text​Field:​customize​Text​View:​)

public init(text: Binding<String>,
                prefixText: String = "",
                labelText: String = "",
                helperText: String = "",
                isMultiline: Bool = false,
                isSecureText: Bool = false,
                showsShowHideButtonWithSecureText: Bool = true,
                inputMask: DSInputMask? = nil,
                rawText: Binding<String?>? = nil,
                validationRules: [DSValidationRule] = [],
                isValid: Binding<Bool>,
                clearButtonMode: UITextField.ViewMode = .whileEditing,
                sharedBackgroundColor: Binding<Color?>? = nil,
                customizeTextEntry: ((DSTextField) -> ())? = nil,
                customizeTextField: ((UITextField) -> ())? = nil,
                customizeTextView: ((UITextView) -> ())? = nil)  

Properties

input​Mask

public var inputMask: DSInputMask? 

An input mask that formats entered text and/or prevents certain characters from being entered at all

validation​Rules

public var validationRules: [DSValidationRule] 

The array of ValidationRule objects to be used for validating the current state of the DSTextField contents.

body

public var body: some View