react-native-unit-components 3.1.2-beta.6 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/android/src/main/java/com/unitreactnativecomponents/UnitReactNativeComponentsPackage.kt +1 -3
  2. package/android/src/main/java/com/unitreactnativecomponents/nativeModules/sharefile/UNShareFile.kt +18 -8
  3. package/ios/NativeModules/UNShareFile/UNShareFileExportModule.m +7 -0
  4. package/ios/NativeModules/UNShareFile/UNShareFileModule.swift +54 -0
  5. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
  6. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js +1 -0
  7. package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
  8. package/lib/commonjs/components/UNWhiteLabelAppComponent/UNWhiteLabelAppComponent.js +0 -1
  9. package/lib/commonjs/components/UNWhiteLabelAppComponent/UNWhiteLabelAppComponent.js.map +1 -1
  10. package/lib/commonjs/nativeModulesHelpers/RNShareFile/RNShareFile.js +1 -11
  11. package/lib/commonjs/nativeModulesHelpers/RNShareFile/RNShareFile.js.map +1 -1
  12. package/lib/commonjs/scripts/html/bodyScript.js +10 -1
  13. package/lib/commonjs/scripts/html/bodyScript.js.map +1 -1
  14. package/lib/commonjs/unitComponentsSdkManager/UnitComponentsSdkManager.js +1 -1
  15. package/lib/commonjs/unitComponentsSdkManager/UnitComponentsSdkManager.js.map +1 -1
  16. package/lib/commonjs/webComponent/WebComponent.js +10 -10
  17. package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
  18. package/lib/commonjs/webComponent/WebComponent.utils.js +19 -10
  19. package/lib/commonjs/webComponent/WebComponent.utils.js.map +1 -1
  20. package/lib/commonjs/webComponent/html.js +4 -3
  21. package/lib/commonjs/webComponent/html.js.map +1 -1
  22. package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
  23. package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js +1 -0
  24. package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
  25. package/lib/module/components/UNWhiteLabelAppComponent/UNWhiteLabelAppComponent.js +0 -1
  26. package/lib/module/components/UNWhiteLabelAppComponent/UNWhiteLabelAppComponent.js.map +1 -1
  27. package/lib/module/nativeModulesHelpers/RNShareFile/RNShareFile.js +2 -12
  28. package/lib/module/nativeModulesHelpers/RNShareFile/RNShareFile.js.map +1 -1
  29. package/lib/module/scripts/html/bodyScript.js +9 -0
  30. package/lib/module/scripts/html/bodyScript.js.map +1 -1
  31. package/lib/module/unitComponentsSdkManager/UnitComponentsSdkManager.js +1 -1
  32. package/lib/module/unitComponentsSdkManager/UnitComponentsSdkManager.js.map +1 -1
  33. package/lib/module/webComponent/WebComponent.js +10 -10
  34. package/lib/module/webComponent/WebComponent.js.map +1 -1
  35. package/lib/module/webComponent/WebComponent.utils.js +20 -11
  36. package/lib/module/webComponent/WebComponent.utils.js.map +1 -1
  37. package/lib/module/webComponent/html.js +5 -4
  38. package/lib/module/webComponent/html.js.map +1 -1
  39. package/lib/typescript/src/components/UNActivityComponent/UNActivityComponent.d.ts +1 -0
  40. package/lib/typescript/src/components/UNActivityComponent/UNActivityComponent.d.ts.map +1 -1
  41. package/lib/typescript/src/components/UNActivityComponent/UNActivityComponent.utils.d.ts.map +1 -1
  42. package/lib/typescript/src/components/UNWhiteLabelAppComponent/UNWhiteLabelAppComponent.d.ts.map +1 -1
  43. package/lib/typescript/src/nativeModulesHelpers/RNShareFile/RNShareFile.d.ts +5 -1
  44. package/lib/typescript/src/nativeModulesHelpers/RNShareFile/RNShareFile.d.ts.map +1 -1
  45. package/lib/typescript/src/scripts/html/bodyScript.d.ts +1 -0
  46. package/lib/typescript/src/scripts/html/bodyScript.d.ts.map +1 -1
  47. package/lib/typescript/src/unitComponentsSdkManager/UnitComponentsSdkManager.d.ts.map +1 -1
  48. package/lib/typescript/src/webComponent/WebComponent.d.ts.map +1 -1
  49. package/lib/typescript/src/webComponent/WebComponent.utils.d.ts +5 -1
  50. package/lib/typescript/src/webComponent/WebComponent.utils.d.ts.map +1 -1
  51. package/lib/typescript/src/webComponent/html.d.ts.map +1 -1
  52. package/package.json +1 -1
  53. package/src/components/UNActivityComponent/UNActivityComponent.tsx +1 -0
  54. package/src/components/UNActivityComponent/UNActivityComponent.utils.ts +1 -0
  55. package/src/components/UNWhiteLabelAppComponent/UNWhiteLabelAppComponent.tsx +0 -1
  56. package/src/nativeModulesHelpers/RNShareFile/RNShareFile.ts +5 -15
  57. package/src/scripts/html/bodyScript.ts +10 -0
  58. package/src/unitComponentsSdkManager/UnitComponentsSdkManager.ts +1 -1
  59. package/src/webComponent/WebComponent.tsx +25 -24
  60. package/src/webComponent/WebComponent.utils.ts +19 -9
  61. package/src/webComponent/html.ts +5 -3
  62. package/android/src/main/java/com/unitreactnativecomponents/nativeComponents/scrollInterop/UNScrollInteropViewManager.kt +0 -63
  63. package/lib/commonjs/nativeComponents/UNScrollInteropView/UNScrollInteropView.android.js +0 -9
  64. package/lib/commonjs/nativeComponents/UNScrollInteropView/UNScrollInteropView.android.js.map +0 -1
  65. package/lib/commonjs/nativeComponents/UNScrollInteropView/UNScrollInteropView.ios.js +0 -10
  66. package/lib/commonjs/nativeComponents/UNScrollInteropView/UNScrollInteropView.ios.js.map +0 -1
  67. package/lib/commonjs/nativeComponents/UNScrollInteropView/UNScrollInteropView.js +0 -11
  68. package/lib/commonjs/nativeComponents/UNScrollInteropView/UNScrollInteropView.js.map +0 -1
  69. package/lib/module/nativeComponents/UNScrollInteropView/UNScrollInteropView.android.js +0 -3
  70. package/lib/module/nativeComponents/UNScrollInteropView/UNScrollInteropView.android.js.map +0 -1
  71. package/lib/module/nativeComponents/UNScrollInteropView/UNScrollInteropView.ios.js +0 -5
  72. package/lib/module/nativeComponents/UNScrollInteropView/UNScrollInteropView.ios.js.map +0 -1
  73. package/lib/module/nativeComponents/UNScrollInteropView/UNScrollInteropView.js +0 -5
  74. package/lib/module/nativeComponents/UNScrollInteropView/UNScrollInteropView.js.map +0 -1
  75. package/lib/typescript/src/nativeComponents/UNScrollInteropView/UNScrollInteropView.android.d.ts +0 -3
  76. package/lib/typescript/src/nativeComponents/UNScrollInteropView/UNScrollInteropView.android.d.ts.map +0 -1
  77. package/lib/typescript/src/nativeComponents/UNScrollInteropView/UNScrollInteropView.d.ts +0 -3
  78. package/lib/typescript/src/nativeComponents/UNScrollInteropView/UNScrollInteropView.d.ts.map +0 -1
  79. package/lib/typescript/src/nativeComponents/UNScrollInteropView/UNScrollInteropView.ios.d.ts +0 -3
  80. package/lib/typescript/src/nativeComponents/UNScrollInteropView/UNScrollInteropView.ios.d.ts.map +0 -1
  81. package/src/nativeComponents/UNScrollInteropView/UNScrollInteropView.android.ts +0 -3
  82. package/src/nativeComponents/UNScrollInteropView/UNScrollInteropView.ios.ts +0 -4
  83. package/src/nativeComponents/UNScrollInteropView/UNScrollInteropView.ts +0 -5
