-
Notifications
You must be signed in to change notification settings - Fork 661
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
[Identity] Remove all parameters for Scan and Upload destinations #7555
Conversation
351a313
to
d7f81cb
Compare
3c46568
to
b64dff3
Compare
@stripe/stripe-identity-observers |
Diffuse output:
APK
DEX
|
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 cleanup! just some feedback on using UI to communicate viewmodels.
identity/src/main/java/com/stripe/android/identity/navigation/IdentityTopLevelDestination.kt
Outdated
Show resolved
Hide resolved
identity/src/main/java/com/stripe/android/identity/ui/DocumenetScanScreen.kt
Outdated
Show resolved
Hide resolved
identity/src/main/java/com/stripe/android/identity/ui/CameraScreenLaunchedEffectLight.kt
Show resolved
Hide resolved
identityScanViewModel.interimResults.observe(lifecycleOwner) { | ||
identityViewModel.fpsTracker.trackFrame() | ||
} | ||
|
||
// Handles final result - upload if success, transition to CouldNotCapture if timeout | ||
identityScanViewModel.finalResult.observe(lifecycleOwner) { finalResult -> | ||
lifecycleOwner.lifecycleScope.launch { | ||
identityViewModel.fpsTracker.reportAndReset( |
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.
looks like we're using launched effects (UI layer) to communicate viewModels (more no the controller layer).
This works but it might be hard to maintain long term. A potential alternative would be to have a coordinator that can be injected on both the parent and the child viewmodel, so the UI does not need to be involved.
This is how we do this on Connections:
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.
Thanks for the pointers, this LaunchedEffect
is a bit wonky as it's mostly inherited from the legacy architecture with Fragment and navigation components.
The essential goal is to remove any observe
and collectLatest
and totally rely on IdentityScanViewModel's new State
to drive UI, and handle these non-UI logics within identityScanViewModel
itself without the need to reference the parent IdentityViewModel
.
- E.g we'll directly inject the
fpsTracker
intoIdentityScanViewModel
and handle thetrackFrame
within IdentityScanViewModel.onInterimResult callback.
Need to double check but I think with the decoupling there will be need to send messages from childIdentityScanViewModel
to parent IdentityViewModel
, but I have added your reference in the follow up ticket here incase we do need that!
Summary
Remove all parameters passed to the following 6 types of destinations to capture document through camera/file upload
DriverLicenseScanDestination
PassportScanDestination
IDScanDestination
⬆️ all replaced with
DocumentScanDestination
without params⬆️ all replaced with
DocumentUploadDestination
without paramsNow
DocumentScanScreen
andUploadScreen
will not read the parameters to determine its UI, but instead use the states fromIdentityViewModel
andIdentityScanViewModel
to determine them.Motivation
This is one step further to clean up the legacy
someFlow.collectLast
call prior to compose. And is a prerequisite to Butter M1 UX change to remove document select pageTesting
Changelog