|
@@ -151,7 +151,8 @@ class SideBar extends React.Component<Props, State> {
|
151
|
151
|
},
|
152
|
152
|
];
|
153
|
153
|
this.colors = props.theme.colors;
|
154
|
|
- ConnectionManager.getInstance().addLoginStateListener((value) => this.onLoginStateChange(value));
|
|
154
|
+ ConnectionManager.getInstance().addLoginStateListener(this.onLoginStateChange);
|
|
155
|
+ this.props.navigation.addListener('state', this.onRouteChange);
|
155
|
156
|
this.state = {
|
156
|
157
|
isLoggedIn: ConnectionManager.getInstance().isLoggedIn(),
|
157
|
158
|
dialogVisible: false,
|
|
@@ -159,14 +160,27 @@ class SideBar extends React.Component<Props, State> {
|
159
|
160
|
};
|
160
|
161
|
}
|
161
|
162
|
|
|
163
|
+ onRouteChange = (event) => {
|
|
164
|
+ if (event.data.state.routes !== undefined) {
|
|
165
|
+ const route = event.data.state.routes[0]; // get the current route (ROOT)
|
|
166
|
+ if (route.state !== undefined) {
|
|
167
|
+ const state = route.state; // Get the Drawer's state if it exists
|
|
168
|
+ // Get the current route name. This will only show Drawer routes.
|
|
169
|
+ // Tab routes will be shown as 'Main'
|
|
170
|
+ const routeName = state.routeNames[state.index];
|
|
171
|
+ if (this.state.activeRoute !== routeName)
|
|
172
|
+ this.setState({activeRoute: routeName});
|
|
173
|
+ }
|
|
174
|
+
|
|
175
|
+ }
|
|
176
|
+ };
|
|
177
|
+
|
162
|
178
|
showDisconnectDialog = () => this.setState({dialogVisible: true});
|
163
|
179
|
|
164
|
180
|
hideDisconnectDialog = () => this.setState({dialogVisible: false});
|
165
|
181
|
|
166
|
182
|
|
167
|
|
- onLoginStateChange(isLoggedIn: boolean) {
|
168
|
|
- this.setState({isLoggedIn: isLoggedIn});
|
169
|
|
- }
|
|
183
|
+ onLoginStateChange = (isLoggedIn: boolean) => this.setState({isLoggedIn: isLoggedIn});
|
170
|
184
|
|
171
|
185
|
/**
|
172
|
186
|
* Callback when a drawer item is pressed.
|
|
@@ -179,10 +193,8 @@ class SideBar extends React.Component<Props, State> {
|
179
|
193
|
openBrowser(item.link, this.colors.primary);
|
180
|
194
|
else if (item.action !== undefined)
|
181
|
195
|
item.action();
|
182
|
|
- else {
|
|
196
|
+ else
|
183
|
197
|
this.props.navigation.navigate(item.route);
|
184
|
|
- this.setState({activeRoute: item.route});
|
185
|
|
- }
|
186
|
198
|
}
|
187
|
199
|
|
188
|
200
|
/**
|