@@ -3,6 +3,10 @@ import WebView from 'react-native-webview';
3
3
  export declare const getInfoParams: () => Promise<{
4
4
  [key: string]: string;
5
5
  }>;
6
- export declare const handleRequestDownload: (details: RequestDownloadEvent, onReadyToShare: () => void) => Promise<void>;
6
+ export interface DownloadResult {
7
+ url: string;
8
+ error?: string;
9
+ }
10
+ export declare const handleRequestDownload: (details: RequestDownloadEvent) => Promise<DownloadResult>;
7
11
  export declare const injectEventToContinue: (currentWeb: WebView | null, eventToContinueEvent: EventToContinueEvent) => void;
8
12
  //# sourceMappingURL=WebComponent.utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WebComponent.utils.d.ts","sourceRoot":"","sources":["../../../../src/webComponent/WebComponent.utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AAEjH,OAAO,OAAO,MAAM,sBAAsB,CAAC;AAG3C,eAAO,MAAM,aAAa;;EAazB,CAAC;AAEF,eAAO,MAAM,qBAAqB,YAAmB,oBAAoB,kBAAkB,MAAM,IAAI,kBAoBpG,CAAC;AAEF,eAAO,MAAM,qBAAqB,eAAgB,OAAO,GAAG,IAAI,wBAAwB,oBAAoB,SAE3G,CAAC"}
