/**
 * 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 { push,tab } from '../BasicNavigator/actions';


type Props = {};

class JSPage extends Component<Props> {
  render() {
    console.log('JSPage', this.props);
    return (
      <View style={styles.container}>
        <TouchableOpacity onPress={() => { this.props.push('NativePage'); }}>
          <Text style={styles.instructions}>JSPage</Text>
        </TouchableOpacity>
        <TouchableOpacity onPress={() => { this.props.tab('ServicePage'); }}>
          <Text style={styles.instructions}>Tab切换</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) {
  const { nav } = props
  return {
    nav,
  };
}
function actionMapping(dispatch) {
  return {
    push: compose(dispatch, push),
    tab: compose(dispatch, tab),
  };
}
//const mapDispatchToProps = dispatch => (bindActionCreators({goNext}, dispatch))

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