1 回答
TA贡献1802条经验 获得超4个赞
您可以在课堂上使用showBag和renderContentHomeScreen
class HomeScreen extends React.Component {
constructor() {
super();
this.state = {
bagTitle: 'View Bag'
}
this.showBag = this.showBag.bind(this);
this.renderContent = this.renderContent.bind(this);
}
// FUNCTIONS
showBag = (item) => {
sheetRef.current.snapTo(1);
if (item.title !== null) {
this.setState({
bagTitle: item.title
})
console.log('ITEM: ', item);
}
}
renderContent = () => (
<View
style={{
backgroundColor: '#ecf0f1',
padding: 16,
fontSize: 20,
height: windowHeight,
width: windowWidth,
marginBottom: -200
}}
>
<Text onPress={this.showBag} style={{ fontSize: 17, fontWeight: '600', textAlign: 'center', position: "absolute", marginTop: 20, width: windowWidth }}>{this.state.bagTitle}</Text>
</View>
);
render() {
const title = 'View Bag'
return (
<View style={styles.container}>
<StatusBar style="auto" />
{/* Bottomsheet View */}
<BottomSheet
ref={sheetRef}
snapPoints={[100, 300, Dimensions.get('window').height - 100]}
borderRadius={10}
renderContent={this.renderContent}
/>
</View>
);
}
}
添加回答
举报