Skip to main content
Version: 12.10.0

Text Input

Text fields allow users to enter text into a user interface. They usually appear in forms and dialogs. There are five types of Input Fields: Active, Focus, Filled, Error and Inactive State. There are also Search Input Fields with the same states of the Input Fields. Mandatory fields are marked only if there are additional optional fields on the screen. The height of an expanded text field is fixed and the content will scroll once text reaches the max height.

Features

  • Update title text, image icons and placeholder text and colour.

  • Interact with component using textfield and text editor.

    /// - Parameters: /// - configuration: An instance of OCTextInputConfiguration to configure placeholder text, icon, etc. /// - imageButtonAction: A closure triggered when the image button is clicked, passing the current button state. /// - onTextChanged: A closure called whenever the text in the field changes.

Installation

  1. Copy the TextInput component folder into your Xcode project.

  2. Use the OCTextInputView view in your SwiftUI code:

import SwiftUI

/// var textInputConfigurationForNormalType: OCTextInputConfiguration {
/// OCTextInputConfiguration(
/// inputText: $focusTextOnNormal,
/// helperText: .constant("Helper text"),
/// isTextFieldActive: .constant(false),
/// isTextFieldFocused: .constant(false),
/// textInputType: .normal,
/// placeholderText: "Username"
/// )
/// }

struct ContentView: View {

/// OCTextInput(
/// configuration: textInputConfigurationForNormalType, // Configuration with placeholder text
/// imageButtonAction: { state in
/// print("Image button clicked \(state)")
/// },
/// onTextChanged: { _ in
/// print("Text Changed callback")
/// }
/// )
}