-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FX-1460] Insert ForageVaultElement into PIN class hierarchy #267
[FX-1460] Insert ForageVaultElement into PIN class hierarchy #267
Conversation
...e-android/src/main/java/com/joinforage/forage/android/core/ui/element/state/EditTextState.kt
Outdated
Show resolved
Hide resolved
...ge-android/src/main/java/com/joinforage/forage/android/core/ui/element/state/ElementState.kt
Outdated
Show resolved
Hide resolved
interface DerivedCardInfo { | ||
val usState: USState? | ||
} | ||
|
||
/** | ||
* An interface that represents the state of a | ||
* [ForagePANEditText][com.joinforage.forage.android.ui.ForagePANEditText] Element. | ||
* @property derivedCardInfo The [DerivedCardInfo] for the card number submitted to the Element. | ||
*/ | ||
interface PanEditTextState : EditTextState { | ||
val derivedCardInfo: DerivedCardInfo // the interface not the DTO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are both the interface and the dto supposed to be public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question! Two notes here:
Regarding the interface,
PanEditTextState
, being public
Since this interface get's exposed in a few methods inForagePanElement
, we unfortunately need to make this interface public.
Regarding the
dto
being public
What I think may be relevant to point out is that we no longer have adata class
that implements thePanEditTextState
; insteadPanEditTextState.from(...)
(see below) returns an anonymous object. Returning an anonymous object that implements thePanEditTextState
instead of defining a specificdata class
has the desirable affect of us not needing to add any DTO classes to the public surface area! But, lmk I am not speaking to your point as I could by misunderstanding.
...id/src/main/java/com/joinforage/forage/android/core/ui/element/state/pin/PinEditTextState.kt
Outdated
Show resolved
Hide resolved
10a0d66
to
2dec633
Compare
cb896ab
to
4042887
Compare
2dec633
to
d197e36
Compare
a62d07a
to
cf140c8
Compare
override fun setOnFocusEventListener(l: SimpleElementListener) { | ||
manager.setOnFocusEventListener(l) | ||
onFocusEventListener = l | ||
restartFocusChangeListener() | ||
} | ||
override fun setOnBlurEventListener(l: SimpleElementListener) { | ||
manager.setOnBlurEventListener(l) | ||
onBlurEventListener = l | ||
restartFocusChangeListener() | ||
} | ||
override fun setOnChangeEventListener(l: StatefulElementListener<PanElementState>) { | ||
manager.setOnChangeEventListener(l) | ||
override fun setOnChangeEventListener(l: StatefulElementListener<PanEditTextState>) { | ||
onChangeEventListener = l | ||
} | ||
|
||
override fun getElementState(): PanElementState { | ||
return manager.getState() | ||
} | ||
override fun getElementState(): PanEditTextState = PanEditTextState.from( | ||
focusState, | ||
inputState | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These methods expose the PanElementState
to the public surface area, which forces us to make PanElementState
public
😕
d197e36
to
9fc0eff
Compare
ForageVaultElement is basically the union type ForagePinElement and ForagePinPad (pos repo). To realize this union type, we need to ensure that ForagePinElement subclasses ForageVaultElement. The main complexity of this initiative came from ForageVaultElement being a generic that requires knowing the shape of the state that will be passed in on-change events, focus / blur, etc. We now have (or rather, need) three different states: 1. PanEditTextState 2. PinEditTextState 3. PinPadState (pos repo only) The problem was that PinElementStateManager was not flexible enough to support a PinEditTextState and a PinPadState, and this meant we needed to re-home the state tracking functionality into more atomic concepts such as FocusState and PinInputState; teasing out these separate concerns gave us the the flexibility we needed to support all three new states outlined above Signed-off-by: Devin Morgan <[email protected]>
cf140c8
to
dccef8f
Compare
Merge activity
|
What (and Why)
ForageVaultElement
is basically the union typeForagePinElement
andForagePinPad
(pos repo). To realize this union type, we need to ensure thatForagePinElement
subclassesForageVaultElement
.The main complexity of this initiative came from
ForageVaultElement
being a generic class, so it requires knowing the shape of the state passed to on-change events, focus / blur, etc. We now have (or rather, need) three different states:PanEditTextState
PinEditTextState
PinPadState
(pos repo only)The problem was that
PinElementStateManager
was not flexible enough to support aPinEditTextState
and aPinPadState
, and this meant we needed to re-home the state-tracking functionality into more atomic concepts such asFocusState
andPinInputState
; teasing out these separate concerns now gives us the flexibility we needed to support all three new states outlined aboveWhy
See above
Test Plan
Demo
N/A since it's just an implementation change
How
Can be rolled out once #266 is merged