React_Native常用第三方库

原文链接

React Native常用第三方库

code_xzh 2017-05-05 17:52:36 浏览77 评论0

android native react HTTPS github

摘要: 前言 React Native出来一年多了,受到各大开发人员的喜爱,但是由于只是专注于View层的开发,因此在很多深层次上还需要结合原生app做一定的兼容,还有就是现在好多控件,如Android中已是系统的控件的sidemenu、checkbox、gridview等,这些在react native中 系统是没有给我们提供的,这时候就借助了第三方开源的力量。

前言

React Native出来一年多了,受到各大开发人员的喜爱,但是由于只是专注于View层的开发,因此在很多深层次上还需要结合原生app做一定的兼容,还有就是现在好多控件,如Android中已是系统的控件的sidemenu、checkbox、gridview等,这些在react native中 系统是没有给我们提供的,这时候就借助了第三方开源的力量。
那么我们今天说说在React Native项目开发中常见的一些第三方库。

常见的第三方库

组件篇

CheckBox(多选按钮)

react-native-check-box CheckBox
基本用法:

1 <CheckBox 2 style= 3 onClick={()=>this.onClick(data)} 4 isChecked={data.checked} 5 leftText={leftText} />;

当然我们也可以自定义样式,主要是对选中和未选中的样式做修改:

1renderCheckBox(data) { 2 var leftText = data.name; 3 return ( 4 <CheckBox 5 style= 6 onClick={()=>this.onClick(data)} 7 isChecked={data.checked} 8 leftText={leftText} 9 checkedImage={<Image source={require('../../page/my/img/ic_check_box.png')} style={this.props.theme.styles.tabBarSelectedIcon}/>} 10 unCheckedImage={<Image source={require('../../page/my/img/ic_check_box_outline_blank.png')} style={this.props.theme.styles.tabBarSelectedIcon}/>} 11 />); 12}

RadioButton(单选按钮)

react-native-flexi-radio-button
使用也很简单,就是在中嵌套下就行:

1 <RadioGroup 2 onSelect = {(index, value) => this.onSelect(index, value)} 3 > 4 <RadioButton value={'item1'} > 5 <Text>This is item #1</Text> 6 </RadioButton> 7 8 <RadioButton value={'item2'}> 9 <Text>This is item #2</Text> 10 </RadioButton> 11 12 <RadioButton value={'item3'}> 13 <Text>This is item #3</Text> 14 </RadioButton> 15 </RadioGroup>

sidemenu (侧滑栏)

react-native-side-menu
使用:

1<SideMenu menu={menu}> 2 <ContentView/> 3 </SideMenu>

splashscreen

react-native-splash-screen
使用也很简单,就是添加一个闪屏的xml
这里写图片描述

imagepicker

这个组件帮助我们选取图片和调用相机等,这个组件同时支持photo和video,也就是照片和视频都可以用这个组件实现。
用法:

