2017-09-21 17:08:00 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { TouchableOpacity } from 'react-native';
|
2018-05-21 18:39:26 +00:00
|
|
|
import { createStackNavigator } from 'react-navigation';
|
2017-09-21 17:08:00 +00:00
|
|
|
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
|
|
|
|
|
|
import ListServerView from '../../views/ListServerView';
|
|
|
|
import NewServerView from '../../views/NewServerView';
|
2018-04-24 19:34:03 +00:00
|
|
|
import LoginSignupView from '../../views/LoginSignupView';
|
2017-09-21 17:08:00 +00:00
|
|
|
import LoginView from '../../views/LoginView';
|
2017-11-07 16:28:02 +00:00
|
|
|
import RegisterView from '../../views/RegisterView';
|
2017-11-13 13:32:46 +00:00
|
|
|
|
|
|
|
import TermsServiceView from '../../views/TermsServiceView';
|
|
|
|
import PrivacyPolicyView from '../../views/PrivacyPolicyView';
|
2017-11-10 13:42:02 +00:00
|
|
|
import ForgotPasswordView from '../../views/ForgotPasswordView';
|
2018-04-24 19:34:03 +00:00
|
|
|
import database from '../../lib/realm';
|
2018-06-01 17:38:13 +00:00
|
|
|
import I18n from '../../i18n';
|
2018-04-24 19:34:03 +00:00
|
|
|
|
|
|
|
const hasServers = () => {
|
|
|
|
const db = database.databases.serversDB.objects('servers');
|
|
|
|
return db.length > 0;
|
|
|
|
};
|
|
|
|
|
2018-05-21 18:39:26 +00:00
|
|
|
const ServerStack = createStackNavigator({
|
2018-04-24 19:34:03 +00:00
|
|
|
ListServer: {
|
|
|
|
screen: ListServerView,
|
|
|
|
navigationOptions({ navigation }) {
|
|
|
|
return {
|
2018-06-01 17:38:13 +00:00
|
|
|
title: I18n.t('Servers'),
|
2018-04-24 19:34:03 +00:00
|
|
|
headerRight: (
|
|
|
|
<TouchableOpacity
|
|
|
|
onPress={() => navigation.navigate({ key: 'AddServer', routeName: 'AddServer' })}
|
|
|
|
style={{ width: 50, alignItems: 'center' }}
|
2018-06-01 17:38:13 +00:00
|
|
|
accessibilityLabel={I18n.t('Add_Server')}
|
2018-04-24 19:34:03 +00:00
|
|
|
accessibilityTraits='button'
|
|
|
|
>
|
|
|
|
<Icon name='plus' size={16} />
|
|
|
|
</TouchableOpacity>
|
|
|
|
)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
|
|
|
AddServer: {
|
|
|
|
screen: NewServerView,
|
|
|
|
navigationOptions: {
|
|
|
|
header: null
|
|
|
|
}
|
|
|
|
},
|
|
|
|
LoginSignup: {
|
|
|
|
screen: LoginSignupView,
|
|
|
|
navigationOptions: {
|
|
|
|
header: null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
headerMode: 'screen',
|
|
|
|
initialRouteName: hasServers() ? 'ListServer' : 'AddServer'
|
|
|
|
});
|
|
|
|
|
2018-05-21 18:39:26 +00:00
|
|
|
const LoginStack = createStackNavigator({
|
2018-04-24 19:34:03 +00:00
|
|
|
Login: {
|
|
|
|
screen: LoginView,
|
|
|
|
navigationOptions: {
|
|
|
|
header: null
|
|
|
|
}
|
|
|
|
},
|
|
|
|
ForgotPassword: {
|
|
|
|
screen: ForgotPasswordView,
|
|
|
|
navigationOptions: {
|
2018-06-01 17:38:13 +00:00
|
|
|
title: I18n.t('Forgot_my_password'),
|
2018-04-24 19:34:03 +00:00
|
|
|
headerTintColor: '#292E35'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
headerMode: 'screen'
|
|
|
|
});
|
|
|
|
|
2018-05-21 18:39:26 +00:00
|
|
|
const RegisterStack = createStackNavigator({
|
2018-04-24 19:34:03 +00:00
|
|
|
Register: {
|
|
|
|
screen: RegisterView,
|
|
|
|
navigationOptions: {
|
|
|
|
header: null
|
|
|
|
}
|
|
|
|
},
|
|
|
|
TermsService: {
|
|
|
|
screen: TermsServiceView,
|
|
|
|
navigationOptions: {
|
2018-06-01 17:38:13 +00:00
|
|
|
title: I18n.t('Terms_of_Service'),
|
2018-04-24 19:34:03 +00:00
|
|
|
headerTintColor: '#292E35'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
PrivacyPolicy: {
|
|
|
|
screen: PrivacyPolicyView,
|
|
|
|
navigationOptions: {
|
2018-06-01 17:38:13 +00:00
|
|
|
title: I18n.t('Privacy_Policy'),
|
2018-04-24 19:34:03 +00:00
|
|
|
headerTintColor: '#292E35'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
headerMode: 'screen'
|
|
|
|
});
|
2017-09-21 17:08:00 +00:00
|
|
|
|
2018-05-21 18:39:26 +00:00
|
|
|
const PublicRoutes = createStackNavigator(
|
2017-09-21 17:08:00 +00:00
|
|
|
{
|
2018-04-24 19:34:03 +00:00
|
|
|
Server: {
|
|
|
|
screen: ServerStack
|
2017-09-21 17:08:00 +00:00
|
|
|
},
|
|
|
|
Login: {
|
2018-04-24 19:34:03 +00:00
|
|
|
screen: LoginStack
|
2017-11-07 16:28:02 +00:00
|
|
|
},
|
|
|
|
Register: {
|
2018-04-24 19:34:03 +00:00
|
|
|
screen: RegisterStack
|
2017-09-21 17:08:00 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2018-04-24 19:34:03 +00:00
|
|
|
mode: 'modal',
|
|
|
|
headerMode: 'none'
|
2017-09-21 17:08:00 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
export default PublicRoutes;
|