diff --git a/app/components/NavDrawer.js b/app/components/NavDrawer.js
index 4bb6f8b1..ab3e4a9d 100644
--- a/app/components/NavDrawer.js
+++ b/app/components/NavDrawer.js
@@ -52,13 +52,15 @@ class NavDrawer extends Component {
}
onResetHomeProfilePressed() {
+ const {tracker, actions} = this.props;
+
Alert.alert('Logout',
'Are you sure that you want to logout?',
[
{text: 'Cancel', style: 'cancel'},
{text: 'OK', onPress: () => {
- this.props.tracker.trackEvent('Logout', 'Success');
- this.props.actions.resetHomeProfile();
+ tracker.trackEvent('Logout', 'Success');
+ actions.resetHomeProfile();
setTimeout(() => {
AsyncStorage.setItem("homeProfile", "");
}, 1000);
@@ -67,21 +69,23 @@ class NavDrawer extends Component {
}
goto(route) {
+ const {actions, contextIdStackFavourite, contextIdStackHome, contextIdStackSearch} = this.props;
+
Actions.drawerClose();
- this.props.actions.changeParent(route);
+ actions.changeParent(route);
if(route == 'Home') {
- if(this.props.contextIdStackHome.length > 0) {
- this.props.actions.changeContextId(this.props.contextIdStackHome[this.props.contextIdStackHome.length-1]);
+ if(contextIdStackHome.length > 0) {
+ actions.changeContextId(contextIdStackHome[contextIdStackHome.length-1]);
}
Actions.homeTab();
} else if(route == 'Favourites') {
- if(this.props.contextIdStackFavourite.length > 0) {
- this.props.actions.changeContextId(this.props.contextIdStackFavourite[this.props.contextIdStackFavourite.length-1]);
+ if(contextIdStackFavourite.length > 0) {
+ actions.changeContextId(contextIdStackFavourite[contextIdStackFavourite.length-1]);
}
Actions.favouriteTab();
} else if(route == 'Search') {
- if(this.props.contextIdStackSearch.length > 0) {
- this.props.actions.changeContextId(this.props.contextIdStackSearch[this.props.contextIdStackSearch.length-1]);
+ if(contextIdStackSearch.length > 0) {
+ actions.changeContextId(contextIdStackSearch[contextIdStackSearch.length-1]);
}
Actions.searchTab();
} else if(route == 'Settings') {
@@ -89,88 +93,72 @@ class NavDrawer extends Component {
}
}
- render() {
- var paddingView;
+ getPaddingView = () => {
if(Platform.OS === 'ios') {
if(DeviceInfo.getModel() == "iPhone X")
- paddingView =
+ return ;
else
- paddingView =
+ return ;
} else {
- paddingView =
+ return ;
}
- var logout = ();
- if(this.props.profile != "") {
- logout = (
-
+ }
+
+ getLogoutView = () => {
+ const { profile, mod, legend, secondLegend } = this.props;
+
+ return (profile != "") ?
+
{this.onResetHomeProfilePressed()}}>
-
+
-
+
- Logout
+ Logout
-
+
- );
+ :
+ ;
}
+
+ getMenuItem = (itemName, fontName) => {
+ const { mod, legend, secondLegend } = this.props;
+
+ return {this.goto(itemName)}}>
+
+
+
+
+
+ {itemName}
+
+
+ ;
+ }
+
+ render() {
+ const { mod, legend } = this.props;
+
+ const paddingView = this.getPaddingView();
+ const logoutView = this.getLogoutView();
+
return (
-
+
{paddingView}
- {this.goto('Home')}}>
-
-
-
-
-
- Home
-
-
-
-
-
- {this.goto('Favourites')}}>
-
-
-
-
-
- Favourites
-
-
-
-
-
- {this.goto('Search')}}>
-
-
-
-
-
- Search
-
-
-
-
-
- {this.goto('Settings')}}>
-
-
-
-
-
- Settings
-
-
-
-
-
- {logout}
-
+ {this.getMenuItem("Home", "home")}
+
+ {this.getMenuItem("Favourites", "star")}
+
+ {this.getMenuItem("Search", "search")}
+
+ {this.getMenuItem("Settings", "cog")}
+
+ {logoutView}
)