forked from octopitus/rn-sliding-up-panel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScrollViewInsidePanel.js
79 lines (73 loc) · 2.57 KB
/
ScrollViewInsidePanel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* You MUST control the allowDragging prop manually.
* In this example i simply use onTouchStart, onTouchCancel and onTouchEnd of ScrollView.
* But in real world, you must enable allowDragging if the scrollable content is at top or bottom.
*/
import React from 'react'
import {
AppRegistry,
View,
ScrollView,
Text,
TouchableOpacity
} from 'react-native'
import SlidingUpPanel from 'rn-sliding-up-panel'
const styles = {
container: {
flex: 1,
zIndex: 1,
backgroundColor: 'white',
alignItems: 'center',
justifyContent: 'center'
}
}
class ScrollViewInsidePanel extends React.Component {
state = {
visible: false,
allowDragging: true
}
render() {
return (
<View style={styles.container}>
<TouchableOpacity onPress={() => this.setState({visible: true})}>
<View>
<Text>Show</Text>
</View>
</TouchableOpacity>
<SlidingUpPanel
ref={c => (this._panel = c)}
visible={this.state.visible}
allowDragging={this.state.allowDragging}
onRequestClose={() => this.setState({visible: false})}>
<View style={styles.container}>
<TouchableOpacity onPress={() => this.setState({visible: false})}>
<View>
<Text>Hide</Text>
</View>
</TouchableOpacity>
<ScrollView
onTouchEnd={() => this.setState({allowDragging: true})}
onTouchCancel={() => this.setState({allowDragging: true})}
onTouchStart={() => this.setState({allowDragging: false})}>
<Text>Here is the content inside panel</Text>
<Text>Here is the content inside panel</Text>
<Text>Here is the content inside panel</Text>
<Text>Here is the content inside panel</Text>
<Text>Here is the content inside panel</Text>
<Text>Here is the content inside panel</Text>
<Text>Here is the content inside panel</Text>
<Text>Here is the content inside panel</Text>
<Text>Here is the content inside panel</Text>
<Text>Here is the content inside panel</Text>
<Text>Here is the content inside panel</Text>
<Text>Here is the content inside panel</Text>
<Text>Here is the content inside panel</Text>
<Text>Here is the content inside panel</Text>
</ScrollView>
</View>
</SlidingUpPanel>
</View>
)
}
}
AppRegistry.registerComponent('ScrollViewInsidePanel', () => ScrollViewInsidePanel)