@plusscommunities/pluss-core-app 1.8.1 → 1.8.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,9 +4,10 @@ import React, { Component } from 'react';
|
|
|
4
4
|
import { View, Text, TouchableOpacity, Modal, Dimensions } from 'react-native';
|
|
5
5
|
import { Icon } from 'react-native-elements';
|
|
6
6
|
import { WebView } from 'react-native-webview';
|
|
7
|
+
import * as FileSystem from 'expo-file-system';
|
|
7
8
|
import { Pl60Icon } from '../fonts';
|
|
8
9
|
import { Spinner } from './Spinner';
|
|
9
|
-
import { StatusBarHeight } from '../helper';
|
|
10
|
+
import { StatusBarHeight, getFileName } from '../helper';
|
|
10
11
|
const SCREEN_HEIGHT = Dimensions.get('window').height;
|
|
11
12
|
|
|
12
13
|
class PDFPopup extends Component {
|
|
@@ -16,6 +17,20 @@ class PDFPopup extends Component {
|
|
|
16
17
|
_defineProperty(this, "state", {
|
|
17
18
|
loaded: false
|
|
18
19
|
});
|
|
20
|
+
|
|
21
|
+
_defineProperty(this, "download", () => {
|
|
22
|
+
console.log('attempting download');
|
|
23
|
+
console.log(this.props.source);
|
|
24
|
+
console.log(FileSystem.documentDirectory);
|
|
25
|
+
console.log(getFileName(this.props.source));
|
|
26
|
+
FileSystem.downloadAsync(this.props.source, FileSystem.documentDirectory + getFileName(this.props.source)).then(res => {
|
|
27
|
+
console.log('success');
|
|
28
|
+
console.log(res);
|
|
29
|
+
}).catch(e => {
|
|
30
|
+
console.log('error');
|
|
31
|
+
console.log(e);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
19
34
|
}
|
|
20
35
|
|
|
21
36
|
onLoadStarted() {
|
|
@@ -97,7 +112,14 @@ class PDFPopup extends Component {
|
|
|
97
112
|
style: styles.titleContainer
|
|
98
113
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
99
114
|
style: styles.title
|
|
100
|
-
}, this.props.title))
|
|
115
|
+
}, this.props.title)), /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
116
|
+
onPress: this.download,
|
|
117
|
+
activeOpacity: 0.6
|
|
118
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
119
|
+
type: "font-awesome",
|
|
120
|
+
name: "cloud-download",
|
|
121
|
+
iconStyle: [styles.menuIcon]
|
|
122
|
+
}))), /*#__PURE__*/React.createElement(View, {
|
|
101
123
|
style: {
|
|
102
124
|
flex: 1,
|
|
103
125
|
backgroundColor: '#fff'
|
|
@@ -152,8 +174,7 @@ const styles = {
|
|
|
152
174
|
height: 70
|
|
153
175
|
},
|
|
154
176
|
titleContainer: {
|
|
155
|
-
flex: 1
|
|
156
|
-
paddingRight: 55
|
|
177
|
+
flex: 1
|
|
157
178
|
},
|
|
158
179
|
title: {
|
|
159
180
|
color: '#fff',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["PDFPopup.js"],"names":["React","Component","View","Text","TouchableOpacity","Modal","Dimensions","Icon","WebView","Pl60Icon","Spinner","StatusBarHeight","SCREEN_HEIGHT","get","height","PDFPopup","loaded","onLoadStarted","setState","onLoadEnded","onChangeIndex","index","props","getUrl","linkPrefix","source","closePopup","onClose","renderFooter","pdfCount","styles","footerContent","bind","chevron","footerText","selectedIndex","render","visible","flex","backgroundColor","paddingTop","headerContent","menuIcon","titleContainer","title","state","uri","e","console","log","container","position","innerContainer","paddingLeft","paddingRight","fontSize","padding","width","textAlign","color","zIndex","flexDirection","alignItems","fontFamily","justifyContent"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,SAASC,IAAT,EAAeC,IAAf,EAAqBC,gBAArB,EAAuCC,KAAvC,EAA8CC,UAA9C,QAAgE,cAAhE;AACA,SAASC,IAAT,QAAqB,uBAArB;AACA,SAASC,OAAT,QAAwB,sBAAxB;AACA,SAASC,QAAT,QAAyB,UAAzB;AACA,SAASC,OAAT,QAAwB,WAAxB;AACA,SAASC,eAAT,QAAgC,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G;AAIVF,IAAAA,KAAK,EAAE,GAJG;AAKVC,IAAAA,SAAS,EAAE;AALD;AAjDC,CAAf;AA0DA,SAAS3C,QAAT","sourcesContent":["import React, { Component } from 'react';\nimport { View, Text, TouchableOpacity, Modal, Dimensions } from 'react-native';\nimport { Icon } from 'react-native-elements';\nimport { WebView } from 'react-native-webview';\nimport { Pl60Icon } from '../fonts';\nimport { Spinner } from './Spinner';\nimport { StatusBarHeight } from '../helper';\n\nconst SCREEN_HEIGHT = Dimensions.get('window').height;\n\nclass PDFPopup extends Component {\n state = {\n loaded: false,\n };\n\n onLoadStarted() {\n this.setState({\n loaded: false,\n });\n }\n\n onLoadEnded() {\n this.setState({\n loaded: true,\n });\n }\n\n onChangeIndex(index) {\n this.props.onChangeIndex(index);\n }\n\n getUrl() {\n const linkPrefix = 'http://drive.google.com/viewerng/viewer?embedded=true&url=';\n return `${linkPrefix}${this.props.source}`;\n }\n\n closePopup() {\n this.props.onClose();\n }\n\n renderFooter() {\n if (this.props.pdfCount && this.props.pdfCount === 1) {\n return null;\n }\n return (\n <View style={styles.footerContent}>\n <TouchableOpacity onPress={this.onChangeIndex.bind(this, -1)} activeOpacity={0.6}>\n <Icon type=\"font-awesome\" name=\"angle-left\" iconStyle={[styles.chevron]} />\n </TouchableOpacity>\n <Text style={styles.footerText}>\n {this.props.selectedIndex + 1} / {this.props.pdfCount}\n </Text>\n <TouchableOpacity onPress={this.onChangeIndex.bind(this, 1)} activeOpacity={0.6}>\n <Icon type=\"font-awesome\" name=\"angle-right\" iconStyle={[styles.chevron]} />\n </TouchableOpacity>\n </View>\n );\n }\n\n render() {\n if (!this.props.source) {\n return null;\n }\n return (\n <Modal visible={this.props.visible} transparent animationType=\"slide\" onRequestClose={this.closePopup.bind(this)}>\n <View\n style={{\n flex: 1,\n backgroundColor: '#000',\n paddingTop: StatusBarHeight(0),\n }}\n >\n <View style={styles.headerContent}>\n <TouchableOpacity onPress={this.closePopup.bind(this)} activeOpacity={0.6}>\n <Pl60Icon name=\"close\" style={[styles.menuIcon]} />\n </TouchableOpacity>\n <View style={styles.titleContainer}>\n <Text style={styles.title}>{this.props.title}</Text>\n </View>\n </View>\n <View style={{ flex: 1, backgroundColor: '#fff' }}>\n {this.state.loaded ? null : <Spinner style={{ height: SCREEN_HEIGHT - StatusBarHeight(145), flex: 0 }} />}\n <WebView\n ref=\"PDFWebView\"\n source={{\n uri: this.getUrl(),\n }}\n renderError={e => {\n console.log('errored');\n console.log(e);\n }}\n style={[\n {\n flex: 1,\n backgroundColor: '#fff',\n },\n ]}\n onLoadStart={this.onLoadStarted.bind(this)}\n onLoadEnd={this.onLoadEnded.bind(this)}\n />\n </View>\n {this.renderFooter()}\n </View>\n </Modal>\n );\n }\n}\n\nconst styles = {\n container: {\n flex: 1,\n position: 'relative',\n backgroundColor: '#000',\n },\n innerContainer: {\n flex: 1,\n paddingLeft: 15,\n paddingRight: 15,\n },\n menuIcon: {\n fontSize: 25,\n padding: 15,\n width: 55,\n textAlign: 'center',\n color: '#fff',\n zIndex: 3,\n },\n headerContent: {\n flexDirection: 'row',\n alignItems: 'center',\n height: 70,\n },\n titleContainer: {\n flex: 1,\n paddingRight: 55,\n },\n title: {\n color: '#fff',\n fontFamily: 'sf-semibold',\n fontSize: 16,\n textAlign: 'center',\n },\n footerContent: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'center',\n height: 70,\n //alignSelf: 'flex-end'\n },\n chevron: {\n fontSize: 25,\n padding: 15,\n width: 55,\n textAlign: 'center',\n color: '#fff',\n zIndex: 3,\n },\n footerText: {\n fontFamily: 'sf-regular',\n fontSize: 14,\n color: '#fff',\n width: 150,\n textAlign: 'center',\n },\n};\n\nexport { PDFPopup };\n"]}
|
|
1
|
+
{"version":3,"sources":["PDFPopup.js"],"names":["React","Component","View","Text","TouchableOpacity","Modal","Dimensions","Icon","WebView","FileSystem","Pl60Icon","Spinner","StatusBarHeight","getFileName","SCREEN_HEIGHT","get","height","PDFPopup","loaded","console","log","props","source","documentDirectory","downloadAsync","then","res","catch","e","onLoadStarted","setState","onLoadEnded","onChangeIndex","index","getUrl","linkPrefix","closePopup","onClose","renderFooter","pdfCount","styles","footerContent","bind","chevron","footerText","selectedIndex","render","visible","flex","backgroundColor","paddingTop","headerContent","menuIcon","titleContainer","title","download","state","uri","container","position","innerContainer","paddingLeft","paddingRight","fontSize","padding","width","textAlign","color","zIndex","flexDirection","alignItems","fontFamily","justifyContent"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,SAASC,IAAT,EAAeC,IAAf,EAAqBC,gBAArB,EAAuCC,KAAvC,EAA8CC,UAA9C,QAAgE,cAAhE;AACA,SAASC,IAAT,QAAqB,uBAArB;AACA,SAASC,OAAT,QAAwB,sBAAxB;AACA,OAAO,KAAKC,UAAZ,MAA4B,kBAA5B;AACA,SAASC,QAAT,QAAyB,UAAzB;AACA,SAASC,OAAT,QAAwB,WAAxB;AACA,SAASC,eAAT,EAA0BC,WAA1B,QAA6C,WAA7C;AAEA,MAAMC,aAAa,GAAGR,UAAU,CAACS,GAAX,CAAe,QAAf,EAAyBC,MAA/C;;AAEA,MAAMC,QAAN,SAAuBhB,SAAvB,CAAiC;AAAA;AAAA;;AAAA,mCACvB;AACNiB,MAAAA,MAAM,EAAE;AADF,KADuB;;AAAA,sCA0BpB,MAAM;AACfC,MAAAA,OAAO,CAACC,GAAR,CAAY,qBAAZ;AACAD,MAAAA,OAAO,CAACC,GAAR,CAAY,KAAKC,KAAL,CAAWC,MAAvB;AACAH,MAAAA,OAAO,CAACC,GAAR,CAAYX,UAAU,CAACc,iBAAvB;AACAJ,MAAAA,OAAO,CAACC,GAAR,CAAYP,WAAW,CAAC,KAAKQ,KAAL,CAAWC,MAAZ,CAAvB;AACAb,MAAAA,UAAU,CAACe,aAAX,CAAyB,KAAKH,KAAL,CAAWC,MAApC,EAA4Cb,UAAU,CAACc,iBAAX,GAA+BV,WAAW,CAAC,KAAKQ,KAAL,CAAWC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A,OAAO,EAAE;AACPoB,IAAAA,QAAQ,EAAE,EADH;AAEPC,IAAAA,OAAO,EAAE,EAFF;AAGPC,IAAAA,KAAK,EAAE,EAHA;AAIPC,IAAAA,SAAS,EAAE,QAJJ;AAKPC,IAAAA,KAAK,EAAE,MALA;AAMPC,IAAAA,MAAM,EAAE;AAND,GAxCI;AAgDbxB,EAAAA,UAAU,EAAE;AACV2B,IAAAA,UAAU,EAAE,YADF;AAEVR,IAAAA,QAAQ,EAAE,EAFA;AAGVI,IAAAA,KAAK,EAAE,MAHG;AAIVF,IAAAA,KAAK,EAAE,GAJG;AAKVC,IAAAA,SAAS,EAAE;AALD;AAhDC,CAAf;AAyDA,SAASjD,QAAT","sourcesContent":["import React, { Component } from 'react';\nimport { View, Text, TouchableOpacity, Modal, Dimensions } from 'react-native';\nimport { Icon } from 'react-native-elements';\nimport { WebView } from 'react-native-webview';\nimport * as FileSystem from 'expo-file-system';\nimport { Pl60Icon } from '../fonts';\nimport { Spinner } from './Spinner';\nimport { StatusBarHeight, getFileName } from '../helper';\n\nconst SCREEN_HEIGHT = Dimensions.get('window').height;\n\nclass PDFPopup extends Component {\n state = {\n loaded: false,\n };\n\n onLoadStarted() {\n this.setState({\n loaded: false,\n });\n }\n\n onLoadEnded() {\n this.setState({\n loaded: true,\n });\n }\n\n onChangeIndex(index) {\n this.props.onChangeIndex(index);\n }\n\n getUrl() {\n const linkPrefix = 'http://drive.google.com/viewerng/viewer?embedded=true&url=';\n return `${linkPrefix}${this.props.source}`;\n }\n\n download = () => {\n console.log('attempting download');\n console.log(this.props.source);\n console.log(FileSystem.documentDirectory);\n console.log(getFileName(this.props.source));\n FileSystem.downloadAsync(this.props.source, FileSystem.documentDirectory + getFileName(this.props.source))\n .then(res => {\n console.log('success');\n console.log(res);\n })\n .catch(e => {\n console.log('error');\n console.log(e);\n });\n };\n\n closePopup() {\n this.props.onClose();\n }\n\n renderFooter() {\n if (this.props.pdfCount && this.props.pdfCount === 1) {\n return null;\n }\n return (\n <View style={styles.footerContent}>\n <TouchableOpacity onPress={this.onChangeIndex.bind(this, -1)} activeOpacity={0.6}>\n <Icon type=\"font-awesome\" name=\"angle-left\" iconStyle={[styles.chevron]} />\n </TouchableOpacity>\n <Text style={styles.footerText}>\n {this.props.selectedIndex + 1} / {this.props.pdfCount}\n </Text>\n <TouchableOpacity onPress={this.onChangeIndex.bind(this, 1)} activeOpacity={0.6}>\n <Icon type=\"font-awesome\" name=\"angle-right\" iconStyle={[styles.chevron]} />\n </TouchableOpacity>\n </View>\n );\n }\n\n render() {\n if (!this.props.source) {\n return null;\n }\n return (\n <Modal visible={this.props.visible} transparent animationType=\"slide\" onRequestClose={this.closePopup.bind(this)}>\n <View\n style={{\n flex: 1,\n backgroundColor: '#000',\n paddingTop: StatusBarHeight(0),\n }}\n >\n <View style={styles.headerContent}>\n <TouchableOpacity onPress={this.closePopup.bind(this)} activeOpacity={0.6}>\n <Pl60Icon name=\"close\" style={[styles.menuIcon]} />\n </TouchableOpacity>\n <View style={styles.titleContainer}>\n <Text style={styles.title}>{this.props.title}</Text>\n </View>\n <TouchableOpacity onPress={this.download} activeOpacity={0.6}>\n <Icon type=\"font-awesome\" name=\"cloud-download\" iconStyle={[styles.menuIcon]} />\n </TouchableOpacity>\n </View>\n <View style={{ flex: 1, backgroundColor: '#fff' }}>\n {this.state.loaded ? null : <Spinner style={{ height: SCREEN_HEIGHT - StatusBarHeight(145), flex: 0 }} />}\n <WebView\n ref=\"PDFWebView\"\n source={{\n uri: this.getUrl(),\n }}\n renderError={e => {\n console.log('errored');\n console.log(e);\n }}\n style={[\n {\n flex: 1,\n backgroundColor: '#fff',\n },\n ]}\n onLoadStart={this.onLoadStarted.bind(this)}\n onLoadEnd={this.onLoadEnded.bind(this)}\n />\n </View>\n {this.renderFooter()}\n </View>\n </Modal>\n );\n }\n}\n\nconst styles = {\n container: {\n flex: 1,\n position: 'relative',\n backgroundColor: '#000',\n },\n innerContainer: {\n flex: 1,\n paddingLeft: 15,\n paddingRight: 15,\n },\n menuIcon: {\n fontSize: 25,\n padding: 15,\n width: 55,\n textAlign: 'center',\n color: '#fff',\n zIndex: 3,\n },\n headerContent: {\n flexDirection: 'row',\n alignItems: 'center',\n height: 70,\n },\n titleContainer: {\n flex: 1,\n },\n title: {\n color: '#fff',\n fontFamily: 'sf-semibold',\n fontSize: 16,\n textAlign: 'center',\n },\n footerContent: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'center',\n height: 70,\n //alignSelf: 'flex-end'\n },\n chevron: {\n fontSize: 25,\n padding: 15,\n width: 55,\n textAlign: 'center',\n color: '#fff',\n zIndex: 3,\n },\n footerText: {\n fontFamily: 'sf-regular',\n fontSize: 14,\n color: '#fff',\n width: 150,\n textAlign: 'center',\n },\n};\n\nexport { PDFPopup };\n"]}
|
package/package.json
CHANGED
|
@@ -2,9 +2,10 @@ import React, { Component } from 'react';
|
|
|
2
2
|
import { View, Text, TouchableOpacity, Modal, Dimensions } from 'react-native';
|
|
3
3
|
import { Icon } from 'react-native-elements';
|
|
4
4
|
import { WebView } from 'react-native-webview';
|
|
5
|
+
import * as FileSystem from 'expo-file-system';
|
|
5
6
|
import { Pl60Icon } from '../fonts';
|
|
6
7
|
import { Spinner } from './Spinner';
|
|
7
|
-
import { StatusBarHeight } from '../helper';
|
|
8
|
+
import { StatusBarHeight, getFileName } from '../helper';
|
|
8
9
|
|
|
9
10
|
const SCREEN_HEIGHT = Dimensions.get('window').height;
|
|
10
11
|
|
|
@@ -34,6 +35,22 @@ class PDFPopup extends Component {
|
|
|
34
35
|
return `${linkPrefix}${this.props.source}`;
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
download = () => {
|
|
39
|
+
console.log('attempting download');
|
|
40
|
+
console.log(this.props.source);
|
|
41
|
+
console.log(FileSystem.documentDirectory);
|
|
42
|
+
console.log(getFileName(this.props.source));
|
|
43
|
+
FileSystem.downloadAsync(this.props.source, FileSystem.documentDirectory + getFileName(this.props.source))
|
|
44
|
+
.then(res => {
|
|
45
|
+
console.log('success');
|
|
46
|
+
console.log(res);
|
|
47
|
+
})
|
|
48
|
+
.catch(e => {
|
|
49
|
+
console.log('error');
|
|
50
|
+
console.log(e);
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
|
|
37
54
|
closePopup() {
|
|
38
55
|
this.props.onClose();
|
|
39
56
|
}
|
|
@@ -77,6 +94,9 @@ class PDFPopup extends Component {
|
|
|
77
94
|
<View style={styles.titleContainer}>
|
|
78
95
|
<Text style={styles.title}>{this.props.title}</Text>
|
|
79
96
|
</View>
|
|
97
|
+
<TouchableOpacity onPress={this.download} activeOpacity={0.6}>
|
|
98
|
+
<Icon type="font-awesome" name="cloud-download" iconStyle={[styles.menuIcon]} />
|
|
99
|
+
</TouchableOpacity>
|
|
80
100
|
</View>
|
|
81
101
|
<View style={{ flex: 1, backgroundColor: '#fff' }}>
|
|
82
102
|
{this.state.loaded ? null : <Spinner style={{ height: SCREEN_HEIGHT - StatusBarHeight(145), flex: 0 }} />}
|
|
@@ -132,7 +152,6 @@ const styles = {
|
|
|
132
152
|
},
|
|
133
153
|
titleContainer: {
|
|
134
154
|
flex: 1,
|
|
135
|
-
paddingRight: 55,
|
|
136
155
|
},
|
|
137
156
|
title: {
|
|
138
157
|
color: '#fff',
|