1
+ {"version":3,"file":"WebComponent.utils.d.ts","sourceRoot":"","sources":["../../../../src/webComponent/WebComponent.utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AAEjH,OAAO,OAAO,MAAM,sBAAsB,CAAC;AAG3C,eAAO,MAAM,aAAa;;EAazB,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAID,eAAO,MAAM,qBAAqB,YAAmB,oBAAoB,KAAG,QAAQ,cAAc,CAuBjG,CAAC;AAEF,eAAO,MAAM,qBAAqB,eAAgB,OAAO,GAAG,IAAI,wBAAwB,oBAAoB,SAE3G,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../../src/webComponent/html.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,gBAAgB;;;;;;CAM5B,CAAC;AAEF,QAAA,MAAM,QAAQ,QAsGb,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../../src/webComponent/html.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,gBAAgB;;;;;;CAM5B,CAAC;AAEF,QAAA,MAAM,QAAQ,QAuGb,CAAC;AAEF,eAAe,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unit-components",
3
- "version": "3.1.2-beta.6",
3
+ "version": "3.1.2",
4
4
  "description": "Unit React Native components",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -52,6 +52,7 @@ export interface UNActivityComponentProps {
52
52
  paginationType?: UNActivityComponentPaginationType;
53
53
  transactionsPerPage?: number;
54
54
  showDeclinedActivity?: boolean;
55
+ showCsvDownload?: boolean;
55
56
  // event
56
57
  onLoad?: (response: UNComponentsOnLoadResponse<UNActivityOnLoadData>) => void;
57
58
  }
@@ -15,6 +15,7 @@ export const getActivityParams = (props: UNActivityComponentProps) => {
15
15
  hide-back-to-top="${props.hideBackToTop || false}"
16
16
  hide-title="${props.hideTitle || false}"
17
17
  show-declined-activity="${props.showDeclinedActivity || false}"
18
+ show-csv-download="${props.showCsvDownload || false}"
18
19
  ${queryFilterParam}
19
20
  ${paginationTypeParam}
20
21
  ${transactionsPerPageParam}
@@ -150,7 +150,6 @@ const UNWhiteLabelAppComponent = (props: UNWhiteLabelAppComponentProps) => {
150
150
  params={getWhiteLabelAppParams(props)}
151
151
  onMessage={handleWebViewMessage}
152
152
  isScrollable={true}
153
- nestedScrollEnabled={true}
154
153
  theme={props.theme}
155
154
  language={props.language}
156
155
  script={getWhiteLabelAppScript()}
@@ -1,20 +1,10 @@
1
1
  import type {TurboModule} from 'react-native';
2
- import {Platform, TurboModuleRegistry} from 'react-native';
2
+ import {TurboModuleRegistry} from 'react-native';
3
3
 
4
- let UNShareFileModule: any = null;
5
-
6
- if (Platform.OS === 'android') {
7
- interface Spec extends TurboModule {
8
- share(base64pdf: string, filename: string): boolean
9
- }
10
- UNShareFileModule = TurboModuleRegistry.getEnforcing<Spec>('UNShareFileModule');
11
- } else {
12
- UNShareFileModule = {
13
- requestAccess: async () => {
14
- console.warn('Share file module is not available on iOS.');
15
- return Promise.resolve('Share file module is not available');
16
- },
17
- };
4
+ interface Spec extends TurboModule {
5
+ share(base64Data: string, filename: string): Promise<boolean>
18
6
  }
19
7
 
8
+ const UNShareFileModule = TurboModuleRegistry.getEnforcing<Spec>('UNShareFileModule');
9
+
20
10
  export default UNShareFileModule;
@@ -98,6 +98,7 @@ export const LISTENERS = {
98
98
  `,
99
99
  cardCreated: `
100
100
  window.addEventListener("${CardMessage.CARD_CREATED}", (e) => {
101
+ if (e.detail?.fromSDK) { return }
101
102
  const response = e.detail
102
103
  response.then((data) => {
103
104
  postMessageToSDK({ type: "${CardMessage.CARD_CREATED}", details: JSON.stringify(data.data)})
@@ -409,6 +410,15 @@ export const DISPATCH_ACCOUNT_CREATED_EVENT = `
409
410
  }
410
411
  `;
411
412
 
413
+ export const DISPATCH_ON_DOWNLOAD = `
414
+ const dispatchOnDownload = (url, error) => {
415
+ const detail = { type: "unitOnDownload", url: url };
416
+ if (error) { detail.error = error; }
417
+ const event = new CustomEvent("unitOnDownload", { detail: detail });
418
+ window.dispatchEvent(event);
419
+ }
420
+ `;
421
+
412
422
  export const DISPATCH_COUNTERPARTY_DELETED = `
413
423
  const dispatchCounterpartyDeletedEvent = (details) => {
414
424
  const event = new CustomEvent("unitCounterpartyDeleted",{ detail: { data: details } });
@@ -26,7 +26,7 @@ export class UnitComponentsSDK {
26
26
  protected static fonts?: UNFonts;
27
27
  protected static signedNonce?: string;
28
28
  protected static pushProvisionModule?: typeof NativeModules;
29
- protected static sdkVersion = '3.1.2-beta.6';
29
+ protected static sdkVersion = '3.1.2';
30
30
  static iosFontBase64Map: Record<string, string> = {};
31
31
 
32
32
  public static init = async (
@@ -1,7 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import React, { useEffect, useImperativeHandle, useRef, useState } from 'react';
3
3
  import { Linking, Platform, View } from 'react-native';
4
- import UNScrollInteropView from '../nativeComponents/UNScrollInteropView/UNScrollInteropView';
5
4
  import { useSelector } from 'react-redux';
6
5
  import { WebView, WebViewMessageEvent } from 'react-native-webview';
7
6
  import { useSafeAreaDimensions } from '../hooks/useSafeAreaDimensions';
@@ -53,7 +52,7 @@ export const WebComponent = React.forwardRef<WebView, WebComponentProps>(functio
53
52
  const [androidPackageName, setAndroidPackageName] = useState<string>();
54
53
  const [infoParams, setInfoParams] = useState<{ [key: string]: string }>({});
55
54
 
56
- const webRef = useRef(null);
55
+ const webRef = useRef<WebView>(null);
57
56
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
58
57
  useImperativeHandle(webOutRef, () => webRef.current!);
59
58
 
@@ -157,10 +156,14 @@ export const WebComponent = React.forwardRef<WebView, WebComponentProps>(functio
157
156
  break;
158
157
 
159
158
  case UnitComponentsMessage.UNIT_REQUEST_DOWNLOAD:
160
- message.details &&
161
- handleRequestDownload(message.details as RequestDownloadEvent, () => {
159
+ if (message.details) {
160
+ handleRequestDownload(message.details as RequestDownloadEvent).then((result) => {
161
+ const urlArg = JSON.stringify(result.url);
162
+ const errorArg = result.error ? JSON.stringify(result.error) : 'undefined';
163
+ webRef.current?.injectJavaScript(`dispatchOnDownload(${urlArg}, ${errorArg})`);
162
164
  eventBus.emit(UnitComponentsMessage.UNIT_REQUEST_CLOSE_FLOW, {});
163
165
  });
166
+ }
164
167
  break;
165
168
  case UnitComponentsMessage.UNIT_MULTI_FACTOR_AUTH_FINISHED:
166
169
  if (message.details) {
@@ -199,26 +202,24 @@ export const WebComponent = React.forwardRef<WebView, WebComponentProps>(functio
199
202
  const needsBottomPadding = isInheritMode && effectiveBottomInset > 0;
200
203
 
201
204
  const webView = (
202
- <UNScrollInteropView style={{ flex: 1 }}>
203
- <WebView
204
- ref={webRef}
205
- originWhitelist={['*']}
206
- mediaPlaybackRequiresUserAction={false}
207
- allowsInlineMediaPlayback={true}
208
- cacheEnabled={false}
209
- scrollEnabled={props.isScrollable}
210
- nestedScrollEnabled={props.nestedScrollEnabled}
211
- onScroll={_onScroll}
212
- overScrollMode='never'
213
- injectedJavaScript={unitScript}
214
- style={{ width: '100%', flex: 1, opacity: 0.99, backgroundColor: 'transparent' }}
215
- source={{ html: sourceHtml, baseUrl: `https://${baseName}` }}
216
- onMessage={onMessage}
217
- androidLayerType='hardware'
218
- webviewDebuggingEnabled={__DEV__}
219
- mediaCapturePermissionGrantType='grant'
220
- />
221
- </UNScrollInteropView>
205
+ <WebView
206
+ ref={webRef}
207
+ originWhitelist={['*']}
208
+ mediaPlaybackRequiresUserAction={false}
209
+ allowsInlineMediaPlayback={true}
210
+ cacheEnabled={false}
211
+ scrollEnabled={props.isScrollable}
212
+ nestedScrollEnabled={props.nestedScrollEnabled}
213
+ onScroll={_onScroll}
214
+ overScrollMode='never'
215
+ injectedJavaScript={unitScript}
216
+ style={{ width: '100%', flex: 1, opacity: 0.99, backgroundColor: 'transparent' }}
217
+ source={{ html: sourceHtml, baseUrl: `https://${baseName}` }}
218
+ onMessage={onMessage}
219
+ androidLayerType='hardware'
220
+ webviewDebuggingEnabled={__DEV__}
221
+ mediaCapturePermissionGrantType='grant'
222
+ />
222
223
  );
223
224
 
224
225
  if (needsBottomPadding) {
@@ -1,5 +1,5 @@
1
1
  import axios from 'axios';
2
- import { Share, Platform } from 'react-native';
2
+ import { Platform } from 'react-native';
3
3
  import AppInfo from '../utils/AppInfo';
4
4
  import type { EventToContinueEvent, RequestDownloadEvent } from '../messages/webMessages/unitComponentsMessages';
5
5
  import { UnitComponentsSDK } from '../unitComponentsSdkManager/UnitComponentsSdkManager';
@@ -21,10 +21,22 @@ export const getInfoParams = async () => {
21
21
  return infoParams;
22
22
  };
23
23
 
24
- export const handleRequestDownload = async (details: RequestDownloadEvent, onReadyToShare: () => void) => {
25
- if (details.fileType === 'application/pdf') {
24
+ export interface DownloadResult {
25
+ url: string;
26
+ error?: string;
27
+ }
28
+
29
+ const SUPPORTED_DOWNLOAD_TYPES = ['application/pdf', 'text/csv'];
30
+
31
+ export const handleRequestDownload = async (details: RequestDownloadEvent): Promise<DownloadResult> => {
32
+ if (!SUPPORTED_DOWNLOAD_TYPES.includes(details.fileType)) {
33
+ return { url: details.url, error: `Unsupported file type: ${details.fileType}` };
34
+ }
35
+
36
+ try {
26
37
  const res = await axios.get(details.url, {
27
38
  headers: {
39
+ 'Accept': details.fileType,
28
40
  'Authorization': `Bearer ${details.accessToken}`
29
41
  },
30
42
  responseEncoding: 'base64',
@@ -33,13 +45,11 @@ export const handleRequestDownload = async (details: RequestDownloadEvent, onRea
33
45
 
34
46
  const base64Data = res.request._response;
35
47
 
36
- onReadyToShare();
48
+ await RNShareFile.share(base64Data, details.fileName);
37
49
 
38
- if (Platform.OS === 'ios') {
39
- Share.share({ url: `data:application/pdf;base64,${base64Data}` });
40
- } else {
41
- RNShareFile.share(base64Data, details.fileName);
42
- }
50
+ return { url: details.url };
51
+ } catch (error: any) {
52
+ return { url: details.url, error: error?.message || 'Download failed' };
43
53
  }
44
54
  };
45
55
 
@@ -16,6 +16,7 @@ import {
16
16
  DISPATCH_MULTIPLE_CARDS_FILTER_CHANGED_EVENT,
17
17
  DISPATCH_CARD_CREATED_EVENT,
18
18
  DISPATCH_ACCOUNT_CREATED_EVENT,
19
+ DISPATCH_ON_DOWNLOAD,
19
20
  } from '../scripts/html/bodyScript';
20
21
 
21
22
  export const HTML_PLACEHOLDER = {
@@ -42,14 +43,13 @@ const htmlText = `
42
43
  }
43
44
  ${HTML_PLACEHOLDER.WINDOW_PARAMS}
44
45
  </script>
45
- <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
46
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
46
47
 
47
48
  <style type="text/css">
48
49
  ${HTML_PLACEHOLDER.FONT_FACES}
49
50
 
50
- html, body {
51
+ body {
51
52
  margin: 0;
52
- overscroll-behavior: contain;
53
53
  }
54
54
  </style>
55
55
  </head>
@@ -124,6 +124,8 @@ const htmlText = `
124
124
 
125
125
  ${SET_ITEM_IN_WINDOW_UNIT_STORE}
126
126
 
127
+ ${DISPATCH_ON_DOWNLOAD}
128
+
127
129
  ${HTML_PLACEHOLDER.SCRIPT_FROM_NATIVE}
128
130
  </script>
129
131
  </body>
@@ -1,63 +0,0 @@
1
- package com.unitreactnativecomponents.nativeComponents.scrollInterop
2
-
3
- import android.content.Context
4
- import android.view.MotionEvent
5
- import android.view.ViewParent
6
- import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
7
- import com.facebook.react.module.annotations.ReactModule
8
- import com.facebook.react.uimanager.ThemedReactContext
9
- import com.facebook.react.uimanager.ViewGroupManager
10
- import com.facebook.react.views.view.ReactViewGroup
11
-
12
- /**
13
- * Wraps child WebViews to prevent SwipeRefreshLayout from intercepting
14
- * vertical scroll gestures that belong to the WebView.
15
- *
16
- * On ACTION_DOWN this view disables any ancestor SwipeRefreshLayout so
17
- * that the WebView keeps full control of the touch sequence. The SRL
18
- * is re-enabled when the gesture ends (ACTION_UP / ACTION_CANCEL).
19
- *
20
- * This is the standard Android pattern for WebView-inside-SwipeRefreshLayout:
21
- * https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout
22
- */
23
- @ReactModule(name = UNScrollInteropViewManager.REACT_VIEW_NAME)
24
- class UNScrollInteropViewManager : ViewGroupManager<UNScrollInteropView>() {
25
- override fun getName() = REACT_VIEW_NAME
26
- override fun createViewInstance(ctx: ThemedReactContext) = UNScrollInteropView(ctx)
27
-
28
- companion object {
29
- const val REACT_VIEW_NAME = "UNScrollInteropView"
30
- }
31
- }
32
-
33
- class UNScrollInteropView(context: Context) : ReactViewGroup(context) {
34
-
35
- private var swipeRefreshLayout: SwipeRefreshLayout? = null
36
-
37
- private fun findSwipeRefreshLayout(): SwipeRefreshLayout? {
38
- swipeRefreshLayout?.let { return it }
39
- var p: ViewParent? = parent
40
- while (p != null) {
41
- if (p is SwipeRefreshLayout) {
42
- swipeRefreshLayout = p
43
- return p
44
- }
45
- p = p.parent
46
- }
47
- return null
48
- }
49
-
50
- override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
51
- when (ev.actionMasked) {
52
- MotionEvent.ACTION_DOWN -> {
53
- findSwipeRefreshLayout()?.isEnabled = false
54
- parent?.requestDisallowInterceptTouchEvent(true)
55
- }
56
- MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
57
- findSwipeRefreshLayout()?.isEnabled = true
58
- parent?.requestDisallowInterceptTouchEvent(false)
59
- }
60
- }
61
- return super.dispatchTouchEvent(ev)
62
- }
63
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _reactNative = require("react-native");
8
- var _default = exports.default = (0, _reactNative.requireNativeComponent)('UNScrollInteropView');
9
- //# sourceMappingURL=UNScrollInteropView.android.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_reactNative","require","_default","exports","default","requireNativeComponent"],"sourceRoot":"../../../../src","sources":["nativeComponents/UNScrollInteropView/UNScrollInteropView.android.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAsD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEvC,IAAAC,mCAAsB,EAAC,qBAAqB,CAAC","ignoreList":[]}
@@ -1,10 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _reactNative = require("react-native");
8
- // On iOS, no special scroll interop is needed — use a plain View.
9
- var _default = exports.default = _reactNative.View;
10
- //# sourceMappingURL=UNScrollInteropView.ios.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_reactNative","require","_default","exports","default","View"],"sourceRoot":"../../../../src","sources":["nativeComponents/UNScrollInteropView/UNScrollInteropView.ios.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACeC,iBAAI","ignoreList":[]}
@@ -1,11 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _reactNative = require("react-native");
8
- // Platform-agnostic entry point for TypeScript type generation (bob build).
9
- // At runtime, Metro resolves .android.ts or .ios.ts instead.
10
- var _default = exports.default = _reactNative.View;
11
- //# sourceMappingURL=UNScrollInteropView.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_reactNative","require","_default","exports","default","View"],"sourceRoot":"../../../../src","sources":["nativeComponents/UNScrollInteropView/UNScrollInteropView.ts"],"mappings":";;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AAFA;AACA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGeC,iBAAI","ignoreList":[]}
@@ -1,3 +0,0 @@
1
- import { requireNativeComponent } from 'react-native';
2
- export default requireNativeComponent('UNScrollInteropView');
3
- //# sourceMappingURL=UNScrollInteropView.android.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["requireNativeComponent"],"sourceRoot":"../../../../src","sources":["nativeComponents/UNScrollInteropView/UNScrollInteropView.android.ts"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,cAAc;AAErD,eAAeA,sBAAsB,CAAC,qBAAqB,CAAC","ignoreList":[]}
@@ -1,5 +0,0 @@
1
- import { View } from 'react-native';
2
-
3
- // On iOS, no special scroll interop is needed — use a plain View.
4
- export default View;
5
- //# sourceMappingURL=UNScrollInteropView.ios.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["View"],"sourceRoot":"../../../../src","sources":["nativeComponents/UNScrollInteropView/UNScrollInteropView.ios.ts"],"mappings":"AAAA,SAASA,IAAI,QAAQ,cAAc;;AAEnC;AACA,eAAeA,IAAI","ignoreList":[]}
@@ -1,5 +0,0 @@
1
- // Platform-agnostic entry point for TypeScript type generation (bob build).
2
- // At runtime, Metro resolves .android.ts or .ios.ts instead.
3
- import { View } from 'react-native';
4
- export default View;
5
- //# sourceMappingURL=UNScrollInteropView.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["View"],"sourceRoot":"../../../../src","sources":["nativeComponents/UNScrollInteropView/UNScrollInteropView.ts"],"mappings":"AAAA;AACA;AACA,SAASA,IAAI,QAAQ,cAAc;AAEnC,eAAeA,IAAI","ignoreList":[]}
@@ -1,3 +0,0 @@
1
- declare const _default: import("react-native").HostComponent<unknown>;
2
- export default _default;
3
- //# sourceMappingURL=UNScrollInteropView.android.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UNScrollInteropView.android.d.ts","sourceRoot":"","sources":["../../../../../src/nativeComponents/UNScrollInteropView/UNScrollInteropView.android.ts"],"names":[],"mappings":";AAEA,wBAA6D"}
@@ -1,3 +0,0 @@
1
- import { View } from 'react-native';
2
- export default View;
3
- //# sourceMappingURL=UNScrollInteropView.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UNScrollInteropView.d.ts","sourceRoot":"","sources":["../../../../../src/nativeComponents/UNScrollInteropView/UNScrollInteropView.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,eAAe,IAAI,CAAC"}
@@ -1,3 +0,0 @@
1
- import { View } from 'react-native';
2
- export default View;
3
- //# sourceMappingURL=UNScrollInteropView.ios.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UNScrollInteropView.ios.d.ts","sourceRoot":"","sources":["../../../../../src/nativeComponents/UNScrollInteropView/UNScrollInteropView.ios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,eAAe,IAAI,CAAC"}
@@ -1,3 +0,0 @@
1
- import { requireNativeComponent } from 'react-native';
2
-
3
- export default requireNativeComponent('UNScrollInteropView');
@@ -1,4 +0,0 @@
1
- import { View } from 'react-native';
2
-
3
- // On iOS, no special scroll interop is needed — use a plain View.
4
- export default View;
@@ -1,5 +0,0 @@
1
- // Platform-agnostic entry point for TypeScript type generation (bob build).
2
- // At runtime, Metro resolves .android.ts or .ios.ts instead.
3
- import { View } from 'react-native';
4
-
5
- export default View;