Skip to content

Commit d61b656

Browse files
committed
Add hideable prop
1 parent 402aadb commit d61b656

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ render () {
6363
| visible | boolean | false | Controls the panel's visibility |
6464
| animationDuration | number | 500 | Controls the duration in ms to show or hide the panel |
6565
| expandable | boolean | false | Controls if the panel can be expanded or not |
66+
| hideable | boolean | true | Controls if the panel can be hidden when press outside or on the android physical back button |
6667
| hideOnPressOutside | boolean | true | Controls neither to hide the panel when user presses on the overlay or not |
6768
| overlayBackgroundColor | Color | black | Controls the backgroundColor of the overlay |
6869
| overlayOpacity | number | 0.8 | Is a value between 0 and 1 that controls the overlay opacity |
6970
| borderRadius | number | 0 | Controls the panel top border radius |
70-
| initialHeight | number | SCREEN_HEIGHT / 2 | Controls the panel initial height |
71+
| initialHeight | number | SCREEN_HEIGHT / 2 | Controls the panel initial height |
7172
| hideOnBackButtonPressed | boolean | true | Controls either the panel get dismissed on android physical button pressed or not [Android ONLY] |
7273
| onDismiss | callback | | A callback function when the panel is dismissed |

src/DraggablePanel.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type Props = {
2626
visible?: boolean;
2727
animationDuration?: number;
2828
expandable?: boolean;
29+
hideable?: boolean;
2930
hideOnPressOutside?: boolean;
3031
overlayBackgroundColor?: string;
3132
overlayOpacity?: number;
@@ -50,20 +51,26 @@ export const DraggablePanel = React.forwardRef<
5051
borderRadius = 0,
5152
initialHeight = DEFAULT_PANEL_HEIGHT / 2,
5253
hideOnBackButtonPressed = true,
54+
hideable = true,
5355
onDismiss,
5456
children,
5557
}: Props,
5658
ref: React.Ref<ReactNativeDraggablePanelRef>,
5759
) => {
5860
const [animatedValue] = React.useState(new Animated.Value(0));
61+
5962
const [popupVisible, togglePopupVisibility] = React.useState(false);
63+
6064
const [animating, setAnimating] = React.useState(false);
65+
6166
const [height] = React.useState(
6267
Math.min(initialHeight, DEFAULT_PANEL_HEIGHT),
6368
);
69+
6470
const [innerContentHeight, setInnerContentHeight] = React.useState(
6571
Math.min(initialHeight, DEFAULT_PANEL_HEIGHT),
6672
);
73+
6774
const scrollViewRef: RefObject<ScrollView> = React.useRef(null);
6875

6976
React.useEffect(() => {
@@ -123,7 +130,8 @@ export const DraggablePanel = React.forwardRef<
123130
Platform.OS === 'android' &&
124131
hideOnBackButtonPressed &&
125132
!animating &&
126-
popupVisible
133+
popupVisible &&
134+
hideable
127135
) {
128136
hide();
129137
}
@@ -213,7 +221,7 @@ export const DraggablePanel = React.forwardRef<
213221
SCREEN_HEIGHT,
214222
]}>
215223
<TouchableWithoutFeedback
216-
disabled={!hideOnPressOutside || animating}
224+
disabled={!hideOnPressOutside || animating || !hideable}
217225
onPress={hide}>
218226
<View style={styles.hideContainer} />
219227
</TouchableWithoutFeedback>

0 commit comments

Comments
 (0)