主界面开发
上一节,我们已经完成了首页的开发,现在,我们继续完成主界面的开发,就是添加底部‘首页’和‘我的’两个tabbar。
在js/文件夹下,新建MainScene.js文件
import React,{Component} from 'react';
import {
View,
Text,
TouchableOpacity,
Image,
StyleSheet,
}from 'react-native';
export default class MainScene extends Component{
constructor(props){
super(props);
this.state={
tabIndex:0,
}
}
render(){
return(
<View style={
{flex:1,justifyContent:'flex-end'}}>
<View style={
{backgroundColor:'#d5d5d5',height:1,}}/>
<View style={
{height:55,flexDirection:'row',justifyContent:'center',alignItems:'center'}}>
<TouchableOpacity style={
{flex:1}} activeOpacity={0.6} onPress={this._onTabPress.bind(this,0)}>
<View style={styles.ItemView}>
<Image
style={
{height:30,width:30}}
source={this.state.tabIndex==0?require('../img/icon_home_select.png'):require('../img/icon_home_unselect.png')}
/>
<Text style={this.state.tabIndex==0?styles.TabTextSelect:styles.TabTextUnSelect}>首页</Text>
</View>
</TouchableOpacity>
<TouchableOpacity style={
{flex:1}} activeOpacity={0.6} onPress={this._onTabPress.bind(this,1)}>
<View style={styles.ItemView}>
<Image
style={
{height:30,width:30}}
source={this.state.tabIndex==0?require('../