From 725d85588b920390e0104d00f86bc07d0c89736f Mon Sep 17 00:00:00 2001
From: pranavpandey1998official
<44601530+pranavpandey1998official@users.noreply.github.com>
Date: Thu, 18 Jul 2019 22:37:37 +0530
Subject: [PATCH] [NEW] Video support (#801)
---
app/containers/MessageBox/UploadModal.js | 35 ++++++++++++++++--
app/containers/MessageBox/index.js | 46 ++++++++++++++++++++----
app/i18n/locales/en.js | 2 ++
app/i18n/locales/pt-BR.js | 2 ++
yarn.lock | 4 +--
5 files changed, 79 insertions(+), 10 deletions(-)
diff --git a/app/containers/MessageBox/UploadModal.js b/app/containers/MessageBox/UploadModal.js
index 6bb29470b..d1d3f87f7 100644
--- a/app/containers/MessageBox/UploadModal.js
+++ b/app/containers/MessageBox/UploadModal.js
@@ -13,6 +13,7 @@ import I18n from '../../i18n';
import sharedStyles from '../../views/Styles';
import { isIOS } from '../../utils/deviceInfo';
import { COLOR_PRIMARY, COLOR_BACKGROUND_CONTAINER, COLOR_WHITE } from '../../constants/colors';
+import { CustomIcon } from '../../lib/Icons';
const cancelButtonColor = COLOR_BACKGROUND_CONTAINER;
@@ -63,6 +64,21 @@ const styles = StyleSheet.create({
androidButtonText: {
fontSize: 18,
textAlign: 'center'
+ },
+ fileIcon: {
+ color: COLOR_PRIMARY,
+ margin: 20,
+ flex: 1,
+ textAlign: 'center'
+ },
+ video: {
+ flex: 1,
+ borderRadius: 4,
+ height: 150,
+ backgroundColor: '#1f2329',
+ marginBottom: 6,
+ alignItems: 'center',
+ justifyContent: 'center'
}
});
@@ -166,9 +182,24 @@ export default class UploadModal extends Component {
);
}
+ renderPreview() {
+ const { file } = this.props;
+ if (file.mime && file.mime.match(/image/)) {
+ return ();
+ }
+ if (file.mime && file.mime.match(/video/)) {
+ return (
+
+
+
+ );
+ }
+ return ();
+ }
+
render() {
const { window: { width }, isVisible, close } = this.props;
- const { name, description, file } = this.state;
+ const { name, description } = this.state;
return (
-
+ {this.renderPreview()}
{
+ sendMediaMessage = async(file) => {
const { rid, tmid } = this.props;
this.setState({ file: { isVisible: false } });
@@ -491,9 +513,18 @@ class MessageBox extends Component {
}
}
+ takeVideo = async() => {
+ try {
+ const video = await ImagePicker.openCamera(this.videoPickerConfig);
+ this.showUploadModal(video);
+ } catch (e) {
+ log('err_take_video', e);
+ }
+ }
+
chooseFromLibrary = async() => {
try {
- const image = await ImagePicker.openPicker(this.imagePickerConfig);
+ const image = await ImagePicker.openPicker(this.libraryPickerConfig);
this.showUploadModal(image);
} catch (e) {
log('err_choose_from_library', e);
@@ -518,6 +549,9 @@ class MessageBox extends Component {
case FILE_PHOTO_INDEX:
this.takePhoto();
break;
+ case FILE_VIDEO_INDEX:
+ this.takeVideo();
+ break;
case FILE_LIBRARY_INDEX:
this.chooseFromLibrary();
break;
@@ -896,7 +930,7 @@ class MessageBox extends Component {
isVisible={(file && file.isVisible)}
file={file}
close={() => this.setState({ file: {} })}
- submit={this.sendImageMessage}
+ submit={this.sendMediaMessage}
/>
);
diff --git a/app/i18n/locales/en.js b/app/i18n/locales/en.js
index e390793f9..4284b5d0c 100644
--- a/app/i18n/locales/en.js
+++ b/app/i18n/locales/en.js
@@ -262,6 +262,7 @@ export default {
Private_Channel: 'Private Channel',
Private_Groups: 'Private Groups',
Private: 'Private',
+ Processing: 'Processing...',
Profile_saved_successfully: 'Profile saved successfully!',
Profile: 'Profile',
Public_Channel: 'Public Channel',
@@ -335,6 +336,7 @@ export default {
Started_discussion: 'Started a discussion:',
Submit: 'Submit',
Take_a_photo: 'Take a photo',
+ Take_a_video: 'Take a video',
tap_to_change_status: 'tap to change status',
Tap_to_view_servers_list: 'Tap to view servers list',
Terms_of_Service: ' Terms of Service ',
diff --git a/app/i18n/locales/pt-BR.js b/app/i18n/locales/pt-BR.js
index b22686c10..53fe71e68 100644
--- a/app/i18n/locales/pt-BR.js
+++ b/app/i18n/locales/pt-BR.js
@@ -255,6 +255,7 @@ export default {
Private_Channel: 'Canal Privado',
Private_Groups: 'Grupo Privado',
Private: 'Privado',
+ Processing: 'Processando...',
Profile_saved_successfully: 'Perfil salvo com sucesso!',
Profile: 'Perfil',
Public_Channel: 'Canal Público',
@@ -322,6 +323,7 @@ export default {
Started_discussion: 'Iniciou uma discussão:',
Submit: 'Enviar',
Take_a_photo: 'Tirar uma foto',
+ Take_a_video: 'Gravar um vídeo',
Terms_of_Service: ' Termos de Serviço ',
The_URL_is_invalid: 'A URL fornecida é inválida ou não acessível. Por favor tente novamente, mas com uma url diferente.',
There_was_an_error_while_action: 'Aconteceu um erro {{action}}!',
diff --git a/yarn.lock b/yarn.lock
index d6dfeba67..d3dbb7fd1 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -11547,8 +11547,8 @@ react-native-gesture-handler@^1.2.1:
prop-types "^15.5.10"
"react-native-image-crop-picker@git+https://github.com/RocketChat/react-native-image-crop-picker.git":
- version "0.21.1"
- resolved "git+https://github.com/RocketChat/react-native-image-crop-picker.git#6c205596b5496b207daa93408c9cef886e04bdbb"
+ version "0.24.1"
+ resolved "git+https://github.com/RocketChat/react-native-image-crop-picker.git#d3e92c13fee5ce2f2dd3655ba719a70ba99a7d36"
react-native-image-pan-zoom@^2.1.9:
version "2.1.11"