1 import ImagePickerManager from ‘NativeModules‘; 2 3var options = { 4 title: ‘Select Avatar‘, // 选择器的标题,可以设置为空来不显示标题 5 cancelButtonTitle: ‘Cancel‘, 6 takePhotoButtonTitle: ‘Take Photo..., // 调取摄像头的按钮,可以设置为空使用户不可选择拍照 7 chooseFromLibraryButtonTitle: ‘Choose from Library..., // 调取相册的按钮,可以设置为空使用户不可选择相册照片 8 customButtons: { 9 ‘Choose Photo from Facebook‘: ‘fb‘, // [按钮文字] : [当选择这个按钮时返回的字符串] 10 }, 11 mediaType: ‘photo‘, // ‘photo‘ or ‘video‘ 12 videoQuality: ‘high‘, // ‘low‘, ‘medium‘, or ‘high‘ 13 durationLimit: 10, // video recording max time in seconds 14 maxWidth: 100, // photos only默认为手机屏幕的宽,高与宽一样,为正方形照片 15 maxHeight: 100, // photos only 16 allowsEditing: false, // 当用户选择过照片之后是否允许再次编辑图片 17}; 18 19ImagePickerManager.showImagePicker(options, (response) => { 20 console.log(‘Response =, response); 21 22 if (response.didCancel) { 23 console.log(‘User cancelled image picker‘); 24 } 25 else if (response.error) { 26 console.log(‘ImagePickerManager Error:, response.error); 27 } 28 else if (response.customButton) { 29 // 这是当用户选择customButtons自定义的按钮时,才执行 30 console.log(‘User tapped custom button:, response.customButton); 31 } 32 else { 33 // You can display the image using either data: 34 35 if (Platform.OS === ‘android‘) { 36 source = {uri: response.uri, isStatic: true}; 37 } else { 38 source = { 39 uri: response.uri.replace(‘file://, ‘‘), 40 isStatic: true 41 }; 42 } 43 44 this.setState({ 45 avatarSource: source 46 }); 47 } 48});

然后在页面展示的时候:

<Image source={this.state.avatarSource} style={styles.uploadAvatar} />

说到这里,我们要说一下另一个控件picker

picker-Android

Picker就是ReactNative界的Spinner,其常用的属性有:

  • onValueChange 这个方法在方法在选择Picker某一项时调用 可传两个参数 选择的value和position
  • selectedValue 这个属性是选择的值
  • enabled 设置是否可点击 Android属性
  • mode 设置样式 Android属性 dropdown下拉样式和dialog弹窗样式 默认是dialog
  • prompt 设置Picker标题 Android属性 并且只有是mode为dialog才会显示
  • itemStyle 设置每一项的样式 iOS属性

用法:

1/** 2 * Created by Administrator on 2016/9/7. 3 */ 4import React, {Component} from 'react'; 5import { 6 AppRegistry, 7 View, 8 Picker, 9 10} from 'react-native'; 11 12class PickerG extends Component { 13 14 constructor(porp) { 15 super(porp); 16 this.state= { 17 selectedValue: '' 18 } 19 } 20 21 22 render() { 23 return ( 24 <Picker 25 //Picker样式 dialog弹窗样式默认 dropdown显示在下边 26 // mode = {'dropdown'} 27 //显示选择内容 28 selectedValue={this.state.selectedValue} 29 //选择内容时调用此方法 30 onValueChange={(value)=>this.setState({selectedValue: value})} 31 //设置Title 当设置为dialog时有用 32 prompt={'请选择'} 33 > 34 <Picker.Item label='Android' value='android'/> 35 <Picker.Item label='IOS' value='ios'/> 36 <Picker.Item label='ReactNative' value='reactnative'/> 37 </Picker> 38 ) 39 } 40} 41 42module.exports = PickerG;

easy-toast

react-native-easy-toast 
这个组件兼容了Android和iOS的toast,使用也很简单。
用法:

1render() { 2 return ( 3 <View style={styles.container}> 4 ... 5 <Toast ref="toast"/> 6 </View> 7 ); 8 }

最后在需要调用的地方:

this.refs.toast.show('hello world!');

其他的第三方库

选项卡
各种漂亮的小组件
按钮
输入框表单验证
https://github.com/gcanti/tcomb-form-native
https://github.com/FaridSafi/react-native-gifted-form
https://github.com/bartonhammond/snowflake
炫酷效果的 TextInput
https://github.com/halilb/react-native-textinput-effects
https://github.com/zbtang/React-Native-TextInputLayout
聊天表情
地图
动画
加载动画
日历
可多选的Listview
react-native-uploader //文件上传
这里写图片描述

react-native-animatable 动画

react-native-carousel 轮播

react-native-countdown 倒计时

react-native-device-info设备信息

react-native-icons 图标

react-native-image-picker 图片选择器

react-native-keychain iOS KeyChain管理

react-native-picker滚轮选择器

react-native-picker-Android Android 滚轮选择器

react-native-refreshable-listview 可刷新列表

react-native-scrollable-tab-view 可滚动标签

react-native-side-menu 侧栏

react-native-swiper 轮播

react-native-video 视频播放

react-native-viewpager 分页浏览

react-native-scrollable-tab-view 可滑动的底部或上部导航栏框架

react-native-tab-navigator 底部或上部导航框架(不可滑动)

react-native-check-box CheckBox多选

react-native-splash-screen 启动白屏问题

react-native-simple-router 简易路由跳转框架

react-native-storage 持久化存储

react-native-sortable-listview 分类ListView

react-native-htmlview 将 HTML 目录作为本地视图的控件,其风格可以定制

react-native-easy-toast 一款简单易用的 Toast 组件

react-native-tab-navigator 选项卡

react-native-material-kit 漂亮的小组件

NativeBasebase组件库(各种封装不错的小组件)

不错的按钮:
https://github.com/mastermoo/react-native-action-button
https://github.com/ide/react-native-button

输入框表单验证
https://github.com/gcanti/tcomb-form-native
https://github.com/FaridSafi/react-native-gifted-form
https://github.com/bartonhammond/snowflake

炫酷效果的 TextInput
https://github.com/halilb/react-native-textinput-effects
https://github.com/zbtang/React-Native-TextInputLayout

地图
https://github.com/lelandrichardson/react-native-maps
动画
https://github.com/oblador/react-native-animatable
加载动画
https://github.com/maxs15/react-native-spinkit
抽屉效果
https://github.com/root-two/react-native-drawer
https://github.com/react-native-fellowship/react-native-side-menu
侧滑按钮
https://github.com/dancormier/react-native-swipeout
https://github.com/jemise111/react-native-swipe-list-view
图表
https://github.com/tomauty/react-native-chart
下拉放大
https://github.com/lelandrichardson/react-native-parallax-view
可滑动的日历组件
https://github.com/cqm1994617/react-native-myCalendar
语言转化和一些常用格式转换
https://github.com/joshswan/react-native-globalize
单选多选ListView
https://github.com/hinet/react-native-checkboxlist
选择按钮
https://github.com/sconxu/react-native-checkbox
二维码
https://github.com/ideacreation/react-native-barcodescanner
制作本地库
https://github.com/frostney/react-native-create-library
影音相关
https://github.com/MisterAlex95/react-native-record-sound
安卓录音
https://github.com/bosung90/react-native-audio-android
提示消息的Bar
https://github.com/KBLNY/react-native-message-bar
iOS原生TableView
https://github.com/aksonov/react-native-tableview
点击弹出视图
https://github.com/jeanregisser/react-native-popover
https://github.com/instea/react-native-popup-menu
3D Touch
https://github.com/madriska/react-native-quick-actions
双平台兼容的ActionSheet
https://github.com/beefe/react-native-actionsheet
照片墙
https://github.com/ldn0x7dc/react-native-gallery
键盘遮挡问题
https://github.com/reactnativecn/react-native-inputscrollview
https://github.com/wix/react-native-keyboard-aware-scrollview
本地存储
https://github.com/sunnylqm/react-native-storage
星星
https://github.com/djchie/react-native-star-rating
国际化
https://github.com/joshswan/react-native-globalize
扫描二维码
https://github.com/lazaronixon/react-native-qrcode-reader
通讯录
https://github.com/rt2zz/react-native-contacts
加密
https://www.npmjs.com/package/crypto-js
缓存管理
https://github.com/reactnativecn/react-native-http-cache
ListView的优化
https://github.com/sghiassy/react-native-sglistview
图片和base64互转
https://github.com/xfumihiro/react-native-image-to-base64
安卓 iOS 白屏解决
https://github.com/mehcode/rn-splash-screen
Text跑马灯效果
https://github.com/remobile/react-native-marquee-label
清除按钮的输入框
https://github.com/beefe/react-native-textinput
WebView相关
https://github.com/alinz/react-native-webview-bridge
判断横竖屏
https://github.com/yamill/react-native-orientation
PDF
https://github.com/cnjon/react-native-pdf-view
获取设备信息
https://github.com/rebeccahughes/react-native-device-info
手势放大缩小移动
https://github.com/kiddkai/react-native-gestures
https://github.com/johanneslumpe/react-native-gesture-recognizers
下拉-上拉-刷新
https://github.com/FaridSafi/react-native-gifted-listview
https://github.com/jsdf/react-native-refreshable-listview
https://github.com/greatbsky/react-native-pull/wiki
下拉选择
https://github.com/alinz/react-native-dropdown
图片查看
https://github.com/oblador/react-native-lightbox
照片选择
https://github.com/marcshilling/react-native-image-picker
https://github.com/ivpusic/react-native-image-crop-picker
图片加载进度条
https://github.com/oblador/react-native-image-progress
轮播视图
https://github.com/race604/react-native-viewpager
https://github.com/FuYaoDe/react-native-app-intro
https://github.com/appintheair/react-native-looped-carousel
https://github.com/leecade/react-native-swiper
模态视图
https://github.com/maxs15/react-native-modalbox
https://github.com/brentvatne/react-native-modal
https://github.com/bodyflex/react-native-simple-modal
毛玻璃效果
https://github.com/react-native-fellowship/react-native-blur
头像库
https://github.com/oblador/react-native-vector-icons
滑动选项卡
https://github.com/skv-headless/react-native-scrollable-tab-view

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )