-
Notifications
You must be signed in to change notification settings - Fork 0
/
Drawer.js
123 lines (110 loc) · 3.04 KB
/
Drawer.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
* rn-drawer example app
* https://github.com/facebook/react-native
*/
import React, { Component } from 'react';
import {
AppRegistry,
Text,
View,
} from 'react-native';
import styles from './styles';
const drawerStyles = {
drawer: {
shadowColor: "#000000",
shadowOpacity: 0.8,
shadowRadius: 0,
}
}
import Drawer from 'react-native-drawer';
import MyControlPanel from './ControlPanel';
import CameraView from './Camera'
import tweens from './tweens';
let counter = 0;
class MyDrawer extends Component {
constructor(props, context) {
super(props, context);
this.state = {
drawerType: 'overlay',
openDrawerOffset:150,
closedDrawerOffset:0,
panOpenMask: .1,
panCloseMask: .9,
relativeDrag: false,
panThreshold: .25,
tweenHandlerOn: false,
tweenDuration: 350,
tweenEasing: 'linear',
disabled: false,
tweenHandlerPreset: null,
acceptDoubleTap: false,
acceptTap: false,
acceptPan: true,
tapToClose: true,
negotiatePan: false,
side: "left",
};
}
setDrawerType(type){
this.setState({
drawerType: type
})
}
tweenHandler(ratio){
if(!this.state.tweenHandlerPreset){ return {} }
return tweens[this.state.tweenHandlerPreset](ratio)
}
noopChange(){
this.setState({
changeVal: Math.random()
})
}
openDrawer(){
this.drawer.open()
}
setStateFrag(frag) {
this.setState(frag);
}
render() {
var controlPanel = <MyControlPanel
closeDrawer={() => {this.drawer.close()}}
rootState={this.props.rootState}
getrootstate={()=>this.props.getrootstate()}
getDevices={()=>this.props.getDevices()}
getModeColor= {()=>this.props.getModeColor()}
getActiveMode={()=>this.props.getActiveMode()}
updateActiveMode= {(modeIndex)=>this.props.updateActiveMode(modeIndex)}
updateDeviceParam={(paramObject)=>this.props.updateDeviceParam(paramObject)}
syncDevices={(IPADDRESS, PORT, saveIP)=>this.props.syncDevices(IPADDRESS, PORT, saveIP)}
/>
return (
<Drawer
ref={c => this.drawer = c}
type={this.state.drawerType}
animation={this.state.animation}
openDrawerOffset={this.state.openDrawerOffset}
closedDrawerOffset={this.state.closedDrawerOffset}
relativeDrag={this.state.relativeDrag}
panThreshold={this.state.panThreshold}
content={controlPanel}
styles={drawerStyles}
disabled={this.state.disabled}
tweenHandler={this.tweenHandler.bind(this)}
tweenDuration={this.state.tweenDuration}
tweenEasing={this.state.tweenEasing}
acceptDoubleTap={this.state.acceptDoubleTap}
acceptTap={this.state.acceptTap}
acceptPan={this.state.acceptPan}
tapToClose={this.state.tapToClose}
negotiatePan={this.state.negotiatePan}
changeVal={this.state.changeVal}
side={this.state.side}
>
<CameraView
openDrawer={this.openDrawer.bind(this)}
/>
</Drawer>
);
}
}
export default MyDrawer;