Authored by 张丽霞

分期列表动画,review by 孙凯

... ... @@ -9,6 +9,7 @@ import ReactNative, {
PixelRatio,
TouchableOpacity,
ListView,
LayoutAnimation,
} from 'react-native';
import Immutable, {Map} from 'immutable';
... ... @@ -25,6 +26,43 @@ export default class RepayList extends React.Component {
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
});
this.state = {
bottomContainerPosition_x: -57.5 * DEVICE_WIDTH_RATIO,
animationOnceDone: false,
}
}
componentWillMount() {
LayoutAnimation.linear();
}
componentWillUpdate(nextProps,nextState){
let preFormateData = this.props.repayList.formateData;
let nextFormateData = nextProps.repayList.formateData;
let targetBottom = -1;
if(preFormateData!=nextFormateData && this.state.animationOnceDone){
if (preFormateData.get('currAmtCount') && !nextFormateData.get('currAmtCount')) {
targetBottom = -57.5 * DEVICE_WIDTH_RATIO;
}else if (!preFormateData.get('currAmtCount') && nextFormateData.get('currAmtCount')) {
targetBottom = 0;
}
if (targetBottom != -1) {
LayoutAnimation.linear();
this.setState({bottomContainerPosition_x: targetBottom});
}
}
}
componentDidMount() {
this.timer = setTimeout(() => {
LayoutAnimation.linear();
this.setState({bottomContainerPosition_x: 0, animationOnceDone: true});
},
1000
);
}
componentWillUnmount() {
this.timer && clearTimeout(this.timer);
}
_renderRow(rowData, sectionID, rowID, highlightRow) {
... ... @@ -88,14 +126,14 @@ export default class RepayList extends React.Component {
:null
}
{repaymentList.length?
<View style={styles.bottomContainer}>
<View style={[styles.bottomContainer, {bottom:this.state.bottomContainerPosition_x}]}>
<View style={styles.repaymentTotalContainer}>
<TouchableOpacity onPress={() => {this.props.onPressCheckAll &&this.props.onPressCheckAll()}} >
<Image style={styles.checkboxIcon} source={checkboxIcon}/>
</TouchableOpacity>
<View style={styles.repaymentTotal}>
<Text style={{fontSize:14*DEVICE_WIDTH_RATIO}}>待支付:
<Text style={{color:'#d2000d'}}>¥{formateData.currAmtCount?formateData.currAmtCount:''}</Text>
<Text style={{color:'#d2000d'}}>¥{formateData.currAmtCount?formateData.currAmtCount:'0.00'}</Text>
</Text>
{formateData.isCurrFee?
<Text>含逾期服务费¥{formateData.currFeeCount}</Text>
... ... @@ -190,7 +228,7 @@ let styles = StyleSheet.create({
width: width,
height: 57.5 * DEVICE_WIDTH_RATIO,
position: 'absolute',
bottom: 0,
bottom: -57.5 * DEVICE_WIDTH_RATIO,
backgroundColor: 'white',
flexDirection: 'row',
justifyContent: 'space-between',
... ...