This repository has been archived by the owner on Jan 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.android.js
88 lines (77 loc) · 2.67 KB
/
index.android.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
import React, { Component } from 'react';
import { LoginScene } from './android_components/scenes/login/loginScene.js';
import { GameListScene } from './android_components/scenes/game_list/gameListScene.js';
import { GameDetailScene } from './android_components/scenes/game_detail/gameDetailScene.js';
import { NavbarMapper } from './android_components/navbar/navbarMapper.js';
import {
AppRegistry,
StyleSheet,
Navigator,
BackAndroid,
ToastAndroid
} from 'react-native';
console.disableYellowBox = true;
export default class GamemateAdmin extends Component {
constructor(props) {
super(props);
this.handleBackButtonPress = this._handleBackButtonPress.bind(this);
}
componentWillMount() {
let response = fetch('http://gamemate.di.unito.it:8080/', {
method : 'POST'
}).catch((error) => {
ToastAndroid.show('Please check your network connection', ToastAndroid.SHORT);
});
}
render() {
return (
<Navigator style={{flex : 1}}
ref='nav'
initialRoute={{name : 'Game Owner Platform by Gamemate', component : LoginScene, index : 0}}
renderScene={this.renderScene}
configureScene={this.configureScene}
navigationBar={
<Navigator.NavigationBar
navigationStyles={Navigator.NavigationBar.StylesIOS}
routeMapper={NavbarMapper}
style={styles.navbar} />
} />
);
}
componentDidMount() {
BackAndroid.addEventListener('hardwareBackPress', this.handleBackButtonPress);
}
_handleBackButtonPress() {
const invalidBack = this.refs.nav != undefined &&
this.refs.nav.getCurrentRoutes().length != 1;
if(invalidBack)
this.refs.nav.pop();
return invalidBack;
}
renderScene(route, navigator) {
if(route.name == 'Game Owner Platform by Gamemate') {
return <LoginScene navigator={navigator} />;
}
else if (route.name == 'Your uploaded Games') {
return <GameListScene /*newGame={route.passProps != undefined ? route.passProps.newGame : undefined}*/ navigator={navigator} />;
}
else if (route.name == 'New Game') {
return <GameDetailScene navigator={navigator} />;
}
else if (route.name == "Game Detail" && route.passProps != undefined) {
return <GameDetailScene game={route.passProps.game} navigator={navigator} />;
}
}
configureScene(route, routeStack) {
return Navigator.SceneConfigs.PushFromRight; //FloatFromBottom
}
}
const styles = StyleSheet.create({
navbar : {
backgroundColor : '#e1ec2b',
borderBottomColor : 'brown',
borderBottomWidth : 1,
margin : 0
}
});
AppRegistry.registerComponent('GamemateAdmin', () => GamemateAdmin);