@plusscommunities/pluss-core-app 6.0.6-auth.0 → 6.0.7-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.
- package/dist/module/actions/FollowerActions.js.map +1 -1
- package/dist/module/actions/MediaActions.js.map +1 -1
- package/dist/module/actions/ResidentActions.js.map +1 -1
- package/dist/module/actions/UserActions.js.map +1 -1
- package/dist/module/actions/UserSettingsActions.js.map +1 -1
- package/dist/module/actions/index.js.map +1 -1
- package/dist/module/actions/types.js.map +1 -1
- package/dist/module/apis/analyticsActions.js.map +1 -1
- package/dist/module/apis/contactActions.js.map +1 -1
- package/dist/module/apis/eventActions.js.map +1 -1
- package/dist/module/apis/fileActions.js +28 -21
- package/dist/module/apis/fileActions.js.map +1 -1
- package/dist/module/apis/followerActions.js.map +1 -1
- package/dist/module/apis/index.js.map +1 -1
- package/dist/module/apis/notificationActions.js.map +1 -1
- package/dist/module/apis/profileActions.js.map +1 -1
- package/dist/module/apis/reactionActions.js.map +1 -1
- package/dist/module/apis/stringActions.js.map +1 -1
- package/dist/module/apis/typeActions.js.map +1 -1
- package/dist/module/apis/userActions.js.map +1 -1
- package/dist/module/colours.js.map +1 -1
- package/dist/module/components/AddButton.js.map +1 -1
- package/dist/module/components/AddToCalendarButton.js +5 -4
- package/dist/module/components/AddToCalendarButton.js.map +1 -1
- package/dist/module/components/Attachment.js.map +1 -1
- package/dist/module/components/AudienceSelectorLauncher.js +3 -3
- package/dist/module/components/AudienceSelectorLauncher.js.map +1 -1
- package/dist/module/components/AudienceSelectorPage.js +3 -3
- package/dist/module/components/AudienceSelectorPage.js.map +1 -1
- package/dist/module/components/AutoOffsetImage.js +5 -3
- package/dist/module/components/AutoOffsetImage.js.map +1 -1
- package/dist/module/components/BackButton.js.map +1 -1
- package/dist/module/components/CategoryTabs.js.map +1 -1
- package/dist/module/components/CommentReply.js +3 -3
- package/dist/module/components/CommentReply.js.map +1 -1
- package/dist/module/components/CommentSection.js +4 -3
- package/dist/module/components/CommentSection.js.map +1 -1
- package/dist/module/components/ConfirmPopup.js.map +1 -1
- package/dist/module/components/ConfirmationPopup.js.map +1 -1
- package/dist/module/components/DropDownItem.js +3 -3
- package/dist/module/components/DropDownItem.js.map +1 -1
- package/dist/module/components/DropDownMenu.js +3 -3
- package/dist/module/components/DropDownMenu.js.map +1 -1
- package/dist/module/components/EmptyStateMain.js.map +1 -1
- package/dist/module/components/EmptyStateWidget.js.map +1 -1
- package/dist/module/components/FontScaleButton.js.map +1 -1
- package/dist/module/components/FontScalePopup.js.map +1 -1
- package/dist/module/components/Forbidden.js +58 -0
- package/dist/module/components/Forbidden.js.map +1 -0
- package/dist/module/components/FormCard.js.map +1 -1
- package/dist/module/components/FormCardSection.js.map +1 -1
- package/dist/module/components/FormCardSectionOptionLauncher.js.map +1 -1
- package/dist/module/components/FormattedText.js +3 -3
- package/dist/module/components/FormattedText.js.map +1 -1
- package/dist/module/components/GenericInput.js.map +1 -1
- package/dist/module/components/GenericInputSection.js +1 -1
- package/dist/module/components/GenericInputSection.js.map +1 -1
- package/dist/module/components/Header.js.map +1 -1
- package/dist/module/components/ImagePopup.js +3 -3
- package/dist/module/components/ImagePopup.js.map +1 -1
- package/dist/module/components/ImageUploadProgress.js +3 -3
- package/dist/module/components/ImageUploadProgress.js.map +1 -1
- package/dist/module/components/ImageUploader.js +32 -20
- package/dist/module/components/ImageUploader.js.map +1 -1
- package/dist/module/components/InlineButton.js.map +1 -1
- package/dist/module/components/Input.js +3 -3
- package/dist/module/components/Input.js.map +1 -1
- package/dist/module/components/LoadingCircles.js +4 -3
- package/dist/module/components/LoadingCircles.js.map +1 -1
- package/dist/module/components/LoadingIndicator.js +3 -3
- package/dist/module/components/LoadingIndicator.js.map +1 -1
- package/dist/module/components/LoadingStateWidget.js.map +1 -1
- package/dist/module/components/MediaPlayer.js +20 -32
- package/dist/module/components/MediaPlayer.js.map +1 -1
- package/dist/module/components/MiddlePopup.js.map +1 -1
- package/dist/module/components/PDFPopup.js +4 -3
- package/dist/module/components/PDFPopup.js.map +1 -1
- package/dist/module/components/PlussChat.js +5 -4
- package/dist/module/components/PlussChat.js.map +1 -1
- package/dist/module/components/PlussChatMessage.js +1 -1
- package/dist/module/components/PlussChatMessage.js.map +1 -1
- package/dist/module/components/PlussChatTime.js.map +1 -1
- package/dist/module/components/Popup.js.map +1 -1
- package/dist/module/components/PopupMenu.js.map +1 -1
- package/dist/module/components/PositionedImage.js +4 -4
- package/dist/module/components/PositionedImage.js.map +1 -1
- package/dist/module/components/ProfilePic.js +1 -0
- package/dist/module/components/ProfilePic.js.map +1 -1
- package/dist/module/components/RadioButton.js.map +1 -1
- package/dist/module/components/Reaction.js +3 -3
- package/dist/module/components/Reaction.js.map +1 -1
- package/dist/module/components/Reactions.js +3 -3
- package/dist/module/components/Reactions.js.map +1 -1
- package/dist/module/components/SharingTools.js +3 -3
- package/dist/module/components/SharingTools.js.map +1 -1
- package/dist/module/components/Spinner.js.map +1 -1
- package/dist/module/components/StickyFooter.js.map +1 -1
- package/dist/module/components/TextStyle.js +1 -1
- package/dist/module/components/TextStyle.js.map +1 -1
- package/dist/module/components/Toggle.js.map +1 -1
- package/dist/module/components/TouchableSearchBar.js +3 -3
- package/dist/module/components/TouchableSearchBar.js.map +1 -1
- package/dist/module/components/UserListPopup.js.map +1 -1
- package/dist/module/components/UserListing.js.map +1 -1
- package/dist/module/components/VideoPopup.js +3 -3
- package/dist/module/components/VideoPopup.js.map +1 -1
- package/dist/module/components/WarningPopup.js.map +1 -1
- package/dist/module/components/expo-image-picker-multiple/ImageBrowser.js +3 -3
- package/dist/module/components/expo-image-picker-multiple/ImageBrowser.js.map +1 -1
- package/dist/module/components/expo-image-picker-multiple/ImageTile.js.map +1 -1
- package/dist/module/components/index.js +1 -0
- package/dist/module/components/index.js.map +1 -1
- package/dist/module/components/react-native-expo-image-cropper/ExpoImageManipulator.js +4 -3
- package/dist/module/components/react-native-expo-image-cropper/ExpoImageManipulator.js.map +1 -1
- package/dist/module/components/react-native-expo-image-cropper/ImageCropOverlay.js +4 -4
- package/dist/module/components/react-native-expo-image-cropper/ImageCropOverlay.js.map +1 -1
- package/dist/module/config.js +1 -6
- package/dist/module/config.js.map +1 -1
- package/dist/module/constants.js.map +1 -1
- package/dist/module/fonts/index.js.map +1 -1
- package/dist/module/fonts/pluss60-icons.js.map +1 -1
- package/dist/module/helper.js +19 -2
- package/dist/module/helper.js.map +1 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/js/images/detectFaces.js.map +1 -1
- package/dist/module/js/images/findLandmarkRange.js.map +1 -1
- package/dist/module/js/images/getScaledOffset.js.map +1 -1
- package/dist/module/js/site/getSiteLevelFromState.js.map +1 -1
- package/dist/module/js/site/isTVEnabled.js.map +1 -1
- package/dist/module/session.js +2 -2
- package/dist/module/session.js.map +1 -1
- package/dist/module/styles.js.map +1 -1
- package/package.json +1 -4
- package/src/apis/fileActions.js +27 -19
- package/src/components/CommentSection.js +1 -1
- package/src/components/Forbidden.js +54 -0
- package/src/components/ImageUploader.js +29 -18
- package/src/components/MediaPlayer.js +16 -29
- package/src/components/index.js +1 -0
- package/src/config.js +0 -5
- package/src/helper.js +20 -1
- package/src/session.js +2 -2
package/src/apis/fileActions.js
CHANGED
|
@@ -1,34 +1,41 @@
|
|
|
1
|
-
import
|
|
1
|
+
import mime from 'mime-types';
|
|
2
|
+
import { Storage } from 'aws-amplify';
|
|
2
3
|
import { getUrl, generateImageName, randomString } from '../helper';
|
|
3
4
|
import { authedFunction } from '../session';
|
|
5
|
+
import Config from '../config';
|
|
4
6
|
|
|
5
7
|
export const fileActions = {
|
|
6
|
-
getPresignedUrl: async (filename, contentType) => {
|
|
7
|
-
// const newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
8
|
-
const signedUrlRes = await authedFunction({
|
|
9
|
-
method: 'GET',
|
|
10
|
-
url: getUrl('media', 'get/presignedurl', { filename, contentType }),
|
|
11
|
-
});
|
|
12
|
-
return signedUrlRes.data;
|
|
13
|
-
},
|
|
14
8
|
getUploadUrl: (userId, fileName) => {
|
|
15
9
|
const newFilename = fileName.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
16
10
|
return `uploads/users/${userId}/public/${randomString()}/${newFilename}`;
|
|
17
11
|
},
|
|
18
|
-
uploadUserMediaWithProgress: async (
|
|
19
|
-
|
|
12
|
+
uploadUserMediaWithProgress: async (imageUri, url, progressCallback = null) => {
|
|
13
|
+
const blob = await fileActions.imageToBlob(imageUri);
|
|
14
|
+
return fileActions.uploadBlobAWS(Config.env.awsUploadsBucket, url, blob, '', progressCallback);
|
|
20
15
|
},
|
|
16
|
+
// uploadUserMedia: async (userId, image, fileName) => {
|
|
17
|
+
// const blob = await fileActions.imageToBlob(image.uri);
|
|
18
|
+
// const url = fileActions.getUploadUrl(userId, fileName);
|
|
19
|
+
// return fileActions.uploadBlobAWS(Config.env.awsUploadsBucket, url, blob);
|
|
20
|
+
// },
|
|
21
|
+
// uploadSignatureImage: async (image, name) => {
|
|
22
|
+
// const blob = await fileActions.imageToBlob(image);
|
|
23
|
+
// const newImageName = generateImageName(name, 'signature.png');
|
|
24
|
+
// return fileActions.uploadBlobAWS(Config.env.awsStorageBucket, newImageName, blob, 'images/');
|
|
25
|
+
// },
|
|
21
26
|
imageToBlob: async imageUri => {
|
|
22
27
|
const response = await fetch(imageUri);
|
|
23
28
|
return response.blob();
|
|
24
29
|
},
|
|
25
|
-
uploadBlobAWS:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
uploadBlobAWS: (bucket, uri, blob, prefix = '', progressCallback = null) => {
|
|
31
|
+
const imageName = prefix ? uri.replace(/^.*[\\/]/, '') : uri;
|
|
32
|
+
const fileType = mime.lookup(uri);
|
|
33
|
+
const access = {
|
|
34
|
+
level: 'public',
|
|
35
|
+
bucket,
|
|
36
|
+
contentType: fileType,
|
|
37
|
+
customPrefix: { public: '' },
|
|
38
|
+
progressCallback: progress =>
|
|
32
39
|
progressCallback &&
|
|
33
40
|
progressCallback({
|
|
34
41
|
uri,
|
|
@@ -36,7 +43,8 @@ export const fileActions = {
|
|
|
36
43
|
total: progress.total,
|
|
37
44
|
percentage: `${Math.floor((progress.loaded / progress.total) * 100)}%`,
|
|
38
45
|
}),
|
|
39
|
-
}
|
|
46
|
+
};
|
|
47
|
+
return Storage.put(`${prefix}${imageName}`, blob, access);
|
|
40
48
|
},
|
|
41
49
|
getStockPhotos: async () => {
|
|
42
50
|
const response = await authedFunction({
|
|
@@ -416,7 +416,7 @@ class CommentSection extends Component {
|
|
|
416
416
|
content = (
|
|
417
417
|
<View style={styles.multiReplyContainer}>
|
|
418
418
|
{profilePics.map((c, i) => {
|
|
419
|
-
return <ProfilePic style={{ marginRight: -10 }} Diameter={20} ProfilePic={c.User.profilePic} />;
|
|
419
|
+
return <ProfilePic key={c.Id} style={{ marginRight: -10 }} Diameter={20} ProfilePic={c.User.profilePic} />;
|
|
420
420
|
})}
|
|
421
421
|
<Text style={[styles.commentRepliesText, { marginLeft: 20, color: this.props.colourBrandingMain }]}>{`${
|
|
422
422
|
threadComments.length
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import { TextStyle } from './TextStyle';
|
|
5
|
+
import { getMainBrandingColourFromState } from '../colours';
|
|
6
|
+
import { InlineButton } from './InlineButton';
|
|
7
|
+
import { Services } from '../config';
|
|
8
|
+
import { connect } from 'react-redux';
|
|
9
|
+
import Header from './Header';
|
|
10
|
+
|
|
11
|
+
const Forbidden = ({ colourBrandingMain, title, description }) => {
|
|
12
|
+
const goBack = () => {
|
|
13
|
+
Services.navigation.goBack();
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<View
|
|
18
|
+
style={{
|
|
19
|
+
flex: 1,
|
|
20
|
+
backgroundColor: '#fff',
|
|
21
|
+
}}
|
|
22
|
+
>
|
|
23
|
+
<Header leftIcon="angle-left" onPressLeft={goBack} />
|
|
24
|
+
<View
|
|
25
|
+
style={{
|
|
26
|
+
padding: 16,
|
|
27
|
+
}}
|
|
28
|
+
>
|
|
29
|
+
<TextStyle type="pageHeading" style={{ color: colourBrandingMain }}>
|
|
30
|
+
{!_.isEmpty(title) ? title : 'Oops!'}
|
|
31
|
+
</TextStyle>
|
|
32
|
+
<TextStyle type="body" style={{ marginTop: 10 }}>
|
|
33
|
+
{!_.isEmpty(description)
|
|
34
|
+
? description
|
|
35
|
+
: 'It seems this item is no longer accessible. It may have been removed or your access might have changed.'}
|
|
36
|
+
</TextStyle>
|
|
37
|
+
<View style={{ marginTop: 20 }}>
|
|
38
|
+
<InlineButton onPress={goBack} color={colourBrandingMain}>
|
|
39
|
+
Go back
|
|
40
|
+
</InlineButton>
|
|
41
|
+
</View>
|
|
42
|
+
</View>
|
|
43
|
+
</View>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const mapStateToProps = state => {
|
|
48
|
+
return {
|
|
49
|
+
colourBrandingMain: getMainBrandingColourFromState(state),
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const forbidden = connect(mapStateToProps, {}, null, { forwardRef: true })(Forbidden);
|
|
54
|
+
export { forbidden as Forbidden };
|
|
@@ -142,25 +142,23 @@ class ImageUploader extends Component {
|
|
|
142
142
|
let uploadUri;
|
|
143
143
|
try {
|
|
144
144
|
const fileName = `${getValueOrDefault(this.props.fileName, DEFAULT_IMAGE_NAME)}.${DEFULAT_IMAGE_TYPE}`;
|
|
145
|
+
uploadUri = fileActions.getUploadUrl(this.props.userId, fileName);
|
|
145
146
|
|
|
147
|
+
this.props.onUploadStarted(uploadUri, imageUri);
|
|
146
148
|
this.hideUploadMenu();
|
|
147
149
|
|
|
148
150
|
const resized = await this.resizeImageAsync(imageUri);
|
|
149
|
-
const blob = await fileActions.imageToBlob(resized.uri);
|
|
150
|
-
const presignedUriRes = await fileActions.getPresignedUrl(_.last(resized.uri.split('/')), blob.type);
|
|
151
|
-
uploadUri = presignedUriRes.key;
|
|
152
|
-
this.props.onUploadStarted(uploadUri, imageUri);
|
|
153
151
|
if (this.props.onlySelectImage) {
|
|
154
152
|
this.props.onImageSelected(resized, fileName);
|
|
155
153
|
return;
|
|
156
154
|
}
|
|
157
155
|
|
|
158
|
-
const
|
|
156
|
+
const res = await fileActions.uploadUserMediaWithProgress(resized.uri, uploadUri, progress => {
|
|
159
157
|
if (this.props.onUploadProgress) this.props.onUploadProgress(progress);
|
|
160
158
|
});
|
|
161
159
|
|
|
162
|
-
this.props.onUploadSuccess(Config.env.baseUploadsUrl +
|
|
163
|
-
console.log('upload success', Config.env.baseUploadsUrl +
|
|
160
|
+
this.props.onUploadSuccess(Config.env.baseUploadsUrl + res.key, uploadUri);
|
|
161
|
+
console.log('upload success', Config.env.baseUploadsUrl + res.key);
|
|
164
162
|
} catch (e) {
|
|
165
163
|
console.log('handleImagePicked error', e);
|
|
166
164
|
this.props.onUploadFailed(uploadUri);
|
|
@@ -172,6 +170,7 @@ class ImageUploader extends Component {
|
|
|
172
170
|
const imagesUploaded = imagesSelected.map(image => {
|
|
173
171
|
const fileName = `${getValueOrDefault(this.props.fileName, DEFAULT_IMAGE_NAME)}.${DEFULAT_IMAGE_TYPE}`;
|
|
174
172
|
const uploadUri = fileActions.getUploadUrl(this.props.userId, fileName);
|
|
173
|
+
if (!this.props.onlySelectImage) this.props.onUploadStarted(uploadUri, image.uri);
|
|
175
174
|
return { imageUri: image.uri, uploadUri, fileName };
|
|
176
175
|
});
|
|
177
176
|
this.hideUploadMenu();
|
|
@@ -182,21 +181,16 @@ class ImageUploader extends Component {
|
|
|
182
181
|
const { imageUri, uploadUri, fileName } = image;
|
|
183
182
|
try {
|
|
184
183
|
const resized = await this.resizeImageAsync(imageUri);
|
|
185
|
-
const blob = await fileActions.imageToBlob(resized.uri);
|
|
186
184
|
if (this.props.onlySelectImage) {
|
|
187
185
|
this.props.onImageSelected(resized, fileName);
|
|
188
186
|
return;
|
|
189
187
|
}
|
|
190
|
-
const presignedUriRes = await fileActions.getPresignedUrl(_.last(resized.uri.split('/')), blob.type);
|
|
191
|
-
const uploadUri = presignedUriRes.key;
|
|
192
|
-
if (!this.props.onlySelectImage) this.props.onUploadStarted(uploadUri, imageUri);
|
|
193
188
|
|
|
194
|
-
const
|
|
189
|
+
const res = await fileActions.uploadUserMediaWithProgress(resized.uri, uploadUri, progress => {
|
|
195
190
|
if (this.props.onUploadProgress) this.props.onUploadProgress(progress);
|
|
196
191
|
});
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
console.log('upload success', Config.env.baseUploadsUrl + uploadUri);
|
|
192
|
+
this.props.onUploadSuccess(Config.env.baseUploadsUrl + res.key, uploadUri);
|
|
193
|
+
console.log('upload success', Config.env.baseUploadsUrl + res.key);
|
|
200
194
|
} catch (e) {
|
|
201
195
|
console.log('handleMultiImagePicked error', e);
|
|
202
196
|
this.props.onUploadFailed(uploadUri);
|
|
@@ -209,7 +203,7 @@ class ImageUploader extends Component {
|
|
|
209
203
|
try {
|
|
210
204
|
const fileType = uri.substring(uri.lastIndexOf('.') + 1);
|
|
211
205
|
const fileName = `${getValueOrDefault(this.props.fileName, DEFAULT_VIDEO_NAME)}.${fileType}`;
|
|
212
|
-
uploadUri =
|
|
206
|
+
uploadUri = fileActions.getUploadUrl(this.props.userId, fileName);
|
|
213
207
|
|
|
214
208
|
this.props.onUploadStarted(uploadUri, uri);
|
|
215
209
|
this.hideUploadMenu();
|
|
@@ -262,7 +256,7 @@ class ImageUploader extends Component {
|
|
|
262
256
|
askPermissionsAsync = async () => {
|
|
263
257
|
const cameraPermission = await Camera.requestCameraPermissionsAsync();
|
|
264
258
|
const rollPermission = await MediaLibrary.requestPermissionsAsync();
|
|
265
|
-
if (cameraPermission.status !== 'granted' || rollPermission.status !== 'granted') {
|
|
259
|
+
if (cameraPermission.status !== 'granted' || (Platform.OS === 'ios' && rollPermission.status !== 'granted')) {
|
|
266
260
|
this.showWarningPopup(cameraPermission.status !== 'granted', rollPermission.status !== 'granted');
|
|
267
261
|
return false;
|
|
268
262
|
}
|
|
@@ -272,7 +266,6 @@ class ImageUploader extends Component {
|
|
|
272
266
|
};
|
|
273
267
|
|
|
274
268
|
isEditingEnabled = () => {
|
|
275
|
-
return false;
|
|
276
269
|
return !this.props.multiple && !this.props.allowVideo && getValueOrDefault(this.props.allowsEditing, DEFAULT_ALLOWS_EDITING);
|
|
277
270
|
};
|
|
278
271
|
|
|
@@ -321,6 +314,24 @@ class ImageUploader extends Component {
|
|
|
321
314
|
};
|
|
322
315
|
|
|
323
316
|
openPhotos = async () => {
|
|
317
|
+
if (Platform.OS === 'android') {
|
|
318
|
+
const result = await ImagePicker.launchImageLibraryAsync({
|
|
319
|
+
allowsEditing: this.isEditingEnabled(),
|
|
320
|
+
aspect: getValueOrDefault(this.props.aspect, DEFAULT_ASPECT),
|
|
321
|
+
exif: getValueOrDefault(this.props.exif, DEFAULT_EXIF),
|
|
322
|
+
mediaTypes: this.props.allowVideo ? ImagePicker.MediaTypeOptions.All : ImagePicker.MediaTypeOptions.Images,
|
|
323
|
+
});
|
|
324
|
+
if (!result.cancelled) {
|
|
325
|
+
if (result.assets.length === 1 && result.assets[0].type === 'video') {
|
|
326
|
+
this.handleVideoPicked(result.assets[0].uri);
|
|
327
|
+
} else {
|
|
328
|
+
this.handleMultiImagePicked(result.assets);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// iOS behaviour
|
|
324
335
|
if (!(await this.askPermissionsAsync())) return;
|
|
325
336
|
|
|
326
337
|
this.setState({
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import * as ScreenOrientation from 'expo-screen-orientation';
|
|
4
|
-
import { DeviceMotion } from 'expo-sensors';
|
|
2
|
+
import { View, StyleSheet, Dimensions } from 'react-native';
|
|
5
3
|
import YoutubePlayer, { getYoutubeMeta } from 'react-native-youtube-iframe';
|
|
6
4
|
import { Vimeo } from 'react-native-vimeo-iframe';
|
|
7
5
|
import { WebView } from 'react-native-webview';
|
|
8
6
|
import { Video } from 'expo-av';
|
|
9
|
-
import VideoPlayer from 'expo-video-player';
|
|
10
7
|
import { Spinner } from './Spinner';
|
|
11
8
|
|
|
12
9
|
const SCREEN_HEIGHT = Dimensions.get('window').height;
|
|
@@ -40,20 +37,10 @@ class MediaPlayer extends Component {
|
|
|
40
37
|
|
|
41
38
|
componentDidMount = async () => {
|
|
42
39
|
await this.setupForPlaying();
|
|
43
|
-
|
|
44
|
-
ScreenOrientation.lockAsync(Platform.OS === 'ios' ? ScreenOrientation.OrientationLock.DEFAULT : ScreenOrientation.OrientationLock.ALL);
|
|
45
|
-
const motionAvailalble = await DeviceMotion.isAvailableAsync();
|
|
46
|
-
// console.log('motionAvailalble', motionAvailalble);
|
|
47
|
-
if (motionAvailalble) {
|
|
48
|
-
DeviceMotion.setUpdateInterval(500);
|
|
49
|
-
DeviceMotion.addListener(this.onMotionChange);
|
|
50
|
-
}
|
|
51
40
|
};
|
|
52
41
|
|
|
53
42
|
componentWillUnmount = () => {
|
|
54
43
|
if (this.checkStreamLoaded) clearInterval(this.checkStreamLoaded);
|
|
55
|
-
DeviceMotion.removeAllListeners();
|
|
56
|
-
ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.PORTRAIT_UP);
|
|
57
44
|
};
|
|
58
45
|
|
|
59
46
|
getYoutubeVideoId = url => {
|
|
@@ -292,20 +279,20 @@ class MediaPlayer extends Component {
|
|
|
292
279
|
/>
|
|
293
280
|
);
|
|
294
281
|
|
|
295
|
-
getVideoPlayer = (embedUrl, width, height, autoPlay) => (
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
);
|
|
282
|
+
// getVideoPlayer = (embedUrl, width, height, autoPlay) => (
|
|
283
|
+
// <VideoPlayer
|
|
284
|
+
// videoProps={{
|
|
285
|
+
// shouldPlay: autoPlay,
|
|
286
|
+
// resizeMode: Video.RESIZE_MODE_CONTAIN,
|
|
287
|
+
// source: { uri: embedUrl },
|
|
288
|
+
// }}
|
|
289
|
+
// showFullscreenButton={false}
|
|
290
|
+
// errorCallback={this.onVideoPlayError}
|
|
291
|
+
// playbackCallback={this.onVideoPlayStatusUpdate}
|
|
292
|
+
// height={height}
|
|
293
|
+
// width={width}
|
|
294
|
+
// />
|
|
295
|
+
// );
|
|
309
296
|
|
|
310
297
|
render() {
|
|
311
298
|
let width, height;
|
|
@@ -351,7 +338,7 @@ class MediaPlayer extends Component {
|
|
|
351
338
|
} else if (useVideoPlayer) {
|
|
352
339
|
embedUrl = source;
|
|
353
340
|
// console.log('getVideoPlayer', embedUrl, width, height, autoPlay);
|
|
354
|
-
player = this.
|
|
341
|
+
player = this.getStreamPlayer(embedUrl, width, height, autoPlay);
|
|
355
342
|
}
|
|
356
343
|
}
|
|
357
344
|
if (!player && isUrlLink) {
|
package/src/components/index.js
CHANGED
package/src/config.js
CHANGED
|
@@ -18,11 +18,6 @@ const CoreConfig = {
|
|
|
18
18
|
strings: {},
|
|
19
19
|
newEventDefaults: '',
|
|
20
20
|
defaultAllowComments: true,
|
|
21
|
-
AuthStrategy: {
|
|
22
|
-
getAccessToken: async () => null,
|
|
23
|
-
getCurrentUserId: async () => null,
|
|
24
|
-
hasActiveSession: async () => false,
|
|
25
|
-
},
|
|
26
21
|
},
|
|
27
22
|
init: (environment, navigation) => {
|
|
28
23
|
CoreConfig.env = environment;
|
package/src/helper.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Platform, StatusBar, Dimensions, Text } from 'react-native';
|
|
3
4
|
import Constants from 'expo-constants';
|
|
4
5
|
import Config from './config';
|
|
5
6
|
import { LINEGREY } from './colours';
|
|
@@ -121,6 +122,9 @@ const getThumb300 = url => {
|
|
|
121
122
|
if (!url) {
|
|
122
123
|
return url;
|
|
123
124
|
}
|
|
125
|
+
if (isVideo(url)) {
|
|
126
|
+
return 'https://pluss60-demo-uploads.s3.ap-southeast-2.amazonaws.com/uploads/users/ap-southeast-2:97769b56-25ec-41c0-a73c-6c2c4140f629/public/9d0bbec64614b1ed654a03f7e7/movie.jpg';
|
|
127
|
+
}
|
|
124
128
|
if (url.indexOf('https://plussprdstorage.blob.core.windows.net/') !== -1) {
|
|
125
129
|
return url.replace('https://plussprdstorage.blob.core.windows.net/', 'https://plusscdn.azureedge.net/');
|
|
126
130
|
}
|
|
@@ -445,6 +449,20 @@ const allowComments = canComment => {
|
|
|
445
449
|
return Config.env.defaultAllowComments;
|
|
446
450
|
};
|
|
447
451
|
|
|
452
|
+
const toParagraphed = (text, style) => {
|
|
453
|
+
if (!text) {
|
|
454
|
+
return text;
|
|
455
|
+
}
|
|
456
|
+
const textSplit = text.split('\n');
|
|
457
|
+
return _.map(textSplit, (t, i) => {
|
|
458
|
+
return (
|
|
459
|
+
<Text key={`paragraph_${i}`} style={style}>
|
|
460
|
+
{t}
|
|
461
|
+
</Text>
|
|
462
|
+
);
|
|
463
|
+
});
|
|
464
|
+
};
|
|
465
|
+
|
|
448
466
|
export {
|
|
449
467
|
TIMESTAMP_FORMAT,
|
|
450
468
|
DATE_FORMAT,
|
|
@@ -484,6 +502,7 @@ export {
|
|
|
484
502
|
getValidUrl,
|
|
485
503
|
getUserPreview,
|
|
486
504
|
allowComments,
|
|
505
|
+
toParagraphed,
|
|
487
506
|
isVideoUrl,
|
|
488
507
|
detectFaces,
|
|
489
508
|
findLandmarkRange,
|
package/src/session.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import { Auth } from 'aws-amplify';
|
|
4
|
-
import Config from './config';
|
|
5
4
|
|
|
6
5
|
export const getSessionTokenAWS = async prefix => {
|
|
7
|
-
const
|
|
6
|
+
const data = await Auth.currentSession();
|
|
7
|
+
const token = data.accessToken.jwtToken;
|
|
8
8
|
if (_.isUndefined(prefix)) return token;
|
|
9
9
|
return `${prefix} ${token}`;
|
|
10
10
|
};
|