-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
58 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,65 @@ | ||
import React, { Component } from 'react' | ||
import { | ||
AppRegistry, | ||
StyleSheet, | ||
TextInput, | ||
Button, | ||
Alert, | ||
View | ||
} from 'react-native' | ||
import Profile from './src/pages/profile.js' | ||
import React from 'react' | ||
import { AppRegistry, BackAndroid, Navigator } from 'react-native' | ||
|
||
export default class GithubClient extends Component { | ||
import routes from './src/routes' | ||
import Profile from './src/pages/profile' | ||
import Auth from './src/pages/auth' | ||
import Repository from './src/pages/repository' | ||
import Readme from './src/pages/readme' | ||
import Dashboard from './src/pages/dashboard' | ||
import Notification from './src/pages/notification' | ||
import UserList from './src/pages/user-list' | ||
import Issue from './src/pages/issue' | ||
import IssueList from './src/pages/issue-list' | ||
import Commit from './src/pages/commit' | ||
import CommitDetail from './src/pages/commit-detail' | ||
|
||
class GiltApplication extends React.Component { | ||
initNavigator = navigator => { | ||
this.navigator = navigator | ||
BackAndroid.addEventListener('hardwareBackPress', () => { | ||
if (navigator.getCurrentRoutes().length !== 1) { | ||
this.navigator.pop() | ||
return true | ||
} | ||
return false | ||
}) | ||
} | ||
renderScene = (route, navigator) => { | ||
if (!this.navigator) { | ||
this.initNavigator(navigator) | ||
} | ||
switch (route.name) { | ||
case 'LOGIN': | ||
return <Auth route={route} navigator={navigator} /> | ||
case 'DASHBOARD': | ||
return <Dashboard route={route} navigator={navigator} /> | ||
case 'REPOSITORY': | ||
return <Repository route={route} navigator={navigator} /> | ||
case 'README': | ||
return <Readme route={route} navigator={navigator} /> | ||
case 'PROFILE': | ||
return <Profile route={route} navigator={navigator} /> | ||
case 'NOTIFICATION': | ||
return <Notification route={route} navigator={navigator} /> | ||
case 'USER_LIST': | ||
return <UserList route={route} navigator={navigator} /> | ||
case 'ISSUE': | ||
return <Issue route={route} navigator={navigator} /> | ||
case 'ISSUE_LIST': | ||
return <IssueList route={route} navigator={navigator} /> | ||
case 'COMMIT': | ||
return <Commit route={route} navigator={navigator} /> | ||
case 'COMMIT_DETAIL': | ||
return <CommitDetail route={route} navigator={navigator} /> | ||
} | ||
} | ||
render() { | ||
return ( | ||
<Profile/> | ||
<Navigator initialRoute={routes[10]} renderScene={this.renderScene} | ||
configureScene={() => Navigator.SceneConfigs.FloatFromBottomAndroid} /> | ||
) | ||
} | ||
} | ||
|
||
AppRegistry.registerComponent('GithubClient', () => GithubClient) | ||
AppRegistry.registerComponent('Gilt', () => GiltApplication) |