-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from Hiseen/henry-main-panel
[Issue #9] Implement main panel, session, and data loader. Introduce new gui codebase that runs on expo-client
- Loading branch information
Showing
56 changed files
with
8,074 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+930 Bytes
...ain/res/drawable-mdpi/node_modules_reactnativeratings_src_images_airbnbstar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+934 Bytes
...drawable-mdpi/node_modules_reactnativeratings_src_images_airbnbstarselected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.92 KB
.../src/main/res/drawable-mdpi/node_modules_reactnativeratings_src_images_bell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.88 KB
...src/main/res/drawable-mdpi/node_modules_reactnativeratings_src_images_heart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.96 KB
...rc/main/res/drawable-mdpi/node_modules_reactnativeratings_src_images_rocket.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.92 KB
.../src/main/res/drawable-mdpi/node_modules_reactnativeratings_src_images_star.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+127 KB
BalancedBite/android/app/src/main/res/drawable-mdpi/src_images_bblogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
const HOST = "169.234.29.1"; | ||
const HOST = "169.234.3.29"; | ||
export const SERVER_URL = "http://" + HOST + ":8080"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,34 @@ | ||
import React, { Component } from "react"; | ||
import { View, Text } from "react-native"; | ||
|
||
import { View, Text, Button, Input, StyleSheet } from "react-native"; | ||
|
||
class ClickSuggestionPanel extends Component { | ||
import { connect } from "react-redux"; | ||
|
||
static navigationOptions = { | ||
title: "ClickSuggestion" | ||
const mapStateToProps = (state) => { | ||
return { | ||
currentToken: state.currentToken | ||
} | ||
|
||
} | ||
|
||
class ClickSuggestionComponent extends Component { | ||
|
||
render() { | ||
return ( | ||
<View> | ||
<Text>Suggestion panel</Text> | ||
<View style={styles.container}> | ||
<Text>ClickSuggestionComponent panel</Text> | ||
<Text>{this.props.currentToken}</Text> | ||
</View> | ||
); | ||
} | ||
} | ||
|
||
export default connect(mapStateToProps)(ClickSuggestionComponent); | ||
|
||
export default ClickSuggestionPanel; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
alignItems: 'center', | ||
justifyContent: 'center' | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import AppContainer from "../AppContainer"; | ||
import React, { Component } from 'react'; | ||
import { | ||
StyleSheet, | ||
View, | ||
StatusBar | ||
} from 'react-native'; | ||
|
||
class EntireApp extends Component { | ||
render() { | ||
return ( | ||
<View style={styles.container}> | ||
<StatusBar | ||
backgroundColor="#1c313a" | ||
barStyle="light-content" | ||
/> | ||
<AppContainer></AppContainer> | ||
</View> | ||
) | ||
} | ||
} | ||
|
||
export default EntireApp | ||
|
||
|
||
|
||
const styles = StyleSheet.create({ | ||
container : { | ||
flex: 1, | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
import React, { Component } from "react"; | ||
import { View, Text, StyleSheet, SafeAreaView, AsyncStorage, Button } from "react-native"; | ||
|
||
import { createMaterialTopTabNavigator, createAppContainer, withNavigation } from "react-navigation"; | ||
|
||
import Icon from "react-native-vector-icons/FontAwesome5"; | ||
|
||
import { SERVER_URL } from "../../commons/serverRequest"; | ||
|
||
import UserInformationComponent from "../UserInformationPanel"; | ||
import ClickSuggestionComponent from "../ClickSuggestionPanel"; | ||
|
||
import { connect } from "react-redux"; | ||
|
||
const SESSION_URL = SERVER_URL + "/check-session"; | ||
|
||
const AppTabNavigator = createMaterialTopTabNavigator({ | ||
UserInformation: { | ||
screen: UserInformationComponent, | ||
navigationOptions: { | ||
tabBarLabel: 'User', | ||
tabBarIcon: ({ tintColor }) => <Icon name="user-circle" color={tintColor} size={24}></Icon> | ||
} | ||
}, | ||
ClickSuggestion: { | ||
screen: ClickSuggestionComponent, | ||
navigationOptions: { | ||
tabBarLabel: "Suggest", | ||
tabBarIcon: ({ tintColor }) => <Icon name="search" color={tintColor} size={24}></Icon> | ||
} | ||
} | ||
}, | ||
{ | ||
initialRouteName: 'UserInformation', | ||
tabBarPosition: 'bottom', | ||
tabBarOptions: { | ||
activeTintColor : '#2A67BF', | ||
inactiveTintColor: 'grey', | ||
style: { | ||
backgroundColor: '#f2f2f2', | ||
borderTopWidth : 0.5, | ||
borderTopColor: 'grey' | ||
}, | ||
indicatorStyle: { | ||
height: 0 | ||
}, | ||
showIcon: true, | ||
showLabel: true | ||
} | ||
}) | ||
|
||
const AppTabContainer = createAppContainer(AppTabNavigator) | ||
|
||
class MainTab extends Component { | ||
|
||
static navigationOptions = { | ||
header: null | ||
} | ||
|
||
checkTokenStatus(UItoken) { | ||
console.warn("Current UItoken = " + UItoken); | ||
fetch(SESSION_URL, { | ||
method: "POST", | ||
body : UItoken, | ||
headers: { | ||
"Content-Type" : "text/plain" | ||
} | ||
}) | ||
.then(backendRes => backendRes.json()) | ||
.then(backendRes => { | ||
if (backendRes.code == 0) { | ||
console.warn("backendRes code = 0"); | ||
this.props.navigation.navigate("loginPanel"); | ||
} else { | ||
// change token in redux storage | ||
this.props.changeCurrentToken(UItoken); | ||
} | ||
}) | ||
.catch(error => { | ||
throw error; | ||
}); | ||
} | ||
|
||
handleUserSessionCall() { | ||
// fetch user data from async storage in react-native | ||
const fetchAsyncTokenData = async () => { | ||
let token = 'none'; | ||
try { | ||
token = await AsyncStorage.getItem('token') || 'none'; | ||
} catch (error) { | ||
// Error retrieving data | ||
console.warn(error.message); | ||
} | ||
return token; | ||
} | ||
|
||
fetchAsyncTokenData().then(UItoken => { | ||
if (UItoken == 'none'){ | ||
console.warn("UI token = none"); | ||
this.props.navigation.navigate("loginPanel"); | ||
} else { | ||
// check if token is valid in db | ||
this.checkTokenStatus(UItoken); | ||
} | ||
}); | ||
} | ||
|
||
componentDidMount(){ | ||
const { navigation } = this.props; | ||
// listen to navigation focus on this screen | ||
this.focusListener = navigation.addListener("didFocus", () => { | ||
this.handleUserSessionCall(); | ||
}) | ||
} | ||
|
||
componentWillUnmount() { | ||
this.focusListener.remove(); | ||
} | ||
|
||
render() { | ||
return ( | ||
<SafeAreaView style={{flex : 1, backgroundColor: '#f2f2f2' }}> | ||
<AppTabContainer></AppTabContainer> | ||
</SafeAreaView> | ||
); | ||
} | ||
} | ||
|
||
const mapStateToProps = (state) => { | ||
return { | ||
currentToken: state.currentToken | ||
} | ||
} | ||
|
||
const mapDispatchToProps = (dispatch) => { | ||
return { | ||
changeCurrentToken: (token) => dispatch({type : 'CHANGE_TOKEN', token: token}) | ||
} | ||
} | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(withNavigation(MainTab)); | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
alignItems: 'center', | ||
justifyContent: 'center' | ||
} | ||
}) |
Oops, something went wrong.