Skip to content

Commit

Permalink
Update sample app to show usState of PAN
Browse files Browse the repository at this point in the history
The change of adding `details` to `ElementState` by making
`ElementState` generic appears to be non-breaking becasue the compiler
did not complain before making this commit (i.e. before modify the
sample app).
  • Loading branch information
devinmorgan committed Dec 1, 2023
1 parent 824c190 commit 2032ef9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ class FlowTokenizeFragment : Fragment() {
val isComplete: TextView = binding.isComplete
val isEmpty: TextView = binding.isEmpty
val isValid: TextView = binding.isValid
val usState: TextView = binding.usState

fun setState() {
val state = foragePanEditText.getElementState()
isFocused.text = "isFocused: ${state.isFocused}"
isComplete.text = "isComplete: ${state.isComplete}"
isEmpty.text = "isEmpty: ${state.isEmpty}"
isValid.text = "isValid: ${state.isValid}"
usState.text = "usState: ${state.details.derivedCardInfo?.usState?.abbreviation}"
}

foragePanEditText.setOnFocusEventListener { setState() }
Expand All @@ -77,6 +79,7 @@ class FlowTokenizeFragment : Fragment() {
isComplete.text = "isComplete: ${state.isComplete}"
isEmpty.text = "isEmpty: ${state.isEmpty}"
isValid.text = "isValid: ${state.isValid}"
usState.text ="usState: ${state.details.derivedCardInfo?.usState?.abbreviation}"

viewModel.paymentMethod.observe(viewLifecycleOwner) {
when (it == null) {
Expand Down
17 changes: 16 additions & 1 deletion sample-app/src/main/res/layout/fragment_flow_tokenize.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,21 @@
app:layout_constraintVertical_bias="0.0"
tools:text="isValid: false" />

<TextView
android:id="@+id/usState"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:textColor="@color/black"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/isValid"
app:layout_constraintVertical_bias="0.0"
tools:text="usState: null" />

<TextView
android:id="@+id/errorResponse"
android:layout_width="0dp"
Expand All @@ -143,7 +158,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/isValid"
app:layout_constraintTop_toBottomOf="@+id/usState"
app:layout_constraintVertical_bias="0.0"
tools:text="error: tok_sandbox_sYiPe9Q249qQ5wQyUPP5f7" />

Expand Down

0 comments on commit 2032ef9

Please sign in to comment.