index.js 3.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
import React, {Component} from 'react';
import {View, Text, Image, StyleSheet} from 'react-native';
import TabNavigator from 'react-native-tab-navigator';
import Map from '../Map';
import Study from '../Study';
import Mine from '../Mine';
class Navigation extends Component {
  constructor(props) {
    super(props);
    this.state = {selectedTab: '地图'};
  }

  render() {
    return (
      <TabNavigator
        tabBarStyle={{
          height: 'auto',
YYYTDMS's avatar
YYYTDMS 已提交
18 19 20
          borderStyle: 'solid',
          backgroundColor: '#CE9561',
          paddingBottom: 0,
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
        }}>
        <TabNavigator.Item
          selected={this.state.selectedTab === '地图'}
          title="地图"
          titleStyle={styles.tabText}
          selectedTitleStyle={styles.selectedTabText}
          renderIcon={() => (
            <Image
              style={styles.icon}
              source={require('../../images/Navigation/map.png')}
            />
          )}
          renderSelectedIcon={() => (
            <Image
              style={styles.icon}
              source={require('../../images/Navigation/sel_map.png')}
            />
          )}
YYYTDMS's avatar
YYYTDMS 已提交
39 40 41 42
          onPress={() => {
            this.setState({selectedTab: '地图'});
            this.props.changeName('地图');
          }}>
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
          <Map />
        </TabNavigator.Item>

        <TabNavigator.Item
          selected={this.state.selectedTab === '自习'}
          title="自习"
          titleStyle={styles.tabText}
          selectedTitleStyle={styles.selectedTabText}
          renderIcon={() => (
            <Image
              style={styles.icon}
              source={require('../../images/Navigation/study.png')}
            />
          )}
          renderSelectedIcon={() => (
            <Image
              style={styles.icon}
              source={require('../../images/Navigation/sel_study.png')}
            />
          )}
YYYTDMS's avatar
YYYTDMS 已提交
63 64 65 66
          onPress={() => {
            this.setState({selectedTab: '自习'});
            this.props.changeName('自习');
          }}>
ItbGcthate's avatar
ItbGcthate 已提交
67
          <Study navi={this.props.navi} />
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
        </TabNavigator.Item>

        <TabNavigator.Item
          selected={this.state.selectedTab === ''}
          title=""
          titleStyle={styles.tabText}
          selectedTitleStyle={styles.selectedTabText}
          renderIcon={() => (
            <Image
              style={styles.icon}
              source={require('../../images/Navigation/mine.png')}
            />
          )}
          renderSelectedIcon={() => (
            <Image
              style={styles.icon}
              source={require('../../images/Navigation/sel_mine.png')}
            />
          )}
YYYTDMS's avatar
YYYTDMS 已提交
87 88 89 90
          onPress={() => {
            this.setState({selectedTab: ''});
            this.props.changeName('');
          }}>
YYYTDMS's avatar
YYYTDMS 已提交
91
          <Mine changeName={this.props.changeName} />
92 93 94 95 96
        </TabNavigator.Item>
      </TabNavigator>
    );
  }
}
YYYTDMS's avatar
YYYTDMS 已提交
97

98 99 100
const styles = StyleSheet.create({
  container: {
    backgroundColor: '#F2E2CE',
ItbGcthate's avatar
ItbGcthate 已提交
101
    //opacity: 0.5,
102 103 104
    flex: 1,
  },
  icon: {
YYYTDMS's avatar
YYYTDMS 已提交
105
    height: 30,
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
    width: 40,
  },
  tabText: {
    fontSize: 15,
    color: '#9f5022',
    // fontWeight: 'bold',
    textAlign: 'center',
  },
  selectedTabText: {
    fontSize: 15,
    color: '#592202',
    fontWeight: 'bold',
    textAlign: 'center',
  },
});

export default Navigation;