React Native布局实践:开发京东client首页(三)——轮播图的实现
上篇文章中,我们一起构建了京东client的TabBar。在本文中。将继续向大家介绍京东client首页轮播图及其下发功能button的开发方法,如今就让我们開始吧!
1.相关控件调研
眼下在Github开源的轮播图控件,个人觉得做得比較好的,一个是react-native-swiper(https://github.com/leecade/react-native-swiper),一个是react-native-viewpager(https://github.com/race604/react-native-viewpager),而经过试用发现。react-native-swiper尽管效果和样式较多、控制方便,但在将它缩小为一个固定高度的视图时,其底部的指示符号(即几个点,例如以下图)就不见了,所以终于我推荐使用react-native-viewpager。简单好用。
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKYAAAA7CAYAAADxcPHqAAAgAElEQVR4Ab2d6Y40x5We34hcaumdEiVyKInUeOzx2D8M+K+vwIAvwgYM2/Ad2PNH9+DrMgz4jwfjZbRYXCSR7O7qrSozI4znxInq7Pq6v25SGougkqefOCcy4kRGvhmVS/gv//V/5K7/UFN3rSafanq4VtOePNr3N2q6uX2tpj/V1F6qyeea7qvt/nt7zs9m5S/V9Oea2m/d/8rtWn7G04XGh0t1/bmG9lJdOtdwf6lueaGh+Vpd+kDD/bfqlh9oaL5x+xu338fxr+Xf4z/9QMNDjfeNuumDmf21ur8vvrrQEGt936pbfTCzv1G3575/r3LiXaobzzXs6L9zjfFbNeOFpt2lmuW5pnipZjwv9upMU8B2vjp3+5BjX6tZnWoK12rG05ld4834cKppwD4p5bHHjZql+5t9rW75Q7Vxe6a+XWgbjtXnhba7Y/VxpW24UJ+l7S6rbw54s9K2O1efs7a7VHg383/CJ/VNr213oj732u5O1LfEP3P/SX3baxsqP37kysq70XiCq1di/7qVUvtzLCV43yu1lZ+o71/ja6WW+g/8s8dfrJXCqcffqV/0elL/4sj5pLSb8eq/dJ6dL91/z4+Lfx6L/xN+on55okT/pKG0b+X+if07Ub+ac+zvwo/VL089/k5b+m/p/Z/Iz7H61Zm24Vx9gk8W3/IzHfBpW/K/8vExMX6OHv0PefLxtboo4ys9lPG1dP/Kl2v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8MLNf4MmP/OVaadmo39srpWWY2e/jUf2S8q36aaF0H9SvlkrLqH5aKt1H9avXOPHn/pSP6sel0gPxVkqLVgu3F2bHR3t9wM2OWgxLpW3QYr0u/sNCaRu1WC+VFk3hD9juDzf7kOPv5fGv9Q8ri7dc8VnoxZV23M0z3WiXH5T6jXac66cfaEfiFtfON9qhLRavccrz/R/8F0o99k5pwp8X0eP/Gk/FH23k/hP+qA/bn6yJ+GgvbLTcnKM538LRlHN/4tA+8/+hvT2o2PP4cD6lAuc+a2zn1Z+/wykHZ7/Zvz1vnOsZTnu6sv/sB/v3xB/7rTw/9ef5I/oTiUb/oO3JB+uI7B95gpM341Ph5G3PyeOcU57xgz/jA3vp/ryU1cfNS5z6GXeMv+jjTx0a869/sTSNGbVghtqxfsdMgsKU0o432hbNsGCG2rH+hs3qFJrlkOOP5nDOOp9rVos/wGf+xrG9/jlnnbPGZ6Zmhrb6WQdjxp3t3xPOTAp/zf+Qe/vCka2jsk7JW3L3Zw72m/oD9Te2jvk8/1P400/Uz7op7fG8WP3Ex0azfU9Of5s/66blmsLyRHxuqphzO3PV+skT+cVm/yQbF5z5rH/mvGjKdznxKc+7M6lvXn+0dcz/B8UfJyWy3cJIAAAAAElFTkSuQmCC" alt="" />
2.加入相关文件
下来我们将素材和相关的库导入项目当中,当中,react-native-viewpager的加入方法例如以下:
npm i -d react-native-viewpager --save
然后在project的images目录中创建banner目录,当中放入4个jpg文件:
接着,我们在HomePage类的定义前。创建一个数组常量,用于存放图片:
const BANNER_IMGS = [
require('../images/banner/1.jpg'),
require('../images/banner/2.jpg'),
require('../images/banner/3.jpg'),
require('../images/banner/4.jpg')
];
经过这么几个简单的步骤。我们对图片的引入也就完毕了。下来须要构建轮播图控件的布局。
3.构建ViewPager
经过分析,我们能够看到。首页轮播图的样式十分简单,仅仅须要指定高度,而水平方向,利用flex:1进行拉伸
但因为react-native-viewpager作者在构建这个控件的时候,应该是用到一些变量进行控制,并提供了一种方法。用于创建图片数据源,所以,假设须要使用react-native-viewpager必须在构造函数中进行初始化,详细代码例如以下:
constructor(props) {
super(props);
// 用于构建DataSource对象
var dataSource = new ViewPager.DataSource({
pageHasChanged: (p1, p2) => p1 !== p2,
});
// 实际的DataSources存放在state中
this.state = {
dataSource: dataSource.cloneWithPages(BANNER_IMGS)
}
}
而在render函数中,ViewPager的使用也是相当简单的。详细写法例如以下:
<ViewPager
style={{height:130}}
dataSource={this.state.dataSource}
renderPage={this._renderPage}
isLoop={true}
autoPlay={true}/>
当中:
style:样式,和其它控件设置方式相似
dataSource:即在构造函数中利用dataSource对象和图片数组常量,创建的真实dataSource
renderPage:方法类型,返回一段JSX。用于指定ViewPager每页的内容,该方法写法例如以下,切忌依据WebStorm的提示加上static!:
_renderPage(data, pageID) {
return (
<Image
source={data}
style={styles.page}/>
);
}
isLoop:是否循环播放。依照演示样例代码设置就可以
autoPlay:是否自己主动播放,依照演示样例代码设置就可以
locked: 设置为true即禁用ViewPager的点击
onChangePage: 页面切换的回调函数
renderPageIndicator: 自己定义指示器样式的渲染
animation:假设觉得原始的效果不惬意,能够在这个字段中设置一个函数,自己定义动画效果
当然,要记得给ViewPager和当中的item加入样式:
const styles = StyleSheet.create({
page: {
flex: 1,
height: 130,
resizeMode: 'stretch'
}
});
保存一下代码。在模拟器上看看效果吧
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
project源代码及资源文件:https://github.com/yuanguozheng/JdApp
本次Commit:https://github.com/yuanguozheng/JdApp/commit/2d1741bef1c7908c9e0d2f52c23210e8de2fcc7a
转载请注明出处:http://blog.csdn.net/yuanguozhengjust/article/details/50556700
React Native布局实践:开发京东client首页(三)——轮播图的实现的更多相关文章
- React Native入门——布局实践:开发京东client首页(一)
有了一些对React Native开发的简单了解,让我们从实战出发.一起来构建一个简单的京东client. 这个client是仿照之前版本号的京东client开发的Android版应用,来源于CSDN ...
- 微信小程序从零开始开发步骤(五)轮播图
上一章完成页面自定义分享,这一章来说说轮播图,最常见的一个轮播图,中间带小圆点,自动轮播. Swiper是滑动特效插件,面向手机.平板电脑等移动终端.能实现触屏焦点图.触屏Tab切换.触屏多图切换等常 ...
- phpcms首页实现轮播图
1.在你想要加轮播图的位置加入以下 <div id="flowDiagram" > <div id="button"> <span ...
- Luffy之Xadmin以及首页搭建(轮播图,导航)
1. 首页 1.1 轮播图 admin站点配置支持图片上传 pip install Pillow 默认情况下,Django会将上传的图片保存在本地服务器上,需要配置保存的路径.我们可以将上传的文件保存 ...
- 京东商城首页jquery轮播特效
<!DOCTYPE html><html> <head> <meta charset="utf-8" /> <title> ...
- 李洪强iOS开发之使用CycleScrollView实现轮播图
01 导入头文件,并且定义CycleScrollView属性 02 初始化,设置frame并且添加到collectionView上 03 调用方法并且设置轮播的图片
- 前端笔记之JavaScript面向对象(四)组件化开发&轮播图|俄罗斯方块实战
一.组件化开发 1.1组件化概述 页面特效的制作,特别需要HTML.CSS有固定的布局,所以说现在越来越流行组件开发的模式,就是用JS写一个类,当你实例化这个类的时候,页面上的效果布局也能自动完成. ...
- React Native – 使用 JavaScript 开发原生应用
前不久,Facebook 在F8开发者大会上正式开源了 React Native 项目.不过目前只有 iOS 版,Android 版还需要再等一段时间,这是最新的用 JavaScript 语言开发原生 ...
- 模仿东京首页banner轮播,京东新闻上下滚动动画实现(动画实现)
接着上篇 微信小程序-阅读小程序demo写:http://www.cnblogs.com/muyixiaoguang/p/5917986.html 首页banner动画实现 京东新闻上下动画实现 想着 ...
随机推荐
- Laravel 5.4.36 session 发现
由于Laravel session机制完全脱离了PHP自带的session机制 因此对于php.ini 配置session对Laravel 是不会产生影响 代码路径: vendor/larav ...
- activiti 表——介绍
Activiti 用到的表都是act_开头 下面分别来介绍下 activiti 所用到的表: Act_RE_* 表示 RepositoryService接口所操作的表:包含了流程定义信息 .流程静态资 ...
- Android使用的webcview中带有音乐播放控件,在关闭或分享时处于界面不可见状态下,声音仍在播放的问题解决
一. 问题出现原因 我们在做APP分享时,分享webview加载带有音乐播放控件的网页.当弹出分享界面,webview的网页处于后台状态或关闭该网页时,音乐声仍在播放.出现该类现象使我 ...
- 联想 A5(L18011) 免解锁BL 免rec Magisk Xposed ROOT 救砖 ZUI 3.9.068
>>>重点介绍<<< 第一:本刷机包可卡刷可线刷,刷机包比较大的原因是采用同时兼容卡刷和线刷的格式,所以比较大第二:[卡刷方法]卡刷不要解压刷机包,直接传入手机后用 ...
- vim之补全2(完全个人定制版)
关于补全的方面要说的的确很多, 这里选择分为两个章叙述. 如果你想学vim, 你需要有很强的耐心, 如果你想锻炼这种耐心, 你可以试着先看完我之前的文章. 好了, 下面继续我们的vim补全吧. vim ...
- 在CentOS下搭建Android 开发环境
在CentOS下搭建Android 开发环境 目录 1.环境搭建 1.1.JDK安装 1.2.Eclipse安装 1.3.ADT安装 1.4.Android SDK安装 1.5.Android NDK ...
- Html test
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> ...
- Mysql 之主从复制,mysql-proxy读写分离
准备两台mysql服务器,master(192.168.43.64).slave(192.168.84.129) master配置: log-bin=mysql-bin binlog_format=m ...
- PHP 之递归遍历目录与删除
/** * @Description: 递归查询目录文件 * @Author: Yang * @param $path * @param int $level * @return array */ f ...
- ESX/ESXi 主机的某些存储阵列可能存在读取或写入性能问题 (1002598)
Last Updated: 12/14/2018Categories: Troubleshooting Details 免责声明:本文为 ESX/ESXi hosts might experienc ...