-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ios.js
103 lines (91 loc) · 2.81 KB
/
index.ios.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
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, {Component} from 'react';
import {
AppRegistry,
StyleSheet,
Text,
Navigator,
TouchableHighlight
} from 'react-native';
// Creamos barra de navegación
let NavigationBarRouteMapper = {
LeftButton: function (route, navigator, index) {
if (route.name == 'Login' || route.name == 'Dashboard') {
return null;
}
return (<TouchableHighlight underlayColor='rgba(0,0,0,0)' onPress={() => {
if(index > 0){
navigator.pop();
}
}}>
<Text style={{marginTop: 10, marginLeft:20, color:'#e3e3e3'}}>Back</Text>
</TouchableHighlight>
)
},
RightButton: function (route) {
return null;
},
Title: function (route) {
if (route.name == 'Login' || route.name == 'Dashboard') {
return null;
}
return (
<Text style={{marginTop: 10, color:'#e3e3e3', fontWeight: 'bold' }}>
{route.name}
</Text>
)
},
};
// Importamos componentes de Login y Pestañas
const Login = require('./src/components/loginView')
const Tabs = require('./src/components/tabs')
// Importamos vista de detalle
const Details = require('./src/components/komikiDetailView')
export default class KomikiApp extends Component {
// Implementamos navegación
renderScene(route, navigator) {
switch (route.name) {
case 'Login':
return (
<Login {...route.props} navigator={navigator} route={route}/>
);
case 'Dashboard':
return (
<Tabs {...route.props} navigator={navigator} route={route}/>
);
// Sin esto no podemos acceder a la navegación a vista de detalle
case 'Details':
return (
<Details {...route.props} navigator={navigator} route={route}/>
)
}
}
// Método principal que nos muestra los diferentes componentes por pantalla
render() {
return (
<Navigator style={styles.bar}
initialRoute={{name: 'Login'}}
renderScene={this.renderScene}
configureScene={(route) => {
if(route.sceneConfig){
return route.sceneConfig;
}
return Navigator.SceneConfigs.FloatFromRight
}}
navigationBar={
<Navigator.NavigationBar
routeMapper={NavigationBarRouteMapper}/>}
/>
);
}
}
const styles = StyleSheet.create({
bar: {
backgroundColor: '#2c2c2d',
}
});
AppRegistry.registerComponent('KomikiApp', () => KomikiApp);