AboutUsContainer.js 1.36 KB
'use strict';

import React from 'react-native';

import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';

import {Map} from 'immutable';

import AboutUs from '../components/AboutUs';

import * as userActions from '../reducers/user/userActions';

let {
    Component,
    View,
    Text,
    Alert,
} = React;

const actions = [
    userActions
];

function mapStateToProps(state) {
    return {
        ...state
    };
};

function mapDispatchToProps(dispatch) {

    const creators = Map()
        .merge(...actions)
        .filter(value => typeof value === 'function')
        .toObject();

    return {
        actions: bindActionCreators(creators, dispatch),
        dispatch
    };
}

class AboutUsContainer extends Component {

    componentWillMount() {
        this.props.actions.checkUpdate();
    }

	render() {
        return (
            <AboutUs showUpdate={this.props.user.isShowUpdate}
                updateVersion={() => {
                    Alert.alert(null,
                    '确认下载更新?',
                    [
                        {text: '确定', onPress: () => this.props.actions.updateVersion(this.props.user.updateUrl)},
                        {text: '取消', onPress: () => {}},
                    ])
                }}/>
        );
    }
}

export default connect(mapStateToProps, mapDispatchToProps)(AboutUsContainer);