React Native 分享弹窗 ShareAlertDialog

ShareAlertDialog.js文件

/**
* 分享弹窗
*/
import React, {Component} from 'react';
import {View, TouchableOpacity, Alert, StyleSheet, Dimensions, Modal, Text, Image} from 'react-native'; const {width, height} = Dimensions.get('window');
const dialogH = ; export default class ShareAlertDialog extends Component { constructor(props) {
super(props);
this.state = {
isVisible: this.props.show,
};
} componentWillReceiveProps(nextProps) {
this.setState({isVisible: nextProps.show});
} closeModal() {
this.setState({
isVisible: false
});
this.props.closeModal(false);
} renderDialog() {
return (
<View style={styles.modalStyle}>
<Text style={styles.text}>分享到</Text> <View style={styles.divide}/> <View style={styles.optArea}>
<TouchableOpacity style={styles.item} onPress={() => Alert.alert('分享')}>
<Image resizeMode='contain' style={styles.image}
source={require('./icon_share_qq.png')}/>
<Text style={styles.itemText}>QQ好友</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.item}>
<Image resizeMode='contain' style={styles.image}
source={require('./icon_share_wxsession.png')}/>
<Text style={styles.itemText}>微信好友</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.item}>
<Image resizeMode='contain' style={styles.image}
source={require('./icon_share_wxtimeline.png')}/>
<Text style={styles.itemText}>朋友圈</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.item}>
<Image resizeMode='contain' style={styles.image}
source={require('./icon_share_qq.png')}/>
<Text style={styles.itemText}>复制链接</Text>
</TouchableOpacity> </View> <View style={styles.divide}/> <TouchableOpacity style={styles.cancel} onPress={() => this.closeModal()}>
<Text style={styles.cancelText}>取消</Text>
</TouchableOpacity>
</View>
)
} render() { return (
<View style={{flex: }}>
<Modal
transparent={true}
visible={this.state.isVisible}
animationType={'fade'}
onRequestClose={() => this.closeModal()}>
<TouchableOpacity style={styles.container} activeOpacity={}
onPress={() => this.closeModal()}>
{this.renderDialog()}
</TouchableOpacity>
</Modal>
</View>
);
}
} const styles = StyleSheet.create({
container: {
flex: ,
backgroundColor: 'rgba(0, 0, 0, 0.5)',
},
modalStyle: {
position: "absolute",
left: ,
bottom: ,
width: width,
flex: ,
flexDirection: "column",
backgroundColor: '#ffffff',
},
subView: {
width: width,
height: dialogH,
backgroundColor: '#ffffff'
},
text: {
flex: ,
fontSize: ,
paddingTop: ,
paddingBottom: ,
justifyContent: 'center',
alignItems: 'center',
alignSelf: 'center'
},
optArea: {
flex: ,
flexDirection: 'row',
marginTop: ,
marginBottom: ,
},
item: {
width: width / ,
alignItems: 'center',
},
itemText: {
fontSize: ,
},
cancel: {
width: width,
height: ,
marginTop: ,
alignItems: 'center',
backgroundColor: '#ffffff'
},
cancelText: {
fontSize: ,
},
image: {
width: ,
height: ,
marginBottom: ,
},
divide: {
width: width,
height: 0.5,
backgroundColor: "#ccc",
}
});

调用代码:

import React, {Component} from "react";
import {StyleSheet, Text, TouchableHighlight, View,} from 'react-native';
import ShareAlertDialog from "./ShareAlertDialog"; export default class TestShareModal extends Component {
constructor(props) {
super(props);
this.state = {
showSharePop: false,//分享弹窗,默认不显示
}
} _share() {
this.setState({showSharePop: !this.state.showSharePop})
} render() {
return (
<View style={{flex: }}> <TouchableHighlight onPress={() => this._share()} style={styles.button} underlayColor="#a5a5a5">
<Text>点击分享</Text>
</TouchableHighlight> <ShareAlertDialog show={this.state.showSharePop} closeModal={(show) => {
this.setState({
showSharePop: show
})
}}/>
</View>
); }
} const styles = StyleSheet.create({
button: {
margin: ,
backgroundColor: 'white',
padding: ,
borderBottomWidth: StyleSheet.hairlineWidth,
borderBottomColor: '#cdcdcd'
},
});

本博客地址: wukong1688

本文原文地址:https://www.cnblogs.com/wukong1688/p/10967254.html

转载请著名出处!谢谢~~

