react-native-unit-components 1.0.0 → 1.0.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.
- package/android/src/main/java/com/unitreactnativecomponents/UnitAddToWalletButtonViewManager.kt +27 -0
- package/android/src/main/java/com/unitreactnativecomponents/UnitReactNativeComponentsEvent.kt +21 -0
- package/android/src/main/java/com/unitreactnativecomponents/UnitReactNativeComponentsPackage.kt +2 -1
- package/android/src/main/java/com/unitreactnativecomponents/visapresentation/UNGooglePayView.kt +197 -0
- package/android/src/main/res/drawable/ic_launcher_background.xml +170 -0
- package/android/src/main/res/drawable/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable/un_black_googlepay_button_background.xml +6 -0
- package/android/src/main/res/drawable/un_black_googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/drawable/un_black_googlepay_button_content.xml +48 -0
- package/android/src/main/res/drawable/un_black_googlepay_button_no_shadow_background.xml +6 -0
- package/android/src/main/res/drawable/un_black_googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/drawable/un_black_googlepay_button_overlay.xml +12 -0
- package/android/src/main/res/drawable/un_border.xml +6 -0
- package/android/src/main/res/drawable/un_condensed_googlepay.xml +27 -0
- package/android/src/main/res/drawable/un_googlepay_button_background.xml +18 -0
- package/android/src/main/res/drawable/un_googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/drawable/un_googlepay_button_background_image_focused.9.png +0 -0
- package/android/src/main/res/drawable/un_googlepay_button_background_image_pressed.9.png +0 -0
- package/android/src/main/res/drawable/un_googlepay_button_content.xml +48 -0
- package/android/src/main/res/drawable/un_googlepay_button_no_shadow_background.xml +18 -0
- package/android/src/main/res/drawable/un_googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/drawable/un_googlepay_button_no_shadow_background_image_focused.9.png +0 -0
- package/android/src/main/res/drawable/un_googlepay_button_no_shadow_background_image_pressed.9.png +0 -0
- package/android/src/main/res/drawable/un_googlepay_button_overlay.xml +11 -0
- package/android/src/main/res/drawable/un_ic_launcher_foreground.xml +30 -0
- package/android/src/main/res/drawable/un_ic_unit_logo.xml +25 -0
- package/android/src/main/res/drawable/un_ic_visa.xml +13 -0
- package/android/src/main/res/drawable-bg/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-bg/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-ca/un_add_to_googlepay_button_content.xml +30 -0
- package/android/src/main/res/drawable-ca/un_black_add_to_googlepay_button_content.xml +30 -0
- package/android/src/main/res/drawable-cs/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-cs/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-da/un_add_to_googlepay_button_content.xml +30 -0
- package/android/src/main/res/drawable-da/un_black_add_to_googlepay_button_content.xml +30 -0
- package/android/src/main/res/drawable-de/un_add_to_googlepay_button_content.xml +60 -0
- package/android/src/main/res/drawable-de/un_black_add_to_googlepay_button_content.xml +60 -0
- package/android/src/main/res/drawable-el/un_add_to_googlepay_button_content.xml +67 -0
- package/android/src/main/res/drawable-el/un_black_add_to_googlepay_button_content.xml +67 -0
- package/android/src/main/res/drawable-es/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-es/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-et/un_add_to_googlepay_button_content.xml +64 -0
- package/android/src/main/res/drawable-et/un_black_add_to_googlepay_button_content.xml +64 -0
- package/android/src/main/res/drawable-fi/un_add_to_googlepay_button_content.xml +39 -0
- package/android/src/main/res/drawable-fi/un_black_add_to_googlepay_button_content.xml +39 -0
- package/android/src/main/res/drawable-fr/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-fr/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-hr/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-hr/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-hu/un_add_to_googlepay_button_content.xml +64 -0
- package/android/src/main/res/drawable-hu/un_black_add_to_googlepay_button_content.xml +64 -0
- package/android/src/main/res/drawable-in/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-in/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-it/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-it/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-iw/un_add_to_googlepay_button_content.xml +41 -0
- package/android/src/main/res/drawable-iw/un_black_add_to_googlepay_button_content.xml +41 -0
- package/android/src/main/res/drawable-ja/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-ja/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-ko/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-ko/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-lt/un_add_to_googlepay_button_content.xml +70 -0
- package/android/src/main/res/drawable-lt/un_black_add_to_googlepay_button_content.xml +70 -0
- package/android/src/main/res/drawable-lv/un_add_to_googlepay_button_content.xml +61 -0
- package/android/src/main/res/drawable-lv/un_black_add_to_googlepay_button_content.xml +61 -0
- package/android/src/main/res/drawable-ms/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-ms/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-nb/un_add_to_googlepay_button_content.xml +30 -0
- package/android/src/main/res/drawable-nb/un_black_add_to_googlepay_button_content.xml +30 -0
- package/android/src/main/res/drawable-nl/un_add_to_googlepay_button_content.xml +58 -0
- package/android/src/main/res/drawable-nl/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-pl/un_add_to_googlepay_button_content.xml +30 -0
- package/android/src/main/res/drawable-pl/un_black_add_to_googlepay_button_content.xml +30 -0
- package/android/src/main/res/drawable-pt/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-pt/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-ro/un_add_to_googlepay_button_content.xml +58 -0
- package/android/src/main/res/drawable-ro/un_black_add_to_googlepay_button_content.xml +58 -0
- package/android/src/main/res/drawable-ru/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-ru/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-sk/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-sk/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-sl/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-sl/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-sr/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-sr/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-sv/un_add_to_googlepay_button_content.xml +30 -0
- package/android/src/main/res/drawable-sv/un_black_add_to_googlepay_button_content.xml +30 -0
- package/android/src/main/res/drawable-th/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-th/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-tr/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-tr/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-uk/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-uk/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-v21/un_black_googlepay_button_background.xml +7 -0
- package/android/src/main/res/drawable-v21/un_black_googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/drawable-v21/un_black_googlepay_button_no_shadow_background.xml +7 -0
- package/android/src/main/res/drawable-v21/un_black_googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/drawable-v24/ic_launcher_background.xml +170 -0
- package/android/src/main/res/drawable-v24/un_border.xml +6 -0
- package/android/src/main/res/drawable-v24/un_ic_launcher_foreground.xml +30 -0
- package/android/src/main/res/drawable-v24/un_ic_unit_logo.xml +25 -0
- package/android/src/main/res/drawable-v24/un_ic_visa.xml +13 -0
- package/android/src/main/res/drawable-zh/un_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/drawable-zh/un_black_add_to_googlepay_button_content.xml +54 -0
- package/android/src/main/res/layout/un_black_add_to_googlepay_button.xml +32 -0
- package/android/src/main/res/layout/un_view_google_push_provisioning.xml +45 -0
- package/android/src/main/res/layout/un_white_add_to_googlepay_button.xml +31 -0
- package/android/src/main/res/layout/un_white_add_to_googlepay_button_no_shadow.xml +31 -0
- package/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
- package/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
- package/android/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/mipmap-xhdpi/black_googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/black_googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/googlepay_button_background_image_focused.9.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/googlepay_button_background_image_pressed.9.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/googlepay_button_no_shadow_background_image_focused.9.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/googlepay_button_no_shadow_background_image_pressed.9.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/mipmap-xhdpi/white_googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/black_googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/black_googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/googlepay_button_background_image_focused.9.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/googlepay_button_background_image_pressed.9.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/googlepay_button_no_shadow_background_image_focused.9.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/googlepay_button_no_shadow_background_image_pressed.9.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/black_googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/black_googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/googlepay_button_background_image_focused.9.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/googlepay_button_background_image_pressed.9.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/googlepay_button_no_shadow_background_image.9.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/googlepay_button_no_shadow_background_image_focused.9.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/googlepay_button_no_shadow_background_image_pressed.9.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/values/colors.xml +14 -0
- package/android/src/main/res/values/googlepay_strings.xml +7 -0
- package/android/src/main/res/values/strings.xml +4 -0
- package/android/src/main/res/values/themes.xml +16 -0
- package/android/src/main/res/values-night/themes.xml +16 -0
- package/ios/UnitReactNativeComponents.xcodeproj/project.pbxproj +8 -8
- package/ios/UnitReactNativeComponentsViewManager.m +3 -2
- package/ios/UnitReactNativeComponentsViewManager.swift +39 -25
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js +39 -8
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js +0 -3
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js +41 -10
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +0 -3
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js +39 -6
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js +2 -1
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js +0 -3
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.js +7 -6
- package/lib/commonjs/helpers/BottomSheet/BottomSheet.js.map +1 -1
- package/lib/commonjs/messages/nativeMessages/index.js +1 -0
- package/lib/commonjs/messages/nativeMessages/index.js.map +1 -1
- package/lib/commonjs/messages/webMessages/pageMessage.js.map +1 -1
- package/lib/commonjs/nativeComponent/UNNativeAddToWalletButton.js +13 -0
- package/lib/commonjs/nativeComponent/UNNativeAddToWalletButton.js.map +1 -0
- package/lib/commonjs/scripts/html/bodyHtml.js +1 -1
- package/lib/commonjs/scripts/html/bodyHtml.js.map +1 -1
- package/lib/commonjs/unitSdkManager/UnitSdkManager.js +8 -0
- package/lib/commonjs/unitSdkManager/UnitSdkManager.js.map +1 -1
- package/lib/commonjs/webComponent/WebComponent.js +31 -6
- package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js +33 -7
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js +0 -2
- package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js +36 -9
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js +0 -2
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js +37 -5
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
- package/lib/module/components/UNCardComponent/UNCardComponent.js +2 -1
- package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.js +0 -2
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
- package/lib/module/helpers/BottomSheet/BottomSheet.js +7 -6
- package/lib/module/helpers/BottomSheet/BottomSheet.js.map +1 -1
- package/lib/module/messages/nativeMessages/index.js +1 -0
- package/lib/module/messages/nativeMessages/index.js.map +1 -1
- package/lib/module/messages/webMessages/pageMessage.js.map +1 -1
- package/lib/module/nativeComponent/UNNativeAddToWalletButton.js +4 -0
- package/lib/module/nativeComponent/UNNativeAddToWalletButton.js.map +1 -0
- package/lib/module/scripts/html/bodyHtml.js +1 -1
- package/lib/module/scripts/html/bodyHtml.js.map +1 -1
- package/lib/module/unitSdkManager/UnitSdkManager.js +3 -0
- package/lib/module/unitSdkManager/UnitSdkManager.js.map +1 -1
- package/lib/module/webComponent/WebComponent.js +29 -6
- package/lib/module/webComponent/WebComponent.js.map +1 -1
- package/lib/typescript/components/UNBottomSheetComponent/UNBottomSheetComponent.d.ts +6 -0
- package/lib/typescript/helpers/BottomSheet/BottomSheet.d.ts +2 -0
- package/lib/typescript/messages/nativeMessages/index.d.ts +2 -1
- package/lib/typescript/nativeComponent/UNNativeAddToWalletButton.d.ts +6 -0
- package/lib/typescript/unitSdkManager/UnitSdkManager.d.ts +1 -1
- package/lib/typescript/webComponent/WebComponent.d.ts +5 -2
- package/package.json +1 -1
- package/src/components/UNActivityComponent/UNActivityComponent.tsx +33 -7
- package/src/components/UNActivityComponent/UNActivityComponent.utils.ts +0 -2
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +35 -9
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.utils.ts +0 -2
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.tsx +35 -4
- package/src/components/UNCardComponent/UNCardComponent.tsx +2 -1
- package/src/components/UNCardComponent/UNCardComponent.utils.ts +0 -2
- package/src/helpers/BottomSheet/BottomSheet.tsx +7 -5
- package/src/messages/nativeMessages/index.ts +2 -1
- package/src/messages/webMessages/pageMessage.ts +1 -1
- package/src/nativeComponent/UNNativeAddToWalletButton.tsx +12 -0
- package/src/scripts/html/bodyHtml.ts +1 -1
- package/src/unitSdkManager/UnitSdkManager.ts +4 -1
- package/src/webComponent/WebComponent.tsx +33 -9
- package/android/src/main/java/com/unitreactnativecomponents/UnitReactNativeComponentsViewManager.kt +0 -19
- package/lib/commonjs/nativeComponenet/NativeComponentExample.js +0 -19
- package/lib/commonjs/nativeComponenet/NativeComponentExample.js.map +0 -1
- package/lib/module/nativeComponenet/NativeComponentExample.js +0 -10
- package/lib/module/nativeComponenet/NativeComponentExample.js.map +0 -1
- package/lib/typescript/nativeComponenet/NativeComponentExample.d.ts +0 -7
- package/src/nativeComponenet/NativeComponentExample.tsx +0 -26
|
@@ -17,13 +17,15 @@ const BottomSheet = props => {
|
|
|
17
17
|
const [dy, setDy] = useState(0);
|
|
18
18
|
|
|
19
19
|
const _parentPanResponder = PanResponder.create({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
//gestureState) => {
|
|
23
|
-
return false; // return Math.abs(gestureState.dy) > 10
|
|
20
|
+
onMoveShouldSetPanResponderCapture: (_, gestureState) => {
|
|
21
|
+
return props.shouldEnableBottomSheetScroll && Math.abs(gestureState.dy) > 10;
|
|
24
22
|
},
|
|
25
23
|
|
|
26
24
|
onPanResponderMove(_, gestureState) {
|
|
25
|
+
if (props.shouldEnableBottomSheetScroll && gestureState.dy < 5) {
|
|
26
|
+
props.handleWebViewScroll();
|
|
27
|
+
}
|
|
28
|
+
|
|
27
29
|
if (currentHeight + gestureState.dy < 0) return;
|
|
28
30
|
if (!props.expandToMaxHeightEnabled && contentHeight && currentHeight + gestureState.dy < sliderMaxHeight - contentHeight) return;
|
|
29
31
|
panelHeightValue.setValue(currentHeight + gestureState.dy);
|
|
@@ -171,8 +173,7 @@ const BottomSheet = props => {
|
|
|
171
173
|
}, /*#__PURE__*/React.createElement(Image, {
|
|
172
174
|
source: CloseIcon
|
|
173
175
|
})), /*#__PURE__*/React.createElement(View, {
|
|
174
|
-
onLayout: _setSize
|
|
175
|
-
style: [styles.innerContent]
|
|
176
|
+
onLayout: _setSize
|
|
176
177
|
}, /*#__PURE__*/React.createElement(KeyboardAvoidingView, {
|
|
177
178
|
behavior: "padding",
|
|
178
179
|
style: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useRef","useState","Animated","BackHandler","Dimensions","Easing","Image","KeyboardAvoidingView","PanResponder","TouchableOpacity","View","PropTypes","CloseIcon","BOTTOM_SHEET_MAX_PRECANTAGE_SIZE","getStylesObject","BottomSheet","props","panelHeightValue","Value","sliderMaxHeight","current","fadeAnim","styles","isPanelOpened","setIsPanelOpened","isOpen","contentHeight","setContentHeight","undefined","currentHeight","setCurrentHeight","dy","setDy","_parentPanResponder","create","onMoveShouldSetPanResponderCapture","_","onPanResponderMove","gestureState","expandToMaxHeightEnabled","setValue","onPanResponderRelease","collapse","setToContentHeight","expand","fadeIn","_dismiss","addEventListener","_onBackPress","id","addListener","e","value","removeEventListener","removeListener","timing","toValue","duration","useNativeDriver","start","fadeOut","onClose","animationDuration","easing","quad","_setSize","newContentHeight","nativeEvent","layout","height","children","outsideContainer","animation","panHandlers","container","transform","translateY","outerContent","closeButton","innerContent","propTypes","oneOfType","node","bool","number","func","onOpen","defaultProps","get"],"sources":["BottomSheet.tsx"],"sourcesContent":["import React, { ReactNode, useEffect, useRef, useState } from 'react';\nimport {\n Animated,\n BackHandler,\n Dimensions,\n Easing,\n Image,\n KeyboardAvoidingView,\n LayoutChangeEvent,\n PanResponder,\n TouchableOpacity,\n View,\n} from 'react-native';\nimport PropTypes from 'prop-types';\nimport { CloseIcon } from '../../assets/images';\nimport { BOTTOM_SHEET_MAX_PRECANTAGE_SIZE } from '../../components/UNBottomSheetComponent/UNBottomSheetComponent.constants';\nimport { getStylesObject } from './BottomSheet.styles';\n\nexport interface BottomSheetProps {\n isOpen: boolean\n children: ReactNode\n sliderMaxHeight: number\n onOpen: () => void\n onClose: () => void\n height: number,\n animationDuration: number,\n expandToMaxHeightEnabled: boolean\n}\n\nconst BottomSheet = (props: BottomSheetProps) => {\n const panelHeightValue = useRef(new Animated.Value(props.sliderMaxHeight)).current;\n const fadeAnim = useRef(new Animated.Value(0)).current;\n const styles = getStylesObject(fadeAnim);\n const [isPanelOpened, setIsPanelOpened] = useState(props.isOpen);\n const [contentHeight, setContentHeight] = useState<number | undefined>(undefined);\n\n const [currentHeight, setCurrentHeight] = useState<number>(props.sliderMaxHeight);\n\n const [dy, setDy] = useState(0);\n\n const _parentPanResponder = PanResponder.create({\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onMoveShouldSetPanResponderCapture: (_,) => { //gestureState) => {\n return false;\n // return Math.abs(gestureState.dy) > 10\n },\n onPanResponderMove(_, gestureState) {\n if (currentHeight + gestureState.dy < 0) return;\n if (!props.expandToMaxHeightEnabled && contentHeight && currentHeight + gestureState.dy < sliderMaxHeight - contentHeight) return;\n panelHeightValue.setValue(currentHeight + gestureState.dy);\n setDy(gestureState.dy);\n },\n onPanResponderRelease: () => {\n if (dy > 0) {\n collapse();\n } else if (!props.expandToMaxHeightEnabled) {\n contentHeight && setToContentHeight(contentHeight);\n } else if (dy < 0) {\n expand();\n } else {\n expand();\n }\n }\n });\n\n useEffect(() => {\n if (props.isOpen && !isPanelOpened) {\n fadeIn();\n } else if (isPanelOpened) {\n setContentHeight(0);\n _dismiss();\n }\n }, [props.isOpen]);\n\n useEffect(() => {\n BackHandler.addEventListener('hardwareBackPress', _onBackPress);\n const id = panelHeightValue.addListener(e => setCurrentHeight(e.value));\n\n return (() => {\n BackHandler.removeEventListener('hardwareBackPress', _onBackPress);\n panelHeightValue.removeListener(id);\n });\n }, []);\n\n const fadeIn = () => {\n Animated.timing(fadeAnim, {\n toValue: 0.3,\n duration: 500,\n useNativeDriver: false\n }).start(() => { setIsPanelOpened(true); });\n };\n\n const fadeOut = () => {\n Animated.timing(fadeAnim, {\n toValue: 0,\n duration: 500,\n useNativeDriver: false\n }).start(() => {\n setIsPanelOpened(false);\n props.onClose();\n });\n };\n\n const setToContentHeight = (contentHeight: number) => {\n Animated.timing(panelHeightValue, {\n duration: props.animationDuration,\n easing: Easing.quad,\n toValue: sliderMaxHeight - contentHeight,\n useNativeDriver: false,\n }).start();\n };\n\n const expand = () => {\n const { animationDuration } = props;\n\n if (contentHeight && currentHeight > (sliderMaxHeight - contentHeight)) {\n setToContentHeight(contentHeight);\n return;\n }\n\n Animated.timing(panelHeightValue, {\n duration: animationDuration,\n easing: Easing.quad,\n toValue: 0,\n useNativeDriver: false,\n }).start();\n };\n\n const collapse = () => {\n if (contentHeight && currentHeight > (sliderMaxHeight - contentHeight)) {\n _dismiss();\n return;\n }\n\n contentHeight && setToContentHeight(contentHeight);\n };\n\n const _onBackPress = () => {\n isPanelOpened && collapse();\n return isPanelOpened;\n };\n\n const _setSize = (e: LayoutChangeEvent) => {\n const newContentHeight = e.nativeEvent.layout.height;\n\n setContentHeight(newContentHeight);\n setToContentHeight(newContentHeight);\n };\n\n const _dismiss = () => {\n const { animationDuration } = props;\n Animated.timing(panelHeightValue, {\n duration: animationDuration,\n easing: Easing.quad,\n toValue: sliderMaxHeight,\n useNativeDriver: false,\n }).start(() => {\n null;\n });\n fadeOut();\n };\n\n const {\n sliderMaxHeight,\n children,\n } = props;\n\n return (\n <>\n <TouchableOpacity\n style={styles.outsideContainer} activeOpacity={1}\n onPress={_dismiss}\n >\n <Animated.View\n style={styles.animation}\n >\n </Animated.View>\n </TouchableOpacity>\n <Animated.View\n {..._parentPanResponder.panHandlers}\n style={{\n ...styles.container,\n height: sliderMaxHeight,\n transform: [\n { translateY: panelHeightValue },\n ],\n }}\n >\n <View\n style={styles.outerContent}\n >\n <TouchableOpacity\n activeOpacity={1}\n style={styles.closeButton}\n onPress={_dismiss}\n >\n <Image source={CloseIcon} />\n </TouchableOpacity>\n\n <View\n onLayout={_setSize}\n style={[styles.innerContent]}\n >\n <KeyboardAvoidingView\n behavior=\"padding\"\n style={{ height: props.height }}\n keyboardVerticalOffset={props.height * (1 - BOTTOM_SHEET_MAX_PRECANTAGE_SIZE)}\n >\n {children}\n </KeyboardAvoidingView>\n </View>\n </View>\n </Animated.View>\n </>\n );\n};\n\nBottomSheet.propTypes = {\n children: PropTypes.oneOfType([PropTypes.node]),\n isOpen: PropTypes.bool,\n sliderMaxHeight: PropTypes.number,\n animation: PropTypes.func,\n animationDuration: PropTypes.number,\n onOpen: PropTypes.func,\n onClose: PropTypes.func,\n expandToMaxHeightEnabled: PropTypes.bool\n};\n\nBottomSheet.defaultProps = {\n children: <View />,\n isOpen: true,\n sliderMaxHeight: Dimensions.get('window').height * BOTTOM_SHEET_MAX_PRECANTAGE_SIZE,\n animationDuration: 200,\n onOpen: () => null,\n onClose: () => null,\n expandToMaxHeightEnabled: false\n};\n\nexport default BottomSheet;\n"],"mappings":";;AAAA,OAAOA,KAAP,IAA2BC,SAA3B,EAAsCC,MAAtC,EAA8CC,QAA9C,QAA8D,OAA9D;AACA,SACEC,QADF,EAEEC,WAFF,EAGEC,UAHF,EAIEC,MAJF,EAKEC,KALF,EAMEC,oBANF,EAQEC,YARF,EASEC,gBATF,EAUEC,IAVF,QAWO,cAXP;AAYA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,gCAAT,QAAiD,0EAAjD;AACA,SAASC,eAAT,QAAgC,sBAAhC;;AAaA,MAAMC,WAAW,GAAIC,KAAD,IAA6B;EAC/C,MAAMC,gBAAgB,GAAGjB,MAAM,CAAC,IAAIE,QAAQ,CAACgB,KAAb,CAAmBF,KAAK,CAACG,eAAzB,CAAD,CAAN,CAAkDC,OAA3E;EACA,MAAMC,QAAQ,GAAGrB,MAAM,CAAC,IAAIE,QAAQ,CAACgB,KAAb,CAAmB,CAAnB,CAAD,CAAN,CAA8BE,OAA/C;EACA,MAAME,MAAM,GAAGR,eAAe,CAACO,QAAD,CAA9B;EACA,MAAM,CAACE,aAAD,EAAgBC,gBAAhB,IAAoCvB,QAAQ,CAACe,KAAK,CAACS,MAAP,CAAlD;EACA,MAAM,CAACC,aAAD,EAAgBC,gBAAhB,IAAoC1B,QAAQ,CAAqB2B,SAArB,CAAlD;EAEA,MAAM,CAACC,aAAD,EAAgBC,gBAAhB,IAAoC7B,QAAQ,CAASe,KAAK,CAACG,eAAf,CAAlD;EAEA,MAAM,CAACY,EAAD,EAAKC,KAAL,IAAc/B,QAAQ,CAAC,CAAD,CAA5B;;EAEA,MAAMgC,mBAAmB,GA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AAE5B,SAAS,CAACwE;AARd,CAAxB;AAWApE,WAAW,CAACwE,YAAZ,GAA2B;EACzBjB,QAAQ,eAAE,oBAAC,IAAD,OADe;EAEzB7C,MAAM,EAAE,IAFiB;EAGzBN,eAAe,EAAEf,UAAU,CAACoF,GAAX,CAAe,QAAf,EAAyBnB,MAAzB,GAAkCxD,gCAH1B;EAIzBiD,iBAAiB,EAAE,GAJM;EAKzBwB,MAAM,EAAE,MAAM,IALW;EAMzBzB,OAAO,EAAE,MAAM,IANU;EAOzBtB,wBAAwB,EAAE;AAPD,CAA3B;AAUA,eAAexB,WAAf"}
|
|
1
|
+
{"version":3,"names":["React","useEffect","useRef","useState","Animated","BackHandler","Dimensions","Easing","Image","KeyboardAvoidingView","PanResponder","TouchableOpacity","View","PropTypes","CloseIcon","BOTTOM_SHEET_MAX_PRECANTAGE_SIZE","getStylesObject","BottomSheet","props","panelHeightValue","Value","sliderMaxHeight","current","fadeAnim","styles","isPanelOpened","setIsPanelOpened","isOpen","contentHeight","setContentHeight","undefined","currentHeight","setCurrentHeight","dy","setDy","_parentPanResponder","create","onMoveShouldSetPanResponderCapture","_","gestureState","shouldEnableBottomSheetScroll","Math","abs","onPanResponderMove","handleWebViewScroll","expandToMaxHeightEnabled","setValue","onPanResponderRelease","collapse","setToContentHeight","expand","fadeIn","_dismiss","addEventListener","_onBackPress","id","addListener","e","value","removeEventListener","removeListener","timing","toValue","duration","useNativeDriver","start","fadeOut","onClose","animationDuration","easing","quad","_setSize","newContentHeight","nativeEvent","layout","height","children","outsideContainer","animation","panHandlers","container","transform","translateY","outerContent","closeButton","propTypes","oneOfType","node","bool","number","func","onOpen","defaultProps","get"],"sources":["BottomSheet.tsx"],"sourcesContent":["import React, { ReactNode, useEffect, useRef, useState } from 'react';\nimport {\n Animated,\n BackHandler,\n Dimensions,\n Easing,\n Image,\n KeyboardAvoidingView,\n LayoutChangeEvent,\n PanResponder,\n TouchableOpacity,\n View,\n} from 'react-native';\nimport PropTypes from 'prop-types';\nimport { CloseIcon } from '../../assets/images';\nimport { BOTTOM_SHEET_MAX_PRECANTAGE_SIZE } from '../../components/UNBottomSheetComponent/UNBottomSheetComponent.constants';\nimport { getStylesObject } from './BottomSheet.styles';\n\nexport interface BottomSheetProps {\n isOpen: boolean\n children: ReactNode\n sliderMaxHeight: number\n onOpen: () => void\n onClose: () => void\n height: number,\n animationDuration: number,\n expandToMaxHeightEnabled: boolean\n handleWebViewScroll: () => void\n shouldEnableBottomSheetScroll: boolean\n}\n\nconst BottomSheet = (props: BottomSheetProps) => {\n const panelHeightValue = useRef(new Animated.Value(props.sliderMaxHeight)).current;\n const fadeAnim = useRef(new Animated.Value(0)).current;\n const styles = getStylesObject(fadeAnim);\n const [isPanelOpened, setIsPanelOpened] = useState(props.isOpen);\n const [contentHeight, setContentHeight] = useState<number | undefined>(undefined);\n\n const [currentHeight, setCurrentHeight] = useState<number>(props.sliderMaxHeight);\n\n const [dy, setDy] = useState(0);\n\n const _parentPanResponder = PanResponder.create({\n onMoveShouldSetPanResponderCapture: (_, gestureState) => {\n return props.shouldEnableBottomSheetScroll && Math.abs(gestureState.dy) > 10;\n },\n onPanResponderMove(_, gestureState) {\n if (props.shouldEnableBottomSheetScroll && gestureState.dy < 5) {\n props.handleWebViewScroll();\n }\n if (currentHeight + gestureState.dy < 0) return;\n if (!props.expandToMaxHeightEnabled && contentHeight && currentHeight + gestureState.dy < sliderMaxHeight - contentHeight) return;\n panelHeightValue.setValue(currentHeight + gestureState.dy);\n setDy(gestureState.dy);\n },\n onPanResponderRelease: () => {\n if (dy > 0) {\n collapse();\n } else if (!props.expandToMaxHeightEnabled) {\n contentHeight && setToContentHeight(contentHeight);\n } else if (dy < 0) {\n expand();\n } else {\n expand();\n }\n }\n });\n\n useEffect(() => {\n if (props.isOpen && !isPanelOpened) {\n fadeIn();\n } else if (isPanelOpened) {\n setContentHeight(0);\n _dismiss();\n }\n }, [props.isOpen]);\n\n useEffect(() => {\n BackHandler.addEventListener('hardwareBackPress', _onBackPress);\n const id = panelHeightValue.addListener(e => setCurrentHeight(e.value));\n\n return (() => {\n BackHandler.removeEventListener('hardwareBackPress', _onBackPress);\n panelHeightValue.removeListener(id);\n });\n }, []);\n\n const fadeIn = () => {\n Animated.timing(fadeAnim, {\n toValue: 0.3,\n duration: 500,\n useNativeDriver: false\n }).start(() => { setIsPanelOpened(true); });\n };\n\n const fadeOut = () => {\n Animated.timing(fadeAnim, {\n toValue: 0,\n duration: 500,\n useNativeDriver: false\n }).start(() => {\n setIsPanelOpened(false);\n props.onClose();\n });\n };\n\n const setToContentHeight = (contentHeight: number) => {\n Animated.timing(panelHeightValue, {\n duration: props.animationDuration,\n easing: Easing.quad,\n toValue: sliderMaxHeight - contentHeight,\n useNativeDriver: false,\n }).start();\n };\n\n const expand = () => {\n const { animationDuration } = props;\n\n if (contentHeight && currentHeight > (sliderMaxHeight - contentHeight)) {\n setToContentHeight(contentHeight);\n return;\n }\n\n Animated.timing(panelHeightValue, {\n duration: animationDuration,\n easing: Easing.quad,\n toValue: 0,\n useNativeDriver: false,\n }).start();\n };\n\n const collapse = () => {\n if (contentHeight && currentHeight > (sliderMaxHeight - contentHeight)) {\n _dismiss();\n return;\n }\n\n contentHeight && setToContentHeight(contentHeight);\n };\n\n const _onBackPress = () => {\n isPanelOpened && collapse();\n return isPanelOpened;\n };\n\n const _setSize = (e: LayoutChangeEvent) => {\n const newContentHeight = e.nativeEvent.layout.height;\n\n setContentHeight(newContentHeight);\n setToContentHeight(newContentHeight);\n };\n\n const _dismiss = () => {\n const { animationDuration } = props;\n Animated.timing(panelHeightValue, {\n duration: animationDuration,\n easing: Easing.quad,\n toValue: sliderMaxHeight,\n useNativeDriver: false,\n }).start(() => {\n null;\n });\n fadeOut();\n };\n\n const {\n sliderMaxHeight,\n children,\n } = props;\n\n return (\n <>\n <TouchableOpacity\n style={styles.outsideContainer} activeOpacity={1}\n onPress={_dismiss}\n >\n <Animated.View\n style={styles.animation}\n >\n </Animated.View>\n </TouchableOpacity>\n <Animated.View\n {..._parentPanResponder.panHandlers}\n style={{\n ...styles.container,\n height: sliderMaxHeight,\n transform: [\n { translateY: panelHeightValue },\n ],\n }}\n >\n <View\n style={styles.outerContent}\n >\n <TouchableOpacity\n activeOpacity={1}\n style={styles.closeButton}\n onPress={_dismiss}\n >\n <Image source={CloseIcon} />\n </TouchableOpacity>\n\n <View\n onLayout={_setSize}\n >\n <KeyboardAvoidingView\n behavior=\"padding\"\n style={{ height: props.height }}\n keyboardVerticalOffset={props.height * (1 - BOTTOM_SHEET_MAX_PRECANTAGE_SIZE)}\n >\n {children}\n </KeyboardAvoidingView>\n </View>\n </View>\n </Animated.View>\n </>\n );\n};\n\nBottomSheet.propTypes = {\n children: PropTypes.oneOfType([PropTypes.node]),\n isOpen: PropTypes.bool,\n sliderMaxHeight: PropTypes.number,\n animation: PropTypes.func,\n animationDuration: PropTypes.number,\n onOpen: PropTypes.func,\n onClose: PropTypes.func,\n expandToMaxHeightEnabled: PropTypes.bool\n};\n\nBottomSheet.defaultProps = {\n children: <View />,\n isOpen: true,\n sliderMaxHeight: Dimensions.get('window').height * BOTTOM_SHEET_MAX_PRECANTAGE_SIZE,\n animationDuration: 200,\n onOpen: () => null,\n onClose: () => null,\n expandToMaxHeightEnabled: false\n};\n\nexport default BottomSheet;\n"],"mappings":";;AAAA,OAAOA,KAAP,IAA2BC,SAA3B,EAAsCC,MAAtC,EAA8CC,QAA9C,QAA8D,OAA9D;AACA,SACEC,QADF,EAEEC,WAFF,EAGEC,UAHF,EAIEC,MAJF,EAKEC,KALF,EAMEC,oBANF,EAQEC,YARF,EASEC,gBATF,EAUEC,IAVF,QAWO,cAXP;AAYA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,gCAAT,QAAiD,0EAAjD;AACA,SAASC,eAAT,QAAgC,sBAAhC;;AAeA,MAAMC,WAAW,GAAIC,KAAD,IAA6B;EAC/C,MAAMC,gBAAgB,GAAGjB,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sourcesContent":["export enum NativeMessage {\n IS_SCRIPT_FETCHED = 'isScriptFetched'\n}\n"],"mappings":"AAAA,WAAYA,aAAZ;;WAAYA,a;EAAAA,a;GAAAA,a,KAAAA,a"}
|
|
1
|
+
{"version":3,"names":["NativeMessage"],"sources":["index.ts"],"sourcesContent":["export enum NativeMessage {\n IS_SCRIPT_FETCHED = 'isScriptFetched',\n IS_SDK_INITIALIZED = 'isSdkInitialized'\n}\n"],"mappings":"AAAA,WAAYA,aAAZ;;WAAYA,a;EAAAA,a;EAAAA,a;GAAAA,a,KAAAA,a"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PageMessage"],"sources":["pageMessage.ts"],"sourcesContent":["export enum PageMessage {\n PAGE_LOADED = 'pageLoaded',\n PAGE_HEIGHT = 'pageHeight'
|
|
1
|
+
{"version":3,"names":["PageMessage"],"sources":["pageMessage.ts"],"sourcesContent":["export enum PageMessage {\n PAGE_LOADED = 'pageLoaded',\n PAGE_HEIGHT = 'pageHeight',\n}\n\nexport interface HeightEvent {\n height: number;\n}\n\nexport type PageEvent =\n | HeightEvent\n"],"mappings":"AAAA,WAAYA,WAAZ;;WAAYA,W;EAAAA,W;EAAAA,W;GAAAA,W,KAAAA,W"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["requireNativeComponent","UnitAddToWalletButtonView"],"sources":["UNNativeAddToWalletButton.tsx"],"sourcesContent":["import {\n requireNativeComponent,\n} from 'react-native';\n\ntype UnitAddToWalletButtonViewProps = {\n style: object;\n onAddToWalletClicked: () => void;\n};\n\nconst UnitAddToWalletButtonView = requireNativeComponent<UnitAddToWalletButtonViewProps>('UnitAddToWalletButtonView');\n\nexport default UnitAddToWalletButtonView;\n"],"mappings":"AAAA,SACEA,sBADF,QAEO,cAFP;AASA,MAAMC,yBAAyB,GAAGD,sBAAsB,CAAiC,2BAAjC,CAAxD;AAEA,eAAeC,yBAAf"}
|
|
@@ -8,7 +8,7 @@ export let PresentationMode;
|
|
|
8
8
|
})(PresentationMode || (PresentationMode = {}));
|
|
9
9
|
|
|
10
10
|
export const getHtmlBody = (unitComponent, unitComponentProps, presentationMode) => {
|
|
11
|
-
const currentComponent = `<${unitComponent} ${unitComponentProps || ''}> </${unitComponent}>`;
|
|
11
|
+
const currentComponent = `<${unitComponent} ${unitComponentProps || ''} }> </${unitComponent}>`;
|
|
12
12
|
|
|
13
13
|
switch (presentationMode) {
|
|
14
14
|
case PresentationMode.CoverInjectedHeight:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["webViewId","PresentationMode","getHtmlBody","unitComponent","unitComponentProps","presentationMode","currentComponent","CoverInjectedHeight","getCoverInjectedHeightBodyScript","Inherit","getInheritParentSizeScript","currentUnitScript"],"sources":["bodyHtml.ts"],"sourcesContent":["export const webViewId = 'webViewContainer';\n\nexport enum PresentationMode {\n /*\n CoverInjectedHeight - give id (<webViewId> param) to enable style injection to the root. Then cover the injected height.\n\n Inherit - inherit the parent size by style of 100 view height\n\n Default - return the unit component script\n */\n\n CoverInjectedHeight = 'coverInjectedHeight',\n Inherit = 'inherit',\n Default = 'deafult'\n}\n\nexport const getHtmlBody = (unitComponent: string, unitComponentProps?: string, presentationMode?: PresentationMode) => {\n const currentComponent = `<${unitComponent} ${unitComponentProps || ''}> </${unitComponent}>`;\n\n switch (presentationMode) {\n case PresentationMode.CoverInjectedHeight:\n return getCoverInjectedHeightBodyScript(currentComponent);\n case PresentationMode.Inherit:\n return getInheritParentSizeScript(currentComponent);\n default:\n return currentComponent;\n }\n};\n\nconst getCoverInjectedHeightBodyScript = (currentUnitScript: string) => {\n return `\n <div id=${webViewId}>\n <div style=\"height: 100%; display: block; padding: 1px;\">\n ${currentUnitScript}\n </div>\n </div>\n `;\n};\n\nconst getInheritParentSizeScript = (currentUnitScript: string) => {\n return `\n <div style=\"height: 100vh\">\n ${currentUnitScript}\n </div>\n `;\n};\n"],"mappings":"AAAA,OAAO,MAAMA,SAAS,GAAG,kBAAlB;AAEP,WAAYC,gBAAZ;;WAAYA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;GAAAA,gB,KAAAA,gB;;AAcZ,OAAO,MAAMC,WAAW,GAAG,CAACC,aAAD,EAAwBC,kBAAxB,EAAqDC,gBAArD,KAA6F;EACtH,MAAMC,gBAAgB,GAAI,IAAGH,aAAc,IAAGC,kBAAkB,IAAI,EAAG,
|
|
1
|
+
{"version":3,"names":["webViewId","PresentationMode","getHtmlBody","unitComponent","unitComponentProps","presentationMode","currentComponent","CoverInjectedHeight","getCoverInjectedHeightBodyScript","Inherit","getInheritParentSizeScript","currentUnitScript"],"sources":["bodyHtml.ts"],"sourcesContent":["export const webViewId = 'webViewContainer';\n\nexport enum PresentationMode {\n /*\n CoverInjectedHeight - give id (<webViewId> param) to enable style injection to the root. Then cover the injected height.\n\n Inherit - inherit the parent size by style of 100 view height\n\n Default - return the unit component script\n */\n\n CoverInjectedHeight = 'coverInjectedHeight',\n Inherit = 'inherit',\n Default = 'deafult'\n}\n\nexport const getHtmlBody = (unitComponent: string, unitComponentProps?: string, presentationMode?: PresentationMode) => {\n const currentComponent = `<${unitComponent} ${unitComponentProps || ''} }> </${unitComponent}>`;\n\n switch (presentationMode) {\n case PresentationMode.CoverInjectedHeight:\n return getCoverInjectedHeightBodyScript(currentComponent);\n case PresentationMode.Inherit:\n return getInheritParentSizeScript(currentComponent);\n default:\n return currentComponent;\n }\n};\n\nconst getCoverInjectedHeightBodyScript = (currentUnitScript: string) => {\n return `\n <div id=${webViewId}>\n <div style=\"height: 100%; display: block; padding: 1px;\">\n ${currentUnitScript}\n </div>\n </div>\n `;\n};\n\nconst getInheritParentSizeScript = (currentUnitScript: string) => {\n return `\n <div style=\"height: 100vh\">\n ${currentUnitScript}\n </div>\n `;\n};\n"],"mappings":"AAAA,OAAO,MAAMA,SAAS,GAAG,kBAAlB;AAEP,WAAYC,gBAAZ;;WAAYA,gB;EAAAA,gB;EAAAA,gB;EAAAA,gB;GAAAA,gB,KAAAA,gB;;AAcZ,OAAO,MAAMC,WAAW,GAAG,CAACC,aAAD,EAAwBC,kBAAxB,EAAqDC,gBAArD,KAA6F;EACtH,MAAMC,gBAAgB,GAAI,IAAGH,aAAc,IAAGC,kBAAkB,IAAI,EAAG,SAAQD,aAAc,GAA7F;;EAEA,QAAQE,gBAAR;IACE,KAAKJ,gBAAgB,CAACM,mBAAtB;MACE,OAAOC,gCAAgC,CAACF,gBAAD,CAAvC;;IACF,KAAKL,gBAAgB,CAACQ,OAAtB;MACE,OAAOC,0BAA0B,CAACJ,gBAAD,CAAjC;;IACF;MACE,OAAOA,gBAAP;EANJ;AAQD,CAXM;;AAaP,MAAME,gCAAgC,GAAIG,iBAAD,IAA+B;EACtE,OAAQ;AACV,cAAcX,SAAU;AACxB;AACA,UAAUW,iBAAkB;AAC5B;AACA;AACA,GANE;AAOD,CARD;;AAUA,MAAMD,0BAA0B,GAAIC,iBAAD,IAA+B;EAChE,OAAQ;AACV;AACA,QAAQA,iBAAkB;AAC1B;AACA,GAJE;AAKD,CAND"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
2
|
|
|
3
|
+
import EventBus from '../helpers/EventBus';
|
|
4
|
+
import { NativeMessage } from '../messages/nativeMessages';
|
|
3
5
|
import { fetchUnitScript } from './UnitSdk.api';
|
|
4
6
|
export let UNEnvironment;
|
|
5
7
|
|
|
@@ -23,6 +25,7 @@ _defineProperty(UnitSDK, "init", async (env, theme) => {
|
|
|
23
25
|
UnitSDK.env = env;
|
|
24
26
|
UnitSDK.theme = theme;
|
|
25
27
|
await fetchUnitScript();
|
|
28
|
+
EventBus.Instance.event(NativeMessage.IS_SDK_INITIALIZED, {});
|
|
26
29
|
} catch (e) {
|
|
27
30
|
console.log(e);
|
|
28
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["fetchUnitScript","UNEnvironment","UNIT_SCRIPT_URL","sandbox","production","UnitSDK","env","theme","e","console","log"],"sources":["UnitSdkManager.ts"],"sourcesContent":["import { fetchUnitScript } from './UnitSdk.api';\n\nexport enum UNEnvironment {\n sandbox = 'sandbox',\n production = 'production'\n}\n\nexport const UNIT_SCRIPT_URL = {\n [UNEnvironment.sandbox]: 'https://ui.s.unit.sh/components.js',\n [UNEnvironment.production]: 'https://ui.unit.co/components.js'\n};\nexport class UnitSDK {\n protected static env?: UNEnvironment;\n protected static theme?: string;\n\n public static init = async (env: UNEnvironment, theme
|
|
1
|
+
{"version":3,"names":["EventBus","NativeMessage","fetchUnitScript","UNEnvironment","UNIT_SCRIPT_URL","sandbox","production","UnitSDK","env","theme","Instance","event","IS_SDK_INITIALIZED","e","console","log"],"sources":["UnitSdkManager.ts"],"sourcesContent":["import EventBus from '../helpers/EventBus';\nimport { NativeMessage } from '../messages/nativeMessages';\nimport { fetchUnitScript } from './UnitSdk.api';\n\nexport enum UNEnvironment {\n sandbox = 'sandbox',\n production = 'production'\n}\n\nexport const UNIT_SCRIPT_URL = {\n [UNEnvironment.sandbox]: 'https://ui.s.unit.sh/components.js',\n [UNEnvironment.production]: 'https://ui.unit.co/components.js'\n};\nexport class UnitSDK {\n protected static env?: UNEnvironment;\n protected static theme?: string;\n\n public static init = async (env: UNEnvironment, theme?: string) => {\n try {\n this.env = env;\n this.theme = theme;\n await fetchUnitScript();\n EventBus.Instance.event(NativeMessage.IS_SDK_INITIALIZED, { });\n } catch (e) {\n console.log(e);\n }\n };\n\n public static getEnv = () => {\n return this.env;\n };\n\n public static getTheme = () => {\n return this.theme;\n };\n}\n"],"mappings":";;AAAA,OAAOA,QAAP,MAAqB,qBAArB;AACA,SAASC,aAAT,QAA8B,4BAA9B;AACA,SAASC,eAAT,QAAgC,eAAhC;AAEA,WAAYC,aAAZ;;WAAYA,a;EAAAA,a;EAAAA,a;GAAAA,a,KAAAA,a;;AAKZ,OAAO,MAAMC,eAAe,GAAG;EAC7B,CAACD,aAAa,CAACE,OAAf,GAAyB,oCADI;EAE7B,CAACF,aAAa,CAACG,UAAf,GAA4B;AAFC,CAAxB;AAIP,OAAO,MAAMC,OAAN,CAAc;;gBAARA,O;;gBAAAA,O;;gBAAAA,O,UAIU,OAAOC,GAAP,EAA2BC,KAA3B,KAA8C;EACjE,IAAI;IALKF,OAMP,CAAKC,GAAL,GAAWA,GAAX;IANOD,OAOP,CAAKE,KAAL,GAAaA,KAAb;IACA,MAAMP,eAAe,EAArB;IACAF,QAAQ,CAACU,QAAT,CAAkBC,KAAlB,CAAwBV,aAAa,CAACW,kBAAtC,EAA0D,EAA1D;EACD,CALD,CAKE,OAAOC,CAAP,EAAU;IACVC,OAAO,CAACC,GAAR,CAAYF,CAAZ;EACD;AACF,C;;gBAbUN,O,YAeY,MAAM;EAC3B,OAhBSA,OAgBF,CAAKC,GAAZ;AACD,C;;gBAjBUD,O,cAmBc,MAAM;EAC7B,OApBSA,OAoBF,CAAKE,KAAZ;AACD,C"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1
2
|
import React, { useEffect, useState } from 'react';
|
|
2
3
|
import { WebView } from 'react-native-webview';
|
|
3
4
|
import EventBus from '../helpers/EventBus';
|
|
@@ -7,6 +8,7 @@ import { useListenerToBus } from '../hooks/listenerToBus';
|
|
|
7
8
|
import { getHtmlBody } from '../scripts/html/bodyHtml';
|
|
8
9
|
import { fetchUnitScript, globalUnitScript } from '../unitSdkManager/UnitSdk.api';
|
|
9
10
|
import { NativeMessage } from '../messages/nativeMessages';
|
|
11
|
+
import { UnitSDK } from '../unitSdkManager/UnitSdkManager';
|
|
10
12
|
export let WebComponentType;
|
|
11
13
|
|
|
12
14
|
(function (WebComponentType) {
|
|
@@ -19,14 +21,23 @@ export let WebComponentType;
|
|
|
19
21
|
export const WebComponent = /*#__PURE__*/React.forwardRef(function WebComponent(props, webRef) {
|
|
20
22
|
const [unitScript, setUnitScript] = useState(globalUnitScript);
|
|
21
23
|
const [sourceHtml, setSourceHtml] = useState(null);
|
|
24
|
+
const [componentCurrentTheme, setComponentCurrentTheme] = useState(props.theme ?? UnitSDK.getTheme());
|
|
25
|
+
const width = props.width ?? '100%';
|
|
22
26
|
|
|
23
|
-
const
|
|
27
|
+
const updateUnitScript = data => {
|
|
24
28
|
setUnitScript(data.unitScript);
|
|
25
29
|
};
|
|
26
30
|
|
|
31
|
+
const updateInitializedParams = () => {
|
|
32
|
+
setComponentCurrentTheme(props.theme ?? UnitSDK.getTheme());
|
|
33
|
+
};
|
|
34
|
+
|
|
27
35
|
useListenerToBus([{
|
|
28
36
|
busEventKey: NativeMessage.IS_SCRIPT_FETCHED,
|
|
29
|
-
action:
|
|
37
|
+
action: updateUnitScript
|
|
38
|
+
}, {
|
|
39
|
+
busEventKey: NativeMessage.IS_SDK_INITIALIZED,
|
|
40
|
+
action: updateInitializedParams
|
|
30
41
|
}]);
|
|
31
42
|
useEffect(() => {
|
|
32
43
|
if (!unitScript) {
|
|
@@ -34,10 +45,11 @@ export const WebComponent = /*#__PURE__*/React.forwardRef(function WebComponent(
|
|
|
34
45
|
return;
|
|
35
46
|
}
|
|
36
47
|
|
|
37
|
-
|
|
48
|
+
const componentParams = (props.params || '') + (componentCurrentTheme ? ` theme="${componentCurrentTheme}"` : '');
|
|
49
|
+
let newHtml = html.replace(HTML_PLACEHOLDER.BODY, getHtmlBody(props.type.valueOf(), componentParams, props.presentationMode));
|
|
38
50
|
newHtml = newHtml.replace(HTML_PLACEHOLDER.SCRIPT_FROM_NATIVE, props.script || '');
|
|
39
51
|
setSourceHtml(newHtml);
|
|
40
|
-
}, [props.params, unitScript]);
|
|
52
|
+
}, [props.params, unitScript, props.presentationMode, componentCurrentTheme]);
|
|
41
53
|
|
|
42
54
|
const onMessage = e => {
|
|
43
55
|
const message = JSON.parse(e.nativeEvent.data);
|
|
@@ -50,14 +62,25 @@ export const WebComponent = /*#__PURE__*/React.forwardRef(function WebComponent(
|
|
|
50
62
|
};
|
|
51
63
|
|
|
52
64
|
if (!sourceHtml) return null;
|
|
65
|
+
|
|
66
|
+
const _onScroll = event => {
|
|
67
|
+
if (props.handleScroll) {
|
|
68
|
+
props.handleScroll(event);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return null;
|
|
72
|
+
};
|
|
73
|
+
|
|
53
74
|
return /*#__PURE__*/React.createElement(WebView, {
|
|
54
75
|
ref: webRef,
|
|
55
76
|
cacheEnabled: false,
|
|
56
|
-
scrollEnabled: props.
|
|
77
|
+
scrollEnabled: props.isScrollable,
|
|
78
|
+
nestedScrollEnabled: props.nestedScrollEnabled,
|
|
79
|
+
onScroll: _onScroll,
|
|
57
80
|
overScrollMode: "never",
|
|
58
81
|
injectedJavaScript: unitScript,
|
|
59
82
|
style: {
|
|
60
|
-
width:
|
|
83
|
+
width: width,
|
|
61
84
|
flex: 1
|
|
62
85
|
},
|
|
63
86
|
source: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useState","WebView","EventBus","html","HTML_PLACEHOLDER","UnitMessage","useListenerToBus","getHtmlBody","fetchUnitScript","globalUnitScript","NativeMessage","WebComponentType","WebComponent","forwardRef","props","webRef","unitScript","setUnitScript","sourceHtml","setSourceHtml","
|
|
1
|
+
{"version":3,"names":["React","useEffect","useState","WebView","EventBus","html","HTML_PLACEHOLDER","UnitMessage","useListenerToBus","getHtmlBody","fetchUnitScript","globalUnitScript","NativeMessage","UnitSDK","WebComponentType","WebComponent","forwardRef","props","webRef","unitScript","setUnitScript","sourceHtml","setSourceHtml","componentCurrentTheme","setComponentCurrentTheme","theme","getTheme","width","updateUnitScript","data","updateInitializedParams","busEventKey","IS_SCRIPT_FETCHED","action","IS_SDK_INITIALIZED","componentParams","params","newHtml","replace","BODY","type","valueOf","presentationMode","SCRIPT_FROM_NATIVE","script","onMessage","e","message","JSON","parse","nativeEvent","UNIT_REQUEST_REFRESH","details","Instance","event","_onScroll","handleScroll","isScrollable","nestedScrollEnabled","flex"],"sources":["WebComponent.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect, useState } from 'react';\nimport { WebView, WebViewMessageEvent } from 'react-native-webview';\nimport EventBus from '../helpers/EventBus';\nimport html, { HTML_PLACEHOLDER } from './html';\nimport { RequestRefreshEvent, UnitMessage } from '../messages/webMessages/unitMessages';\nimport { useListenerToBus } from '../hooks/listenerToBus';\nimport { getHtmlBody, PresentationMode } from '../scripts/html/bodyHtml';\nimport { fetchUnitScript, globalUnitScript } from '../unitSdkManager/UnitSdk.api';\nimport { NativeMessage } from '../messages/nativeMessages';\nimport { UnitSDK } from '../unitSdkManager/UnitSdkManager';\nimport type { WebViewMessage } from '../messages/webMessages';\n\nexport interface WebComponentProps {\n type: WebComponentType;\n presentationMode?: PresentationMode,\n params?: string;\n theme?: string;\n onMessage?: (message: WebViewMessage) => void;\n script?: string;\n isScrollable?: boolean,\n nestedScrollEnabled?: boolean,\n handleScroll?: (event: any) => void,\n width?: number;\n}\n\nexport enum WebComponentType {\n card = 'unit-elements-card',\n bookPayment = 'unit-elements-book-payment',\n activity = 'unit-elements-activity',\n slot = 'unit-elements-sdk-slot'\n}\n\nexport const WebComponent = React.forwardRef<WebView, WebComponentProps>(function WebComponent(props, webRef) {\n const [unitScript, setUnitScript] = useState<string | undefined>(globalUnitScript);\n const [sourceHtml, setSourceHtml] = useState<string | null>(null);\n const [componentCurrentTheme, setComponentCurrentTheme] = useState<string | undefined>(props.theme ?? UnitSDK.getTheme());\n const width = props.width ?? '100%';\n\n const updateUnitScript = (data: { unitScript?: string }) => {\n setUnitScript(data.unitScript);\n };\n\n const updateInitializedParams = () => {\n setComponentCurrentTheme(props.theme ?? UnitSDK.getTheme());\n };\n\n useListenerToBus([\n { busEventKey: NativeMessage.IS_SCRIPT_FETCHED, action: updateUnitScript },\n { busEventKey: NativeMessage.IS_SDK_INITIALIZED, action: updateInitializedParams },\n ]);\n\n useEffect(() => {\n if (!unitScript) {\n fetchUnitScript();\n return;\n }\n\n const componentParams = (props.params || '') + (componentCurrentTheme ? ` theme=\"${componentCurrentTheme}\"` : '');\n let newHtml = html.replace(HTML_PLACEHOLDER.BODY, getHtmlBody(props.type.valueOf(), componentParams, props.presentationMode));\n newHtml = newHtml.replace(HTML_PLACEHOLDER.SCRIPT_FROM_NATIVE, props.script || '');\n setSourceHtml(newHtml);\n }, [props.params, unitScript, props.presentationMode, componentCurrentTheme]);\n\n const onMessage = (e: WebViewMessageEvent) => {\n const message = JSON.parse(e.nativeEvent.data) as WebViewMessage;\n if (message.type == UnitMessage.UNIT_REQUEST_REFRESH && message.details) {\n EventBus.Instance.event(UnitMessage.UNIT_REQUEST_REFRESH, message.details as RequestRefreshEvent);\n } else {\n props.onMessage && props.onMessage(message);\n }\n };\n\n if (!sourceHtml) return null;\n\n const _onScroll = (event: any) => {\n if (props.handleScroll) {\n props.handleScroll(event);\n }\n\n return null;\n };\n\n return (\n <WebView\n ref={webRef}\n cacheEnabled={false}\n scrollEnabled={props.isScrollable}\n nestedScrollEnabled={props.nestedScrollEnabled}\n onScroll={_onScroll}\n overScrollMode=\"never\"\n injectedJavaScript={unitScript}\n style={{ width: width, flex: 1 }}\n source={{ html: sourceHtml }}\n onMessage={onMessage} />\n );\n});\n"],"mappings":"AAAA;AACA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,QAA3B,QAA2C,OAA3C;AACA,SAASC,OAAT,QAA6C,sBAA7C;AACA,OAAOC,QAAP,MAAqB,qBAArB;AACA,OAAOC,IAAP,IAAeC,gBAAf,QAAuC,QAAvC;AACA,SAA8BC,WAA9B,QAAiD,sCAAjD;AACA,SAASC,gBAAT,QAAiC,wBAAjC;AACA,SAASC,WAAT,QAA8C,0BAA9C;AACA,SAASC,eAAT,EAA0BC,gBAA1B,QAAkD,+BAAlD;AACA,SAASC,aAAT,QAA8B,4BAA9B;AACA,SAASC,OAAT,QAA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,KAAK,CAACyC,mBAJ7B;IAKE,QAAQ,EAAEH,SALZ;IAME,cAAc,EAAC,OANjB;IAOE,kBAAkB,EAAEpC,UAPtB;IAQE,KAAK,EAAE;MAAEQ,KAAK,EAAEA,KAAT;MAAgBgC,IAAI,EAAE;IAAtB,CART;IASE,MAAM,EAAE;MAAEtD,IAAI,EAAEgB;IAAR,CATV;IAUE,SAAS,EAAEwB;EAVb,EADF;AAaD,CA/D2B,CAArB"}
|
|
@@ -9,6 +9,8 @@ export interface BottomSheetProps {
|
|
|
9
9
|
height: number;
|
|
10
10
|
animationDuration: number;
|
|
11
11
|
expandToMaxHeightEnabled: boolean;
|
|
12
|
+
handleWebViewScroll: () => void;
|
|
13
|
+
shouldEnableBottomSheetScroll: boolean;
|
|
12
14
|
}
|
|
13
15
|
declare const BottomSheet: {
|
|
14
16
|
(props: BottomSheetProps): JSX.Element;
|
|
@@ -9,7 +9,7 @@ export declare const UNIT_SCRIPT_URL: {
|
|
|
9
9
|
export declare class UnitSDK {
|
|
10
10
|
protected static env?: UNEnvironment;
|
|
11
11
|
protected static theme?: string;
|
|
12
|
-
static init: (env: UNEnvironment, theme
|
|
12
|
+
static init: (env: UNEnvironment, theme?: string) => Promise<void>;
|
|
13
13
|
static getEnv: () => UNEnvironment | undefined;
|
|
14
14
|
static getTheme: () => string | undefined;
|
|
15
15
|
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { WebView } from 'react-native-webview';
|
|
3
|
-
import type { WebViewMessage } from '../messages/webMessages';
|
|
4
3
|
import { PresentationMode } from '../scripts/html/bodyHtml';
|
|
4
|
+
import type { WebViewMessage } from '../messages/webMessages';
|
|
5
5
|
export interface WebComponentProps {
|
|
6
6
|
type: WebComponentType;
|
|
7
7
|
presentationMode?: PresentationMode;
|
|
8
8
|
params?: string;
|
|
9
|
+
theme?: string;
|
|
9
10
|
onMessage?: (message: WebViewMessage) => void;
|
|
10
11
|
script?: string;
|
|
12
|
+
isScrollable?: boolean;
|
|
13
|
+
nestedScrollEnabled?: boolean;
|
|
14
|
+
handleScroll?: (event: any) => void;
|
|
11
15
|
width?: number;
|
|
12
|
-
shouldEnableWebViewScroll?: boolean;
|
|
13
16
|
}
|
|
14
17
|
export declare enum WebComponentType {
|
|
15
18
|
card = "unit-elements-card",
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Dimensions, View } from 'react-native';
|
|
3
|
+
import type { WebViewMessage } from '../../messages/webMessages';
|
|
4
|
+
import { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';
|
|
2
5
|
import { PresentationMode } from '../../scripts/html/bodyHtml';
|
|
3
6
|
import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
|
|
4
7
|
import { getActivityParams } from './UNActivityComponent.utils';
|
|
5
8
|
|
|
9
|
+
const DEFAULT_HEIGHT = Dimensions.get('window').height * 0.5;
|
|
6
10
|
export interface UNActivityComponentProps {
|
|
7
11
|
accountId: string;
|
|
8
12
|
customerToken: string;
|
|
@@ -10,12 +14,34 @@ export interface UNActivityComponentProps {
|
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
export const UNActivityComponent = (props: UNActivityComponentProps) => {
|
|
17
|
+
const [defaultHeight, setDefaultHeight] = useState<number>();
|
|
18
|
+
const handleWebViewMessage = (message: WebViewMessage) => {
|
|
19
|
+
if (message.type === PageMessage.PAGE_HEIGHT) {
|
|
20
|
+
const currentHeight = (message.details as HeightEvent).height;
|
|
21
|
+
currentHeight === 0 && setDefaultHeight(DEFAULT_HEIGHT);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const renderActivityWebView = () => {
|
|
26
|
+
return (
|
|
27
|
+
<WebComponent
|
|
28
|
+
type={WebComponentType.activity}
|
|
29
|
+
presentationMode={PresentationMode.Inherit}
|
|
30
|
+
params={getActivityParams(props)}
|
|
31
|
+
onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}
|
|
32
|
+
nestedScrollEnabled={true}
|
|
33
|
+
theme={props.theme}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
if (!defaultHeight) {
|
|
39
|
+
return renderActivityWebView();
|
|
40
|
+
}
|
|
41
|
+
|
|
13
42
|
return (
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
params={getActivityParams(props)}
|
|
18
|
-
shouldEnableWebViewScroll={false}
|
|
19
|
-
/>
|
|
43
|
+
<View style={{ height: defaultHeight }}>
|
|
44
|
+
{renderActivityWebView()}
|
|
45
|
+
</View>
|
|
20
46
|
);
|
|
21
47
|
};
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { UnitSDK } from '../../unitSdkManager/UnitSdkManager';
|
|
2
1
|
import type { UNActivityComponentProps } from './UNActivityComponent';
|
|
3
2
|
|
|
4
3
|
export const getActivityParams = (props: UNActivityComponentProps) => {
|
|
5
4
|
return `
|
|
6
5
|
account-id="${props.accountId}"
|
|
7
6
|
customer-token="${props.customerToken}"
|
|
8
|
-
theme="${props.theme ?? UnitSDK.getTheme()}"
|
|
9
7
|
style="height: 100%"
|
|
10
8
|
`;
|
|
11
9
|
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
|
|
3
3
|
import { PresentationMode } from '../../scripts/html/bodyHtml';
|
|
4
4
|
import { getBookPaymentParams, getBookPaymentScript } from './UNBookPaymentComponent.utils';
|
|
5
5
|
import type { WebViewMessage } from '../../messages/webMessages';
|
|
6
6
|
import { BookPaymentEvent, BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';
|
|
7
7
|
import type { UNBookPaymentData } from '../../sharedTypes';
|
|
8
|
+
import { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';
|
|
9
|
+
import { View } from 'react-native';
|
|
8
10
|
|
|
9
11
|
export interface UNBookPaymentComponentProps {
|
|
10
12
|
accountId: string;
|
|
@@ -17,21 +19,45 @@ export interface UNBookPaymentComponentProps {
|
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
export const UNBookPaymentComponent = (props: UNBookPaymentComponentProps) => {
|
|
22
|
+
const [height, setHeight] = useState<number>(0);
|
|
23
|
+
const [presentationMode, setPresentationMode] = useState<PresentationMode>(PresentationMode.Inherit);
|
|
24
|
+
|
|
20
25
|
const handleWebViewMessage = (message: WebViewMessage) => {
|
|
21
26
|
if (message.type === BookPaymentMessage.PAYMENT_CREATED && props.onPaymentCreated) {
|
|
22
27
|
const response = message.details as BookPaymentEvent;
|
|
23
28
|
props.onPaymentCreated(response.data);
|
|
24
29
|
}
|
|
30
|
+
|
|
31
|
+
if (message.type === PageMessage.PAGE_HEIGHT) {
|
|
32
|
+
const currentHeight = (message.details as HeightEvent).height;
|
|
33
|
+
setHeight(currentHeight);
|
|
34
|
+
if (presentationMode === PresentationMode.Inherit && currentHeight === 0) {
|
|
35
|
+
setPresentationMode(PresentationMode.Default);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
25
38
|
};
|
|
26
39
|
|
|
40
|
+
const renderBookPaymentWebView = () => {
|
|
41
|
+
return (
|
|
42
|
+
<WebComponent
|
|
43
|
+
type={WebComponentType.bookPayment}
|
|
44
|
+
presentationMode={presentationMode}
|
|
45
|
+
params={getBookPaymentParams(props)}
|
|
46
|
+
script={getBookPaymentScript()}
|
|
47
|
+
onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}
|
|
48
|
+
isScrollable={false}
|
|
49
|
+
theme={props.theme}
|
|
50
|
+
/>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
if (presentationMode === PresentationMode.Inherit) {
|
|
55
|
+
return renderBookPaymentWebView();
|
|
56
|
+
}
|
|
57
|
+
|
|
27
58
|
return (
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
params={getBookPaymentParams(props)}
|
|
32
|
-
script={getBookPaymentScript()}
|
|
33
|
-
onMessage={(message: WebViewMessage) => handleWebViewMessage(message)}
|
|
34
|
-
shouldEnableWebViewScroll={false}
|
|
35
|
-
/>
|
|
59
|
+
<View style={{ height: height }}>
|
|
60
|
+
{renderBookPaymentWebView()}
|
|
61
|
+
</View>
|
|
36
62
|
);
|
|
37
63
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { UNBookPaymentComponentProps } from './UNBookPaymentComponent';
|
|
2
2
|
|
|
3
3
|
import { BookPaymentMessage } from '../../messages/webMessages/bookPaymentMessage';
|
|
4
|
-
import { UnitSDK } from '../../unitSdkManager/UnitSdkManager';
|
|
5
4
|
|
|
6
5
|
export const getBookPaymentParams = (props: UNBookPaymentComponentProps) => {
|
|
7
6
|
return `
|
|
@@ -10,7 +9,6 @@ export const getBookPaymentParams = (props: UNBookPaymentComponentProps) => {
|
|
|
10
9
|
is-same-customer="${props.isSameCustomer}"
|
|
11
10
|
counterparty-account-id="${props.counterPartyAccountId}"
|
|
12
11
|
counterparty-name="${props.counterPartyName}"
|
|
13
|
-
theme="${props.theme ?? UnitSDK.getTheme()}"
|
|
14
12
|
style="height: 100%"
|
|
15
13
|
`;
|
|
16
14
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1
2
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
3
|
import type WebView from 'react-native-webview';
|
|
3
4
|
import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
|
|
@@ -14,12 +15,19 @@ import { getStylesObject } from './UNBottomSheetComponent.styles';
|
|
|
14
15
|
import { PresentationMode } from '../../scripts/html/bodyHtml';
|
|
15
16
|
import { useAppStateListener } from '../../hooks/useAppStateListener';
|
|
16
17
|
|
|
18
|
+
export enum ScrollState {
|
|
19
|
+
onTop = 'onTop',
|
|
20
|
+
onlyWebView = 'webViewScroll',
|
|
21
|
+
onlyBottomSheet = 'onlyBottomSheet',
|
|
22
|
+
unScrollable = 'unScrollable'
|
|
23
|
+
}
|
|
24
|
+
|
|
17
25
|
export const UNBottomSheetComponent = () => {
|
|
18
26
|
const [isBottomSheetActive, setIsBottomSheetActive] = useState(false);
|
|
19
27
|
const [height, setHeight] = useState(0);
|
|
20
28
|
|
|
21
29
|
const [renderingRequest, setRenderingRequest] = useState<string | null>(null);
|
|
22
|
-
const [
|
|
30
|
+
const [scrollState, setScrollState] = useState<ScrollState>(ScrollState.onTop);
|
|
23
31
|
|
|
24
32
|
const [waitForLoadingNewComponent, setWaitForLoadingNewComponent] = useState(false);
|
|
25
33
|
const [newHeightMessage, setNewHeightMessage] = useState<WebViewMessage | null>(null);
|
|
@@ -53,6 +61,7 @@ export const UNBottomSheetComponent = () => {
|
|
|
53
61
|
webRef.current && resetHtml(webRef.current);
|
|
54
62
|
setHeight(0);
|
|
55
63
|
setRenderingRequest(null);
|
|
64
|
+
setScrollState(ScrollState.onTop);
|
|
56
65
|
}
|
|
57
66
|
}, [isBottomSheetActive]);
|
|
58
67
|
|
|
@@ -71,10 +80,10 @@ export const UNBottomSheetComponent = () => {
|
|
|
71
80
|
if (nativePlace == 'overFullScreen') {
|
|
72
81
|
const bottomSheetNewHeight = handleHtmlFullHeight(webRef.current, Dimensions.get('window').height);
|
|
73
82
|
setHeight(bottomSheetNewHeight);
|
|
74
|
-
|
|
83
|
+
setScrollState(ScrollState.onTop);
|
|
75
84
|
} else {
|
|
76
85
|
setHeight((message.details as HeightEvent).height);
|
|
77
|
-
|
|
86
|
+
setScrollState(ScrollState.unScrollable);
|
|
78
87
|
}
|
|
79
88
|
}
|
|
80
89
|
};
|
|
@@ -108,6 +117,25 @@ export const UNBottomSheetComponent = () => {
|
|
|
108
117
|
}
|
|
109
118
|
};
|
|
110
119
|
|
|
120
|
+
const onScrollWebView = (event: any) => {
|
|
121
|
+
if (scrollState === ScrollState.unScrollable) return;
|
|
122
|
+
|
|
123
|
+
const currY = event.nativeEvent.contentOffset.y;
|
|
124
|
+
|
|
125
|
+
if (ScrollState.onTop && currY < 5) {
|
|
126
|
+
setScrollState(ScrollState.onlyBottomSheet);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if ( scrollState !== ScrollState.onlyWebView && scrollState === ScrollState.onTop && currY > 5) {
|
|
130
|
+
setScrollState(ScrollState.onlyWebView);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const handleWebViewScroll = () => {
|
|
135
|
+
if (scrollState === ScrollState.unScrollable) return;
|
|
136
|
+
setScrollState(ScrollState.onlyWebView);
|
|
137
|
+
};
|
|
138
|
+
|
|
111
139
|
return (
|
|
112
140
|
<>
|
|
113
141
|
<View
|
|
@@ -119,6 +147,8 @@ export const UNBottomSheetComponent = () => {
|
|
|
119
147
|
height={height}
|
|
120
148
|
onClose={() => setIsBottomSheetActive(false)}
|
|
121
149
|
onOpen={() => setIsBottomSheetActive(true)}
|
|
150
|
+
handleWebViewScroll={() => handleWebViewScroll()}
|
|
151
|
+
shouldEnableBottomSheetScroll={scrollState !== ScrollState.onlyWebView}
|
|
122
152
|
>
|
|
123
153
|
{ isAppActive && (
|
|
124
154
|
<WebComponent
|
|
@@ -127,7 +157,8 @@ export const UNBottomSheetComponent = () => {
|
|
|
127
157
|
presentationMode={PresentationMode.CoverInjectedHeight}
|
|
128
158
|
script={getBottomSheetScript()}
|
|
129
159
|
onMessage={onWebMessage}
|
|
130
|
-
|
|
160
|
+
isScrollable={scrollState === ScrollState.onlyWebView || scrollState === ScrollState.onTop}
|
|
161
|
+
handleScroll={onScrollWebView}
|
|
131
162
|
/>)}
|
|
132
163
|
</BottomSheet>
|
|
133
164
|
</View>
|