From aefac65121b73b2cfddee2394597cbc5cf3100b3 Mon Sep 17 00:00:00 2001 From: Masoud Fallahpourbaee Date: Fri, 22 Dec 2023 11:22:33 +0100 Subject: [PATCH] Rename event 'onLoad' to 'onLoadEnd' --- TestApp/src/standalonewebview/StandaloneWebViewScreen.tsx | 8 ++++---- .../standalonewebview/KlarnaStandaloneWebViewEvent.java | 2 +- .../standalonewebview/KlarnaStandaloneWebViewManager.java | 4 ++-- ios/Sources/KlarnaStandaloneWebViewManager.mm | 2 +- .../view/newarch/KlarnaStandaloneWebViewWrapper.mm | 4 ++-- ios/Sources/view/oldarch/KlarnaStandaloneWebViewWrapper.h | 2 +- .../view/oldarch/KlarnaStandaloneWebViewWrapper.mm | 6 +++--- src/KlarnaStandaloneWebView.tsx | 8 ++++---- src/specs/KlarnaStandaloneWebViewNativeComponent.ts | 2 +- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/TestApp/src/standalonewebview/StandaloneWebViewScreen.tsx b/TestApp/src/standalonewebview/StandaloneWebViewScreen.tsx index 78c73096..9eca2da9 100644 --- a/TestApp/src/standalonewebview/StandaloneWebViewScreen.tsx +++ b/TestApp/src/standalonewebview/StandaloneWebViewScreen.tsx @@ -4,7 +4,7 @@ import React, {useRef, useState} from 'react'; import { KlarnaStandaloneWebView, KlarnaWebViewKlarnaMessageEvent, - KlarnaWebViewNavigationError, + KlarnaWebViewError, KlarnaWebViewNavigationEvent, KlarnaWebViewProgressEvent, KlarnaWebViewRenderProcessGoneEvent, @@ -122,10 +122,10 @@ export default function StandaloneWebViewScreen() { onLoadStart={(event: KlarnaWebViewNavigationEvent) => { onEvent('onLoadStart', JSON.stringify(event)); }} - onLoad={(event: KlarnaWebViewNavigationEvent) => { - onEvent('onLoad', JSON.stringify(event)); + onLoadEnd={(event: KlarnaWebViewNavigationEvent) => { + onEvent('onLoadEnd', JSON.stringify(event)); }} - onError={(event: KlarnaWebViewNavigationError) => { + onError={(event: KlarnaWebViewError) => { onEvent('onError', JSON.stringify(event)); }} onLoadProgress={(event: KlarnaWebViewProgressEvent) => { diff --git a/android/src/main/java/com/klarna/mobile/sdk/reactnative/standalonewebview/KlarnaStandaloneWebViewEvent.java b/android/src/main/java/com/klarna/mobile/sdk/reactnative/standalonewebview/KlarnaStandaloneWebViewEvent.java index 5139e9b9..a2394f83 100644 --- a/android/src/main/java/com/klarna/mobile/sdk/reactnative/standalonewebview/KlarnaStandaloneWebViewEvent.java +++ b/android/src/main/java/com/klarna/mobile/sdk/reactnative/standalonewebview/KlarnaStandaloneWebViewEvent.java @@ -21,7 +21,7 @@ public enum Event { // This event is sent just before loading a URL ON_LOAD_START("onLoadStart"), // This event is sent when loading a URL is done - ON_LOAD("onLoad"), + ON_LOAD_END("onLoadEnd"), // This event is sent when loading a URL encounters an error ON_ERROR("onError"), // This event is sent when the progress of loading a page changes diff --git a/android/src/main/java/com/klarna/mobile/sdk/reactnative/standalonewebview/KlarnaStandaloneWebViewManager.java b/android/src/main/java/com/klarna/mobile/sdk/reactnative/standalonewebview/KlarnaStandaloneWebViewManager.java index 9ec24d0d..2454297e 100644 --- a/android/src/main/java/com/klarna/mobile/sdk/reactnative/standalonewebview/KlarnaStandaloneWebViewManager.java +++ b/android/src/main/java/com/klarna/mobile/sdk/reactnative/standalonewebview/KlarnaStandaloneWebViewManager.java @@ -65,7 +65,7 @@ public void onPageStarted(@Nullable KlarnaStandaloneWebView view, @Nullable Stri @Override public void onPageFinished(@Nullable KlarnaStandaloneWebView view, @Nullable String url) { - klarnaStandaloneWebViewEventSender.sendNavigationEvent(view, KlarnaStandaloneWebViewEvent.Event.ON_LOAD, url); + klarnaStandaloneWebViewEventSender.sendNavigationEvent(view, KlarnaStandaloneWebViewEvent.Event.ON_LOAD_END, url); } @Override @@ -174,7 +174,7 @@ public void reload(KlarnaStandaloneWebView view) { public Map getExportedCustomDirectEventTypeConstants() { MapBuilder.Builder builder = MapBuilder.builder(); builder.put(KlarnaStandaloneWebViewEvent.Event.ON_LOAD_START.name, MapBuilder.of("registrationName", KlarnaStandaloneWebViewEvent.Event.ON_LOAD_START.name)); - builder.put(KlarnaStandaloneWebViewEvent.Event.ON_LOAD.name, MapBuilder.of("registrationName", KlarnaStandaloneWebViewEvent.Event.ON_LOAD.name)); + builder.put(KlarnaStandaloneWebViewEvent.Event.ON_LOAD_END.name, MapBuilder.of("registrationName", KlarnaStandaloneWebViewEvent.Event.ON_LOAD_END.name)); builder.put(KlarnaStandaloneWebViewEvent.Event.ON_ERROR.name, MapBuilder.of("registrationName", KlarnaStandaloneWebViewEvent.Event.ON_ERROR.name)); builder.put(KlarnaStandaloneWebViewEvent.Event.ON_LOAD_PROGRESS.name, MapBuilder.of("registrationName", KlarnaStandaloneWebViewEvent.Event.ON_LOAD_PROGRESS.name)); builder.put(KlarnaStandaloneWebViewEvent.Event.ON_KLARNA_MESSAGE.name, MapBuilder.of("registrationName", KlarnaStandaloneWebViewEvent.Event.ON_KLARNA_MESSAGE.name)); diff --git a/ios/Sources/KlarnaStandaloneWebViewManager.mm b/ios/Sources/KlarnaStandaloneWebViewManager.mm index 9940cd4b..1695a85f 100644 --- a/ios/Sources/KlarnaStandaloneWebViewManager.mm +++ b/ios/Sources/KlarnaStandaloneWebViewManager.mm @@ -17,7 +17,7 @@ @implementation KlarnaStandaloneWebViewManager RCT_EXPORT_VIEW_PROPERTY(returnUrl, NSString) RCT_EXPORT_VIEW_PROPERTY(onLoadStart, RCTDirectEventBlock) -RCT_EXPORT_VIEW_PROPERTY(onLoad, RCTDirectEventBlock) +RCT_EXPORT_VIEW_PROPERTY(onLoadEnd, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(onError, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(onLoadProgress, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(onKlarnaMessage, RCTDirectEventBlock) diff --git a/ios/Sources/view/newarch/KlarnaStandaloneWebViewWrapper.mm b/ios/Sources/view/newarch/KlarnaStandaloneWebViewWrapper.mm index 4c119883..1d1b0040 100644 --- a/ios/Sources/view/newarch/KlarnaStandaloneWebViewWrapper.mm +++ b/ios/Sources/view/newarch/KlarnaStandaloneWebViewWrapper.mm @@ -159,11 +159,11 @@ - (void)klarnaStandaloneWebView:(KlarnaStandaloneWebView * _Nonnull)webView didC - (void)klarnaStandaloneWebView:(KlarnaStandaloneWebView * _Nonnull)webView didFinish:(WKNavigation * _Nonnull)navigation { if (_eventEmitter) { - RCTLogInfo(@"Sending onLoad event"); + RCTLogInfo(@"Sending onLoadEnd event"); // 'estimatedProgress' is a double value in range [0..1]. // We need to convert it to an int value in range [0..100]. std::dynamic_pointer_cast(_eventEmitter) - ->onLoad(RNKlarnaStandaloneWebViewEventEmitter::OnLoad{ + ->onLoadEnd(RNKlarnaStandaloneWebViewEventEmitter::OnLoadEnd{ .navigationEvent = { .url = std::string([webView.url.absoluteString UTF8String]), .title = std::string([webView.title UTF8String]), diff --git a/ios/Sources/view/oldarch/KlarnaStandaloneWebViewWrapper.h b/ios/Sources/view/oldarch/KlarnaStandaloneWebViewWrapper.h index 7ef04ef1..acefe5ea 100644 --- a/ios/Sources/view/oldarch/KlarnaStandaloneWebViewWrapper.h +++ b/ios/Sources/view/oldarch/KlarnaStandaloneWebViewWrapper.h @@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN @interface KlarnaStandaloneWebViewWrapper : UIView @property (nonatomic, copy) RCTDirectEventBlock onLoadStart; -@property (nonatomic, copy) RCTDirectEventBlock onLoad; +@property (nonatomic, copy) RCTDirectEventBlock onLoadEnd; @property (nonatomic, copy) RCTDirectEventBlock onError; @property (nonatomic, copy) RCTDirectEventBlock onLoadProgress; @property (nonatomic, copy) RCTDirectEventBlock onKlarnaMessage; diff --git a/ios/Sources/view/oldarch/KlarnaStandaloneWebViewWrapper.mm b/ios/Sources/view/oldarch/KlarnaStandaloneWebViewWrapper.mm index 54c66e52..9c545012 100644 --- a/ios/Sources/view/oldarch/KlarnaStandaloneWebViewWrapper.mm +++ b/ios/Sources/view/oldarch/KlarnaStandaloneWebViewWrapper.mm @@ -125,12 +125,12 @@ - (void)klarnaStandaloneWebView:(KlarnaStandaloneWebView * _Nonnull)webView didC } - (void)klarnaStandaloneWebView:(KlarnaStandaloneWebView * _Nonnull)webView didFinish:(WKNavigation * _Nonnull)navigation { - if (!self.onLoad) { - RCTLog(@"Missing 'onLoad' callback prop."); + if (!self.onLoadEnd) { + RCTLog(@"Missing 'onLoadEnd' callback prop."); return; } NSMutableDictionary *event = [self webViewDict:webView]; - self.onLoad(@{@"navigationEvent": event}); + self.onLoadEnd(@{@"navigationEvent": event}); } - (void)klarnaStandaloneWebView:(KlarnaStandaloneWebView * _Nonnull)webView didFailProvisionalNavigation:(WKNavigation * _Nonnull)navigation withError:(NSError * _Nonnull)error { diff --git a/src/KlarnaStandaloneWebView.tsx b/src/KlarnaStandaloneWebView.tsx index bf13ae8c..aab2ef2d 100644 --- a/src/KlarnaStandaloneWebView.tsx +++ b/src/KlarnaStandaloneWebView.tsx @@ -16,7 +16,7 @@ export interface KlarnaWebViewProps { readonly onLoadStart?: ( navigationEvent: KlarnaWebViewNavigationEvent ) => void; - readonly onLoad?: (navigationEvent: KlarnaWebViewNavigationEvent) => void; + readonly onLoadEnd?: (navigationEvent: KlarnaWebViewNavigationEvent) => void; readonly onError?: (navigationError: KlarnaWebViewError) => void; readonly onLoadProgress?: (progressEvent: KlarnaWebViewProgressEvent) => void; readonly onKlarnaMessage?: ( @@ -65,7 +65,7 @@ export class KlarnaStandaloneWebView extends Component< this.props.onLoadStart(event.nativeEvent.navigationEvent); } }} - onLoad={( + onLoadEnd={( event: NativeSyntheticEvent< Readonly<{ readonly navigationEvent: Readonly<{ @@ -78,8 +78,8 @@ export class KlarnaStandaloneWebView extends Component< }> > ) => { - if (this.props.onLoad != null) { - this.props.onLoad(event.nativeEvent.navigationEvent); + if (this.props.onLoadEnd != null) { + this.props.onLoadEnd(event.nativeEvent.navigationEvent); } }} onError={( diff --git a/src/specs/KlarnaStandaloneWebViewNativeComponent.ts b/src/specs/KlarnaStandaloneWebViewNativeComponent.ts index b58069e2..837b03c2 100644 --- a/src/specs/KlarnaStandaloneWebViewNativeComponent.ts +++ b/src/specs/KlarnaStandaloneWebViewNativeComponent.ts @@ -9,7 +9,7 @@ import type { Double, Int32 } from 'react-native/Libraries/Types/CodegenTypes'; export interface RNKlarnaStandaloneWebViewProps extends ViewProps { returnUrl: string; onLoadStart: DirectEventHandler; - onLoad: DirectEventHandler; + onLoadEnd: DirectEventHandler; onError: DirectEventHandler; onLoadProgress: DirectEventHandler; onKlarnaMessage: DirectEventHandler;