SwiftUI Components

VGS Collect iOS SDK provide support for integration with apps that are buid with SwiftUI toolkit by providing SwiftUI wrappers for all VGS textfields. VGS Collect SwiftUI wrappers are designed to make integration easier and more straight forward by taking care of all needed state and editing events.

VGSTextFieldRepresentable

A component that displays an editable text interface.

Declaration

struct VGSTextFieldRepresentable: UIViewRepresentable

Creating VGSTextFieldRepresentable

/// Initialization
///
/// - Parameters:
///   - configuration: `VGSConfiguration` instance.
public init(configuration: VGSConfiguration)

Instance Methods

VGSTextFieldRepresentable is a SwiftUI wrapper around VGSTextField and have similar attributes and functionality represented in SwiftUI way.

VGSTextFieldRepresentable Text modifiers

/// Set `UIFont` value.
public func font(_ font: UIFont)
/// Set `placeholder` string.
public func placeholder(_ text: String)
/// Set `attributedPlaceholder` string.
public func attributedPlaceholder(_ text: NSAttributedString?)
/// Set `UITextAutocapitalizationType` type.
public func autocapitalizationType(_ type: UITextAutocapitalizationType)
/// Set `UITextSpellCheckingType` type.
public func spellCheckingType(_ type: UITextSpellCheckingType)
/// Set `NSTextAlignment` type.
public func textAlignment(_ alignment: NSTextAlignment)
/// Set `adjustsFontForContentSizeCategory` value.
public func adjustsFontForContentSizeCategory(_ adjusts: Bool)
/// Set `isSecureTextEntry` value.
public func setSecureTextEntry(_ secure: Bool)
/// Coordinates connection between scan data and text field.
public func cardScanCoordinator(_ coordinator: VGSCardScanCoordinator)

VGSTextFieldRepresentable View and Layout modifiers

VGSTextFieldRepresentable Accessibility modifiers

VGSTextFieldRepresentable Event modifiers

Code example

VGSCardTextFieldRepresentable

A component that displays an editable text interface, for use instead of a VGSTextFieldRepresentable when you need to detect credit card brand while user typing data and display card brand image in a text field. All card brand images are included in the SDK, however you still can set your custom images.

Declaration

Creating VGSCardTextFieldRepresentable

Instance Methods

VGSCardTextFieldRepresentable is a SwiftUI wrapper around VGSCardTextField and have similar attributes and functionality represented in SwiftUI way. VGSCardTextFieldRepresentable has same functionality as VGSTextFieldRepresentable with additional modifiers.

VGSCardTextFieldRepresentable Card Icon modifiers

Also VGSCardTextFieldRepresentable provide extandable VGSCardState with attributes specific to Card Number validation

Code example

VGSCVCTextFieldRepresentable

A component that displays an editable text interface, for use instead of a VGSCVCTextFieldRepresentable when you need to display CVC image. CVC image can change dynamically for specific card brand(e.g. CVC image for Amex contains 4 digits). CVC image files are included in the SDK, however you still can set your custom images.

Declaration

Creating VGSCVCTextFieldRepresentable

Instance Methods

VGSCVCTextFieldRepresentable is a SwiftUI wrapper around VGSCVCTextField and have similar attributes and functionality represented in SwiftUI way. VGSCVCTextFieldRepresentable has same functionality as VGSTextFieldRepresentable with additional modifiers.

VGSCVCTextFieldRepresentable Card Icon modifiers

Code example

VGSExpDateTextFieldRepresentable

A component that displays an editable text interface. In addition, VGSExpDateTextFieldRepresentable provides an option to use date picker as input source instead of keyboard. Input source can be specified in VGSExpDateConfiguration.

Declaration

Creating VGSExpDateTextFieldRepresentable

Instance Methods

VGSExpDateTextFieldRepresentable is a SwiftUI wrapper around VGSExpDateTextField and have similar attributes and functionality represented in SwiftUI way. VGSExpDateTextFieldRepresentable has same functionality as VGSTextFieldRepresentable with additional modifiers.

VGSExpDateTextFieldRepresentable Input Source modifiers

Code example

• The date format displayed in the picker doesn't have impact on date format displayed in the field. SDK will automatically convert selected date when setting it into the field, based on the field formatPattern. • Date picker have limited valid expiration date range. Basicaly, it allows to set any date in future from current month plus 20 years. • If you need to collect date with long year format(MM/YYYY) you should update field .formatPattern and change default VGSValidationRuleCardExpirationDate rule in filed validation rules.

VGSDateTextFieldRepresentable

A component that displays an editable text interface. Component provides an option to validate that date is in a specific range. It also allows to use date picker as input source instead of keyboard. Input source and date range can be specified in VGSDateConfiguration.

Declaration

Creating VGSDateTextFieldRepresentable

Instance Methods

VGSDateTextFieldRepresentable is a SwiftUI wrapper around VGSDateTextField and have similar attributes and functionality represented in SwiftUI way. VGSDateTextFieldRepresentable has same functionality as VGSTextFieldRepresentable with additional modifiers.

VGSDateTextFieldRepresentable Input Source modifiers

• The date format displayed in the picker doesn't have impact on date format displayed in the field. SDK will automatically convert selected date when setting it into the field, based on the field formatPattern. • Date picker will use the datePickerStartDate and datePickerEndDate dates as limited valid range. If they are not supplied, it will use the default range as: - datePickerStartDate: Today minus 100 years. - datePickerEndDate: Today plus 100 years.\

Code example

For more details about available attributes and functionality check our Demo Apparrow-up-right

Last updated