VGSTextFieldRepresentable

@MainActor
public struct VGSTextFieldRepresentable : UIViewRepresentable, VGSTextFieldRepresentableProtocol, VGSTextFieldRepresentableCallbacksProtocol

A SwiftUI wrapper around VGSTextField providing secure data collection with a declarative builder-style API.

Overview: VGSTextFieldRepresentable lets you embed the UIKit VGSTextField inside SwiftUI while configuring appearance, behavior, and callbacks in a chainable, value-type friendly manner.

Features:

  • Chainable modifiers (font, placeholder, border, etc.).
  • Live state & editing event callbacks (onEditingEvent, onStateChange).
  • Optional accessory view and secure text entry.

Security:

  • No sensitive text is exposed through published properties; retrieval and submission handled internally.
  • Avoid storing raw values outside SDK-managed flows.

Clearing Input:

  • Use clearTextTrigger(_:) binding to programmatically clear the field from SwiftUI state.

Example:

VGSTextFieldRepresentable(configuration: config)
  .placeholder("Cardholder name")
  .font(.preferredFont(forTextStyle: .body))
  .border(color: .gray, lineWidth: 1)
  .onStateChange { state in print(state.isValid) }

TextField interaction callbacks

Initialization

Configuration methods

  • Set UIFont value.

    Declaration

    Swift

    @MainActor
    public func font(_ font: UIFont) -> VGSTextFieldRepresentable
  • Set placeholder string.

    Declaration

    Swift

    @MainActor
    public func placeholder(_ text: String) -> VGSTextFieldRepresentable
  • Set attributedPlaceholder string.

    Declaration

    Swift

    @MainActor
    public func attributedPlaceholder(_ text: NSAttributedString?) -> VGSTextFieldRepresentable
  • Set UITextAutocorrectionType type.

    Declaration

    Swift

    @MainActor
    public func autocorrectionType(_ type: UITextAutocorrectionType) -> VGSTextFieldRepresentable
  • Set UITextAutocapitalizationType type.

    Declaration

    Swift

    @MainActor
    public func autocapitalizationType(_ type: UITextAutocapitalizationType) -> VGSTextFieldRepresentable
  • Set UITextSpellCheckingType type.

    Declaration

    Swift

    @MainActor
    public func spellCheckingType(_ type: UITextSpellCheckingType) -> VGSTextFieldRepresentable
  • Set UIEdgeInsets insets.

    Declaration

    Swift

    @MainActor
    public func textFieldPadding(_ insets: UIEdgeInsets) -> VGSTextFieldRepresentable
  • Set NSTextAlignment type.

    Declaration

    Swift

    @MainActor
    public func textAlignment(_ alignment: NSTextAlignment) -> VGSTextFieldRepresentable
  • Set isSecureTextEntry value.

    Declaration

    Swift

    @MainActor
    public func setSecureTextEntry(_ secure: Bool) -> VGSTextFieldRepresentable
  • Set adjustsFontForContentSizeCategory value.

    Declaration

    Swift

    @MainActor
    public func adjustsFontForContentSizeCategory(_ adjusts: Bool) -> VGSTextFieldRepresentable
  • Set keyboardAccessoryView view.

    Declaration

    Swift

    @MainActor
    public func keyboardAccessoryView(_ view: UIView?) -> VGSTextFieldRepresentable
  • Set textFieldAccessibilityLabel string.

    Declaration

    Swift

    @MainActor
    public func textFieldAccessibilityLabel(_ label: String) -> VGSTextFieldRepresentable
  • Set foregroundColor.

    Declaration

    Swift

    @MainActor
    public func foregroundColor(_ color: UIColor) -> VGSTextFieldRepresentable
  • Set backgroundColor.

    Declaration

    Swift

    @MainActor
    public func backgroundColor(_ color: UIColor) -> VGSTextFieldRepresentable
  • Set borderColor and lineWidth.

    Declaration

    Swift

    @MainActor
    public func border(color: UIColor, lineWidth: CGFloat) -> VGSTextFieldRepresentable
  • Set cornerRadius.

    Declaration

    Swift

    @MainActor
    public func cornerRadius(_ cornerRadius: CGFloat) -> VGSTextFieldRepresentable

Handle editing events