Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions app/containers/MessageBox/FilesActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default class FilesActions extends PureComponent {
static propTypes = {
hideActions: PropTypes.func.isRequired,
takePhoto: PropTypes.func.isRequired,
takeVedio: PropTypes.func.isRequired,
chooseFromLibrary: PropTypes.func.isRequired
}

Expand All @@ -22,9 +23,13 @@ export default class FilesActions extends PureComponent {
this.options.push(I18n.t('Take_a_photo'));
this.PHOTO_INDEX = 1;

// Vedio
this.options.push(I18n.t('Take_a_vedio'));
this.VEDIO_INDEX = 2;

// Library
this.options.push(I18n.t('Choose_from_library'));
this.LIBRARY_INDEX = 2;
this.LIBRARY_INDEX = 3;

setTimeout(() => {
this.showActionSheet();
Expand All @@ -41,14 +46,19 @@ export default class FilesActions extends PureComponent {
}

handleActionPress = (actionIndex) => {
const { takePhoto, chooseFromLibrary, hideActions } = this.props;
const {
takePhoto, chooseFromLibrary, hideActions, takeVedio
} = this.props;
switch (actionIndex) {
case this.PHOTO_INDEX:
takePhoto();
break;
case this.LIBRARY_INDEX:
chooseFromLibrary();
break;
case this.VEDIO_INDEX:
takeVedio();
break;
default:
break;
}
Expand Down
25 changes: 22 additions & 3 deletions app/containers/MessageBox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ const imagePickerConfig = {
cropperCancelText: I18n.t('Cancel')
};

const libraryPickerConfig = {
mediaType: 'video'
};

const vedioPickerConfig = {
mediaType: 'video'
};

class MessageBox extends Component {
static propTypes = {
rid: PropTypes.string.isRequired,
Expand Down Expand Up @@ -479,7 +487,7 @@ class MessageBox extends Component {
this.setState(prevState => ({ showFilesAction: !prevState.showFilesAction }));
}

sendImageMessage = async(file) => {
sendMediaMessage = async(file) => {
const { rid } = this.props;

this.setState({ file: { isVisible: false } });
Expand All @@ -499,6 +507,7 @@ class MessageBox extends Component {
}

takePhoto = async() => {
console.warn('take photo');
Comment thread
pranavpandey1998official marked this conversation as resolved.
Outdated
try {
const image = await ImagePicker.openCamera(imagePickerConfig);
this.showUploadModal(image);
Expand All @@ -507,9 +516,18 @@ class MessageBox extends Component {
}
}

takeVedio = async() => {
try {
const vedio = await ImagePicker.openCamera(vedioPickerConfig);
this.showUploadModal(vedio);
} catch (e) {
log('takeVedio', e);
}
}

chooseFromLibrary = async() => {
try {
const image = await ImagePicker.openPicker(imagePickerConfig);
const image = await ImagePicker.openPicker(libraryPickerConfig);
this.showUploadModal(image);
} catch (e) {
log('chooseFromLibrary', e);
Expand Down Expand Up @@ -742,6 +760,7 @@ class MessageBox extends Component {
key='files-actions'
hideActions={this.toggleFilesActions}
takePhoto={this.takePhoto}
takeVedio={this.takeVedio}
chooseFromLibrary={this.chooseFromLibrary}
/>
);
Expand Down Expand Up @@ -807,7 +826,7 @@ class MessageBox extends Component {
isVisible={(file && file.isVisible)}
file={file}
close={() => this.setState({ file: {} })}
submit={this.sendImageMessage}
submit={this.sendMediaMessage}
/>
]
);
Expand Down
1 change: 1 addition & 0 deletions app/i18n/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ export default {
Started_discussion: 'Started a discussion:',
Submit: 'Submit',
Take_a_photo: 'Take a photo',
Take_a_vedio: 'Take a vedio',
tap_to_change_status: 'tap to change status',
Tap_to_view_servers_list: 'Tap to view servers list',
Terms_of_Service: ' Terms of Service ',
Expand Down