Repository navigation
Prototype development/inline android component - #383
kieran-osgood-shopify merged 39 commits into
Conversation
|
Remaining task to be completed here is to update the gradle config to ensure that we are able to build against local android package without modifying lib (JVM_1_8 -> JVM_17) |
2e352cc to
37f95c9
Compare
|
|
||
| @Override | ||
| public void onComplete(@NonNull CheckoutCompleteEvent event) { | ||
| public void onCheckoutCompleted(@NonNull CheckoutCompleteEvent event) { |
There was a problem hiding this comment.
maybe cart before the horse but these should be onComplete present tense for platform consistency.
There was a problem hiding this comment.
Yeah not to worry I'm resolving these locally, had to rebase (this is an old branch)
westeezy
left a comment
There was a problem hiding this comment.
left a few nits but given the holiday and the fact this overall links really solid im approving :)
83e818f to
565c443
Compare
565c443 to
3b9ad9d
Compare
| eventDispatcher.dispatchEvent(new CheckoutEvent(surfaceId, viewId, eventName, params)); | ||
| } | ||
|
|
||
| private class InlineCheckoutEventProcessor extends DefaultCheckoutEventProcessor { |
There was a problem hiding this comment.
@kiftio moved back to RCTCheckoutWebView having its own processor so i could remove all the changes to CustomCheckoutEventProcessor (but I renamed it to SheetCheckoutEventProcessor to distinguish them)
| /// resulting in an empty view being rendered. Cannot move setup to constructor as | ||
| /// checkoutUrl is undefined until setCheckoutUrl is called by RCTCheckoutWebViewManager | ||
| /// requestLayout / invalidate were unsuccessful in remedying this | ||
| checkoutWebView.layout(0, 0, getWidth(), getHeight()); |
There was a problem hiding this comment.
Do we need to override onLayout ot deal with size changes?
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (checkoutWebView != null) {
checkoutWebView.layout(0, 0, right - left, bottom - top);
}
}There was a problem hiding this comment.
That was my initial approach which had the race condition
I've got a comment above that hopefully explains it but the onLayout was executing before setupCheckoutWebView (because the FrameLayout is constructed before react props are passed in) meaning we dont have a view to construct yet
Before:
onLayout (dimensions zero) -> setupCheckoutWebView -> view is zero sized
After:
onLayout (dimensions zero) -> setupCheckoutWebView -> re-measure layout after adding view -> view displays
I tried using requestLayout/invalidate to get android to re-run onLayout but didn't see a subsequent execution
There was a problem hiding this comment.
Ah ok, yeah I was thinking in case the layout changes in some way (orientation?) and we don't resize
There was a problem hiding this comment.
Good point - probably worth keeping it still just incase
| private CheckoutConfiguration lastConfiguration = null; | ||
| private final Handler mainHandler = new Handler(Looper.getMainLooper()); | ||
|
|
||
| private record CheckoutConfiguration(String url, String authToken) {} |
There was a problem hiding this comment.
So just thinking about this, I think support for records might have come after what we've defined for
sourceCompatibility
targetCompatibility
Unless the android gradle plugin supports desugaring
| errorMap.put("recoverable", checkoutError.isRecoverable()); | ||
| errorMap.put("code", checkoutError.getErrorCode()); | ||
| private Map<String, Object> populateErrorDetails(CheckoutException error) { | ||
| Map<String, Object> errorMap = new HashMap<>(Map.of( |
There was a problem hiding this comment.
may want to check when Map.of support was introduced too.
9d5e829 to
3a7c499
Compare

What changes are you making?
This PR integrates the CheckoutWebview thats being exposed in this PR Shopify/checkout-sheet-kit-android#397 so that it can be rendered in an "inline" mode - you'll need to have this branch checked out also to run it
How to test
Run the React Native Android sample app and go to the buy now screen, you should be able to do the same address change flow that occurs in the ios react native app
PR Checklist
Important
Releasing a new version of the kit?
package.jsonfile.Tip
See the Contributing documentation for instructions on how to publish a new version of the library.