Unable hide bottom sheet when click touchable
See original GitHub issuei have bottom sheet with close button on header, but when pressed bottom sheet cannot snap to specified index given,
here my code:
import { default as React } from 'react';
import { Dimensions, StyleSheet, View } from 'react-native';
import { default as BottomSheet } from 'reanimated-bottom-sheet';
import { default as Animated } from 'react-native-reanimated';
import { Portal } from 'react-native-paper';
import { AntDesign } from '@expo/vector-icons';
import { Text, Touchable } from '../common';
import { IProduct } from '../../interface';
import { color } from '../../theme/color';
interface IAddToCartProps {
product: IProduct;
}
const window = Dimensions.get('window');
class AddToCartSheet extends React.Component<IAddToCartProps> {
bottomSheet = React.createRef<BottomSheet>();
sheetOpenValue = new Animated.Value(1);
constructor(props) {
super(props);
this.renderContent = this.renderContent.bind(this);
this.renderHeader = this.renderHeader.bind(this);
this.hideBottomSheet = this.hideBottomSheet.bind(this);
}
showBottomSheet(): void {
if (this.bottomSheet.current) {
this.bottomSheet.current.snapTo(0);
}
}
hideBottomSheet(): void {
// alert called but no snapTo
alert('pressed')
this.bottomSheet.current.snapTo(1)
}
renderHeader() {
return (
<View style={styles.header}>
<Touchable borderless={true} onPress={this.hideBottomSheet}>
<AntDesign name="close" size={21} color={color.typoMedium} />
</Touchable>
<Text font="Medium" style={styles.headerTitle}>
Sesuaikan
</Text>
</View>
);
}
renderContent() {
return (
<View style={styles.content}>
<Text>wkwlland</Text>
</View>
);
}
render() {
const { cond, greaterOrEq } = Animated;
return (
<Portal>
<Animated.View
style={[
styles.overlay,
{
opacity: cond(greaterOrEq(this.sheetOpenValue, 0.95), 0, 1),
},
]}
pointerEvents="none"
/>
<BottomSheet
renderHeader={this.renderHeader}
renderContent={this.renderContent}
ref={this.bottomSheet}
snapPoints={[350, 0]}
initialSnap={1}
enabledInnerScrolling={false}
callbackNode={this.sheetOpenValue}
/>
</Portal>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
header: {
flexDirection: 'row',
alignItems: 'center',
backgroundColor: '#ffffff',
paddingTop: 20,
borderTopLeftRadius: 20,
borderTopRightRadius: 20,
height: 50,
paddingHorizontal: 16,
width: window.width,
},
headerTitle: {
marginLeft: 16,
fontSize: 18,
},
content: {
height: 350,
paddingTop: 20,
backgroundColor: '#ffffff',
},
overlay: {
flex: 1,
backgroundColor: 'rgba(0,0,0, .4)',
...StyleSheet.absoluteFillObject,
},
});
export { AddToCartSheet };
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Prevent dismissal of BottomSheetDialogFragment on touch ...
According to the BottomSheet specification bottom sheets can be dismissed by touching outside of the bottom sheet, therefore what are my options ...
Read more >Make your BottomSheetDialog noncancelable - beta - Medium
Let's find out what makes our bottom sheets canceled first. As mentioned above there are two ways to cancel a BottomSheetDialog , by...
Read more >React Native Bottom Sheet Tutorial with Profile Screen
In this tutorial, you'll learn how to create a bottom sheet in react native app. ... Your browser can't play this video.
Read more >How to Close a React Native Modal with a Button - CodeProject
I used a Pressable component because I didn't want the “dimming” effect on tap when touching outside the popup that comes with the ......
Read more >Excel for Android touch guide - Microsoft Support
Double-tap the cell, or tap in the formula bar. Add or edit cell contents. Hide the onscreen keyboard. Tap the Back key. Tab ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Same issue here!
yes this problem still there and touchable does not work in android that is import from react native, if you import from react-native-gesture-handler then onPress is worked but your sheet will not be close, then for this you need to true enabledInnerScrolling prop then it works fine