diff --git a/components/AuthenticatedScreen.js b/components/AuthenticatedScreen.js index 276f0e2..32a8a8b 100644 --- a/components/AuthenticatedScreen.js +++ b/components/AuthenticatedScreen.js @@ -1,7 +1,8 @@ import * as React from 'react'; -import {View} from "react-native"; -import {ActivityIndicator, Text, withTheme} from 'react-native-paper'; -import ConnectionManager from "../managers/ConnectionManager"; +import {StyleSheet, View} from "react-native"; +import {ActivityIndicator, Subheading, withTheme} from 'react-native-paper'; +import ConnectionManager, {ERROR_TYPE} from "../managers/ConnectionManager"; +import {MaterialCommunityIcons} from "@expo/vector-icons"; type Props = { navigation: Object, @@ -22,6 +23,7 @@ class AuthenticatedScreen extends React.Component { currentUserToken: string; connectionManager: ConnectionManager; + errorCode: number; data: Object; colors: Object; @@ -49,19 +51,20 @@ class AuthenticatedScreen extends React.Component { this.onFinishedLoading(data); }) .catch((error) => { - this.onFinishedLoading(undefined); + this.onFinishedLoading(undefined, error); }); }) - .catch(() => { - this.onFinishedLoading(undefined); + .catch((error) => { + this.onFinishedLoading(undefined, ERROR_TYPE.BAD_CREDENTIALS); }); } - onFinishedLoading(data: Object) { + onFinishedLoading(data: Object, error: number) { this.data = data; this.currentUserToken = data !== undefined ? this.connectionManager.getToken() : ''; + this.errorCode = error; this.setState({loading: false}); } @@ -92,7 +95,41 @@ class AuthenticatedScreen extends React.Component { } getErrorRender() { - return ERROR; + let message; + let icon; + switch (this.errorCode) { + case ERROR_TYPE.BAD_CREDENTIALS: + message = "BAD_CREDENTIALS"; + icon = "account-alert-outline"; + break; + case ERROR_TYPE.CONNECTION_ERROR: + message = "CONNECTION_ERROR"; + icon = "access-point-network-off"; + break; + default: + message = "UNKNOWN"; + icon = "alert-circle-outline"; + break; + } + + return ( + + + + + + + {message} + + + + ); } render() { @@ -104,7 +141,24 @@ class AuthenticatedScreen extends React.Component { : this.getErrorRender()) ); } - } +const styles = StyleSheet.create({ + outer: { + flex: 1, + }, + inner: { + marginTop: 'auto', + marginBottom: 'auto', + }, + iconContainer: { + marginLeft: 'auto', + marginRight: 'auto', + marginBottom: 20 + }, + subheading: { + textAlign: 'center', + } +}); + export default withTheme(AuthenticatedScreen); diff --git a/components/Sidebar.js b/components/Sidebar.js index 32ba78d..0e85445 100644 --- a/components/Sidebar.js +++ b/components/Sidebar.js @@ -59,7 +59,7 @@ class SideBar extends React.PureComponent { { name: 'PROFILE', route: "ProfileScreen", - icon: "circle", + icon: "account", onlyWhenLoggedIn: true, }, {