123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- /**
- * Sample React Native App
- * https://github.com/facebook/react-native
- *
- * @format
- * @flow
- */
- import React, { Component } from "react";
- import {
- Platform,
- StyleSheet,
- Text,
- View,
- Image,
- TouchableOpacity,
- ImageBackground,
- TextInput,
- Button,
- StatusBar,
- Modal,
- TouchableHighlight,
- DeviceEventEmitter
- } from "react-native";
- type Props = {};
- export default class SharedDialog extends Component<Props> {
- state = {
- modalVisible: false
- };
- setModalVisible(visible) {
- this.setState({
- modalVisible: visible
- });
- }
- render() {
- return (
- <Modal
- animationType="slide"
- transparent={true}
- visible={this.state.modalVisible}
- onRequestClose={() => {
- this.setState({ modalVisible: false });
- }}
- >
- <View
- style={{
- flex: 1,
- flexDirection: "column"
- }}
- >
- <TouchableOpacity
- style={{
- flex: 3.5,
- backgroundColor: "rgba(0, 0, 0, 0.5)",
- width: "100%"
- }}
- activeOpacity={1}
- onPress={() => this.setState({ modalVisible: false })}
- >
- <View
- style={{
- flex: 3.5,
- width: "100%"
- }}
- />
- </TouchableOpacity>
- <View
- style={{
- flex: 1,
- width: "100%"
- }}
- >
- <View
- style={{
- flex: 1.5,
- width: "100%",
- flexDirection: "row",
- backgroundColor: "white"
- }}
- >
- <View
- style={{
- flex: 1,
- width: "100%",
- alignItems: "center",
- justifyContent: "center"
- }}
- >
- <View
- style={{
- height: 2,
- left: 40,
- backgroundColor: "#979797",
- width: "60%"
- }}
- />
- </View>
- <View
- style={{
- flex: 1,
- width: "100%",
- alignItems: "center",
- justifyContent: "center"
- }}
- >
- <Text
- style={{
- fontSize: 18,
- color: "black"
- }}
- >
- 分享
- </Text>
- </View>
- <View
- style={{
- flex: 1,
- alignItems: "center",
- justifyContent: "center",
- width: "100%"
- }}
- >
- <View
- style={{
- height: 2,
- right: 40,
- backgroundColor: "#979797",
- width: "60%"
- }}
- />
- </View>
- </View>
- <View
- style={{
- flex: 2,
- backgroundColor: "white",
- flexDirection: "row",
- justifyContent: "center",
- width: "100%"
- }}
- >
- <View
- style={{
- flex: 1,
- alignItems: "center"
- }}
- >
- <TouchableOpacity
- activeOpacity={1}
- onPress={this.wechat.bind(this)}
- >
- <View
- style={{
- flexDirection: "column",
- alignItems: "center",
- justifyContent: "center",
- left: 40
- }}
- >
- <Image
- style={{
- height: 43,
- width: 43
- }}
- source={require("../images/share/wechat.png")}
- />
- <Text
- style={{
- fontSize: 16,
- color: "black"
- }}
- >
- 发给到群/好友
- </Text>
- </View>
- </TouchableOpacity>
- </View>
- <View style={{ flex: 0.3 }} />
- <View
- style={{
- flex: 1
- }}
- >
- <TouchableOpacity
- activeOpacity={1}
- onPress={this.circle.bind(this)}
- >
- <View
- style={{
- flexDirection: "column",
- alignItems: "center",
- justifyContent: "center",
- right: 40
- }}
- >
- <Image
- style={{
- height: 43,
- width: 43
- }}
- source={require("../images/share/circle.png")}
- />
- <Text
- style={{
- fontSize: 16,
- color: "black"
- }}
- >
- 发朋友圈
- </Text>
- </View>
- </TouchableOpacity>
- </View>
- </View>
- </View>
- </View>
- </Modal>
- );
- }
- wechat() {
- alert("wechat");
- }
- circle() {
- alert("circle");
- }
- setModalVisible(visible) {
- this.setState({
- modalVisible: visible
- });
- }
- }
- /***
- 使用方法
- <SharedDialog ref={view => (this.shareddialog = view)} />
- this.shareddialog.setModalVisible(true);//true显示,false消失
- */
|