Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

withReactModal with android not working #467

Open
VictorPulzz opened this issue Dec 30, 2022 · 2 comments
Open

withReactModal with android not working #467

VictorPulzz opened this issue Dec 30, 2022 · 2 comments

Comments

@VictorPulzz
Copy link

VictorPulzz commented Dec 30, 2022

Describe the bug
I use withReactModal for show modalize, but click on backdrop and hide not working on android. I don't want use portlize, because if I use modalize inside react modal modalize show behind the modal.

Code

import React, { forwardRef, PropsWithChildren, useImperativeHandle } from 'react';
import { Easing } from 'react-native';
import { Modalize, ModalizeProps, useModalize } from 'react-native-modalize';
import { useSafeAreaInsets } from 'react-native-safe-area-context';

import { useTheme } from '~/view/plugins/Theme';

const DEFAULT_ANIMATION = {
  timing: { duration: 200, easing: Easing.ease },
  spring: { mass: 1, damping: 50 },
};

export interface BottomSheetRefProps {
  open: () => void;
  close: () => void;
}

export interface BottomSheetProps extends ModalizeProps {}

export const BottomSheet = forwardRef<BottomSheetRefProps, PropsWithChildren<BottomSheetProps>>(
  ({ children, ...props }, ref) => {
    const theme = useTheme();
    const { ref: modalizeRef, open, close } = useModalize();
    const { bottom } = useSafeAreaInsets();

    useImperativeHandle(ref, () => ({
      open,
      close,
    }));

    return (
      <Modalize
        ref={modalizeRef}
        scrollViewProps={{ scrollEnabled: false }}
        adjustToContentHeight
        handlePosition="inside"
        withHandle
        openAnimationConfig={DEFAULT_ANIMATION}
        withReactModal
        modalStyle={{
          borderTopLeftRadius: theme.rounded.l,
          borderTopRightRadius: theme.rounded.l,
        }}
        childrenStyle={{
          paddingBottom: bottom,
        }}
        handleStyle={{
          position: 'relative',
          width: 64,
          height: 5,
          backgroundColor: theme.colors.gray6,
          marginTop: theme.spacing.sm,
        }}
        {...props}
      >
        {children}
      </Modalize>
    );
  },
);

Dependencies:

  • "react-native-modalize": "^2.1.1",
  • "react-native": "0.70.6",
  • "react-native-gesture-handler": "~2.7.1",
@VictorPulzz
Copy link
Author

VictorPulzz commented Dec 30, 2022

@jeremybarbet Can you check pls. This event not callable. Then I replace on TouchableWithoutFeedback, click working!
image

@frenic
Copy link

frenic commented Mar 22, 2023

You need this patch react-native-modalize+2.1.1.patch due to this issue.

diff --git a/node_modules/react-native-modalize/lib/index.js b/node_modules/react-native-modalize/lib/index.js
index 5d5edac..d4c61c0 100644
--- a/node_modules/react-native-modalize/lib/index.js
+++ b/node_modules/react-native-modalize/lib/index.js
@@ -657,7 +657,7 @@ onOpen, onOpened, onClose, onClosed, onBackButtonPress, onPositionChange, onOver
     if (!avoidKeyboardLikeIOS && !adjustToContentHeight) {
         keyboardAvoidingViewProps.onLayout = handleModalizeContentLayout;
     }
-    const renderModalize = (React.createElement(react_native_1.View, { style: [styles_1.default.modalize, rootStyle], pointerEvents: alwaysOpen || !withOverlay ? 'box-none' : 'auto' },
+    const renderModalize = React.createElement(react_native_gesture_handler_1.GestureHandlerRootView, { style: react_native_1.StyleSheet.absoluteFill }, React.createElement(react_native_1.View, { style: [styles_1.default.modalize, rootStyle], pointerEvents: alwaysOpen || !withOverlay ? 'box-none' : 'auto' },
         React.createElement(react_native_gesture_handler_1.TapGestureHandler, { ref: tapGestureModalizeRef, maxDurationMs: tapGestureEnabled ? 100000 : 50, maxDeltaY: lastSnap, enabled: panGestureEnabled },
             React.createElement(react_native_1.View, { style: styles_1.default.modalize__wrapper, pointerEvents: "box-none" },
                 showContent && (React.createElement(AnimatedKeyboardAvoidingView, Object.assign({}, keyboardAvoidingViewProps),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants