|
@@ -5,15 +5,17 @@
|
|
|
import React, { Component } from 'react';
|
|
import React, { Component } from 'react';
|
|
|
import { View, Text, StyleSheet, Image, ScrollView, Switch, Pressable } from 'react-native';
|
|
import { View, Text, StyleSheet, Image, ScrollView, Switch, Pressable } from 'react-native';
|
|
|
import apiUser from '../../api/apiUser';
|
|
import apiUser from '../../api/apiUser';
|
|
|
-import { host } from '../../api/http';
|
|
|
|
|
|
|
+import { setAccessToken } from '../../api/http';
|
|
|
import Button, { ElevationObject } from '../../components/Button';
|
|
import Button, { ElevationObject } from '../../components/Button';
|
|
|
import Dialog from '../../components/Dialog';
|
|
import Dialog from '../../components/Dialog';
|
|
|
import { StationBack } from '../../components/Toolbar';
|
|
import { StationBack } from '../../components/Toolbar';
|
|
|
import ProfileBackground from '../../icons/ProfileBackground';
|
|
import ProfileBackground from '../../icons/ProfileBackground';
|
|
|
import TopChargeBackground from '../../icons/TopChargeBackground';
|
|
import TopChargeBackground from '../../icons/TopChargeBackground';
|
|
|
|
|
+import { getStorageJsonSync, setStorage, setStorageJson } from '../../utils/storage';
|
|
|
import utils from '../../utils/utils';
|
|
import utils from '../../utils/utils';
|
|
|
import { PageList } from '../Router';
|
|
import { PageList } from '../Router';
|
|
|
import VehicleList from './VehicleList';
|
|
import VehicleList from './VehicleList';
|
|
|
|
|
+
|
|
|
export default class Profile extends Component {
|
|
export default class Profile extends Component {
|
|
|
constructor(props) {
|
|
constructor(props) {
|
|
|
super(props);
|
|
super(props);
|
|
@@ -89,9 +91,9 @@ export default class Profile extends Component {
|
|
|
|
|
|
|
|
deleteAccount() {
|
|
deleteAccount() {
|
|
|
Dialog.showDialog({
|
|
Dialog.showDialog({
|
|
|
- title: 'Delete My Account',
|
|
|
|
|
- message: 'Are you sure you want to delete your account? This operation cannot be revoke.',
|
|
|
|
|
- ok: 'CONFIRM',
|
|
|
|
|
|
|
+ title: $t('profile.deleteAccount'),
|
|
|
|
|
+ message: $t('profile.confirmDeleteAccount'),
|
|
|
|
|
+ ok: $t('nav.confirm'),
|
|
|
callback: button => {
|
|
callback: button => {
|
|
|
if (button == Dialog.BUTTON_OK) {
|
|
if (button == Dialog.BUTTON_OK) {
|
|
|
this.deleteMyAccount();
|
|
this.deleteMyAccount();
|
|
@@ -103,7 +105,7 @@ export default class Profile extends Component {
|
|
|
deleteMyAccount() {
|
|
deleteMyAccount() {
|
|
|
Dialog.showProgressDialog();
|
|
Dialog.showProgressDialog();
|
|
|
apiUser.deleteAccount().then(res => {
|
|
apiUser.deleteAccount().then(res => {
|
|
|
- toastShort('Successfully deleted!')
|
|
|
|
|
|
|
+ toastShort($t('profile.deleteAccountSuccess'))
|
|
|
Dialog.dismissLoading();
|
|
Dialog.dismissLoading();
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
|
startPage(PageList.login);
|
|
startPage(PageList.login);
|
|
@@ -114,6 +116,38 @@ export default class Profile extends Component {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ logout() {
|
|
|
|
|
+ Dialog.showDialog({
|
|
|
|
|
+ title: $t('profile.signOut'),
|
|
|
|
|
+ message: $t('profile.tipSignOut'),
|
|
|
|
|
+ callback: btn => {
|
|
|
|
|
+ if (btn == 'ok') {
|
|
|
|
|
+ Dialog.showProgressDialog();
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ this.requestLogout();
|
|
|
|
|
+ }, 500);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ async requestLogout() {
|
|
|
|
|
+ const data = await getStorageJsonSync('loginData');
|
|
|
|
|
+ if (data && data.email) {
|
|
|
|
|
+ delete data.password
|
|
|
|
|
+ setStorageJson('loginData', data);
|
|
|
|
|
+ setStorage('RegisterTokenDate', "");
|
|
|
|
|
+ }
|
|
|
|
|
+ global.userInfo = {}
|
|
|
|
|
+ /*this.setState({
|
|
|
|
|
+ isLogin: false,
|
|
|
|
|
+ userInfo: {}
|
|
|
|
|
+ });*/
|
|
|
|
|
+ setAccessToken('');
|
|
|
|
|
+ goBack();
|
|
|
|
|
+ Dialog.dismissLoading();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
render() {
|
|
render() {
|
|
|
return (
|
|
return (
|
|
|
<ScrollView style={styles.container}>
|
|
<ScrollView style={styles.container}>
|
|
@@ -133,10 +167,10 @@ export default class Profile extends Component {
|
|
|
{ userInfo.photoUrl
|
|
{ userInfo.photoUrl
|
|
|
? <Image
|
|
? <Image
|
|
|
style={styles.avatar}
|
|
style={styles.avatar}
|
|
|
- source={{uri: host + userInfo.photoUrl}}/>
|
|
|
|
|
|
|
+ source={{uri: utils.getImageUrl(userInfo.photoUrl)}}/>
|
|
|
: <Image
|
|
: <Image
|
|
|
style={styles.avatar}
|
|
style={styles.avatar}
|
|
|
- source={require('../../images/user/icon-default.jpg')}/>
|
|
|
|
|
|
|
+ source={require('../../images/user/ic-avatar-default.png')}/>
|
|
|
}
|
|
}
|
|
|
<View style={styles.infoContent}>
|
|
<View style={styles.infoContent}>
|
|
|
<Text
|
|
<Text
|
|
@@ -148,7 +182,7 @@ export default class Profile extends Component {
|
|
|
</View>
|
|
</View>
|
|
|
<FontAwesome
|
|
<FontAwesome
|
|
|
size={34}
|
|
size={34}
|
|
|
- color='#333'
|
|
|
|
|
|
|
+ color={colorDark}
|
|
|
name='angle-right'/>
|
|
name='angle-right'/>
|
|
|
</Pressable>
|
|
</Pressable>
|
|
|
<StationBack bottom={52} scale={0.8}/>
|
|
<StationBack bottom={52} scale={0.8}/>
|
|
@@ -174,7 +208,7 @@ export default class Profile extends Component {
|
|
|
startPage(PageList.wallet);
|
|
startPage(PageList.wallet);
|
|
|
}}>
|
|
}}>
|
|
|
<Text style={styles.cardPrimary}>{currency}{userInfo.credit}</Text>
|
|
<Text style={styles.cardPrimary}>{currency}{userInfo.credit}</Text>
|
|
|
- <Text style={styles.cardLabel}>Credits</Text>
|
|
|
|
|
|
|
+ <Text style={styles.cardLabel}>Credit Wallet</Text>
|
|
|
</Pressable>
|
|
</Pressable>
|
|
|
</View>
|
|
</View>
|
|
|
</View>
|
|
</View>
|
|
@@ -182,14 +216,14 @@ export default class Profile extends Component {
|
|
|
<View style={styles.titleView}>
|
|
<View style={styles.titleView}>
|
|
|
<Text style={styles.title}>My Vehicles</Text>
|
|
<Text style={styles.title}>My Vehicles</Text>
|
|
|
<Button
|
|
<Button
|
|
|
- style={{backgroundColor: '#fff'}}
|
|
|
|
|
|
|
+ style={{backgroundColor: colorLight}}
|
|
|
borderRadius={3}
|
|
borderRadius={3}
|
|
|
viewStyle={styles.titleAdd}
|
|
viewStyle={styles.titleAdd}
|
|
|
onClick={() => {
|
|
onClick={() => {
|
|
|
startPage(PageList.addVehicle)
|
|
startPage(PageList.addVehicle)
|
|
|
}}>
|
|
}}>
|
|
|
- <Entypo name='plus' size={14} color='#333'/>
|
|
|
|
|
- <Text style={{fontSize: 12, paddingLeft: 1, color: '#333'}}>Add Vehicle</Text>
|
|
|
|
|
|
|
+ <Entypo name='plus' size={14} color={colorDark}/>
|
|
|
|
|
+ <Text style={{fontSize: 12, paddingLeft: 1, color: textPrimary}}>Add Vehicle</Text>
|
|
|
</Button>
|
|
</Button>
|
|
|
</View>
|
|
</View>
|
|
|
<View style={styles.verhicleList}>
|
|
<View style={styles.verhicleList}>
|
|
@@ -207,12 +241,12 @@ export default class Profile extends Component {
|
|
|
{/* <View style={styles.titleView}>
|
|
{/* <View style={styles.titleView}>
|
|
|
<Text style={styles.title}>My Cards</Text>
|
|
<Text style={styles.title}>My Cards</Text>
|
|
|
<Button
|
|
<Button
|
|
|
- textColor='#333'
|
|
|
|
|
|
|
+ textColor={textPrimary}
|
|
|
style={styles.titleAdd}
|
|
style={styles.titleAdd}
|
|
|
onClick={() => {
|
|
onClick={() => {
|
|
|
startPage(PageList.addCard)
|
|
startPage(PageList.addCard)
|
|
|
}}>
|
|
}}>
|
|
|
- <Entypo name='plus' size={14} color='#333'/>
|
|
|
|
|
|
|
+ <Entypo name='plus' size={14} color={colorDark}/>
|
|
|
<Text style={{fontSize: 12, paddingLeft: 1}}>Add Card</Text>
|
|
<Text style={{fontSize: 12, paddingLeft: 1}}>Add Card</Text>
|
|
|
</Button>
|
|
</Button>
|
|
|
</View>
|
|
</View>
|
|
@@ -244,7 +278,7 @@ export default class Profile extends Component {
|
|
|
onPress={() => {
|
|
onPress={() => {
|
|
|
this.changeSwitch("notifyLowBalance", !userInfo.notifyLowBalance);
|
|
this.changeSwitch("notifyLowBalance", !userInfo.notifyLowBalance);
|
|
|
}}>
|
|
}}>
|
|
|
- <Text style={styles.notiLabel}>Notify me when credits is low balance</Text>
|
|
|
|
|
|
|
+ <Text style={styles.notiLabel}>Notify me when wallet is low balance</Text>
|
|
|
<Switch
|
|
<Switch
|
|
|
value={this.state.userInfo.notifyLowBalance}
|
|
value={this.state.userInfo.notifyLowBalance}
|
|
|
trackColor={isIOS ? { false: "#B2B2B2", true: colorAccent } : null}
|
|
trackColor={isIOS ? { false: "#B2B2B2", true: colorAccent } : null}
|
|
@@ -270,9 +304,15 @@ export default class Profile extends Component {
|
|
|
<Button
|
|
<Button
|
|
|
style={styles.deleteButton}
|
|
style={styles.deleteButton}
|
|
|
text="DELETE MY ACCOUNT"
|
|
text="DELETE MY ACCOUNT"
|
|
|
- textColor="#fff"
|
|
|
|
|
|
|
+ textColor={textButton}
|
|
|
onClick={() => this.deleteAccount()}
|
|
onClick={() => this.deleteAccount()}
|
|
|
/>
|
|
/>
|
|
|
|
|
+ <Button
|
|
|
|
|
+ style={styles.deleteButton}
|
|
|
|
|
+ text="Logout"
|
|
|
|
|
+ textColor={textButton}
|
|
|
|
|
+ onClick={() => this.logout()}
|
|
|
|
|
+ />
|
|
|
</ScrollView>
|
|
</ScrollView>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
@@ -281,7 +321,7 @@ export default class Profile extends Component {
|
|
|
const styles = StyleSheet.create({
|
|
const styles = StyleSheet.create({
|
|
|
container: {
|
|
container: {
|
|
|
flex: 1,
|
|
flex: 1,
|
|
|
- backgroundColor: 'white'
|
|
|
|
|
|
|
+ backgroundColor: pageBackground
|
|
|
},
|
|
},
|
|
|
headerView: {
|
|
headerView: {
|
|
|
paddingBottom: 72
|
|
paddingBottom: 72
|
|
@@ -305,7 +345,7 @@ const styles = StyleSheet.create({
|
|
|
height: 66,
|
|
height: 66,
|
|
|
borderWidth: 2,
|
|
borderWidth: 2,
|
|
|
borderRadius: 80,
|
|
borderRadius: 80,
|
|
|
- borderColor: '#fff'
|
|
|
|
|
|
|
+ borderColor: colorLight
|
|
|
},
|
|
},
|
|
|
infoContent: {
|
|
infoContent: {
|
|
|
flex: 1,
|
|
flex: 1,
|
|
@@ -318,7 +358,7 @@ const styles = StyleSheet.create({
|
|
|
paddingBottom: 1.5,
|
|
paddingBottom: 1.5,
|
|
|
},
|
|
},
|
|
|
userText: {
|
|
userText: {
|
|
|
- color: '#333',
|
|
|
|
|
|
|
+ color: textPrimary,
|
|
|
fontSize: 13,
|
|
fontSize: 13,
|
|
|
paddingTop: 1.5
|
|
paddingTop: 1.5
|
|
|
},
|
|
},
|
|
@@ -331,7 +371,7 @@ const styles = StyleSheet.create({
|
|
|
...ElevationObject(2),
|
|
...ElevationObject(2),
|
|
|
alignItems: 'center',
|
|
alignItems: 'center',
|
|
|
flexDirection: 'row',
|
|
flexDirection: 'row',
|
|
|
- backgroundColor: 'white',
|
|
|
|
|
|
|
+ backgroundColor: colorLight,
|
|
|
},
|
|
},
|
|
|
cardItem: {
|
|
cardItem: {
|
|
|
flex: 1,
|
|
flex: 1,
|
|
@@ -352,12 +392,12 @@ const styles = StyleSheet.create({
|
|
|
alignItems: 'center'
|
|
alignItems: 'center'
|
|
|
},
|
|
},
|
|
|
cardPrimary: {
|
|
cardPrimary: {
|
|
|
- color: '#333',
|
|
|
|
|
|
|
+ color: textPrimary,
|
|
|
fontSize: 18,
|
|
fontSize: 18,
|
|
|
paddingBottom: 2
|
|
paddingBottom: 2
|
|
|
},
|
|
},
|
|
|
cardLabel: {
|
|
cardLabel: {
|
|
|
- color: '#333',
|
|
|
|
|
|
|
+ color: textPrimary,
|
|
|
fontSize: 13,
|
|
fontSize: 13,
|
|
|
},
|
|
},
|
|
|
titleView: {
|
|
titleView: {
|
|
@@ -373,7 +413,7 @@ const styles = StyleSheet.create({
|
|
|
},
|
|
},
|
|
|
titleAdd: {
|
|
titleAdd: {
|
|
|
padding: 8,
|
|
padding: 8,
|
|
|
- color: '#333',
|
|
|
|
|
|
|
+ color: textPrimary,
|
|
|
alignItems: 'center',
|
|
alignItems: 'center',
|
|
|
flexDirection: 'row'
|
|
flexDirection: 'row'
|
|
|
},
|
|
},
|
|
@@ -397,7 +437,7 @@ const styles = StyleSheet.create({
|
|
|
paddingRight: 16,
|
|
paddingRight: 16,
|
|
|
borderColor: '#f5f5f5',
|
|
borderColor: '#f5f5f5',
|
|
|
borderWidth: 1,
|
|
borderWidth: 1,
|
|
|
- backgroundColor: 'white',
|
|
|
|
|
|
|
+ backgroundColor: colorLight,
|
|
|
...ElevationObject(1.5)
|
|
...ElevationObject(1.5)
|
|
|
},
|
|
},
|
|
|
notificationItem: {
|
|
notificationItem: {
|
|
@@ -408,7 +448,7 @@ const styles = StyleSheet.create({
|
|
|
},
|
|
},
|
|
|
notiLabel: {
|
|
notiLabel: {
|
|
|
flex: 1,
|
|
flex: 1,
|
|
|
- color: '#333',
|
|
|
|
|
|
|
+ color: textPrimary,
|
|
|
fontSize: 14
|
|
fontSize: 14
|
|
|
},
|
|
},
|
|
|
divide: {
|
|
divide: {
|