-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshare.js
More file actions
146 lines (138 loc) · 4.93 KB
/
share.js
File metadata and controls
146 lines (138 loc) · 4.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import React, { Component } from 'react'
import { View, StyleSheet, Dimensions, Text, TouchableHighlight, AsyncStorage, Alert } from 'react-native'
import { FormLabel, FormInput, Button, List, ListItem, Icon } from 'react-native-elements'
const {width, height} = Dimensions.get('window');
import ajax from './components/ajax';
import Spinner from './components/spinner';
import Share from 'react-native-share';
class ShareDoc extends Component {
constructor(props) {
super(props);
this.state = {
loading: false,
docs: []
};
}
static navigationOptions = {
title: 'Поделиться',
};
_share_doc = (v1,v2) => {
let shareOptions = {
title: "Мой документ",
message: "Ссылка для просмотра документа "+v1,
url: "http://localhost/docs/"+v2,
subject: "Share Link"
};
Share.open(shareOptions);
}
componentDidMount() {
this.setState({
loading: true
});
AsyncStorage.getItem("login").then((login) => {
AsyncStorage.getItem("pass").then((pass) => {
ajax('POST','event=get_list'+
'&login='+login+
'&pass='+pass)
.then((data) => {
this.setState({
loading: false
});
if(data.status === "none")
{
this.state.docs.push({
name: "У вас нет документов",
chevron: true,
src: null
});
this.setState({
docs: this.state.docs
});
}else if (data.status === "error")
{
Alert.alert(
'Ошибка',
'Не удалось получить список документов',
[
{text: 'OK'},
]
);
} else {
for (i=0; i<data.length; i++) {
this.state.docs.push({
name: data[i].name,
icon: 'photo',
icon2: 'share',
chevron: false,
src: data[i].src
});
this.setState({
docs: this.state.docs
});
}
}
})
.catch((error) => {
this.setState({
loading: false
});
Alert.alert(
'Ошибка',
'Неизвестная ошибка',
[
{text: 'OK'},
]
);
});
}).done();
}).done();
}
_loadingRender = () => {
if(this.state.loading === true)
{
return(<Spinner/>);
}
}
render(){
return (<View style= {styles.container}>
{this._loadingRender()}
<List containerStyle={{marginBottom: 20, marginTop: 0}}>
{
this.state.docs.map((l, i) => (
<ListItem
leftIcon={{name:l.icon}}
rightIcon={{name:l.icon2}}
key={i}
title={l.name}
hideChevron={l.chevron}
onPress={()=>{this._share_doc(l.name, l.src)}}
/>
))
}
</List>
</View>);
}
}
var styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor:'white'
},
head:{
fontSize: 25,
marginBottom: 40,
},
inputStyle: {
width:width-50,
borderColor: '#fff'
},
btnStyle:{
marginTop: 40
},
hrefStyle:{
marginTop: 40,
color: '#03b1f7',
textAlign: 'center'
}
});
export default ShareDoc;