/**
* 钱包页面
* @邠心vbe on 2021/05/07
*/
import React, { Component } from 'react';
import { View, StyleSheet, ScrollView, RefreshControl, Image, Pressable } from 'react-native';
import { Balance } from './Payment';
import { PageList } from '../Router';
import History from './History';
import Overview from './Overview';
import { MyRefreshProps } from '../../components/ThemesConfig';
import { ElevationObject } from '../../components/Button';
import TextView from '../../components/TextView';
import Dialog from '../../components/Dialog';
import app from '../../../app.json';
import OverviewV2 from './OverviewV2';
import VbeSkeleton from '../../components/VbeSkeleton';
export default class Wallet extends Component {
constructor(props) {
super(props);
this.state = {
balance: 0,
tabIndex: 0,
refreshing: false,
tabWidth: 0,
tabHeight: 0,
balanceText: '',
pageShown: true,
pageLoaded: false
};
}
componentDidMount() {
this.props.navigation.addListener('focus', () => {
this.onRefresh();
this.setState({
pageShown: true
})
getUserInfo(info => {
this.setState({
balance: info.credit,
balanceText: info.creditStr
})
}, true)
});
this.props.navigation.addListener('blur', () => {
this.setState({
pageShown: false
})
});
if (!app.v3.overview) {
this.props.navigation.addListener('beforeRemove', (e) => {
if (this.state.pageShown) {
e.preventDefault();
Dialog.showProgressDialog();
this.setState({
pageShown: false
}, () => {
setTimeout(() => {
Dialog.dismissLoading();
goBack();
}, 500);
});
}
});
}
setTimeout(() => {
this.setState({
pageLoaded: true
})
}, 300);
}
changeTab(index) {
if (this.state.tabIndex !== index) {
this.setState({
tabIndex: index
});
}
}
onRefresh() {
this.setState({
refreshing: true
});
}
stopRefresh() {
this.setState({
refreshing: false
});
}
tabLayout({nativeEvent}) {
//console.log('tab layout\n\n\n\n\n', nativeEvent.layout);
if (nativeEvent.layout.width) {
this.setState({
tabWidth: nativeEvent.layout.width,
tabHeight: 0.171955 * nativeEvent.layout.width
})
}
}
render() {
if (!this.state.pageLoaded) {
return (
)
}
return (
this.onRefresh()}
/>
}>
{/*
toTopupPage()}/>
*/}
this.tabLayout(props)}>
{ this.state.tabIndex == 0
?
:
}
this.changeTab(0)}>
{$t('wallet.tabOverview')}
this.changeTab(1)}>
{$t('wallet.tabHistory')}
{ app.v3.overview
? this.stopRefresh()}
shown={this.state.tabIndex == 0}/>
: this.stopRefresh()}
shown={this.state.tabIndex == 0}/>
}
this.stopRefresh()}
shown={this.state.tabIndex == 1}/>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f5f5f5'
},
balanceView: {
paddingTop: 12,
paddingLeft: 16,
paddingRight: 16,
paddingBottom: 12,
backgroundColor: colorLight
},
tabView: {
height: 60,
padding: 16,
overflow: 'hidden',
alignItems: 'center',
flexDirection: 'row',
justifyContent: 'center'
},
tabItem: {
flex: 1,
marginTop: -14,
alignItems: 'center',
justifyContent: 'center'
},
tabText: {
color: textSecondary,
fontSize: 16,
paddingTop: 5,
paddingLeft: 36,
paddingRight: 36,
paddingBottom: 5,
},
active: {
color: textPrimary,
fontWeight: 'bold'
},
contentView: {
...$margin(8, 16, 16),
overflow: 'hidden',
borderRadius: 6,
...ElevationObject(5),
backgroundColor: colorLight
},
tabBackgroundLeft: {
top: -1,
left: -1,
right: 0,
paddingRight: 1,
width: $vw(90),
height: $vw(14),
position: 'absolute'
},
tabBackgroundRight: {
top: -1,
left: 0,
right: -1,
paddingRight: 1,
width: $vw(90),
height: $vw(14),
position: 'absolute'
}
})