import React from 'react';
import {NavigationContainer} from '@react-navigation/native';
import {createStackNavigator} from '@react-navigation/stack';
//引入各页面
import Xupd from '../pages/xupd';

const routes = {
  Xupd: {
    screen: Xupd,
  },
};

const options = {
  initialRouteName: 'Xupd',
  defaultNavigationOptions: {
    headerTintColor: '#fff',
    headerStyle: {
      backgroundColor: '#fff',
    },
  },
  headerMode: 'none',
  mode: 'card',
  onTransitionStart: (to, from) => {},
  onTransitionEnd: (to, from) => {},
};

const Stack = createStackNavigator();
class Routers extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return (
      <NavigationContainer>
        <Stack.Navigator
          initialRouteName={options.initialRouteName}
          // screenOptions={{
          //   title: 'RainbowDesign 组件列表',
          //   headerStyle: {
          //     backgroundColor: '#ee7530',
          //   },
          //   headerTintColor: '#fff',
          //   headerTitleStyle: {
          //     fontWeight: 'bold',
          //     fontSize: 20,
          //   },
          // }}
        >
          {/* <Stack.Screen name="Xupd" component={Xupd} /> */}
          {Object.keys(routes).map((id) => {
            console.log('=-====routers', id, routes[id].screen, Xupd);
            return (
              <Stack.Screen
                key={id}
                name={id}
                component={routes[id].screen}
                options={{title: id}}
              />
            );
          })}
        </Stack.Navigator>
      </NavigationContainer>
    );
  }
  // render() {
  //   // this.props change options
  //   if (this.props.routerName) {
  //     options.initialRouteName = this.props.routerName;
  //     const keys = Object.keys(routes);
  //     keys.forEach((key) => {
  //       routes[key].params = {};
  //     });
  //     routes[this.props.routerName].params = {
  //       isNative: true,
  //       ...this.props,
  //     };
  //   }
  //   const StackNavigator = createAppContainer(
  //     createStackNavigator(routes, options),
  //   );
  //   return <StackNavigator />;
  // }
}
export default Routers;
