浏览代码

Bugfix: BottomSheet second open problems fixed.

lfabl 2 月之前
父节点
当前提交
2d85aab0d4
共有 2 个文件被更改,包括 11 次插入0 次删除
  1. 1 0
      example/src/pages/home/index.tsx
  2. 10 0
      src/components/bottomSheet/index.tsx

+ 1 - 0
example/src/pages/home/index.tsx

@@ -79,6 +79,7 @@ const Home = () => {
         />
         <BottomSheet
             isWorkAsFullScreen={true}
+            isWorkWithPortal={false}
             ref={bottomSheetRef}
             renderHeader={() => {
                 return <View

+ 10 - 0
src/components/bottomSheet/index.tsx

@@ -176,6 +176,14 @@ const BottomSheet: RefForwardingComponent<IBottomSheetRef, IBottomSheetProps> =
 
     useEffect(() => {
         if(isActive && isMeasured) {
+            if(!isWorkAsFullScreen && !isCanFullScreenOnSwipe && snapPoint) {
+                maxHeight.current = snapPoint;
+            } else if(isWorkAsFullScreen) {
+                maxHeight.current = containerHeightRef.current - (isWrapSafeAreaContext ? topSafeArea : 0);
+            } else {
+                maxHeight.current = containerHeightRef.current - (isForceFullScreenOnSwipe ? 0 : isWrapSafeAreaContext ? topSafeArea : 0);
+            }
+
             openAnimation();
         }
     }, [
@@ -221,6 +229,7 @@ const BottomSheet: RefForwardingComponent<IBottomSheetRef, IBottomSheetProps> =
 
     const openAnimation = () => {
         resetState();
+
         if(onOpen) onOpen();
 
         Animated.timing(animatedTranslateY, {
@@ -248,6 +257,7 @@ const BottomSheet: RefForwardingComponent<IBottomSheetRef, IBottomSheetProps> =
         }) => {
             if(finished) {
                 resetState();
+
                 setIsActive(false);
 
                 if(onClosed) onClosed();