2017-09-21 17:08:00 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { TouchableOpacity } from 'react-native';
|
|
|
|
import { StackNavigator } from 'react-navigation';
|
|
|
|
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';
|
|
|
|
|
|
|
|
const hasServers = () => {
|
|
|
|
const db = database.databases.serversDB.objects('servers');
|
|
|
|
return db.length > 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
const ServerStack = StackNavigator({
|
|
|
|
ListServer: {
|
|
|
|
screen: ListServerView,
|
|
|
|
navigationOptions({ navigation }) {
|
|
|
|
return {
|
|
|
|
title: 'Servers',
|
|
|
|
headerRight: (
|
|
|
|
<TouchableOpacity
|
|
|
|
onPress={() => navigation.navigate({ key: 'AddServer', routeName: 'AddServer' })}
|
|
|
|
style={{ width: 50, alignItems: 'center' }}
|
|
|
|
accessibilityLabel='Add server'
|
|
|
|
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'
|
|
|
|
});
|
|
|
|
|
|
|
|
const LoginStack = StackNavigator({
|
|
|
|
Login: {
|
|
|
|
screen: LoginView,
|
|
|
|
navigationOptions: {
|
|
|
|
header: null
|
|
|
|
}
|
|
|
|
},
|
|
|
|
ForgotPassword: {
|
|
|
|
screen: ForgotPasswordView,
|
|
|
|
navigationOptions: {
|
|
|
|
title: 'Forgot my password',
|
|
|
|
headerTintColor: '#292E35'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
headerMode: 'screen'
|
|
|
|
});
|
|
|
|
|
|
|
|
const RegisterStack = StackNavigator({
|
|
|
|
Register: {
|
|
|
|
screen: RegisterView,
|
|
|
|
navigationOptions: {
|
|
|
|
header: null
|
|
|
|
}
|
|
|
|
},
|
|
|
|
TermsService: {
|
|
|
|
screen: TermsServiceView,
|
|
|
|
navigationOptions: {
|
|
|
|
title: 'Terms of service',
|
|
|
|
headerTintColor: '#292E35'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
PrivacyPolicy: {
|
|
|
|
screen: PrivacyPolicyView,
|
|
|
|
navigationOptions: {
|
|
|
|
title: 'Privacy policy',
|
|
|
|
headerTintColor: '#292E35'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
headerMode: 'screen'
|
|
|
|
});
|
2017-09-21 17:08:00 +00:00
|
|
|
|
|
|
|
const PublicRoutes = StackNavigator(
|
|
|
|
{
|
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;
|