Merge pull request #20 from henrydays/Borges

profile
This commit is contained in:
João Pedro Borges 2019-02-08 14:38:00 +00:00 committed by GitHub
commit 374762b61c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 359 additions and 77 deletions

View File

@ -25,11 +25,42 @@ import logout from './screens/logout'
import Icon from "react-native-vector-icons/Ionicons"
import IconF from "react-native-vector-icons/Foundation"
import IconFA from "react-native-vector-icons/FontAwesome5"
import Profile from "./screens/Profile";
const AppStack = createBottomTabNavigator(
{
Home: {
screen: Home,
navigationOptions: {
tabBarIcon: ({tintColor}) => (
<Icon name="md-home" color={tintColor} size={30}/>
)
},
},
Social: {
screen: Social,
navigationOptions: {
tabBarIcon: ({tintColor}) => (
<Icon name="ios-mail" color={tintColor} size={30}/>
)
},
},
Scan: {
screen: Scan,
navigationOptions: {
tabBarIcon: ({tintColor}) => (
<Icon name="ios-qr-scanner" color={tintColor} size={45}/>
),
},
},
Calendar: {
screen: Calendar,
@ -41,26 +72,6 @@ const AppStack = createBottomTabNavigator(
)
},
},
Social: {
screen: Social,
navigationOptions: {
tabBarIcon: ({tintColor}) => (
<Icon name="ios-mail" color={tintColor} size={30}/>
)
},
},
Scan: {
screen: Scan,
navigationOptions: {
tabBarIcon: ({tintColor}) => (
<Icon name="ios-qr-scanner" color={tintColor} size={45}/>
),
},
},
Eventos: {
screen: Eventos,
@ -72,15 +83,7 @@ const AppStack = createBottomTabNavigator(
)
},
},
Home: {
screen: Home,
navigationOptions: {
tabBarIcon: ({tintColor}) => (
<Icon name="md-home" color={tintColor} size={30}/>
)
},
},
},
{
@ -111,30 +114,33 @@ const AuthStack = createStackNavigator(
}*/
);
const Stack = createStackNavigator({
tabs: {
screen: AppStack,
navigationOptions: ({navigation}) => {
const index = navigation.state.index;
if (navigation.state.routes[index].routeName !== 'Scan') {
return {
headerTitle: `${navigation.state.routes[index].routeName}`,
headerRight: (
<TouchableOpacity style={{marginRight: 20}} onPress={() => navigation.navigate('Home')}>
<IconFA name="user-edit" size={22}/>
</TouchableOpacity>
)
}
} else {
return {
header: null
}
const Stack = createStackNavigator({
tabs: {
screen: AppStack,
navigationOptions: ({navigation}) => {
const index = navigation.state.index;
if (navigation.state.routes[index].routeName !== 'Scan') {
return {
headerTitle: `${navigation.state.routes[index].routeName}`,
headerRight: (
<TouchableOpacity style={{marginRight: 20}} onPress={() => navigation.navigate('Profile')}>
<IconFA name="user-edit" size={22}/>
</TouchableOpacity>
)
}
} else {
return {
header: null
}
}
}
});
},
Profile: {
screen: Profile
}
});
export default createAppContainer(createSwitchNavigator(

View File

@ -2,11 +2,11 @@ export const DATA_AVAILABLE = 'DATA_AVAILABLE';
export const API_LOGIN = 'API_LOGIN';
export const CHECK_USER='CHECK_USER';
export const LOGOUT_USER= 'LOGOUT_USER';
export const USER_INFO= 'USER_INFO'
export const HOLD='HOLD'
export const GET_EVENTS='GET_EVENTS'
import { AsyncStorage } from 'react-native';
@ -85,8 +85,8 @@ const saveToken = async token => {
const getToken = async () => {
obj={}
try {
@ -187,6 +187,7 @@ export function login(user, pass){
fetch('http://enei2019.uingress.com/internal/api/token', {
method: 'POST',
headers: {
@ -208,6 +209,7 @@ export function login(user, pass){
tokenData:'error'
});
}).then(res=>res.json()).then(parsed=>{
var obj={
@ -277,8 +279,7 @@ export function hold(){
export function getUserInfo(token){
return (dispatch)=>{
//TODO: verificar validade do token
console.log('Chamada "getUserInfo"');
@ -288,7 +289,8 @@ export function getUserInfo(token){
method: 'GET',
headers: {
'Authorization':"Bearer "+token.access_token,
'Authorization':`Bearer ${token.access_token}`,
},
}
@ -297,7 +299,7 @@ export function getUserInfo(token){
.then(function(res) {
var obj = JSON.parse(res._bodyText);
let obj = JSON.parse(res._bodyText);
dispatch({ type: USER_INFO, user: obj,onHold:false, logged:true });

View File

@ -23,7 +23,7 @@ import {Provider} from 'react-redux'
class Home extends Component {
constructor(props) {
super(props);
this.state = {
@ -31,9 +31,10 @@ class Home extends Component {
logged:true,
onHold:true,
user:{Name:''}
};
}
componentDidMount() {
@ -41,6 +42,7 @@ class Home extends Component {
this.props.hold();
//this.props.logoutUser();
//console.log(this.props.token);
this.props.getUserInfo(this.props.token);
@ -54,7 +56,10 @@ class Home extends Component {
}
bClick(){
bClick() {
//this.props.logoutUser();
let a={};
// this.setState({ user: this.props.user });
@ -62,7 +67,6 @@ class Home extends Component {
//
//var navigate = this.props.navigation.navigate
}
@ -104,8 +108,7 @@ class Home extends Component {
if(this.props.onHold){
return (
return (
<View>
<Text>lollsss {this.props.onHold}</Text>
<ActivityIndicator size="large" color="#0000ff" />
@ -114,10 +117,9 @@ class Home extends Component {
}
if(this.props.logged){
return (
<View >
<View>
<Button onPress={this._logout} title="LOGOUT"/>
<Button onPress={this.update} title="update"/>
@ -128,28 +130,28 @@ class Home extends Component {
<Text> phone: {this.props.user.Mobile}</Text>
</View>
);
}
else{
else {
return (
<View >
<Text>sem permissões para aceder aqui</Text>
<View>
<Text>sem permissões para aceder aqui</Text>
</View>
);
}
}
renderItem({item, index}) {
return (
<View>
<Text >
<Text>
{(parseInt(index) + 1)}{". "}{item.title}
</Text>
<Text >
<Text>
{item.description}
</Text>
</View>
@ -162,13 +164,13 @@ class Home extends Component {
function mapStateToProps(state, props) {
return {
token: state.apiReducer.token,
user: state.apiReducer.user,
logged: state.apiReducer.logged
}
}

200
App/app/screens/Profile.js Normal file
View File

@ -0,0 +1,200 @@
import React, {Component} from 'react'
import {Card, Icon} from 'react-native-elements'
import {
Image,
ImageBackground,
Linking,
ListView,
Platform,
ScrollView,
StyleSheet,
Text,
View,
TouchableOpacity
} from 'react-native'
import PropTypes from 'prop-types';
import {connect, Provider} from "react-redux";
import {bindActionCreators} from "redux";
import * as Actions from "../actions";
import {createStore} from 'redux';
class Profile extends Component {
constructor(props) {
super(props);
this.state = {
token: false,
tokenData: '',
loggedIn: false,
onHold: true,
user: {}
};
}
/*
state = {
telDS: new ListView.DataSource({
rowHasChanged: (r1, r2) => r1 !== r2,
}).cloneWithRows(this.props.tels),
emailDS: new ListView.DataSource({
rowHasChanged: (r1, r2) => r1 !== r2,
}).cloneWithRows(this.props.emails),
};
*/
onPressPlace = () => {
console.log('place')
};
onPressTel = number => {
Linking.openURL(`tel://${number}`).catch(err =>
console.log('Error:', err))
};
onPressSms = () => {
console.log('sms')
};
onPressEmail = email => {
Linking.openURL(`mailto:${email}-+`).catch(err =>
console.log('Error:', err)
)
};
renderHeader = () => {
/* const {
avatar,
avatarBackground,
name,
address: {city, country},
} = this.props;*/
return (
<View style={styles.header}>
<View style={styles.headerContent}>
<Image style={styles.avatar}
source={{uri: `${this.props.user.Avatar}`}}/>
<Text style={styles.name}> {this.props.user.Name} {this.props.user.LastName}</Text>
<Text style={styles.userInfo}> {this.props.user.City} </Text>
</View>
</View>
)
};
renderTel = () => {
return (
<View style={styles.telContainer}>
<TouchableOpacity onPress={() => this.onPressTel(`${this.props.user.Mobile}`)}>
<Text>{this.props.user.Mobile}</Text>
</TouchableOpacity>
</View>
)
};
/* <ListView
contentContainerStyle={styles.telContainer}
/*dataSource={this.state.telDS}
renderRow = {({id, name, number}, _, k)
=>
{
}
}
/>}*/
renderEmail = () => {
return (
<View styles={styles.emailContainer}>
<TouchableOpacity onPress={() => this.onPressEmail(`${this.props.user.Email}`)}>
<Text>{this.props.user.Email} </Text>
</TouchableOpacity>
</View>
)
/* <ListView
contentContainerStyle={styles.emailContainer}
/*dataSource={this.state.emailDS}
renderRow={({email, id, name}, _, k) => {
}}
/>*/
};
render() {
return (
<ScrollView style={styles.scroll}>
<View style={styles.container}>
{this.renderHeader()}
<View style={styles.body}>
{this.renderTel()}
{this.renderEmail()}
</View>
</View>
</ScrollView>
)
}
}
const styles = StyleSheet.create({
scroll: {
backgroundColor: '#FFF',
},
emailContainer: {
backgroundColor: '#FFF',
flex: 1,
paddingTop: 30,
},
telContainer: {
backgroundColor: '#FFF',
flex: 1,
paddingTop: 30,
},
header: {
backgroundColor: "#DCDCDC",
},
headerContent: {
padding: 30,
alignItems: 'center',
},
avatar: {
width: 130,
height: 130,
borderRadius: 63,
borderWidth: 4,
borderColor: "white",
marginBottom: 10,
},
userInfo: {
fontSize: 16,
color: "#778899",
fontWeight: '600',
},
});
mapStateToProps = (state, props) => {
return {
token: state.apiReducer.token,
user: state.apiReducer.user
}
};
function mapDispatchToProps(dispatch) {
return bindActionCreators(Actions, dispatch);
}
export default connect(mapStateToProps, mapDispatchToProps)(Profile);

View File

@ -35,6 +35,6 @@ getPersonalInfo(){
;
}
}
};
export default api;

71
App/package-lock.json generated
View File

@ -2038,6 +2038,15 @@
"object-visit": "^1.0.0"
}
},
"color": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/color/-/color-3.1.0.tgz",
"integrity": "sha512-CwyopLkuRYO5ei2EpzpIh6LqJMt6Mt+jZhO5VI5f/wJLZriXQE32/SSqzmrh+QB+AZT81Cj8yv+7zwToW8ahZg==",
"requires": {
"color-convert": "^1.9.1",
"color-string": "^1.5.2"
}
},
"color-convert": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
@ -2051,6 +2060,15 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
},
"color-string": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/color-string/-/color-string-1.5.3.tgz",
"integrity": "sha512-dC2C5qeWoYkxki5UAXapdjqO672AM4vZuPGRQfO8b5HKuKGBbKWpITyDYN7TOFKvRW7kOgAn3746clDBMDJyQw==",
"requires": {
"color-name": "^1.0.0",
"simple-swizzle": "^0.2.2"
}
},
"color-support": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz",
@ -5507,6 +5525,11 @@
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg=="
},
"lodash.merge": {
"version": "4.6.1",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.1.tgz",
"integrity": "sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ=="
},
"lodash.pad": {
"version": "4.5.1",
"resolved": "https://registry.npmjs.org/lodash.pad/-/lodash.pad-4.5.1.tgz",
@ -6346,6 +6369,11 @@
"mimic-fn": "^1.0.0"
}
},
"opencollective-postinstall": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/opencollective-postinstall/-/opencollective-postinstall-2.0.1.tgz",
"integrity": "sha512-saQQ9hjLwu/oS0492eyYotoh+bra1819cfAT5rjY/e4REWwuc8IgZ844Oo44SiftWcJuBiqp0SA0BFVbmLX0IQ=="
},
"opn": {
"version": "3.0.3",
"resolved": "http://registry.npmjs.org/opn/-/opn-3.0.3.tgz",
@ -6890,6 +6918,20 @@
"prop-types": "^15.5.10"
}
},
"react-native-elements": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/react-native-elements/-/react-native-elements-1.0.0.tgz",
"integrity": "sha512-m5kzFCOIEyoY5qTYn6c2n9AYodn1Ol4tVNEaQ5wVXwaDDNyafshqXQ3QmYUWW8yfogMmCdLSi0KfQmYQNElEtA==",
"requires": {
"color": "^3.1.0",
"hoist-non-react-statics": "^3.1.0",
"lodash.merge": "^4.6.1",
"opencollective-postinstall": "^2.0.0",
"prop-types": "^15.5.8",
"react-native-ratings": "^6.3.0",
"react-native-status-bar-height": "^2.2.0"
}
},
"react-native-gesture-handler": {
"version": "1.0.15",
"resolved": "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-1.0.15.tgz",
@ -6948,6 +6990,15 @@
"react-native-permissions": "^1.1.1"
}
},
"react-native-ratings": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/react-native-ratings/-/react-native-ratings-6.3.0.tgz",
"integrity": "sha512-vjzsTM4L3J3n0X9fJMFSJ3ZUqbPp2ExZtgg/Ycst9SqwiHCOouEwEpEcLF+KzYp3MgL62ZACIKSUyfWIIdBafA==",
"requires": {
"lodash": "^4.17.4",
"prop-types": "^15.5.10"
}
},
"react-native-safe-area-view": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/react-native-safe-area-view/-/react-native-safe-area-view-0.11.0.tgz",
@ -6968,6 +7019,11 @@
"resolved": "https://registry.npmjs.org/react-native-screens/-/react-native-screens-1.0.0-alpha.19.tgz",
"integrity": "sha512-+a7GdwzLWYWYVUJMg+XuyBoRFGD8GdGyBfebuTNBY+xwUZpTXCaK/GlLGL6EE3h0iBHZu83do7zViEailWRNyA=="
},
"react-native-status-bar-height": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/react-native-status-bar-height/-/react-native-status-bar-height-2.2.0.tgz",
"integrity": "sha512-4WJpyZirzeMHyZiyNEy4LnSPOtuLRVy3+28Rhz7ffrjCVcc5RFcC0HVjFnkwfuhcTyXIDtzPG6canJkXzbTtBA=="
},
"react-native-tab-view": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/react-native-tab-view/-/react-native-tab-view-1.3.1.tgz",
@ -7937,6 +7993,21 @@
}
}
},
"simple-swizzle": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz",
"integrity": "sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo=",
"requires": {
"is-arrayish": "^0.3.1"
},
"dependencies": {
"is-arrayish": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz",
"integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ=="
}
}
},
"sisteransi": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-0.1.1.tgz",

View File

@ -14,6 +14,7 @@
"react-native-app-intro-slider": "^1.0.1",
"react-native-camera": "^1.9.2",
"react-native-confirmation-code-input": "^1.0.4",
"react-native-elements": "^1.0.0",
"react-native-gesture-handler": "^1.0.15",
"react-native-ionicons": "^4.5.5",
"react-native-loader": "^1.2.1",