RN-121 Upload thumbnail (#565)
This commit is contained in:
parent
ce4f8a2600
commit
1478bb47b1
3 changed files with 56 additions and 5 deletions
|
|
@ -15,6 +15,7 @@ import Icon from 'react-native-vector-icons/Ionicons';
|
|||
import {RequestStatus} from 'mattermost-redux/constants';
|
||||
|
||||
import FileAttachmentImage from 'app/components/file_attachment_list/file_attachment_image';
|
||||
import FileAttachmentIcon from 'app/components/file_attachment_list/file_attachment_icon';
|
||||
import KeyboardLayout from 'app/components/layout/keyboard_layout';
|
||||
|
||||
const {height: deviceHeight} = Dimensions.get('window');
|
||||
|
|
@ -33,6 +34,7 @@ export default class FileUploadPreview extends PureComponent {
|
|||
files: PropTypes.array.isRequired,
|
||||
inputHeight: PropTypes.number.isRequired,
|
||||
rootId: PropTypes.string,
|
||||
theme: PropTypes.object.isRequired,
|
||||
uploadFileRequestStatus: PropTypes.string.isRequired
|
||||
};
|
||||
|
||||
|
|
@ -46,17 +48,30 @@ export default class FileUploadPreview extends PureComponent {
|
|||
|
||||
buildFilePreviews = () => {
|
||||
return this.props.files.map((file) => {
|
||||
let filePreviewComponent;
|
||||
if (file.loading | file.has_preview_image) {
|
||||
filePreviewComponent = (
|
||||
<FileAttachmentImage
|
||||
addFileToFetchCache={this.props.actions.addFileToFetchCache}
|
||||
fetchCache={this.props.fetchCache}
|
||||
file={file}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
filePreviewComponent = (
|
||||
<FileAttachmentIcon
|
||||
file={file}
|
||||
theme={this.props.theme}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<View
|
||||
key={file.clientId}
|
||||
style={style.preview}
|
||||
>
|
||||
<View style={style.previewShadow}>
|
||||
<FileAttachmentImage
|
||||
addFileToFetchCache={this.props.actions.addFileToFetchCache}
|
||||
fetchCache={this.props.fetchCache}
|
||||
file={file}
|
||||
/>
|
||||
{filePreviewComponent}
|
||||
{file.failed &&
|
||||
<TouchableOpacity
|
||||
style={style.failed}
|
||||
|
|
|
|||
|
|
@ -255,6 +255,10 @@ class PostTextbox extends PureComponent {
|
|||
noData: true
|
||||
};
|
||||
|
||||
if (Platform.OS === 'ios') {
|
||||
options.mediaType = 'mixed';
|
||||
}
|
||||
|
||||
ImagePicker.launchImageLibrary(options, (response) => {
|
||||
if (response.error) {
|
||||
return;
|
||||
|
|
@ -264,6 +268,26 @@ class PostTextbox extends PureComponent {
|
|||
});
|
||||
};
|
||||
|
||||
attachVideoFromLibraryAndroid = () => {
|
||||
this.props.navigator.dismissModal({
|
||||
animationType: 'none'
|
||||
});
|
||||
|
||||
const options = {
|
||||
quality: 0.7,
|
||||
mediaType: 'video',
|
||||
noData: true
|
||||
};
|
||||
|
||||
ImagePicker.launchImageLibrary(options, (response) => {
|
||||
if (response.error) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.uploadFiles([response]);
|
||||
});
|
||||
}
|
||||
|
||||
uploadFiles = (images) => {
|
||||
this.props.actions.handleUploadFiles(images, this.props.rootId);
|
||||
};
|
||||
|
|
@ -288,6 +312,17 @@ class PostTextbox extends PureComponent {
|
|||
}]
|
||||
};
|
||||
|
||||
if (Platform.OS === 'android') {
|
||||
options.items.push({
|
||||
action: this.attachVideoFromLibraryAndroid,
|
||||
text: {
|
||||
id: 'mobile.file_upload.video',
|
||||
defaultMessage: 'Video Libary'
|
||||
},
|
||||
icon: 'file-video-o'
|
||||
});
|
||||
}
|
||||
|
||||
this.props.navigator.showModal({
|
||||
screen: 'OptionsModal',
|
||||
title: '',
|
||||
|
|
|
|||
|
|
@ -1709,6 +1709,7 @@
|
|||
"mobile.file_upload.camera": "Take Photo or Video",
|
||||
"mobile.file_upload.library": "Photo Library",
|
||||
"mobile.file_upload.more": "More",
|
||||
"mobile.file_upload.video": "Video Libary",
|
||||
"mobile.help.title": "Help",
|
||||
"mobile.intro_messages.DM": "This is the start of your direct message history with {teammate}. Direct messages and files shared here are not shown to people outside this area.",
|
||||
"mobile.intro_messages.default_message": "This is the first channel teammates see when they sign up - use it for posting updates everyone needs to know.",
|
||||
|
|
|
|||
Loading…
Reference in a new issue