ListContainer.js 2.14 KB
'use strict'

import React, {Component} from 'react';
import ReactNative, {
    StyleSheet,
    Dimensions,
    Platform,
    View,
    Text,
    NativeModules,
    InteractionManager,
    NativeAppEventEmitter,
} from 'react-native'

import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {Map} from 'immutable';
import * as listActions from '../reducers/list/listActions';

import List from '../components/list/List';


const actions = [
    listActions,
];

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 ListContainer extends Component {
    constructor(props) {
        super(props);

        this._onRefresh = this._onRefresh.bind(this);
        this._onEndReached = this._onEndReached.bind(this);

        this.subscription = NativeAppEventEmitter.addListener(
            'ChannelDidChangeEvent',
            (reminder) => {
                this.home && this.home.trigggePullToRefresh();
            }
        );
    }

    componentDidMount() {
        
    }

    componentWillUnmount() {
        this.subscription && this.subscription.remove();
    }

    _onRefresh() {
        InteractionManager.runAfterInteractions(() => {
            
        });
    }

    _onEndReached() {
        InteractionManager.runAfterInteractions(() => {
            
        });
    }

    render() {
        let {sale} = this.props;
        return (
            <View style={styles.container}>
                <List
                    ref={(c) => {
                        this.sale = c;
                    }}
                    data={sale}
                    onRefresh={this._onRefresh}
                    onEndReached={this._onEndReached}
                />
            </View>
        );
    }
}

let styles = StyleSheet.create({
    container: {
        flex: 1,
    },

});

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