@plusscommunities/pluss-core-app 8.0.23-beta.0 → 8.0.24

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.
@@ -12,214 +12,218 @@ import { StatusBarHeight, getFileName } from "../helper";
12
12
  const SCREEN_HEIGHT = Dimensions.get("window").height;
13
13
 
14
14
  class PDFPopup extends Component {
15
- state = {
16
- loaded: false,
17
- };
15
+ state = {
16
+ loaded: false,
17
+ };
18
18
 
19
- onLoadStarted() {
20
- this.setState({
21
- loaded: false,
22
- });
23
- }
19
+ onLoadStarted() {
20
+ this.setState({
21
+ loaded: false,
22
+ });
23
+ }
24
24
 
25
- onLoadEnded() {
26
- this.setState({
27
- loaded: true,
28
- });
29
- }
25
+ onLoadEnded() {
26
+ this.setState({
27
+ loaded: true,
28
+ });
29
+ }
30
30
 
31
- onChangeIndex(index) {
32
- this.props.onChangeIndex(index);
33
- }
31
+ onChangeIndex(index) {
32
+ this.props.onChangeIndex(index);
33
+ }
34
34
 
35
- getUrl() {
36
- const linkPrefix =
37
- "http://drive.google.com/viewerng/viewer?embedded=true&url=";
38
- return `${linkPrefix}${this.props.source}`;
39
- }
35
+ getUrl() {
36
+ const linkPrefix =
37
+ "http://drive.google.com/viewerng/viewer?embedded=true&url=";
38
+ return `${linkPrefix}${this.props.source}`;
39
+ }
40
40
 
41
- download = async () => {
42
- try {
43
- const file = await File.downloadFileAsync(
44
- this.props.source,
45
- new File(Paths.document, getFileName(this.props.source)),
46
- { idempotent: true },
47
- );
48
- await Sharing.shareAsync(file.uri, {
49
- UTI: "public.item",
50
- });
51
- } catch (error) {
52
- console.log("PDFPopup download error:", error);
53
- Alert.alert(
54
- "Download Failed",
55
- "Unable to download PDF. Please try again.",
56
- [{ text: "OK" }],
57
- );
58
- }
59
- };
41
+ download = async () => {
42
+ try {
43
+ const file = await File.downloadFileAsync(
44
+ this.props.source,
45
+ new File(Paths.document, getFileName(this.props.source)),
46
+ { idempotent: true },
47
+ );
48
+ await Sharing.shareAsync(file.uri, {
49
+ UTI: "public.item",
50
+ });
51
+ } catch (error) {
52
+ console.log("PDFPopup download error:", error);
53
+ Alert.alert(
54
+ "Download Failed",
55
+ "Unable to download PDF. Please try again.",
56
+ [{ text: "OK" }],
57
+ );
58
+ }
59
+ };
60
60
 
61
- closePopup() {
62
- this.props.onClose();
63
- }
61
+ closePopup() {
62
+ this.props.onClose();
63
+ }
64
64
 
65
- renderFooter() {
66
- if (this.props.pdfCount && this.props.pdfCount === 1) {
67
- return null;
68
- }
69
- return (
70
- <View style={styles.footerContent}>
71
- <TouchableOpacity
72
- onPress={this.onChangeIndex.bind(this, -1)}
73
- activeOpacity={0.6}
74
- >
75
- <Icon
76
- type="font-awesome"
77
- name="angle-left"
78
- iconStyle={[styles.chevron]}
79
- />
80
- </TouchableOpacity>
81
- <Text style={styles.footerText}>
82
- {this.props.selectedIndex + 1} / {this.props.pdfCount}
83
- </Text>
84
- <TouchableOpacity
85
- onPress={this.onChangeIndex.bind(this, 1)}
86
- activeOpacity={0.6}
87
- >
88
- <Icon
89
- type="font-awesome"
90
- name="angle-right"
91
- iconStyle={[styles.chevron]}
92
- />
93
- </TouchableOpacity>
94
- </View>
95
- );
96
- }
65
+ renderFooter() {
66
+ if (this.props.pdfCount && this.props.pdfCount === 1) {
67
+ return null;
68
+ }
69
+ return (
70
+ <View style={styles.footerContent}>
71
+ <TouchableOpacity
72
+ onPress={this.onChangeIndex.bind(this, -1)}
73
+ activeOpacity={0.6}
74
+ >
75
+ <Icon
76
+ type="font-awesome"
77
+ name="angle-left"
78
+ iconStyle={[styles.chevron]}
79
+ />
80
+ </TouchableOpacity>
81
+ <Text style={styles.footerText}>
82
+ {this.props.selectedIndex + 1} / {this.props.pdfCount}
83
+ </Text>
84
+ <TouchableOpacity
85
+ onPress={this.onChangeIndex.bind(this, 1)}
86
+ activeOpacity={0.6}
87
+ >
88
+ <Icon
89
+ type="font-awesome"
90
+ name="angle-right"
91
+ iconStyle={[styles.chevron]}
92
+ />
93
+ </TouchableOpacity>
94
+ </View>
95
+ );
96
+ }
97
97
 
98
- render() {
99
- if (!this.props.source) {
100
- return null;
101
- }
102
- return (
103
- <Modal
104
- visible={this.props.visible}
105
- transparent
106
- animationType="slide"
107
- onRequestClose={this.closePopup.bind(this)}
108
- >
109
- <View
110
- style={{
111
- flex: 1,
112
- backgroundColor: "#000",
113
- paddingTop: StatusBarHeight(0),
114
- }}
115
- >
116
- <View style={styles.headerContent}>
117
- <TouchableOpacity
118
- onPress={this.closePopup.bind(this)}
119
- activeOpacity={0.6}
120
- >
121
- <FontAwesome name="x" style={[styles.menuIcon]} />
122
- </TouchableOpacity>
123
- <View style={styles.titleContainer}>
124
- <Text style={styles.title}>{this.props.title}</Text>
125
- </View>
126
- <TouchableOpacity onPress={this.download} activeOpacity={0.6}>
127
- <Icon
128
- type="font-awesome"
129
- name="cloud-download"
130
- iconStyle={[styles.menuIcon]}
131
- />
132
- </TouchableOpacity>
133
- </View>
134
- <View style={{ flex: 1, backgroundColor: "#fff" }}>
135
- {this.state.loaded ? null : (
136
- <Spinner
137
- style={{
138
- height: SCREEN_HEIGHT - StatusBarHeight(145),
139
- flex: 0,
140
- }}
141
- />
142
- )}
143
- <WebView
144
- source={{
145
- uri: this.getUrl(),
146
- }}
147
- renderError={(e) => {
148
- console.log("errored");
149
- console.log(e);
150
- }}
151
- style={[
152
- {
153
- flex: 1,
154
- backgroundColor: "#fff",
155
- },
156
- ]}
157
- onLoadStart={this.onLoadStarted.bind(this)}
158
- onLoadEnd={this.onLoadEnded.bind(this)}
159
- />
160
- </View>
161
- {this.renderFooter()}
162
- </View>
163
- </Modal>
164
- );
165
- }
98
+ render() {
99
+ if (!this.props.source) {
100
+ return null;
101
+ }
102
+ return (
103
+ <Modal
104
+ visible={this.props.visible}
105
+ transparent
106
+ animationType="slide"
107
+ onRequestClose={this.closePopup.bind(this)}
108
+ >
109
+ <View
110
+ style={{
111
+ flex: 1,
112
+ backgroundColor: "#000",
113
+ paddingTop: StatusBarHeight(0),
114
+ }}
115
+ >
116
+ <View style={styles.headerContent}>
117
+ <TouchableOpacity
118
+ onPress={this.closePopup.bind(this)}
119
+ activeOpacity={0.6}
120
+ >
121
+ <FontAwesome name="x" style={[styles.menuIcon]} />
122
+ </TouchableOpacity>
123
+ <View style={styles.titleContainer}>
124
+ <Text style={styles.title}>{this.props.title}</Text>
125
+ </View>
126
+ <TouchableOpacity onPress={this.download} activeOpacity={0.6}>
127
+ <Icon
128
+ type="font-awesome"
129
+ name="cloud-download"
130
+ iconStyle={[styles.menuIcon]}
131
+ />
132
+ </TouchableOpacity>
133
+ </View>
134
+ <View style={{ flex: 1, backgroundColor: "#fff" }}>
135
+ {this.state.loaded ? null : (
136
+ <Spinner
137
+ style={{
138
+ height: SCREEN_HEIGHT - StatusBarHeight(145),
139
+ flex: 0,
140
+ }}
141
+ />
142
+ )}
143
+ <WebView
144
+ source={{
145
+ uri: this.getUrl(),
146
+ }}
147
+ javaScriptEnabled
148
+ domStorageEnabled
149
+ originWhitelist={["*"]}
150
+ mixedContentMode="always"
151
+ renderError={(e) => {
152
+ console.log("errored");
153
+ console.log(e);
154
+ }}
155
+ style={[
156
+ {
157
+ flex: 1,
158
+ backgroundColor: "#fff",
159
+ },
160
+ ]}
161
+ onLoadStart={this.onLoadStarted.bind(this)}
162
+ onLoadEnd={this.onLoadEnded.bind(this)}
163
+ />
164
+ </View>
165
+ {this.renderFooter()}
166
+ </View>
167
+ </Modal>
168
+ );
169
+ }
166
170
  }
