numandev1 / react-native-bottomsheet-reanimated

React Native bottom sheet with fully native 60 FPS animations and awesome user experience
MIT License
277 stars 28 forks source link

Keyboard Aware Error (Using Context) #19

Open anhquan291 opened 3 years ago

anhquan291 commented 3 years ago

Hi, Thanks for this great library.

I'm having a problem with the KeyboardAware. Don't know if it is a bug. Please help. It gives the error. Thank you so much Simulator Screen Shot - iPhone 11 - 2021-05-31 at 17 08 35

<BottomSheet dragEnabled={true} keyboardAware keyboardAwareExtraSnapHeight={300} ref={ShareBottomRef} initialPosition={0} snapPoints={snapPoints} isBackDrop={true} isBackDropDismissByPress={true} isRoundBorderWithTipHeader={true} onClose={onClose} onChangeSnap={(e) => setSnapIndex(e.index)} containerStyle={{backgroundColor: theme.BACKGROUND_COLOR_RGB}} headerStyle={{padding: 0}} tipStyle={{ backgroundColor: 'rgb(255, 255, 255)', top: snapIndex === 1 ? -20 : 0, }}/>

numandev1 commented 3 years ago

@anhquan291 can you provide a reproducible example through github?

anhquan291 commented 3 years ago

@anhquan291 can you provide a reproducible example through github?

Unfortunately, I can't. I only can share the screen bottom sheet code here.

const ShareOptionSheet = () => { const [ BottomRef, selectedPost, setSelectedPost, setActionLoading, ShareBottomRef, selectedSharePost, setSelectedSharePost, ] = useContext(CommunityContext); const dispatch = useDispatch(); const navigation = useNavigation(); const [privacy, setPrivacy] = useState(false); const [snapIndex, setSnapIndex] = useState(0); const [content, setContent] = useState(''); const [feeling, setFeeling] = useState(''); const inputRef = useRef(null); const user = useSelector((state) => state.auth.user); const theme = useSelector((state) => state.themes.theme); const snapPoints = [0, HEIGHT / 1.2]; const togglePrivacy = () => { setPrivacy((prev) => !prev); }; const sharePostHandler = async () => { ShareBottomRef.current.snapTo(0); const shareId = uuid.v4(); try { setActionLoading(true); await dispatch( PostUserActions.postShare( selectedSharePost, shareId, content, feeling, privacy, ), ); setActionLoading(false); SuccessNotifier(Messages.SUCCESS_SHARE); } catch (e) { console.log(e); } }; const onClose = () => { setTimeout(() => { setContent(null); if (inputRef.current !== null) { inputRef.current.blur(); } setSelectedSharePost(null); }, 50); }; return (

setSnapIndex(e.index)} containerStyle={{backgroundColor: theme.BACKGROUND_COLOR_RGB}} headerStyle={{padding: 0}} tipStyle={{ backgroundColor: 'rgb(255, 255, 255)', top: snapIndex === 1 ? -20 : 0, }} body={ {/* */} {selectedSharePost !== null && ( {user.name} {privacy ? ( <> Chỉ mình tôi ) : ( <> Công khai )} )} Chia sẻ {/* */} } />

); };

And one more thing, the Bottom Sheet doesn't work correctly on android, isBackDropDismissByPress and dragEnabled doesn't work. When the bottom sheet shows up on android, it seems to freeze the app. Thank you so much

numandev1 commented 3 years ago

@anhquan291 I can only help you when you will provide a reproducible example to me. because on busy days it is hard to get time to reproduce and fix. it is easy for me to fix it if i have reproducible example thanks

anhquan291 commented 3 years ago

Yes, I'll. Thank you

anhquan291 commented 3 years ago

Hi, I got a new update. On Android, it doesn't work when provide the props "keyboardAware". I also tried your example. The error occurs. When I remove keyboardAware props It works well. However, when I want the bottom sheet to be on the top of Bottom Tabbar. I tried to put the BS inside {Portal} from '@gorhom/portal'. Unfortunately, the bottom sheet does not work correctly, cannot drag or close it. (Only works on IOS) I think it is related this one: https://github.com/gorhom/react-native-portal/issues/14

Thank you so much for your time.

***Update: I reconfigured the React Native Gesture Handler and isBackDropDismissByPress works but dragEnabled doesn't.

Screen Shot 2021-06-06 at 11 13 16