【有用】rn-viewpager中的IndicatorViewPager
2024-08-27 14:12:25
实现引导页滑动
//js/pages/GuidePage.js
import {StyleSheet, View, Button, Text, Image, TouchableOpacity,AsyncStorage} from 'react-native';
import React, {Component} from 'react';
import {PagerTabIndicator, IndicatorViewPager, PagerTitleIndicator, PagerDotIndicator} from 'rn-viewpager';
import HomePage from "./HomePage";
export default class GuidePage extends Component {
render() {
let text1 = '消费者第一\n合作伙伴第二\nQunar第三';
let text2 = '大声说话\n无\'总\'称谓\n遇到批评三不问';
let text3 = '高层不诿过\n中层不放羊\n基层不跳步';
return (
<View style={{flex: 1}}>
<IndicatorViewPager
style={{flex: 1}}
indicator={GuidePage._renderDotIndicator()}>
<View style={{backgroundColor: '#ff8800', justifyContent: 'center'}}>
<Image resizeMode={'contain'} style={styles.image}
source={require('../../res/images/s_0_1.png')}/>
<Text style={styles.text_desc}>{text1}</Text>
</View>
<View style={{backgroundColor: '#669900', justifyContent: 'center'}}>
<Image resizeMode={'contain'} style={styles.image}
source={require('../../res/images/s_1_1.png')}/>
<Text style={styles.text_desc}>{text2}</Text>
</View>
<View style={{backgroundColor: '#aa66cc', justifyContent: 'center'}}>
<Image resizeMode={'contain'} style={styles.image}
source={require('../../res/images/s_2_1.png')}/>
<Text style={styles.text_desc}>{text3}</Text>
<TouchableOpacity onPress={()=>{
// 存储
AsyncStorage.setItem('isFirst','false',(error)=>{
if (error) {
alert(error);
}
});
this.props.navigator.resetTo({
component:HomePage,
params:{
// theme:this.props.theme,
...this.props
}
})
}}>
<Text style={styles.text}>开始使用</Text>
</TouchableOpacity>
</View>
</IndicatorViewPager>
</View>
);
}
static _renderDotIndicator() {
return <PagerDotIndicator pageCount={3}/>;
}
}
const styles = StyleSheet.create({
text: {
alignSelf: 'center',
padding: 5,
backgroundColor: '#2196f3',
borderRadius: 5,
fontSize: 18,
color: 'white',
},
text_desc: {
height:200,
textAlign: 'center',
textAlignVertical:'center',
fontSize: 20,
color: 'white',
alignSelf: 'center',
},
image: {
width: 200,
height: 200,
alignSelf: 'center'
},
btn: {
width: 150,
height: 40,
backgroundColor: '#1296db',
borderRadius: 8,
justifyContent: 'center',
alignItems: 'center',
marginBottom: 50
},
btnText: {
fontSize: 18,
color: '#fff'
},
});
最新文章
- js学习之类型识别
- R语言—图像初阶
- 在网页中嵌入地图API
- Nginx针对https站点的部署
- [转]js中的字符串函数集和代码片段
- javascript常用代码大全
- vs linq to db template
- BZOJ 1597: [Usaco2008 Mar]土地购买( dp + 斜率优化 )
- Android: Fragment (Trying to instantiate a class that is not a Fragment)
- Java I/O不迷茫,一文为你导航!
- 在线批量将gps经纬度坐标转换为百度经纬度坐标
- yii2 中excel表导出
- 实验 2:备份和还原IOS
- Window 由于未经处理的异常,进程终止。
- 【LOJ#6280】数列分块4
- centos磁盘满了,查找大文件并清理
- 八一八android开发规范(一种建议)
- (翻译)React Container Components
- 【转】dijkstra算法
- 安装Https证书
热门文章
- python中defaultdict方法的使用
- hdu1693 Eat the Trees [插头DP经典例题]
- 在Spring框架中获取连接池的四种方式
- Django项目:CMDB(服务器硬件资产自动采集系统)--03--03CMDB信息安全API接口交互认证
- ArccGIS 10发布WFS服务并加载到Skyline中
- JS创建和存储 cookie的一些方法
- Spring注解驱动开发(二)-----生命周期、属性赋值
- python—时间与时间戳之间的转换
- hdu 1171 (背包或者母函数问题)
- Merge array and hash in ruby if key appears in array