项目作者: jiangzhenfei

项目描述 :
react-native的提示框,确认框。具体效果请移步
高级语言: JavaScript
项目地址: git://github.com/jiangzhenfei/react-native-ms.git


react-native-ms

效果图
main

看不到效果图请移步

Install react-native-ms

Using npm:

  1. npm install react-native-ms --save

Usage

Using via import:

  1. import { TipModal } from 'react-native-ms';
  2. import React, {Component} from 'react';
  3. import {Platform, StyleSheet, Text, View,Button} from 'react-native';
  4. export default class App extends Component {
  5. /* 打开loading弹出框 */
  6. loading(){
  7. this.refs.tipModal._loading()
  8. }
  9. /* 打开成功提示框,参数一是提示内容,参数二是多少时间自动关闭*/
  10. success(){
  11. this.refs.tipModal._success('成功了',500)
  12. }
  13. /* 打开失败提示框,参数一是提示内容,参数二是多少时间自动关闭*/
  14. error(){
  15. this.refs.tipModal._error('失败了',500)
  16. }
  17. render() {
  18. return (
  19. <View style={styles.container}>
  20. <TipModal ref="tipModal"></TipModal>
  21. <Button title="loading" onPress={this.loading.bind(this)}></Button>
  22. <Button title="_success" onPress={this.success.bind(this)}></Button>
  23. <Button title="_error" onPress={this.error.bind(this)}></Button>
  24. </View>
  25. );
  26. }
  27. }

Props

1.animationType

提示框的出现和消失运动形式 none | fade (default) | slide

  • none 没有任何运动效果
  • fade 从屏幕中间隐现
  • slide 从屏幕地下滑到中间
    1. <TipModal ref="tipModal"
    2. animationType='slide'
    3. ></TipModal>

2.successIconComponent

组件有默认的成功提示图片,但是并不能符合所有人要求,使用如下

  1. <TipModal ref="tipModal"
  2. successIconComponent={
  3. <Icon
  4. color = '#FFFFFF'
  5. type = 'evilicon'
  6. name = 'check'
  7. size = { 30 }
  8. ></TipModal>
  9. }
  10. />

3.errorIconComponent

组件有默认的失败提示图片,但是并不能符合所有人要求,使用如下

  1. <TipModal ref="tipModal"
  2. errorIconComponent={
  3. <Icon
  4. color = '#FFFFFF'
  5. type = 'evilicon'
  6. name = 'close-o'
  7. size = { 30 }
  8. ></TipModal>
  9. }
  10. />

4.opacity

组件有默认弹出框透明度为0.5,自定义透明度

  1. <TipModal ref="tipModal"
  2. opacity = { 0.5 }
  3. ></TipModal>

ConfirmModal的使用

  1. import {Platform, StyleSheet, Text, View,Button} from 'react-native';
  2. import { ConfirmModal } from 'react-native-ms'
  3. export default class App extends Component {
  4.   confirm(){
  5.     this.refs.tipModal2._open('默认的提示')
  6.   }
  7.   render() {
  8.     return (
  9.       <View style={styles.container}>
  10.         <ConfirmModal ref="tipModal2"
  11. animationType='slide' //弹出框出现消失的运动形式
  12.           confirmFunc={()=>{alert(1)}} //确认按钮按下需要执行的操作       
  13. />
  14.         <Button title="confirm" onPress={this.confirm.bind(this)}></Button>
  15.       </View>
  16.     );<br>  
  17. }
  18. }