-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.android.js
More file actions
55 lines (46 loc) · 1.13 KB
/
index.android.js
File metadata and controls
55 lines (46 loc) · 1.13 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
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react'
import Search from './app/components/Search.js'
import Webview from './app/components/Webview.js'
import {
Navigator,
AppRegistry,
BackAndroid
} from 'react-native';
var _navigator; //keeps track of app navigation
class Githubr extends Component {
render() {
return (
//simple router
<Navigator
style={{ flex:1 }}
initialRoute={{ name: 'search' }}
renderScene={ this.renderScene } />
)
}
//router logic
renderScene ( route, navigator ) {
_navigator = navigator;
if (route.name === 'search') {
return ( <Search navigator={navigator} /> )
} else if(route.name === 'webview'){
return (
<Webview
navigator={navigator}
url={route.url} /> )
}
}
}
//this handles our back button for us
BackAndroid.addEventListener('hardwareBackPress', () => {
if (_navigator.getCurrentRoutes().length === 1 ) {
return false
}
_navigator.pop()
return true
})
AppRegistry.registerComponent('Githubr', () => Githubr)