-
-
Notifications
You must be signed in to change notification settings - Fork 840
feat: add enabled prop to draggable view #2160
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import React, { useCallback, useMemo, useRef } from 'react'; | ||
import { View, StyleSheet, Text } from 'react-native'; | ||
import BottomSheet, { BottomSheetDraggableView, BottomSheetView } from '@gorhom/bottom-sheet'; | ||
import { Button } from '../../components/button'; | ||
|
||
const DraggableViewExample = () => { | ||
// hooks | ||
const bottomSheetRef = useRef<BottomSheet>(null); | ||
|
||
// variables | ||
const snapPoints = useMemo(() => ['25%', '50%'], []); | ||
|
||
// callbacks | ||
const handleExpandPress = useCallback(() => { | ||
bottomSheetRef.current?.expand(); | ||
}, []); | ||
const handleCollapsePress = useCallback(() => { | ||
bottomSheetRef.current?.collapse(); | ||
}, []); | ||
const handleClosePress = useCallback(() => { | ||
bottomSheetRef.current?.close(); | ||
}, []); | ||
|
||
// renders | ||
return ( | ||
<View style={styles.container}> | ||
<Button label="Expand" onPress={handleExpandPress} /> | ||
<Button label="Collapse" onPress={handleCollapsePress} /> | ||
<Button label="Close" onPress={handleClosePress} /> | ||
<BottomSheet | ||
ref={bottomSheetRef} | ||
snapPoints={snapPoints} | ||
keyboardBehavior="interactive" | ||
keyboardBlurBehavior="restore" | ||
enablePanDownToClose={true} | ||
enableContentPanningGesture={false} | ||
> | ||
<BottomSheetView style={styles.row}> | ||
<BottomSheetDraggableView style={styles.leftView}> | ||
<Text>Draggable</Text> | ||
</BottomSheetDraggableView> | ||
<View style={styles.rightView}> | ||
<Text>Not draggable</Text> | ||
</View> | ||
</BottomSheetView> | ||
</BottomSheet> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
padding: 24, | ||
}, | ||
row: { | ||
flexDirection: 'row', | ||
height: '100%', | ||
}, | ||
leftView: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
backgroundColor: '#ccc', | ||
}, | ||
rightView: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
backgroundColor: '#ddd', | ||
}, | ||
}); | ||
|
||
export default DraggableViewExample; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1866,9 +1866,6 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>( | |
//#endregion | ||
|
||
// render | ||
const DraggableView = enableContentPanningGesture | ||
? BottomSheetDraggableView | ||
: Animated.View; | ||
return ( | ||
<BottomSheetProvider value={externalContextVariables}> | ||
<BottomSheetInternalProvider value={internalContextVariables}> | ||
|
@@ -1906,12 +1903,13 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>( | |
accessibilityRole={_providedAccessibilityRole ?? undefined} | ||
accessibilityLabel={_providedAccessibilityLabel ?? undefined} | ||
> | ||
<DraggableView | ||
<BottomSheetDraggableView | ||
key="BottomSheetRootDraggableView" | ||
style={contentContainerStyle} | ||
enabled={enableContentPanningGesture} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i dont think we need to pass it as props, as it is already read internally from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is necessary so that I've added an example There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mmm i see, i think for scalability , i would move the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, in my case I need to wrap an external component so the solution of this MR would work better for me... |
||
> | ||
{children} | ||
</DraggableView> | ||
</BottomSheetDraggableView> | ||
{footerComponent && ( | ||
<BottomSheetFooterContainer | ||
footerComponent={footerComponent} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you miss
enabled
prop here, no?Edit: it's set as default as true, okie