@plusscommunities/pluss-core-app 1.5.6 → 1.6.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.
- package/dist/module/components/AddToCalendarButton.js +241 -0
- package/dist/module/components/AddToCalendarButton.js.map +1 -0
- package/dist/module/components/ConfirmPopup.js +38 -10
- package/dist/module/components/ConfirmPopup.js.map +1 -1
- package/dist/module/components/EmptyStateMain.js +12 -5
- package/dist/module/components/EmptyStateMain.js.map +1 -1
- package/dist/module/components/index.js +1 -0
- package/dist/module/components/index.js.map +1 -1
- package/package.json +5 -4
- package/src/components/AddToCalendarButton.js +215 -0
- package/src/components/ConfirmPopup.js +47 -7
- package/src/components/EmptyStateMain.js +11 -5
- package/src/components/index.js +1 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
|
|
5
|
+
import React, { Component } from 'react';
|
|
6
|
+
import { Platform, Linking, StyleSheet, Text, View, TouchableOpacity, ScrollView } from 'react-native';
|
|
7
|
+
import { connect } from 'react-redux';
|
|
8
|
+
import _ from 'lodash';
|
|
9
|
+
import * as Calendar from 'expo-calendar';
|
|
10
|
+
import { TEXT_DARK, getMainBrandingColourFromState } from '../colours';
|
|
11
|
+
import { InlineButton } from './InlineButton';
|
|
12
|
+
import { Popup } from './Popup';
|
|
13
|
+
import { MiddlePopup } from './MiddlePopup';
|
|
14
|
+
const DEFAULT_TITLE = 'Add to Calendar';
|
|
15
|
+
const ERROR_EVENT_ADD = 'There was a problem adding a calendar event.'; // Required: eventToAdd
|
|
16
|
+
// Documentation: https://docs.expo.dev/versions/latest/sdk/calendar/#event
|
|
17
|
+
|
|
18
|
+
class AddToCalendarButton extends Component {
|
|
19
|
+
constructor(props) {
|
|
20
|
+
super(props);
|
|
21
|
+
|
|
22
|
+
_defineProperty(this, "showWarningPopup", () => {
|
|
23
|
+
if (Platform.OS !== 'ios') return;
|
|
24
|
+
this.setState({
|
|
25
|
+
showPermissionWarning: true
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
_defineProperty(this, "closeWarningPopup", () => {
|
|
30
|
+
this.setState({
|
|
31
|
+
showPermissionWarning: false
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
_defineProperty(this, "goToPermissionSettings", () => {
|
|
36
|
+
Linking.openURL('app-settings:');
|
|
37
|
+
this.setState({
|
|
38
|
+
showPermissionWarning: false
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
_defineProperty(this, "onAdd", async () => {
|
|
43
|
+
if (!this.props.eventToAdd) {
|
|
44
|
+
this.setState({
|
|
45
|
+
message: 'There is no event to add'
|
|
46
|
+
});
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const {
|
|
51
|
+
status
|
|
52
|
+
} = await Calendar.requestCalendarPermissionsAsync();
|
|
53
|
+
|
|
54
|
+
if (status !== 'granted') {
|
|
55
|
+
this.showWarningPopup();
|
|
56
|
+
} else {
|
|
57
|
+
let calendars = await Calendar.getCalendarsAsync(Calendar.EntityTypes.EVENT); // console.log('all calendars', calendars);
|
|
58
|
+
|
|
59
|
+
if (calendars && calendars.length > 0) {
|
|
60
|
+
calendars = calendars.filter(c => c.allowsModifications).map(c => {
|
|
61
|
+
return {
|
|
62
|
+
id: c.id,
|
|
63
|
+
title: c.title,
|
|
64
|
+
source: c.source.name,
|
|
65
|
+
color: c.color,
|
|
66
|
+
type: c.type
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
calendars = _.orderBy(calendars, ['source', 'title']); // console.log('sorted calendars', calendars);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
this.setState({
|
|
73
|
+
calendars
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
_defineProperty(this, "onCloseCalendars", () => {
|
|
79
|
+
this.setState({
|
|
80
|
+
calendars: null
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
_defineProperty(this, "onSelectCalendar", async calendar => {
|
|
85
|
+
try {
|
|
86
|
+
const {
|
|
87
|
+
eventToAdd
|
|
88
|
+
} = this.props;
|
|
89
|
+
if (!eventToAdd) return;
|
|
90
|
+
const eventId = await Calendar.createEventAsync(calendar.id, eventToAdd);
|
|
91
|
+
this.setState({
|
|
92
|
+
calendars: null,
|
|
93
|
+
message: eventId ? `${eventToAdd.title} was added to ${calendar.title} successfully.` : ERROR_EVENT_ADD
|
|
94
|
+
});
|
|
95
|
+
} catch (error) {
|
|
96
|
+
console.log('onSelectCalendar', error);
|
|
97
|
+
this.setState({
|
|
98
|
+
calendars: null,
|
|
99
|
+
message: ERROR_EVENT_ADD
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
_defineProperty(this, "onCloseMessage", () => {
|
|
105
|
+
this.setState({
|
|
106
|
+
message: null
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
this.state = {
|
|
111
|
+
showPermissionWarning: false,
|
|
112
|
+
calendars: null,
|
|
113
|
+
message: null
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
renderPermission() {
|
|
118
|
+
return /*#__PURE__*/React.createElement(Popup, {
|
|
119
|
+
title: "Permissions missing",
|
|
120
|
+
text: "You must grant access to the Calendars. Tap Go to settings to change your permission settings.",
|
|
121
|
+
options: [{
|
|
122
|
+
text: 'Go to settings',
|
|
123
|
+
action: this.goToPermissionSettings,
|
|
124
|
+
bold: true
|
|
125
|
+
}, {
|
|
126
|
+
text: 'Ignore',
|
|
127
|
+
action: this.closeWarningPopup
|
|
128
|
+
}]
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
renderCalendars(calendars) {
|
|
133
|
+
return /*#__PURE__*/React.createElement(MiddlePopup, {
|
|
134
|
+
style: [styles.calendarsPopup, {
|
|
135
|
+
height: calendars.length * 60 + 120
|
|
136
|
+
}],
|
|
137
|
+
onClose: this.onCloseCalendars
|
|
138
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
139
|
+
style: styles.calendarPopupTitle
|
|
140
|
+
}, "Select Calendar"), /*#__PURE__*/React.createElement(View, {
|
|
141
|
+
style: styles.calendarPopupContainer
|
|
142
|
+
}, /*#__PURE__*/React.createElement(ScrollView, {
|
|
143
|
+
style: {
|
|
144
|
+
flex: 1
|
|
145
|
+
},
|
|
146
|
+
showsVerticalScrollIndicator: false
|
|
147
|
+
}, calendars.map(cal => {
|
|
148
|
+
return /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
149
|
+
key: cal.id,
|
|
150
|
+
onPress: () => this.onSelectCalendar(cal)
|
|
151
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
152
|
+
style: [styles.calendarContainer, {
|
|
153
|
+
backgroundColor: cal.color
|
|
154
|
+
}]
|
|
155
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
156
|
+
style: styles.calendarText
|
|
157
|
+
}, `${cal.source}${cal.source === cal.title ? '' : `\n${cal.title}`}`)));
|
|
158
|
+
})), /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
159
|
+
key: 'cancel',
|
|
160
|
+
onPress: this.onCloseCalendars
|
|
161
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
162
|
+
style: [styles.calendarContainer, {
|
|
163
|
+
marginTop: 20,
|
|
164
|
+
backgroundColor: this.props.colourBrandingMain
|
|
165
|
+
}]
|
|
166
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
167
|
+
style: styles.calendarText
|
|
168
|
+
}, "Cancel")))));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
renderMessage(message) {
|
|
172
|
+
return /*#__PURE__*/React.createElement(Popup, {
|
|
173
|
+
title: "Add to Calendar",
|
|
174
|
+
text: message,
|
|
175
|
+
options: [{
|
|
176
|
+
text: 'Ok',
|
|
177
|
+
action: this.onCloseMessage
|
|
178
|
+
}]
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
render() {
|
|
183
|
+
const {
|
|
184
|
+
showPermissionWarning,
|
|
185
|
+
calendars,
|
|
186
|
+
message
|
|
187
|
+
} = this.state;
|
|
188
|
+
if (showPermissionWarning) return this.renderPermission();
|
|
189
|
+
if (calendars && calendars.length > 0) return this.renderCalendars(calendars);
|
|
190
|
+
if (message) return this.renderMessage(message);
|
|
191
|
+
return /*#__PURE__*/React.createElement(InlineButton, _extends({}, this.props, {
|
|
192
|
+
onPress: this.onAdd
|
|
193
|
+
}), this.props.children || DEFAULT_TITLE);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const styles = StyleSheet.create({
|
|
199
|
+
calendarsPopup: {
|
|
200
|
+
width: 250,
|
|
201
|
+
maxHeight: 400,
|
|
202
|
+
padding: 16,
|
|
203
|
+
borderRadius: 12
|
|
204
|
+
},
|
|
205
|
+
calendarPopupTitle: {
|
|
206
|
+
fontFamily: 'sf-bold',
|
|
207
|
+
color: TEXT_DARK,
|
|
208
|
+
fontSize: 18,
|
|
209
|
+
marginBottom: 16
|
|
210
|
+
},
|
|
211
|
+
calendarPopupContainer: {
|
|
212
|
+
flex: 1,
|
|
213
|
+
justifyContent: 'space-between'
|
|
214
|
+
},
|
|
215
|
+
calendarContainer: {
|
|
216
|
+
flexDirection: 'row',
|
|
217
|
+
alignItems: 'center',
|
|
218
|
+
width: 200,
|
|
219
|
+
height: 40,
|
|
220
|
+
paddingHorizontal: 8,
|
|
221
|
+
borderRadius: 4,
|
|
222
|
+
marginBottom: 10
|
|
223
|
+
},
|
|
224
|
+
calendarText: {
|
|
225
|
+
color: '#fff',
|
|
226
|
+
textAlign: 'center',
|
|
227
|
+
fontFamily: 'sf-semibold',
|
|
228
|
+
fontSize: 13,
|
|
229
|
+
flex: 1
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
const mapStateToProps = state => {
|
|
234
|
+
return {
|
|
235
|
+
colourBrandingMain: getMainBrandingColourFromState(state)
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
const button = connect(mapStateToProps, {})(AddToCalendarButton);
|
|
240
|
+
export { button as AddToCalendarButton };
|
|
241
|
+
//# sourceMappingURL=AddToCalendarButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["AddToCalendarButton.js"],"names":["React","Component","Platform","Linking","StyleSheet","Text","View","TouchableOpacity","ScrollView","connect","_","Calendar","TEXT_DARK","getMainBrandingColourFromState","InlineButton","Popup","MiddlePopup","DEFAULT_TITLE","ERROR_EVENT_ADD","AddToCalendarButton","constructor","props","OS","setState","showPermissionWarning","openURL","eventToAdd","message","status","requestCalendarPermissionsAsync","showWarningPopup","calendars","getCalendarsAsync","EntityTypes","EVENT","length","filter","c","allowsModifications","map","id","title","source","name","color","type","orderBy","calendar","eventId","createEventAsync","error","console","log","state","renderPermission","text","action","goToPermissionSettings","bold","closeWarningPopup","renderCalendars","styles","calendarsPopup","height","onCloseCalendars","calendarPopupTitle","calendarPopupContainer","flex","cal","onSelectCalendar","calendarContainer","backgroundColor","calendarText","marginTop","colourBrandingMain","renderMessage","onCloseMessage","render","onAdd","children","create","width","maxHeight","padding","borderRadius","fontFamily","fontSize","marginBottom","justifyContent","flexDirection","alignItems","paddingHorizontal","textAlign","mapStateToProps","button"],"mappings":";;;;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,SA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ADE;AAEjBC,IAAAA,UAAU,EAAE,QAFK;AAGjBT,IAAAA,KAAK,EAAE,GAHU;AAIjBlB,IAAAA,MAAM,EAAE,EAJS;AAKjB4B,IAAAA,iBAAiB,EAAE,CALF;AAMjBP,IAAAA,YAAY,EAAE,CANG;AAOjBG,IAAAA,YAAY,EAAE;AAPG,GAjBY;AA0B/Bf,EAAAA,YAAY,EAAE;AACZ5B,IAAAA,KAAK,EAAE,MADK;AAEZgD,IAAAA,SAAS,EAAE,QAFC;AAGZP,IAAAA,UAAU,EAAE,aAHA;AAIZC,IAAAA,QAAQ,EAAE,EAJE;AAKZnB,IAAAA,IAAI,EAAE;AALM;AA1BiB,CAAlB,CAAf;;AAmCA,MAAM0B,eAAe,GAAGxC,KAAK,IAAI;AAC/B,SAAO;AACLqB,IAAAA,kBAAkB,EAAE7D,8BAA8B,CAACwC,KAAD;AAD7C,GAAP;AAGD,CAJD;;AAMA,MAAMyC,MAAM,GAAGrF,OAAO,CAACoF,eAAD,EAAkB,EAAlB,CAAP,CAA6B1E,mBAA7B,CAAf;AACA,SAAS2E,MAAM,IAAI3E,mBAAnB","sourcesContent":["import React, { Component } from 'react';\nimport { Platform, Linking, StyleSheet, Text, View, TouchableOpacity, ScrollView } from 'react-native';\nimport { connect } from 'react-redux';\nimport _ from 'lodash';\nimport * as Calendar from 'expo-calendar';\nimport { TEXT_DARK, getMainBrandingColourFromState } from '../colours';\nimport { InlineButton } from './InlineButton';\nimport { Popup } from './Popup';\nimport { MiddlePopup } from './MiddlePopup';\n\nconst DEFAULT_TITLE = 'Add to Calendar';\nconst ERROR_EVENT_ADD = 'There was a problem adding a calendar event.';\n\n// Required: eventToAdd\n// Documentation: https://docs.expo.dev/versions/latest/sdk/calendar/#event\nclass AddToCalendarButton extends Component {\n constructor(props) {\n super(props);\n\n this.state = {\n showPermissionWarning: false,\n calendars: null,\n message: null,\n };\n }\n\n showWarningPopup = () => {\n if (Platform.OS !== 'ios') return;\n this.setState({ showPermissionWarning: true });\n };\n\n closeWarningPopup = () => {\n this.setState({ showPermissionWarning: false });\n };\n\n goToPermissionSettings = () => {\n Linking.openURL('app-settings:');\n this.setState({ showPermissionWarning: false });\n };\n\n onAdd = async () => {\n if (!this.props.eventToAdd) {\n this.setState({ message: 'There is no event to add' });\n return;\n }\n\n const { status } = await Calendar.requestCalendarPermissionsAsync();\n if (status !== 'granted') {\n this.showWarningPopup();\n } else {\n let calendars = await Calendar.getCalendarsAsync(Calendar.EntityTypes.EVENT);\n // console.log('all calendars', calendars);\n if (calendars && calendars.length > 0) {\n calendars = calendars\n .filter(c => c.allowsModifications)\n .map(c => {\n return {\n id: c.id,\n title: c.title,\n source: c.source.name,\n color: c.color,\n type: c.type,\n };\n });\n calendars = _.orderBy(calendars, ['source', 'title']);\n // console.log('sorted calendars', calendars);\n }\n this.setState({ calendars });\n }\n };\n\n onCloseCalendars = () => {\n this.setState({ calendars: null });\n };\n\n onSelectCalendar = async calendar => {\n try {\n const { eventToAdd } = this.props;\n if (!eventToAdd) return;\n\n const eventId = await Calendar.createEventAsync(calendar.id, eventToAdd);\n\n this.setState({\n calendars: null,\n message: eventId ? `${eventToAdd.title} was added to ${calendar.title} successfully.` : ERROR_EVENT_ADD,\n });\n } catch (error) {\n console.log('onSelectCalendar', error);\n this.setState({ calendars: null, message: ERROR_EVENT_ADD });\n }\n };\n\n onCloseMessage = () => {\n this.setState({ message: null });\n };\n\n renderPermission() {\n return (\n <Popup\n title=\"Permissions missing\"\n text=\"You must grant access to the Calendars. Tap Go to settings to change your permission settings.\"\n options={[\n {\n text: 'Go to settings',\n action: this.goToPermissionSettings,\n bold: true,\n },\n {\n text: 'Ignore',\n action: this.closeWarningPopup,\n },\n ]}\n />\n );\n }\n\n renderCalendars(calendars) {\n return (\n <MiddlePopup style={[styles.calendarsPopup, { height: calendars.length * 60 + 120 }]} onClose={this.onCloseCalendars}>\n <Text style={styles.calendarPopupTitle}>Select Calendar</Text>\n <View style={styles.calendarPopupContainer}>\n <ScrollView style={{ flex: 1 }} showsVerticalScrollIndicator={false}>\n {calendars.map(cal => {\n return (\n <TouchableOpacity key={cal.id} onPress={() => this.onSelectCalendar(cal)}>\n <View style={[styles.calendarContainer, { backgroundColor: cal.color }]}>\n <Text style={styles.calendarText}>{`${cal.source}${cal.source === cal.title ? '' : `\\n${cal.title}`}`}</Text>\n </View>\n </TouchableOpacity>\n );\n })}\n </ScrollView>\n <TouchableOpacity key={'cancel'} onPress={this.onCloseCalendars}>\n <View style={[styles.calendarContainer, { marginTop: 20, backgroundColor: this.props.colourBrandingMain }]}>\n <Text style={styles.calendarText}>Cancel</Text>\n </View>\n </TouchableOpacity>\n </View>\n </MiddlePopup>\n );\n }\n\n renderMessage(message) {\n return (\n <Popup\n title=\"Add to Calendar\"\n text={message}\n options={[\n {\n text: 'Ok',\n action: this.onCloseMessage,\n },\n ]}\n />\n );\n }\n\n render() {\n const { showPermissionWarning, calendars, message } = this.state;\n\n if (showPermissionWarning) return this.renderPermission();\n if (calendars && calendars.length > 0) return this.renderCalendars(calendars);\n if (message) return this.renderMessage(message);\n\n return (\n <InlineButton {...this.props} onPress={this.onAdd}>\n {this.props.children || DEFAULT_TITLE}\n </InlineButton>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n calendarsPopup: {\n width: 250,\n maxHeight: 400,\n padding: 16,\n borderRadius: 12,\n },\n calendarPopupTitle: {\n fontFamily: 'sf-bold',\n color: TEXT_DARK,\n fontSize: 18,\n marginBottom: 16,\n },\n calendarPopupContainer: {\n flex: 1,\n justifyContent: 'space-between',\n },\n calendarContainer: {\n flexDirection: 'row',\n alignItems: 'center',\n width: 200,\n height: 40,\n paddingHorizontal: 8,\n borderRadius: 4,\n marginBottom: 10,\n },\n calendarText: {\n color: '#fff',\n textAlign: 'center',\n fontFamily: 'sf-semibold',\n fontSize: 13,\n flex: 1,\n },\n});\n\nconst mapStateToProps = state => {\n return {\n colourBrandingMain: getMainBrandingColourFromState(state),\n };\n};\n\nconst button = connect(mapStateToProps, {})(AddToCalendarButton);\nexport { button as AddToCalendarButton };\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { PureComponent } from 'react';
|
|
2
2
|
import { Text, View } from 'react-native';
|
|
3
|
+
import _ from 'lodash';
|
|
3
4
|
import { connect } from 'react-redux';
|
|
4
5
|
import { getMainBrandingColourFromState, TEXT_DARK } from '../colours';
|
|
5
6
|
import { Spinner } from './Spinner';
|
|
@@ -19,29 +20,33 @@ class ConfirmPopup extends PureComponent {
|
|
|
19
20
|
width: 350,
|
|
20
21
|
marginBottom: 16
|
|
21
22
|
}
|
|
22
|
-
}, this.props.headerContent), /*#__PURE__*/React.createElement(Text, {
|
|
23
|
-
style: styles.text
|
|
24
|
-
}, this.props.text), this.props.
|
|
23
|
+
}, this.props.headerContent), !_.isEmpty(this.props.text) && /*#__PURE__*/React.createElement(Text, {
|
|
24
|
+
style: [styles.text, this.props.textAlignLeft && styles.textAlignLeft]
|
|
25
|
+
}, this.props.text), !_.isEmpty(this.props.subtext) && /*#__PURE__*/React.createElement(Text, {
|
|
26
|
+
style: [styles.subtext, this.props.textAlignLeft && styles.textAlignLeft]
|
|
27
|
+
}, this.props.subtext), this.props.extraContent && /*#__PURE__*/React.createElement(View, {
|
|
25
28
|
style: {
|
|
26
29
|
width: 350,
|
|
27
30
|
marginTop: 16
|
|
28
31
|
}
|
|
29
|
-
}, this.props.extraContent), /*#__PURE__*/React.createElement(View, {
|
|
30
|
-
style: styles.buttonsContainer
|
|
31
|
-
}, this.props.buttonsLoading && /*#__PURE__*/React.createElement(View,
|
|
32
|
+
}, this.props.extraContent), this.props.children, /*#__PURE__*/React.createElement(View, {
|
|
33
|
+
style: [styles.buttonsContainer, this.props.verticalButtons && styles.verticalButtons]
|
|
34
|
+
}, this.props.buttonsLoading && /*#__PURE__*/React.createElement(View, {
|
|
35
|
+
style: styles.loadingContainer
|
|
36
|
+
}, /*#__PURE__*/React.createElement(Spinner, null)), !this.props.hideNo && !this.props.buttonsLoading && /*#__PURE__*/React.createElement(InlineButton, {
|
|
32
37
|
onPress: this.props.onCancel,
|
|
33
38
|
color: "#fff",
|
|
34
|
-
style: [styles.button, styles.noButton, {
|
|
39
|
+
style: [styles.button, styles.noButton, this.props.verticalButtons && styles.buttonVertical, {
|
|
35
40
|
borderColor: this.props.colourBrandingMain
|
|
36
41
|
}],
|
|
37
42
|
textStyle: {
|
|
38
43
|
color: this.props.colourBrandingMain
|
|
39
44
|
},
|
|
40
45
|
large: true
|
|
41
|
-
}, this.props.noText || 'No'), !this.props.buttonsLoading && /*#__PURE__*/React.createElement(InlineButton, {
|
|
46
|
+
}, this.props.noText || 'No'), !this.props.hideYes && !this.props.buttonsLoading && /*#__PURE__*/React.createElement(InlineButton, {
|
|
42
47
|
onPress: this.props.onConfirm,
|
|
43
48
|
color: this.props.colourBrandingMain,
|
|
44
|
-
style: styles.button,
|
|
49
|
+
style: [styles.button, this.props.verticalButtons && styles.buttonVertical],
|
|
45
50
|
large: true
|
|
46
51
|
}, this.props.yesText || 'Yes')));
|
|
47
52
|
}
|
|
@@ -50,7 +55,7 @@ class ConfirmPopup extends PureComponent {
|
|
|
50
55
|
|
|
51
56
|
const styles = {
|
|
52
57
|
popup: {
|
|
53
|
-
padding:
|
|
58
|
+
padding: 24,
|
|
54
59
|
margin: 16,
|
|
55
60
|
maxWidth: 350
|
|
56
61
|
},
|
|
@@ -60,10 +65,24 @@ const styles = {
|
|
|
60
65
|
color: TEXT_DARK,
|
|
61
66
|
textAlign: 'center'
|
|
62
67
|
},
|
|
68
|
+
subtext: {
|
|
69
|
+
fontFamily: 'sf-regular',
|
|
70
|
+
fontSize: 17,
|
|
71
|
+
color: TEXT_DARK,
|
|
72
|
+
textAlign: 'center'
|
|
73
|
+
},
|
|
74
|
+
textAlignLeft: {
|
|
75
|
+
textAlign: 'left'
|
|
76
|
+
},
|
|
63
77
|
buttonsContainer: {
|
|
64
78
|
flexDirection: 'row',
|
|
65
79
|
marginTop: 24
|
|
66
80
|
},
|
|
81
|
+
loadingContainer: {
|
|
82
|
+
height: 40,
|
|
83
|
+
justifyContent: 'center',
|
|
84
|
+
alignItems: 'center'
|
|
85
|
+
},
|
|
67
86
|
button: {
|
|
68
87
|
width: 120,
|
|
69
88
|
paddingHorizontal: 2
|
|
@@ -71,6 +90,15 @@ const styles = {
|
|
|
71
90
|
noButton: {
|
|
72
91
|
borderWidth: 1,
|
|
73
92
|
marginRight: 16
|
|
93
|
+
},
|
|
94
|
+
buttonVertical: {
|
|
95
|
+
width: '100%',
|
|
96
|
+
marginTop: 16,
|
|
97
|
+
marginRight: 0,
|
|
98
|
+
paddingHorizontal: 8
|
|
99
|
+
},
|
|
100
|
+
verticalButtons: {
|
|
101
|
+
flexDirection: 'column-reverse'
|
|
74
102
|
}
|
|
75
103
|
};
|
|
76
104
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ConfirmPopup.js"],"names":["React","PureComponent","Text","View","connect","getMainBrandingColourFromState","TEXT_DARK","Spinner","InlineButton","MiddlePopup","ConfirmPopup","render","props","visible","onClose","styles","popup","headerContent","paddingTop","width","marginBottom","text","extraContent","marginTop","buttonsContainer","buttonsLoading","hideNo","onCancel","button","noButton","borderColor","colourBrandingMain","color","noText","onConfirm","yesText","padding","margin","maxWidth","fontFamily","fontSize","textAlign","flexDirection","paddingHorizontal","borderWidth","marginRight","mapStateToProps","state","confirmPopup"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,aAAhB,QAAqC,OAArC;AACA,SAASC,IAAT,EAAeC,IAAf,QAA2B,cAA3B;AACA,SAASC,OAAT,QAAwB,aAAxB;AACA,SAASC,8BAAT,EAAyCC,SAAzC,QAA0D,YAA1D;AACA,SAASC,OAAT,QAAwB,WAAxB;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,WAAT,QAA4B,eAA5B;;AAEA,MAAMC,YAAN,
|
|
1
|
+
{"version":3,"sources":["ConfirmPopup.js"],"names":["React","PureComponent","Text","View","_","connect","getMainBrandingColourFromState","TEXT_DARK","Spinner","InlineButton","MiddlePopup","ConfirmPopup","render","props","visible","onClose","styles","popup","headerContent","paddingTop","width","marginBottom","isEmpty","text","textAlignLeft","subtext","extraContent","marginTop","children","buttonsContainer","verticalButtons","buttonsLoading","loadingContainer","hideNo","onCancel","button","noButton","buttonVertical","borderColor","colourBrandingMain","color","noText","hideYes","onConfirm","yesText","padding","margin","maxWidth","fontFamily","fontSize","textAlign","flexDirection","height","justifyContent","alignItems","paddingHorizontal","borderWidth","marginRight","mapStateToProps","state","confirmPopup"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,aAAhB,QAAqC,OAArC;AACA,SAASC,IAAT,EAAeC,IAAf,QAA2B,cAA3B;AACA,OAAOC,CAAP,MAAc,QAAd;AACA,SAASC,OAAT,QAAwB,aAAxB;AACA,SAASC,8BAAT,EAAyCC,SAAzC,QAA0D,YAA1D;AACA,SAASC,OAAT,QAAwB,WAAxB;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,WAAT,QAA4B,eAA5B;;AAEA,MAAMC,YAAN,SAA2BV,aAA3B,CAAyC;AACvCW,EAAAA,MAAM,GAAG;AACP,wBACE,oBAAC,WAAD;AACE,MAAA,OAAO,EAAE,KAAKC,KAAL,CAAWC,OADtB;AAEE,MAAA,OAAO,EAAE,KAAKD,KAAL,CAAWE,OAFtB;AAGE,MAAA,KAAK,EAAE,CAACC,MAAM,CAACC,KAAR,EAAe,KAAKJ,KAAL,CAAWK,aAAX,IAA4B;AAAEC,QAAAA,UAAU,EAAE;AAAd,OAA3C;AAHT,OAKG,KAAKN,KAAL,CAAWK,aAAX,iBAA4B,oBAAC,IAAD;AAAM,MAAA,KAAK,EAAE;AAAEE,QAAAA,KAAK,EAAE,GAAT;AAAcC,QAAAA,YAAY,EAAE;AAA5B;AAAb,OAAgD,KAAKR,KAAL,CAAWK,aAA3D,CAL/B,EAMG,CAACd,CAAC,CAACkB,OAAF,CAAU,KAAKT,KAAL,CAAWU,IA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0B,IAAAA,SAAS,EAAE;AADE,GAlBF;AAqBbrB,EAAAA,gBAAgB,EAAE;AAChBsB,IAAAA,aAAa,EAAE,KADC;AAEhBxB,IAAAA,SAAS,EAAE;AAFK,GArBL;AAyBbK,EAAAA,gBAAgB,EAAE;AAChBoB,IAAAA,MAAM,EAAE,EADQ;AAEhBC,IAAAA,cAAc,EAAE,QAFA;AAGhBC,IAAAA,UAAU,EAAE;AAHI,GAzBL;AA8BbnB,EAAAA,MAAM,EAAE;AACNf,IAAAA,KAAK,EAAE,GADD;AAENmC,IAAAA,iBAAiB,EAAE;AAFb,GA9BK;AAkCbnB,EAAAA,QAAQ,EAAE;AACRoB,IAAAA,WAAW,EAAE,CADL;AAERC,IAAAA,WAAW,EAAE;AAFL,GAlCG;AAsCbpB,EAAAA,cAAc,EAAE;AACdjB,IAAAA,KAAK,EAAE,MADO;AAEdO,IAAAA,SAAS,EAAE,EAFG;AAGd8B,IAAAA,WAAW,EAAE,CAHC;AAIdF,IAAAA,iBAAiB,EAAE;AAJL,GAtCH;AA4CbzB,EAAAA,eAAe,EAAE;AACfqB,IAAAA,aAAa,EAAE;AADA;AA5CJ,CAAf;;AAiDA,MAAMO,eAAe,GAAGC,KAAK,IAAI;AAC/B,SAAO;AACLpB,IAAAA,kBAAkB,EAAEjC,8BAA8B,CAACqD,KAAD;AAD7C,GAAP;AAGD,CAJD;;AAMA,MAAMC,YAAY,GAAGvD,OAAO,CAACqD,eAAD,EAAkB,EAAlB,CAAP,CAA6B/C,YAA7B,CAArB;AACA,SAASiD,YAAY,IAAIjD,YAAzB","sourcesContent":["import React, { PureComponent } from 'react';\nimport { Text, View } from 'react-native';\nimport _ from 'lodash';\nimport { connect } from 'react-redux';\nimport { getMainBrandingColourFromState, TEXT_DARK } from '../colours';\nimport { Spinner } from './Spinner';\nimport { InlineButton } from './InlineButton';\nimport { MiddlePopup } from './MiddlePopup';\n\nclass ConfirmPopup extends PureComponent {\n render() {\n return (\n <MiddlePopup\n visible={this.props.visible}\n onClose={this.props.onClose}\n style={[styles.popup, this.props.headerContent && { paddingTop: 16 }]}\n >\n {this.props.headerContent && <View style={{ width: 350, marginBottom: 16 }}>{this.props.headerContent}</View>}\n {!_.isEmpty(this.props.text) && (\n <Text style={[styles.text, this.props.textAlignLeft && styles.textAlignLeft]}>{this.props.text}</Text>\n )}\n {!_.isEmpty(this.props.subtext) && (\n <Text style={[styles.subtext, this.props.textAlignLeft && styles.textAlignLeft]}>{this.props.subtext}</Text>\n )}\n {this.props.extraContent && <View style={{ width: 350, marginTop: 16 }}>{this.props.extraContent}</View>}\n {this.props.children}\n <View style={[styles.buttonsContainer, this.props.verticalButtons && styles.verticalButtons]}>\n {this.props.buttonsLoading && (\n <View style={styles.loadingContainer}>\n <Spinner />\n </View>\n )}\n {!this.props.hideNo && !this.props.buttonsLoading && (\n <InlineButton\n onPress={this.props.onCancel}\n color=\"#fff\"\n style={[\n styles.button,\n styles.noButton,\n this.props.verticalButtons && styles.buttonVertical,\n { borderColor: this.props.colourBrandingMain },\n ]}\n textStyle={{ color: this.props.colourBrandingMain }}\n large\n >\n {this.props.noText || 'No'}\n </InlineButton>\n )}\n {!this.props.hideYes && !this.props.buttonsLoading && (\n <InlineButton\n onPress={this.props.onConfirm}\n color={this.props.colourBrandingMain}\n style={[styles.button, this.props.verticalButtons && styles.buttonVertical]}\n large\n >\n {this.props.yesText || 'Yes'}\n </InlineButton>\n )}\n </View>\n </MiddlePopup>\n );\n }\n}\n\nconst styles = {\n popup: {\n padding: 24,\n margin: 16,\n maxWidth: 350,\n },\n text: {\n fontFamily: 'sf-bold',\n fontSize: 20,\n color: TEXT_DARK,\n textAlign: 'center',\n },\n subtext: {\n fontFamily: 'sf-regular',\n fontSize: 17,\n color: TEXT_DARK,\n textAlign: 'center',\n },\n textAlignLeft: {\n textAlign: 'left',\n },\n buttonsContainer: {\n flexDirection: 'row',\n marginTop: 24,\n },\n loadingContainer: {\n height: 40,\n justifyContent: 'center',\n alignItems: 'center',\n },\n button: {\n width: 120,\n paddingHorizontal: 2,\n },\n noButton: {\n borderWidth: 1,\n marginRight: 16,\n },\n buttonVertical: {\n width: '100%',\n marginTop: 16,\n marginRight: 0,\n paddingHorizontal: 8,\n },\n verticalButtons: {\n flexDirection: 'column-reverse',\n },\n};\n\nconst mapStateToProps = state => {\n return {\n colourBrandingMain: getMainBrandingColourFromState(state),\n };\n};\n\nconst confirmPopup = connect(mapStateToProps, {})(ConfirmPopup);\nexport { confirmPopup as ConfirmPopup };\n"]}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import React, { PureComponent } from 'react';
|
|
2
2
|
import { Text, View, ScrollView, StyleSheet } from 'react-native';
|
|
3
|
+
import _ from 'lodash';
|
|
3
4
|
import { TEXT_BLUEGREY } from '../colours';
|
|
4
5
|
|
|
5
6
|
class EmptyStateMain extends PureComponent {
|
|
6
|
-
renderPlaceHolder() {
|
|
7
|
-
let opacity = arguments.length >
|
|
7
|
+
renderPlaceHolder(index) {
|
|
8
|
+
let opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
9
|
+
const barCount = _.isUndefined(this.props.barCount) ? 3 : this.props.barCount;
|
|
10
|
+
|
|
11
|
+
if (barCount <= index) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
return /*#__PURE__*/React.createElement(View, {
|
|
9
16
|
style: [styles.item, {
|
|
10
17
|
opacity
|
|
@@ -15,11 +22,11 @@ class EmptyStateMain extends PureComponent {
|
|
|
15
22
|
render() {
|
|
16
23
|
return /*#__PURE__*/React.createElement(View, {
|
|
17
24
|
style: [styles.container, this.props.style]
|
|
18
|
-
}, /*#__PURE__*/React.createElement(Text, {
|
|
25
|
+
}, !this.props.hideTitle && /*#__PURE__*/React.createElement(Text, {
|
|
19
26
|
style: styles.titleText
|
|
20
|
-
}, this.props.title || 'Nothing to see here'), /*#__PURE__*/React.createElement(ScrollView, {
|
|
27
|
+
}, this.props.title || 'Nothing to see here'), this.props.content, /*#__PURE__*/React.createElement(ScrollView, {
|
|
21
28
|
style: styles.itemContainer
|
|
22
|
-
}, this.renderPlaceHolder(0.8), this.renderPlaceHolder(0.6), this.renderPlaceHolder(0.4)));
|
|
29
|
+
}, this.renderPlaceHolder(0, 0.8), this.renderPlaceHolder(1, 0.6), this.renderPlaceHolder(2, 0.4)));
|
|
23
30
|
}
|
|
24
31
|
|
|
25
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["EmptyStateMain.js"],"names":["React","PureComponent","Text","View","ScrollView","StyleSheet","TEXT_BLUEGREY","EmptyStateMain","renderPlaceHolder","opacity","styles","item","render","container","
|
|
1
|
+
{"version":3,"sources":["EmptyStateMain.js"],"names":["React","PureComponent","Text","View","ScrollView","StyleSheet","_","TEXT_BLUEGREY","EmptyStateMain","renderPlaceHolder","index","opacity","barCount","isUndefined","props","styles","item","render","container","style","hideTitle","titleText","title","content","itemContainer","create","borderRadius","paddingVertical","fontFamily","fontSize","color","marginTop","flexDirection","width","height","backgroundColor","marginBottom"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,aAAhB,QAAqC,OAArC;AACA,SAASC,IAAT,EAAeC,IAAf,EAAqBC,UAArB,EAAiCC,UAAjC,QAAmD,cAAnD;AACA,OAAOC,CAAP,MAAc,QAAd;AACA,SAASC,aAAT,QAA8B,YAA9B;;AAEA,MAAMC,cAAN,SAA6BP,aAA7B,CAA2C;AACzCQ,EAAAA,iBAAiB,CAACC,KAAD,EAAqB;AAAA,QAAbC,OAAa,uEAAH,CAAG;AACpC,UAAMC,QAAQ,GAAGN,CAAC,CAACO,WAAF,CAAc,KAAKC,KAAL,CAAWF,QAAzB,IAAqC,CAArC,GAAyC,KAAKE,KAAL,CAAWF,QAArE;;AACA,QAAIA,QAAQ,IAAIF,KAAhB,EAAuB;AACrB,aAAO,IAAP;AACD;;AACD,wBAAO,oBAAC,IAAD;AAAM,MAAA,KAAK,EAAE,CAACK,MAAM,CAACC,IAAR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BA,eAAe5B,cAAf","sourcesContent":["import React, { PureComponent } from 'react';\nimport { Text, View, ScrollView, StyleSheet } from 'react-native';\nimport _ from 'lodash';\nimport { TEXT_BLUEGREY } from '../colours';\n\nclass EmptyStateMain extends PureComponent {\n renderPlaceHolder(index, opacity = 1) {\n const barCount = _.isUndefined(this.props.barCount) ? 3 : this.props.barCount;\n if (barCount <= index) {\n return null;\n }\n return <View style={[styles.item, { opacity }]} />;\n }\n\n render() {\n return (\n <View style={[styles.container, this.props.style]}>\n {!this.props.hideTitle && <Text style={styles.titleText}>{this.props.title || 'Nothing to see here'}</Text>}\n {this.props.content}\n <ScrollView style={styles.itemContainer}>\n {this.renderPlaceHolder(0, 0.8)}\n {this.renderPlaceHolder(1, 0.6)}\n {this.renderPlaceHolder(2, 0.4)}\n </ScrollView>\n </View>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n container: {\n borderRadius: 5,\n paddingVertical: 5,\n },\n titleText: {\n fontFamily: 'qs-bold',\n fontSize: 16,\n color: TEXT_BLUEGREY,\n },\n itemContainer: {\n marginTop: 20,\n flexDirection: 'column',\n },\n item: {\n borderRadius: 4,\n width: '100%',\n height: 32,\n backgroundColor: '#e6ebef',\n marginBottom: 17,\n },\n});\n\nexport default EmptyStateMain;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.js"],"names":["default","EmptyStateWidget","EmptyStateMain","LoadingStateWidget","Header","LoadingIndicator","ImageUploader","ImageUploadProgress","UserListing","PlussChat","PositionedImage","FormattedText","MediaPlayer","AudienceSelectorPage"],"mappings":"AAAA,cAAc,gBAAd;AACA,cAAc,YAAd;AACA,cAAc,mBAAd;AACA,cAAc,iCAAd;AACA,cAAc,cAAd;AACA,cAAc,WAAd;AACA,cAAc,kBAAd;AACA,cAAc,SAAd;AACA,cAAc,cAAd;AACA,cAAc,cAAd;AACA,cAAc,gBAAd;AACA,cAAc,eAAd;AACA,cAAc,gBAAd;AACA,cAAc,qBAAd;AACA,cAAc,kBAAd;AACA,cAAc,gBAAd;AACA,cAAc,aAAd;AACA,cAAc,aAAd;AACA,cAAc,cAAd;AACA,cAAc,uBAAd;AACA,cAAc,gBAAd;AACA,cAAc,eAAd;AACA,cAAc,YAAd;AACA,cAAc,aAAd;AACA,cAAc,UAAd;AACA,cAAc,SAAd;AACA,cAAc,gBAAd;AACA,cAAc,gBAAd;AACA,cAAc,gBAAd;AACA,cAAc,gBAAd;AACA,cAAc,cAAd;AACA,cAAc,YAAd;AACA,cAAc,sBAAd;AACA,cAAc,gBAAd;AACA,cAAc,kBAAd;AACA,cAAc,mBAAd;AACA,cAAc,iBAAd;AACA,cAAc,aAAd;AACA,cAAc,4BAAd;AACA,SAASA,OAAO,IAAIC,gBAApB,QAA4C,oBAA5C;AACA,SAASD,OAAO,IAAIE,cAApB,QAA0C,kBAA1C;AACA,SAASF,OAAO,IAAIG,kBAApB,QAA8C,sBAA9C;AACA,SAASH,OAAO,IAAII,MAApB,QAAkC,UAAlC;AACA,SAASJ,OAAO,IAAIK,gBAApB,QAA4C,oBAA5C;AACA,SAASL,OAAO,IAAIM,aAApB,QAAyC,iBAAzC;AACA,SAASN,OAAO,IAAIO,mBAApB,QAA+C,uBAA/C;AACA,SAASP,OAAO,IAAIQ,WAApB,QAAuC,eAAvC;AACA,SAASR,OAAO,IAAIS,SAApB,QAAqC,aAArC;AACA,SAAST,OAAO,IAAIU,eAApB,QAA2C,mBAA3C;AACA,SAASV,OAAO,IAAIW,aAApB,QAAyC,iBAAzC;AACA,SAASX,OAAO,IAAIY,WAApB,QAAuC,eAAvC;AACA,SAASZ,OAAO,IAAIa,oBAApB,QAAgD,wBAAhD","sourcesContent":["export * from './InlineButton';\nexport * from './FormCard';\nexport * from './FormCardSection';\nexport * from './FormCardSectionOptionLauncher';\nexport * from './ProfilePic';\nexport * from './Spinner';\nexport * from './LoadingCircles';\nexport * from './Popup';\nexport * from './ImagePopup';\nexport * from './VideoPopup';\nexport * from './SharingTools';\nexport * from './MiddlePopup';\nexport * from './ConfirmPopup';\nexport * from './ConfirmationPopup';\nexport * from './CommentSection';\nexport * from './CommentReply';\nexport * from './PopupMenu';\nexport * from './AddButton';\nexport * from './Attachment';\nexport * from './GenericInputSection';\nexport * from './GenericInput';\nexport * from './RadioButton';\nexport * from './PDFPopup';\nexport * from './TextStyle';\nexport * from './Toggle';\nexport * from './Input';\nexport * from './StickyFooter';\nexport * from './CategoryTabs';\nexport * from './DropDownMenu';\nexport * from './DropDownItem';\nexport * from './BackButton';\nexport * from './Reaction';\nexport * from './TouchableSearchBar';\nexport * from './WarningPopup';\nexport * from './FontScalePopup';\nexport * from './FontScaleButton';\nexport * from './UserListPopup';\nexport * from './Reactions';\nexport * from './AudienceSelectorLauncher';\nexport { default as EmptyStateWidget } from './EmptyStateWidget';\nexport { default as EmptyStateMain } from './EmptyStateMain';\nexport { default as LoadingStateWidget } from './LoadingStateWidget';\nexport { default as Header } from './Header';\nexport { default as LoadingIndicator } from './LoadingIndicator';\nexport { default as ImageUploader } from './ImageUploader';\nexport { default as ImageUploadProgress } from './ImageUploadProgress';\nexport { default as UserListing } from './UserListing';\nexport { default as PlussChat } from './PlussChat';\nexport { default as PositionedImage } from './PositionedImage';\nexport { default as FormattedText } from './FormattedText';\nexport { default as MediaPlayer } from './MediaPlayer';\nexport { default as AudienceSelectorPage } from './AudienceSelectorPage';\n"]}
|
|
1
|
+
{"version":3,"sources":["index.js"],"names":["default","EmptyStateWidget","EmptyStateMain","LoadingStateWidget","Header","LoadingIndicator","ImageUploader","ImageUploadProgress","UserListing","PlussChat","PositionedImage","FormattedText","MediaPlayer","AudienceSelectorPage"],"mappings":"AAAA,cAAc,gBAAd;AACA,cAAc,uBAAd;AACA,cAAc,YAAd;AACA,cAAc,mBAAd;AACA,cAAc,iCAAd;AACA,cAAc,cAAd;AACA,cAAc,WAAd;AACA,cAAc,kBAAd;AACA,cAAc,SAAd;AACA,cAAc,cAAd;AACA,cAAc,cAAd;AACA,cAAc,gBAAd;AACA,cAAc,eAAd;AACA,cAAc,gBAAd;AACA,cAAc,qBAAd;AACA,cAAc,kBAAd;AACA,cAAc,gBAAd;AACA,cAAc,aAAd;AACA,cAAc,aAAd;AACA,cAAc,cAAd;AACA,cAAc,uBAAd;AACA,cAAc,gBAAd;AACA,cAAc,eAAd;AACA,cAAc,YAAd;AACA,cAAc,aAAd;AACA,cAAc,UAAd;AACA,cAAc,SAAd;AACA,cAAc,gBAAd;AACA,cAAc,gBAAd;AACA,cAAc,gBAAd;AACA,cAAc,gBAAd;AACA,cAAc,cAAd;AACA,cAAc,YAAd;AACA,cAAc,sBAAd;AACA,cAAc,gBAAd;AACA,cAAc,kBAAd;AACA,cAAc,mBAAd;AACA,cAAc,iBAAd;AACA,cAAc,aAAd;AACA,cAAc,4BAAd;AACA,SAASA,OAAO,IAAIC,gBAApB,QAA4C,oBAA5C;AACA,SAASD,OAAO,IAAIE,cAApB,QAA0C,kBAA1C;AACA,SAASF,OAAO,IAAIG,kBAApB,QAA8C,sBAA9C;AACA,SAASH,OAAO,IAAII,MAApB,QAAkC,UAAlC;AACA,SAASJ,OAAO,IAAIK,gBAApB,QAA4C,oBAA5C;AACA,SAASL,OAAO,IAAIM,aAApB,QAAyC,iBAAzC;AACA,SAASN,OAAO,IAAIO,mBAApB,QAA+C,uBAA/C;AACA,SAASP,OAAO,IAAIQ,WAApB,QAAuC,eAAvC;AACA,SAASR,OAAO,IAAIS,SAApB,QAAqC,aAArC;AACA,SAAST,OAAO,IAAIU,eAApB,QAA2C,mBAA3C;AACA,SAASV,OAAO,IAAIW,aAApB,QAAyC,iBAAzC;AACA,SAASX,OAAO,IAAIY,WAApB,QAAuC,eAAvC;AACA,SAASZ,OAAO,IAAIa,oBAApB,QAAgD,wBAAhD","sourcesContent":["export * from './InlineButton';\nexport * from './AddToCalendarButton';\nexport * from './FormCard';\nexport * from './FormCardSection';\nexport * from './FormCardSectionOptionLauncher';\nexport * from './ProfilePic';\nexport * from './Spinner';\nexport * from './LoadingCircles';\nexport * from './Popup';\nexport * from './ImagePopup';\nexport * from './VideoPopup';\nexport * from './SharingTools';\nexport * from './MiddlePopup';\nexport * from './ConfirmPopup';\nexport * from './ConfirmationPopup';\nexport * from './CommentSection';\nexport * from './CommentReply';\nexport * from './PopupMenu';\nexport * from './AddButton';\nexport * from './Attachment';\nexport * from './GenericInputSection';\nexport * from './GenericInput';\nexport * from './RadioButton';\nexport * from './PDFPopup';\nexport * from './TextStyle';\nexport * from './Toggle';\nexport * from './Input';\nexport * from './StickyFooter';\nexport * from './CategoryTabs';\nexport * from './DropDownMenu';\nexport * from './DropDownItem';\nexport * from './BackButton';\nexport * from './Reaction';\nexport * from './TouchableSearchBar';\nexport * from './WarningPopup';\nexport * from './FontScalePopup';\nexport * from './FontScaleButton';\nexport * from './UserListPopup';\nexport * from './Reactions';\nexport * from './AudienceSelectorLauncher';\nexport { default as EmptyStateWidget } from './EmptyStateWidget';\nexport { default as EmptyStateMain } from './EmptyStateMain';\nexport { default as LoadingStateWidget } from './LoadingStateWidget';\nexport { default as Header } from './Header';\nexport { default as LoadingIndicator } from './LoadingIndicator';\nexport { default as ImageUploader } from './ImageUploader';\nexport { default as ImageUploadProgress } from './ImageUploadProgress';\nexport { default as UserListing } from './UserListing';\nexport { default as PlussChat } from './PlussChat';\nexport { default as PositionedImage } from './PositionedImage';\nexport { default as FormattedText } from './FormattedText';\nexport { default as MediaPlayer } from './MediaPlayer';\nexport { default as AudienceSelectorPage } from './AudienceSelectorPage';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plusscommunities/pluss-core-app",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Core extension package for Pluss Communities platform",
|
|
5
5
|
"main": "dist/module/index.js",
|
|
6
6
|
"module": "dist/module/index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"src/"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
-
"build": "bob build",
|
|
13
|
+
"build": "npm i && bob build",
|
|
14
14
|
"betapatch": "npm version prepatch --preid=beta",
|
|
15
15
|
"patch": "npm version patch",
|
|
16
16
|
"betaupload": "npm run build && npm publish --access public --tag beta",
|
|
@@ -28,11 +28,12 @@
|
|
|
28
28
|
"aws-amplify": "^4.3.11",
|
|
29
29
|
"aws-amplify-react-native": "^6.0.2",
|
|
30
30
|
"expo-av": "~10.2.0",
|
|
31
|
+
"expo-calendar": "~10.1.0",
|
|
31
32
|
"expo-constants": "~13.0.0",
|
|
32
|
-
"expo-file-system": "~13.1.
|
|
33
|
+
"expo-file-system": "~13.1.4",
|
|
33
34
|
"expo-image-manipulator": "~10.2.0",
|
|
34
35
|
"expo-image-picker": "~12.0.1",
|
|
35
|
-
"expo-linear-gradient": "~11.0.
|
|
36
|
+
"expo-linear-gradient": "~11.0.3",
|
|
36
37
|
"expo-media-library": "~14.0.0",
|
|
37
38
|
"expo-screen-orientation": "~4.1.1",
|
|
38
39
|
"expo-sharing": "~10.1.0",
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { Platform, Linking, StyleSheet, Text, View, TouchableOpacity, ScrollView } from 'react-native';
|
|
3
|
+
import { connect } from 'react-redux';
|
|
4
|
+
import _ from 'lodash';
|
|
5
|
+
import * as Calendar from 'expo-calendar';
|
|
6
|
+
import { TEXT_DARK, getMainBrandingColourFromState } from '../colours';
|
|
7
|
+
import { InlineButton } from './InlineButton';
|
|
8
|
+
import { Popup } from './Popup';
|
|
9
|
+
import { MiddlePopup } from './MiddlePopup';
|
|
10
|
+
|
|
11
|
+
const DEFAULT_TITLE = 'Add to Calendar';
|
|
12
|
+
const ERROR_EVENT_ADD = 'There was a problem adding a calendar event.';
|
|
13
|
+
|
|
14
|
+
// Required: eventToAdd
|
|
15
|
+
// Documentation: https://docs.expo.dev/versions/latest/sdk/calendar/#event
|
|
16
|
+
class AddToCalendarButton extends Component {
|
|
17
|
+
constructor(props) {
|
|
18
|
+
super(props);
|
|
19
|
+
|
|
20
|
+
this.state = {
|
|
21
|
+
showPermissionWarning: false,
|
|
22
|
+
calendars: null,
|
|
23
|
+
message: null,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
showWarningPopup = () => {
|
|
28
|
+
if (Platform.OS !== 'ios') return;
|
|
29
|
+
this.setState({ showPermissionWarning: true });
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
closeWarningPopup = () => {
|
|
33
|
+
this.setState({ showPermissionWarning: false });
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
goToPermissionSettings = () => {
|
|
37
|
+
Linking.openURL('app-settings:');
|
|
38
|
+
this.setState({ showPermissionWarning: false });
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
onAdd = async () => {
|
|
42
|
+
if (!this.props.eventToAdd) {
|
|
43
|
+
this.setState({ message: 'There is no event to add' });
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const { status } = await Calendar.requestCalendarPermissionsAsync();
|
|
48
|
+
if (status !== 'granted') {
|
|
49
|
+
this.showWarningPopup();
|
|
50
|
+
} else {
|
|
51
|
+
let calendars = await Calendar.getCalendarsAsync(Calendar.EntityTypes.EVENT);
|
|
52
|
+
// console.log('all calendars', calendars);
|
|
53
|
+
if (calendars && calendars.length > 0) {
|
|
54
|
+
calendars = calendars
|
|
55
|
+
.filter(c => c.allowsModifications)
|
|
56
|
+
.map(c => {
|
|
57
|
+
return {
|
|
58
|
+
id: c.id,
|
|
59
|
+
title: c.title,
|
|
60
|
+
source: c.source.name,
|
|
61
|
+
color: c.color,
|
|
62
|
+
type: c.type,
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
calendars = _.orderBy(calendars, ['source', 'title']);
|
|
66
|
+
// console.log('sorted calendars', calendars);
|
|
67
|
+
}
|
|
68
|
+
this.setState({ calendars });
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
onCloseCalendars = () => {
|
|
73
|
+
this.setState({ calendars: null });
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
onSelectCalendar = async calendar => {
|
|
77
|
+
try {
|
|
78
|
+
const { eventToAdd } = this.props;
|
|
79
|
+
if (!eventToAdd) return;
|
|
80
|
+
|
|
81
|
+
const eventId = await Calendar.createEventAsync(calendar.id, eventToAdd);
|
|
82
|
+
|
|
83
|
+
this.setState({
|
|
84
|
+
calendars: null,
|
|
85
|
+
message: eventId ? `${eventToAdd.title} was added to ${calendar.title} successfully.` : ERROR_EVENT_ADD,
|
|
86
|
+
});
|
|
87
|
+
} catch (error) {
|
|
88
|
+
console.log('onSelectCalendar', error);
|
|
89
|
+
this.setState({ calendars: null, message: ERROR_EVENT_ADD });
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
onCloseMessage = () => {
|
|
94
|
+
this.setState({ message: null });
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
renderPermission() {
|
|
98
|
+
return (
|
|
99
|
+
<Popup
|
|
100
|
+
title="Permissions missing"
|
|
101
|
+
text="You must grant access to the Calendars. Tap Go to settings to change your permission settings."
|
|
102
|
+
options={[
|
|
103
|
+
{
|
|
104
|
+
text: 'Go to settings',
|
|
105
|
+
action: this.goToPermissionSettings,
|
|
106
|
+
bold: true,
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
text: 'Ignore',
|
|
110
|
+
action: this.closeWarningPopup,
|
|
111
|
+
},
|
|
112
|
+
]}
|
|
113
|
+
/>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
renderCalendars(calendars) {
|
|
118
|
+
return (
|
|
119
|
+
<MiddlePopup style={[styles.calendarsPopup, { height: calendars.length * 60 + 120 }]} onClose={this.onCloseCalendars}>
|
|
120
|
+
<Text style={styles.calendarPopupTitle}>Select Calendar</Text>
|
|
121
|
+
<View style={styles.calendarPopupContainer}>
|
|
122
|
+
<ScrollView style={{ flex: 1 }} showsVerticalScrollIndicator={false}>
|
|
123
|
+
{calendars.map(cal => {
|
|
124
|
+
return (
|
|
125
|
+
<TouchableOpacity key={cal.id} onPress={() => this.onSelectCalendar(cal)}>
|
|
126
|
+
<View style={[styles.calendarContainer, { backgroundColor: cal.color }]}>
|
|
127
|
+
<Text style={styles.calendarText}>{`${cal.source}${cal.source === cal.title ? '' : `\n${cal.title}`}`}</Text>
|
|
128
|
+
</View>
|
|
129
|
+
</TouchableOpacity>
|
|
130
|
+
);
|
|
131
|
+
})}
|
|
132
|
+
</ScrollView>
|
|
133
|
+
<TouchableOpacity key={'cancel'} onPress={this.onCloseCalendars}>
|
|
134
|
+
<View style={[styles.calendarContainer, { marginTop: 20, backgroundColor: this.props.colourBrandingMain }]}>
|
|
135
|
+
<Text style={styles.calendarText}>Cancel</Text>
|
|
136
|
+
</View>
|
|
137
|
+
</TouchableOpacity>
|
|
138
|
+
</View>
|
|
139
|
+
</MiddlePopup>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
renderMessage(message) {
|
|
144
|
+
return (
|
|
145
|
+
<Popup
|
|
146
|
+
title="Add to Calendar"
|
|
147
|
+
text={message}
|
|
148
|
+
options={[
|
|
149
|
+
{
|
|
150
|
+
text: 'Ok',
|
|
151
|
+
action: this.onCloseMessage,
|
|
152
|
+
},
|
|
153
|
+
]}
|
|
154
|
+
/>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
render() {
|
|
159
|
+
const { showPermissionWarning, calendars, message } = this.state;
|
|
160
|
+
|
|
161
|
+
if (showPermissionWarning) return this.renderPermission();
|
|
162
|
+
if (calendars && calendars.length > 0) return this.renderCalendars(calendars);
|
|
163
|
+
if (message) return this.renderMessage(message);
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<InlineButton {...this.props} onPress={this.onAdd}>
|
|
167
|
+
{this.props.children || DEFAULT_TITLE}
|
|
168
|
+
</InlineButton>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const styles = StyleSheet.create({
|
|
174
|
+
calendarsPopup: {
|
|
175
|
+
width: 250,
|
|
176
|
+
maxHeight: 400,
|
|
177
|
+
padding: 16,
|
|
178
|
+
borderRadius: 12,
|
|
179
|
+
},
|
|
180
|
+
calendarPopupTitle: {
|
|
181
|
+
fontFamily: 'sf-bold',
|
|
182
|
+
color: TEXT_DARK,
|
|
183
|
+
fontSize: 18,
|
|
184
|
+
marginBottom: 16,
|
|
185
|
+
},
|
|
186
|
+
calendarPopupContainer: {
|
|
187
|
+
flex: 1,
|
|
188
|
+
justifyContent: 'space-between',
|
|
189
|
+
},
|
|
190
|
+
calendarContainer: {
|
|
191
|
+
flexDirection: 'row',
|
|
192
|
+
alignItems: 'center',
|
|
193
|
+
width: 200,
|
|
194
|
+
height: 40,
|
|
195
|
+
paddingHorizontal: 8,
|
|
196
|
+
borderRadius: 4,
|
|
197
|
+
marginBottom: 10,
|
|
198
|
+
},
|
|
199
|
+
calendarText: {
|
|
200
|
+
color: '#fff',
|
|
201
|
+
textAlign: 'center',
|
|
202
|
+
fontFamily: 'sf-semibold',
|
|
203
|
+
fontSize: 13,
|
|
204
|
+
flex: 1,
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
const mapStateToProps = state => {
|
|
209
|
+
return {
|
|
210
|
+
colourBrandingMain: getMainBrandingColourFromState(state),
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const button = connect(mapStateToProps, {})(AddToCalendarButton);
|
|
215
|
+
export { button as AddToCalendarButton };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { PureComponent } from 'react';
|
|
2
2
|
import { Text, View } from 'react-native';
|
|
3
|
+
import _ from 'lodash';
|
|
3
4
|
import { connect } from 'react-redux';
|
|
4
5
|
import { getMainBrandingColourFromState, TEXT_DARK } from '../colours';
|
|
5
6
|
import { Spinner } from './Spinner';
|
|
@@ -15,11 +16,17 @@ class ConfirmPopup extends PureComponent {
|
|
|
15
16
|
style={[styles.popup, this.props.headerContent && { paddingTop: 16 }]}
|
|
16
17
|
>
|
|
17
18
|
{this.props.headerContent && <View style={{ width: 350, marginBottom: 16 }}>{this.props.headerContent}</View>}
|
|
18
|
-
|
|
19
|
+
{!_.isEmpty(this.props.text) && (
|
|
20
|
+
<Text style={[styles.text, this.props.textAlignLeft && styles.textAlignLeft]}>{this.props.text}</Text>
|
|
21
|
+
)}
|
|
22
|
+
{!_.isEmpty(this.props.subtext) && (
|
|
23
|
+
<Text style={[styles.subtext, this.props.textAlignLeft && styles.textAlignLeft]}>{this.props.subtext}</Text>
|
|
24
|
+
)}
|
|
19
25
|
{this.props.extraContent && <View style={{ width: 350, marginTop: 16 }}>{this.props.extraContent}</View>}
|
|
20
|
-
|
|
26
|
+
{this.props.children}
|
|
27
|
+
<View style={[styles.buttonsContainer, this.props.verticalButtons && styles.verticalButtons]}>
|
|
21
28
|
{this.props.buttonsLoading && (
|
|
22
|
-
<View>
|
|
29
|
+
<View style={styles.loadingContainer}>
|
|
23
30
|
<Spinner />
|
|
24
31
|
</View>
|
|
25
32
|
)}
|
|
@@ -27,15 +34,25 @@ class ConfirmPopup extends PureComponent {
|
|
|
27
34
|
<InlineButton
|
|
28
35
|
onPress={this.props.onCancel}
|
|
29
36
|
color="#fff"
|
|
30
|
-
style={[
|
|
37
|
+
style={[
|
|
38
|
+
styles.button,
|
|
39
|
+
styles.noButton,
|
|
40
|
+
this.props.verticalButtons && styles.buttonVertical,
|
|
41
|
+
{ borderColor: this.props.colourBrandingMain },
|
|
42
|
+
]}
|
|
31
43
|
textStyle={{ color: this.props.colourBrandingMain }}
|
|
32
44
|
large
|
|
33
45
|
>
|
|
34
46
|
{this.props.noText || 'No'}
|
|
35
47
|
</InlineButton>
|
|
36
48
|
)}
|
|
37
|
-
{!this.props.buttonsLoading && (
|
|
38
|
-
<InlineButton
|
|
49
|
+
{!this.props.hideYes && !this.props.buttonsLoading && (
|
|
50
|
+
<InlineButton
|
|
51
|
+
onPress={this.props.onConfirm}
|
|
52
|
+
color={this.props.colourBrandingMain}
|
|
53
|
+
style={[styles.button, this.props.verticalButtons && styles.buttonVertical]}
|
|
54
|
+
large
|
|
55
|
+
>
|
|
39
56
|
{this.props.yesText || 'Yes'}
|
|
40
57
|
</InlineButton>
|
|
41
58
|
)}
|
|
@@ -47,7 +64,7 @@ class ConfirmPopup extends PureComponent {
|
|
|
47
64
|
|
|
48
65
|
const styles = {
|
|
49
66
|
popup: {
|
|
50
|
-
padding:
|
|
67
|
+
padding: 24,
|
|
51
68
|
margin: 16,
|
|
52
69
|
maxWidth: 350,
|
|
53
70
|
},
|
|
@@ -57,10 +74,24 @@ const styles = {
|
|
|
57
74
|
color: TEXT_DARK,
|
|
58
75
|
textAlign: 'center',
|
|
59
76
|
},
|
|
77
|
+
subtext: {
|
|
78
|
+
fontFamily: 'sf-regular',
|
|
79
|
+
fontSize: 17,
|
|
80
|
+
color: TEXT_DARK,
|
|
81
|
+
textAlign: 'center',
|
|
82
|
+
},
|
|
83
|
+
textAlignLeft: {
|
|
84
|
+
textAlign: 'left',
|
|
85
|
+
},
|
|
60
86
|
buttonsContainer: {
|
|
61
87
|
flexDirection: 'row',
|
|
62
88
|
marginTop: 24,
|
|
63
89
|
},
|
|
90
|
+
loadingContainer: {
|
|
91
|
+
height: 40,
|
|
92
|
+
justifyContent: 'center',
|
|
93
|
+
alignItems: 'center',
|
|
94
|
+
},
|
|
64
95
|
button: {
|
|
65
96
|
width: 120,
|
|
66
97
|
paddingHorizontal: 2,
|
|
@@ -69,6 +100,15 @@ const styles = {
|
|
|
69
100
|
borderWidth: 1,
|
|
70
101
|
marginRight: 16,
|
|
71
102
|
},
|
|
103
|
+
buttonVertical: {
|
|
104
|
+
width: '100%',
|
|
105
|
+
marginTop: 16,
|
|
106
|
+
marginRight: 0,
|
|
107
|
+
paddingHorizontal: 8,
|
|
108
|
+
},
|
|
109
|
+
verticalButtons: {
|
|
110
|
+
flexDirection: 'column-reverse',
|
|
111
|
+
},
|
|
72
112
|
};
|
|
73
113
|
|
|
74
114
|
const mapStateToProps = state => {
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import React, { PureComponent } from 'react';
|
|
2
2
|
import { Text, View, ScrollView, StyleSheet } from 'react-native';
|
|
3
|
+
import _ from 'lodash';
|
|
3
4
|
import { TEXT_BLUEGREY } from '../colours';
|
|
4
5
|
|
|
5
6
|
class EmptyStateMain extends PureComponent {
|
|
6
|
-
renderPlaceHolder(opacity = 1) {
|
|
7
|
+
renderPlaceHolder(index, opacity = 1) {
|
|
8
|
+
const barCount = _.isUndefined(this.props.barCount) ? 3 : this.props.barCount;
|
|
9
|
+
if (barCount <= index) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
7
12
|
return <View style={[styles.item, { opacity }]} />;
|
|
8
13
|
}
|
|
9
14
|
|
|
10
15
|
render() {
|
|
11
16
|
return (
|
|
12
17
|
<View style={[styles.container, this.props.style]}>
|
|
13
|
-
<Text style={styles.titleText}>{this.props.title || 'Nothing to see here'}</Text>
|
|
18
|
+
{!this.props.hideTitle && <Text style={styles.titleText}>{this.props.title || 'Nothing to see here'}</Text>}
|
|
19
|
+
{this.props.content}
|
|
14
20
|
<ScrollView style={styles.itemContainer}>
|
|
15
|
-
{this.renderPlaceHolder(0.8)}
|
|
16
|
-
{this.renderPlaceHolder(0.6)}
|
|
17
|
-
{this.renderPlaceHolder(0.4)}
|
|
21
|
+
{this.renderPlaceHolder(0, 0.8)}
|
|
22
|
+
{this.renderPlaceHolder(1, 0.6)}
|
|
23
|
+
{this.renderPlaceHolder(2, 0.4)}
|
|
18
24
|
</ScrollView>
|
|
19
25
|
</View>
|
|
20
26
|
);
|