Skip to content

Commit b332283

Browse files
Prototype development/inline android component (#383)
* feat: setup android inline component * fix: ensure we can respond to address change events * chore: remove redundant address change map * remove unused imports * fix: rename CheckoutCompletedEvent -> CheckoutCompleteEvent * refactor: remove deprecated method overrides * chore: cleaning up token and networking debugging * fix: remove android debugging code - readd timeout * fix: add event handlers for CheckoutScreen * refactor: remove unnecessary view in buynowbutton * fix: yarn module build errors * refactor(RCTCheckoutWebView): replace complicated if checks with .equals() * refactor: remove lint warnings on type coersion * refactor: use shorter kotlin unit instance * fix: remove absolute user path * fix: issues with inconsistent names of events * refactor: remove unnecesasry logging and overrides * remove classPaths from build.gradle * feat: add event handling to inline webview android * refactor: simplifying map construction * refactor: remove deprecated event emitting * refactor: extract CheckoutEvent for instance based events * fix: webview not loading * cleanup events that arent ready - rename onClickLink * add nonnull annotation for getEventName * fix: remove onLoad from swift * rename customeventprocessor -> Sheeteventprocessor * refactor: undo changes to reuse custom event processor for inline * fix: intermitent flakiness of layout for checkout webview inline * remove unused variable * fix: flatten onerror - implement onlinkclick * format files * fix: type in TAG - remove unused comments * fix: remove record (java16 feature) * fix: ensure layout params are applied to webview * test: RctCheckoutWebViewTests * refactor: improve tests with side effects of setup checks * fix: ts error from unused prop * feat: update snapshot with new classes for components
1 parent 4c2276f commit b332283

File tree

17 files changed

+1134
-169
lines changed

17 files changed

+1134
-169
lines changed

modules/@shopify/checkout-sheet-kit/android/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,10 @@ dependencies {
100100
implementation("com.shopify:checkout-sheet-kit:${SHOPIFY_CHECKOUT_SDK_VERSION}")
101101
implementation("com.fasterxml.jackson.core:jackson-databind:2.12.5")
102102
debugImplementation("com.shopify:checkout-sheet-kit:${SHOPIFY_CHECKOUT_SDK_VERSION}")
103+
104+
testImplementation 'junit:junit:4.13.2'
105+
testImplementation 'org.mockito:mockito-core:4.11.0'
106+
testImplementation 'org.mockito:mockito-inline:5.2.0'
107+
testImplementation 'org.assertj:assertj-core:3.27.6'
103108
}
104109

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
MIT License
3+
4+
Copyright 2023 - Present, Shopify Inc.
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*/
23+
24+
package com.shopify.reactnative.checkoutsheetkit;
25+
26+
import androidx.annotation.NonNull;
27+
28+
import com.facebook.react.bridge.Arguments;
29+
import com.facebook.react.bridge.WritableMap;
30+
import com.facebook.react.uimanager.events.Event;
31+
32+
/**
33+
* Can be used to send events back to props of instances of components
34+
* <p>
35+
* private void sendEvent(String eventName, WritableMap params) {
36+
* ReactContext reactContext = this.context.getReactApplicationContext();
37+
* int viewId = getId();
38+
* EventDispatcher eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContext, viewId);
39+
* int surfaceId = UIManagerHelper.getSurfaceId(reactContext);
40+
* eventDispatcher.dispatchEvent(new CheckoutEvent(surfaceId, viewId, eventName, params));
41+
* }
42+
**/
43+
public class CheckoutEvent extends Event<CheckoutEvent> {
44+
private final String eventName;
45+
private final WritableMap payload;
46+
47+
public CheckoutEvent(int surfaceId, int viewId, String eventName, WritableMap payload) {
48+
super(surfaceId, viewId);
49+
this.eventName = eventName;
50+
this.payload = payload;
51+
}
52+
53+
@NonNull
54+
@Override
55+
public String getEventName() {
56+
return eventName;
57+
}
58+
59+
@Override
60+
protected WritableMap getEventData() {
61+
return payload != null ? payload : Arguments.createMap();
62+
}
63+
}

0 commit comments

Comments
 (0)