Package-level declarations

Types

Link copied to clipboard

This is the controller for a section with a changing number and set of fields. This is in contrast to the SectionController which is a section in which the fields in it do not change.

Link copied to clipboard
open class AddressElement(_identifier: IdentifierSpec, addressRepository: AddressRepository, rawValuesMap: Map<IdentifierSpec, String?> = emptyMap(), addressType: AddressType = AddressType.Normal(), countryCodes: Set<String> = emptySet(), countryDropdownFieldController: DropdownFieldController = DropdownFieldController( CountryConfig(countryCodes), rawValuesMap[IdentifierSpec.Country] ), sameAsShippingElement: SameAsShippingElement?, shippingValuesMap: Map<IdentifierSpec, String?>?, isPlacesAvailable: IsPlacesAvailable = DefaultIsPlacesAvailable(), hideCountry: Boolean = false) : SectionMultiFieldElement
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
class CheckboxFieldElement(val identifier: IdentifierSpec, val controller: CheckboxFieldController = CheckboxFieldController()) : FormElement
Link copied to clipboard

This is a generic controller

Link copied to clipboard
class CountryConfig(val onlyShowCountryCodes: Set<String> = emptySet(), val locale: Locale = Locale.getDefault(), val tinyMode: Boolean = false, val disableDropdownWithSingleElement: Boolean = false, collapsedLabelMapper: (Country) -> String = { country -> country.name }, expandedLabelMapper: (Country) -> String = { country -> "${countryCodeToEmoji(country.code.value)} ${country.name}" }) : DropdownConfig

This is the configuration for a country dropdown.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

This class controls the dropdown view and implements the InputController interface. Because it can never be in error the errorMessage is always null. It is also designed to always have a value selected, so isComplete is always true.

Link copied to clipboard
class EmailConfig(@StringRes val label: Int = R.string.stripe_email) : TextFieldConfig
Link copied to clipboard
class FieldError(@StringRes val errorMessage: Int, val formatArgs: Array<out Any>? = null)

Encapsulates an error message including the string resource and the variable arguments

Link copied to clipboard

This is used to define each section in the visual form layout. Each item in the layout has an identifier and a controller associated with it.

Link copied to clipboard
data class IdentifierSpec(val v1: String, val ignoreField: Boolean = false, val destination: ParameterDestination = ParameterDestination.Api.Params) : Parcelable

This uniquely identifies a element in the form. The vals here are for identifier specs that need to be found when pre-populating fields, or when extracting data.

Link copied to clipboard

This class provides the logic behind the fields.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
data class OTPElement(val identifier: IdentifierSpec, val controller: OTPController) : FormElement
Link copied to clipboard
data class OTPElementColors(val selectedBorder: Color, val placeholder: Color)
Link copied to clipboard
Link copied to clipboard
class PostalCodeConfig(@StringRes val label: Int, val trailingIcon: MutableStateFlow<TextFieldIcon?> = MutableStateFlow(null), country: String) : TextFieldConfig
Link copied to clipboard
Link copied to clipboard

This is the controller for a section with a static number of fields.

Link copied to clipboard
Link copied to clipboard

Indicates a class could be drawn as a Composable within SectionFieldElementUI.

Link copied to clipboard

Any element in a section must have a controller that provides an error and have a type. This is used for a single field in a section or a section field that has other fields in it.

Link copied to clipboard

This is an element that is in a section and accepts user input.

Link copied to clipboard
open class SimpleTextFieldConfig(@StringRes val label: Int? = null, val capitalization: KeyboardCapitalization = KeyboardCapitalization.Words, val keyboard: KeyboardType = KeyboardType.Text, val trailingIcon: MutableStateFlow<TextFieldIcon?> = MutableStateFlow(null)) : TextFieldConfig
Link copied to clipboard
class SimpleTextFieldController(val textFieldConfig: TextFieldConfig, val showOptionalLabel: Boolean = false, val initialValue: String? = null) : TextFieldController, SectionFieldErrorController

This class will provide the onValueChanged and onFocusChanged functionality to the field's composable. These functions will update the observables as needed. It is responsible for exposing immutable observers for its data

Link copied to clipboard
Link copied to clipboard

This represents the different states a field can be in, in each of these cases there might be a reason to show the error in a different way. This interface separates how the state is implemented from what information is required by clients of the interface. This will allow the implementation to change without impacting the clients.

Functions

Link copied to clipboard
fun AddressElementUI(enabled: Boolean, controller: AddressController, hiddenIdentifiers: Set<IdentifierSpec>, lastTextFieldIdentifier: IdentifierSpec?)
Link copied to clipboard
fun AddressTextFieldUI(controller: AddressTextFieldController, onClick: () -> Unit = { controller.launchAutocompleteScreen() })
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun CheckboxElementUI(modifier: Modifier = Modifier, automationTestTag: String = "", isChecked: Boolean = false, label: String? = null, isEnabled: Boolean = false, onValueChange: (Boolean) -> Unit)
Link copied to clipboard
fun CheckboxFieldUI(modifier: Modifier = Modifier, controller: CheckboxFieldController, enabled: Boolean = true)
Link copied to clipboard
Link copied to clipboard
fun DropDown(controller: DropdownFieldController, enabled: Boolean, modifier: Modifier = Modifier, showChevron: Boolean = true)