167
171
 
168
172
  const styles = {
169
- container: {
170
- flex: 1,
171
- position: "relative",
172
- backgroundColor: "#000",
173
- },
174
- innerContainer: {
175
- flex: 1,
176
- paddingLeft: 15,
177
- paddingRight: 15,
178
- },
179
- menuIcon: {
180
- fontSize: 25,
181
- padding: 15,
182
- width: 55,
183
- textAlign: "center",
184
- color: "#fff",
185
- zIndex: 3,
186
- },
187
- headerContent: {
188
- flexDirection: "row",
189
- alignItems: "center",
190
- height: 70,
191
- },
192
- titleContainer: {
193
- flex: 1,
194
- },
195
- title: {
196
- color: "#fff",
197
- fontFamily: "sf-semibold",
198
- fontSize: 16,
199
- textAlign: "center",
200
- },
201
- footerContent: {
202
- flexDirection: "row",
203
- alignItems: "center",
204
- justifyContent: "center",
205
- height: 70,
206
- //alignSelf: 'flex-end'
207
- },
208
- chevron: {
209
- fontSize: 25,
210
- padding: 15,
211
- width: 55,
212
- textAlign: "center",
213
- color: "#fff",
214
- zIndex: 3,
215
- },
216
- footerText: {
217
- fontFamily: "sf-regular",
218
- fontSize: 14,
219
- color: "#fff",
220
- width: 150,
221
- textAlign: "center",
222
- },
173
+ container: {
174
+ flex: 1,
175
+ position: "relative",
176
+ backgroundColor: "#000",
177
+ },
178
+ innerContainer: {
179
+ flex: 1,
180
+ paddingLeft: 15,
181
+ paddingRight: 15,
182
+ },
183
+ menuIcon: {
184
+ fontSize: 25,
185
+ padding: 15,
186
+ width: 55,
187
+ textAlign: "center",
188
+ color: "#fff",
189
+ zIndex: 3,
190
+ },
191
+ headerContent: {
192
+ flexDirection: "row",
193
+ alignItems: "center",
194
+ height: 70,
195
+ },
196
+ titleContainer: {
197
+ flex: 1,
198
+ },
199
+ title: {
200
+ color: "#fff",
201
+ fontFamily: "sf-semibold",
202
+ fontSize: 16,
203
+ textAlign: "center",
204
+ },
205
+ footerContent: {
206
+ flexDirection: "row",
207
+ alignItems: "center",
208
+ justifyContent: "center",
209
+ height: 70,
210
+ //alignSelf: 'flex-end'
211
+ },
212
+ chevron: {
213
+ fontSize: 25,
214
+ padding: 15,
215
+ width: 55,
216
+ textAlign: "center",
217
+ color: "#fff",
218
+ zIndex: 3,
219
+ },
220
+ footerText: {
221
+ fontFamily: "sf-regular",
222
+ fontSize: 14,
223
+ color: "#fff",
224
+ width: 150,
225
+ textAlign: "center",
226
+ },
223
227
  };
224
228
 
225
229
  export { PDFPopup };