/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow
 */

import React, { Component } from 'react';
import {
  Platform, StyleSheet, Text, View, TouchableOpacity,
} from 'react-native';
import { compose } from 'redux';
import { connect } from 'react-redux';
import { pop } from '../BasicNavigator/actions';

type Props = {
  routes: Array,
  pop: () => void
};
class NativePage extends Component<Props> {
  render() {
    console.log('NativePage', this.props);
    return (

      <View style={styles.container}>
        <Text style={styles.instructions}>NativePage</Text>

        <TouchableOpacity onPress={() => {
          console.log('onPress', this.props);
          const { routes } = this.props
          this.props.pop('TabPage');
        }}
        >
          <Text style={styles.instructions}>回首页</Text>
        </TouchableOpacity>
      </View>

    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});
function propsMapping(props, extProps) {
  console.log(extProps);
  const { nav } = props;
  return {
    routes: nav ? nav.routes : [],
  };
}
function actionMapping(dispatch) {
  return {
    pop: compose(dispatch, pop),
  };
}
//const mapDispatchToProps = dispatch => (bindActionCreators({goNext}, dispatch))

export default connect(propsMapping, actionMapping)(NativePage);