[RN] React Native 分享弹窗 ShareAlertDialog的更多相关文章

  1. [RN] React Native 实现图片预览

    [RN] React Native 实现图片预览 效果预览: 代码如下: 'use strict'; import React, {Component} from 'react'; import {I ...

  2. [RN] React Native 常见基本问题归纳总结

    [RN] React Native  常见基本问题归纳总结 本问题总结涉及到版本为: "react": "16.8.3","react-native& ...

  3. [RN] React Native 关闭所有黄色警告

    [RN] React Native 关闭所有黄色警告 console.ignoredYellowBox = ['Warning: BackAndroid is deprecated. Please u ...

  4. [RN] React Native 下实现底部标签(支持滑动切换)

    上一篇文章 [RN] React Native 下实现底部标签(不支持滑动切换) 总结了不支持滑动切换的方法,此篇文章总结出 支持滑动 的方法 准备工作之类的,跟上文类似,大家可点击上文查看相关内容. ...

  5. [RN] React Native 幻灯片效果 Banner

    [RN] React Native 幻灯片效果 Banner 1.定义Banner import React, {Component} from 'react'; import {Image, Scr ...

  6. [RN] React Native 常用命令行

    [RN] React Native 常用命令行 1.查看当前版本 react-native --version 或 react-native -v 2.创建指定版本的React Native项目 1) ...

  7. [RN] React Native 实现 类似QQ 登陆页面

    [RN] React Native 实现 类似QQ 登陆页面 一.主页index.js 项目目录下index.js /** * @format */ import {AppRegistry} from ...

  8. [RN] React Native 使用 阿里 ant-design

    React Native 使用 阿里 ant-design 实例效果如图: 一.安装 npm install antd-mobile-rn --save npm install babel-plugi ...

  9. [RN] React Native 获取地理位置

    React Native 获取地理位置 实现原理: 1.用  navigator.geolocation.getCurrentPosition 获取到坐标信息 2.调用 高德地图 接口,解析位置数据 ...

随机推荐

  1. 【题解】Kathy函数 [BZOJ1223] [P2235] [HNOI2002]

    [题解]Kathy函数 [BZOJ1223] [P2235] [HNOI2002] 这几疯狂刷了数位\(dp\)的题,到这道题时被卡了一天,一看大佬的讲解发现居然是求回文数╮(╯_╰)╭ 感觉被大佬狠 ...

  2. reactiveX沉思(草稿)

    一.第一性原理 将异步的io.事件解释为observable.并借用observer的一些类概念进行处理. ReactiveX is a library for composing asynchron ...

  3. ML学习笔记之XGBoost实现对鸢尾花数据集分类预测

    import xgboost as xgb import numpy as np import pandas as pd from sklearn.model_selection import tra ...

  4. 关于.net core 中的signalR组件的使用

    SignalR是为了提供更方便的web交互响应式到推送式的解决方案.有了它之后可以实现客户端直接调用服务端的方法并且获得返回值 (客户端可以是各种平台,目前SignalR支持的语言版本有C#.java ...

  5. MVC+Ninject+三层架构+代码生成 -- 总结(一、數據庫)

    一.數據表 是參照 別人的庫建表的 ,主鍵都是用int 自增,若是跨數據庫的話,建議使用GUID為主鍵.

  6. CMU-Multimodal SDK Version 1.1 (mmsdk)使用方法总结

    年10月26日 星期六 mmdatasdk: module for downloading and procesing multimodal datasets using computational ...

  7. javascript原型深入解析2--Object和Function,先有鸡先有蛋

    1.提出两个问题: Js 的prototype和__proto__ 是咋回事? 先有function 还是先有object? 2.引用<JavaScript权威指南>的一段描述: 每个JS ...

  8. Vue项目打包发布后CSS中的背景图片不显示

    相信有很多同学在学习vue的刚开始都遇到过项目打包发布后发现CSS中的背景图片不显示,具体如何解决只需要更改bind的配置即可 修改 build/utils.js 中的 generateLoaders ...

  9. Ubuntu下的log日志查看器

    1.lnav:Linux 下一个基于控制台的高级日志文件查看器 https://www.cnblogs.com/michealLang/p/9761886.html http://www.imooc. ...

  10. 关于控制Broker端入站连接数的讨论

    Kafka Broker端处理请求采用Reactor模型.每台Broker上有个类似于Dispatcher的Acceptor线程,还有若干个处理请求的Processor线程(当然真正处理请求逻辑的线程 ...