-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.android.js
More file actions
184 lines (160 loc) · 4.36 KB
/
index.android.js
File metadata and controls
184 lines (160 loc) · 4.36 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Button,
Navigator,
NavigationBar,
TouchableHighlight,
Image,
ScrollView
} from 'react-native';
import HelloWorldApp from './components/HelloWorldApp';
import BleExample from './components/BleExample';
import Dashboard from './components/Dashboard';
const SideMenu = require('react-native-side-menu');
export default class sgreg0rReactNative extends Component {
constructor(props) {
super(props);
this.state = {
menuIsOpen:false,
screen:'0'
};
}
render() {
var _navigator;
var _route;
const BLE = <BleExample title={'BLE'}/>;
const DashScreen = <Dashboard/>;
const HelloScreen = <HelloWorldApp/>;
const Derp = <Navigator navigationBar={
<Navigator.NavigationBar
routeMapper={{
LeftButton: (route, navigator, index, navState) => {
if (route.index === 0) {
return null;
} else {
return (
<TouchableHighlight onPress={() => navigator.pop()}>
<Image source={require('./assets/back.png')} style={{alignSelf:'center', width:32, height:32}} />
</TouchableHighlight>
);
}
},
RightButton: (route, navigator, index, navState) =>
{ return (null); },
Title: (route, navigator, index, navState) =>
{ return (<Text style={{color:'white'}}>{route.title}</Text>);
},
}}
style={{backgroundColor: 'black'}}
/>
}
initialRoute={{ title: 'Derp', index: 0 }}
renderScene={(route, navigator) => {
_navigator = navigator;
_route = route;
console.log(route.title);
switch (route.title) {
case 'Derp':
return <HelloWorldApp title={route.title}
// Function to call when a new scene should be displayed
onForward={() => {
const nextIndex = route.index + 1;
navigator.push({
title: 'Derp',
index: nextIndex,
});
}}
// Function to call to go back to the previous scene
onBack={() => {
if (route.index > 0) {
navigator.pop();
}
}}
/>
}
}}
/>;
const menu = <Menu showOans={() => {
this.setState({menuIsOpen:false, screen:'0'});
}}
showZwoa={() => {
this.setState({menuIsOpen:false, screen:'1'});
}}
showDrei={() => {
this.setState({menuIsOpen:false, screen:'2'});
}}/>;
return (
<SideMenu bounceBackOnOverdraw={false} isOpen={this.props.menuIsOpen} menu={menu}>
<View style={{flex: 1, backgroundColor: 'cadetblue'}}>
{ this.state.screen === '0' ? DashScreen : null }
{ this.state.screen === '1' ? Derp : null }
{ this.state.screen === '2' ? BLE : null }
</View>
</SideMenu>
);
}
}
class Menu extends Component {
render() {
return (
<ScrollView scrollsToTop={false} style={styles.menu}>
<View style={styles.avatarContainer}>
<Image
style={styles.avatar}
source={{ uri, }}/>
<Text style={styles.name}>Deine Mutter</Text>
</View>
<Button
onPress={this.props.showOans}
title="Dääschboard"
accessibilityLabel="Learn more about this purple button"
/>
<Button
onPress={this.props.showZwoa}
title="Derp?"
accessibilityLabel="Learn more about this purple button"
/>
<Button
onPress={this.props.showDrei}
title="BLE Dings"
accessibilityLabel="Learn more about this purple button"
/>
</ScrollView>
);
}
};
const styles = StyleSheet.create({
menu: {
flex: 3,
backgroundColor: '#cc88cc',
padding: 32,
},
avatarContainer: {
marginBottom: 20,
marginTop: 20,
},
avatar: {
width: 48,
height: 48,
borderRadius: 24,
flex: 1,
},
name: {
position: 'absolute',
left: 70,
top: 20,
},
item: {
},
});
const uri = 'https://pickaface.net/gallery/avatar/Opi51c74d0125fd4.png';
AppRegistry.registerComponent('sgreg0rReactNative', () => sgreg0rReactNative);