This composable will handle the display of dropdown items in a lazy column.

Link copied to clipboard
fun H6Text(text: String, modifier: Modifier = Modifier)
Link copied to clipboard
fun OTPElementUI(enabled: Boolean, element: OTPElement, modifier: Modifier = Modifier, boxShape: Shape = MaterialTheme.shapes.medium, boxTextStyle: TextStyle = OTPElementUI.defaultTextStyle(), boxSpacing: Dp = 8.dp, middleSpacing: Dp = 20.dp, otpInputPlaceholder: String = "●", colors: OTPElementColors = OTPElementColors( selectedBorder = MaterialTheme.colors.primary, placeholder = MaterialTheme.stripeColors.placeholderText ), focusRequester: FocusRequester = remember { FocusRequester() })
Link copied to clipboard
fun PhoneNumberCollectionSection(enabled: Boolean, phoneNumberController: PhoneNumberController, modifier: Modifier = Modifier, countryDropdown: @Composable () -> Unit = { CountryDropdown(phoneNumberController, enabled) }, isSelected: Boolean = false, @StringRes sectionTitle: Int? = null, requestFocusWhenShown: Boolean = false, moveToNextFieldOnceComplete: Boolean = false, focusRequester: FocusRequester = remember { FocusRequester() }, imeAction: ImeAction = ImeAction.Done)
Link copied to clipboard
fun PhoneNumberElementUI(enabled: Boolean, controller: PhoneNumberController, modifier: Modifier = Modifier, countryDropdown: @Composable () -> Unit = { CountryDropdown(controller, enabled) }, requestFocusWhenShown: Boolean = false, moveToNextFieldOnceComplete: Boolean = false, focusRequester: FocusRequester = remember { FocusRequester() }, trailingIcon: @Composable () -> Unit? = null, imeAction: ImeAction = ImeAction.Done)
Link copied to clipboard
fun RowElementUI(enabled: Boolean, controller: RowController, hiddenIdentifiers: Set<IdentifierSpec>, lastTextFieldIdentifier: IdentifierSpec?)
Link copied to clipboard
fun Section(@StringRes title: Int?, error: String?, modifier: Modifier = Modifier, isSelected: Boolean = false, addVerticalPadding: Boolean = true, contentOutsideCard: @Composable () -> Unit = {}, contentInCard: @Composable () -> Unit)

This is a simple section that holds content in a card view. It has a label, content specified by the caller, and an error string.

Link copied to clipboard
fun SectionCard(modifier: Modifier = Modifier, shape: Shape = MaterialTheme.shapes.medium, isSelected: Boolean = false, backgroundColor: Color = MaterialTheme.stripeColors.component, border: BorderStroke = MaterialTheme.getBorderStroke(isSelected), content: @Composable () -> Unit)

This is the layout for the section card.

Link copied to clipboard
fun SectionElementUI(enabled: Boolean, element: SectionElement, hiddenIdentifiers: Set<IdentifierSpec>, lastTextFieldIdentifier: IdentifierSpec?, nextFocusDirection: FocusDirection = FocusDirection.Down, previousFocusDirection: FocusDirection = FocusDirection.Up)
Link copied to clipboard

This is how error string for the section are displayed.

Link copied to clipboard
fun SectionFieldElementUI(enabled: Boolean, field: SectionFieldElement, modifier: Modifier = Modifier, hiddenIdentifiers: Set<IdentifierSpec> = emptySet(), lastTextFieldIdentifier: IdentifierSpec?, nextFocusDirection: FocusDirection = FocusDirection.Down, previousFocusDirection: FocusDirection = FocusDirection.Up)
Link copied to clipboard
fun <TDropdownChoice : SingleChoiceDropdownItem> SingleChoiceDropdown(expanded: Boolean, title: ResolvableString, currentChoice: TDropdownChoice?, choices: List<TDropdownChoice>, onChoiceSelected: (TDropdownChoice) -> Unit, headerTextColor: Color, optionTextColor: Color, onDismiss: () -> Unit)
Link copied to clipboard
fun TextField(textFieldController: TextFieldController, enabled: Boolean, imeAction: ImeAction, modifier: Modifier = Modifier, onTextStateChanged: (TextFieldState?) -> Unit = {}, nextFocusDirection: FocusDirection = FocusDirection.Next, previousFocusDirection: FocusDirection = FocusDirection.Previous, focusRequester: FocusRequester = remember { FocusRequester() })

This is focused on converting an TextFieldController into what is displayed in a textField.

Link copied to clipboard
Link copied to clipboard
fun TextFieldSection(modifier: Modifier = Modifier, textFieldController: TextFieldController, imeAction: ImeAction, enabled: Boolean, isSelected: Boolean = false, @StringRes sectionTitle: Int? = null, onTextStateChanged: (TextFieldState?) -> Unit = {})

This is focused on converting an TextFieldController into what is displayed in a section with a single textField.