reactnative tabnavigator

这种效果相信大家见的很多,那么是怎么实现的呢?使用的是reactNavigation

代码如下

import React,{Component} from 'react';
import {
	View,
	Text,
	Image,
	ActivityIndicator,
	StyleSheet,
	Dimensions,
	Animated,
	Easing
} from 'react-native';

import {
	StackNavigator,
	TabNavigator,
} from 'react-navigation'

import ShopInfo from './ShopInfo';
import ShopUrl from './ShopUrl';
import ShopEvaluate from './ShopEvaluate';

const {width,height} = Dimensions.get('window');
const tabWidthPadding = (((width)/3)-30)/2;



const MainScreen = TabNavigator({
	shopInfo:{
		screen:ShopInfo,
		navigationOptions:{
			title:'商品',
		}
	},
	shopUrl:{
		screen:ShopUrl,
		navigationOptions:{
			title:'详情'
		}
	},
	shopEvaluate:{
		screen:ShopEvaluate,
		navigationOptions:{
			title:'评价'
		}
	}
},{
	tabBarOptions:{
		activeTintColor:'#000000',
		inactiveTintColor:'#666666',
		style:{
			backgroundColor:'white',
			height:50,
		},
		indicatorStyle:{
			height:3,
			width:30,
			backgroundColor:'#fa372d',
			marginLeft:tabWidthPadding,
			marginRight:tabWidthPadding,
			justifyContent:'center'
		}
	}
});

const Shop = StackNavigator({
	mainScreen:{
		screen:MainScreen,
		navigationOptions:{
			gesturesEnabled:true,
			header:null
		}
	}
})


export default class ShopHomeInfo extends Component{

	constructor(props){
		super(props)

	}

	render(){
		const {params} = this.props.navigation.state;
		return(
			<View style={styles.container}>
				<Shop style={{flex:1}} />
			</View>
		);
	}
}

const styles = StyleSheet.create({
  container:{
  	width:width,
  	height:height,
  },
})

ShopInfo.js的代码如下

import React,{Component} from 'react';
import {
	View,
	Text,
	Image,
	ScrollView,
	ActivityIndicator,
} from 'react-native';

export default class ShopInfo extends Component{

	constructor(props){
		super(props)
		this.state={

		}
	}

	componentDidMount(){

	}

	render(){
		return(
			<View>
				<Text>商品信息参数是:</Text>
			</View>
		);
	}

}

ShopUrl.js

import React,{Component} from 'react';
import {
	View,
	Text,
	WebView,
	ActivityIndicator,
} from 'react-native';

export default class ShopUrl extends Component{

	render(){
		return(
			<WebView 
				source={{uri:'http://blog.csdn.net/u010648159/article/details/78636281'}}
				style={{flex:1}}
			/>
		);
	}
}

ShopEvaluate.js

import React,{Component} from 'react';
import {
	View,
	Text,
	ActivityIndicator,
} from 'react-native';

export default class ShopEvaluate extends Component{

	render(){
		return(
			<View style={{width:50,height:50}}>
				<Text>商品评价</Text>
			</View>
		);
	}
}

就是这么的简单,如果如果要在导航栏加上左边返回按钮,就比较麻烦了,大家可以想一想啊!!!!


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值