remove react-native-image-crop-picker
This commit is contained in:
parent
7ab2727946
commit
ab4f4aada9
|
@ -2,7 +2,6 @@ import React, { Component } from 'react';
|
||||||
import { Alert, Keyboard, NativeModules, Text, View } from 'react-native';
|
import { Alert, Keyboard, NativeModules, Text, View } from 'react-native';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { KeyboardAccessoryView } from 'react-native-ui-lib/keyboard';
|
import { KeyboardAccessoryView } from 'react-native-ui-lib/keyboard';
|
||||||
import ImagePicker, { Image, ImageOrVideo, Options } from 'react-native-image-crop-picker';
|
|
||||||
import { dequal } from 'dequal';
|
import { dequal } from 'dequal';
|
||||||
import DocumentPicker from 'react-native-document-picker';
|
import DocumentPicker from 'react-native-document-picker';
|
||||||
import { Q } from '@nozbe/watermelondb';
|
import { Q } from '@nozbe/watermelondb';
|
||||||
|
@ -42,7 +41,6 @@ import Navigation from '../../lib/navigation/appNavigation';
|
||||||
import { TActionSheetOptionsItem, withActionSheet } from '../ActionSheet';
|
import { TActionSheetOptionsItem, withActionSheet } from '../ActionSheet';
|
||||||
import { sanitizeLikeString } from '../../lib/database/utils';
|
import { sanitizeLikeString } from '../../lib/database/utils';
|
||||||
import { CustomIcon } from '../CustomIcon';
|
import { CustomIcon } from '../CustomIcon';
|
||||||
import { forceJpgExtension } from './forceJpgExtension';
|
|
||||||
import {
|
import {
|
||||||
IApplicationState,
|
IApplicationState,
|
||||||
IBaseScreen,
|
IBaseScreen,
|
||||||
|
@ -59,27 +57,10 @@ import { hasPermission, debounce, isAndroid, isIOS, isTablet } from '../../lib/m
|
||||||
import { Services } from '../../lib/services';
|
import { Services } from '../../lib/services';
|
||||||
import { TSupportedThemes } from '../../theme';
|
import { TSupportedThemes } from '../../theme';
|
||||||
import { ChatsStackParamList } from '../../stacks/types';
|
import { ChatsStackParamList } from '../../stacks/types';
|
||||||
|
import { pickImageAndVideoFromLibrary, pickImageFromCamera, pickVideoFromCamera } from '../../lib/methods/mediaPicker';
|
||||||
|
|
||||||
require('./EmojiKeyboard');
|
require('./EmojiKeyboard');
|
||||||
|
|
||||||
const imagePickerConfig = {
|
|
||||||
cropping: true,
|
|
||||||
avoidEmptySpaceAroundImage: false,
|
|
||||||
freeStyleCropEnabled: true,
|
|
||||||
forceJpg: true
|
|
||||||
};
|
|
||||||
|
|
||||||
const libraryPickerConfig: Options = {
|
|
||||||
multiple: true,
|
|
||||||
compressVideoPreset: 'Passthrough',
|
|
||||||
mediaType: 'any',
|
|
||||||
forceJpg: true
|
|
||||||
};
|
|
||||||
|
|
||||||
const videoPickerConfig: Options = {
|
|
||||||
mediaType: 'video'
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface IMessageBoxProps extends IBaseScreen<ChatsStackParamList & MasterDetailInsideStackParamList, any> {
|
export interface IMessageBoxProps extends IBaseScreen<ChatsStackParamList & MasterDetailInsideStackParamList, any> {
|
||||||
rid: string;
|
rid: string;
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
|
@ -138,12 +119,6 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
|
||||||
|
|
||||||
private focused: boolean;
|
private focused: boolean;
|
||||||
|
|
||||||
private imagePickerConfig: Options;
|
|
||||||
|
|
||||||
private libraryPickerConfig: Options;
|
|
||||||
|
|
||||||
private videoPickerConfig: Options;
|
|
||||||
|
|
||||||
private room!: TSubscriptionModel;
|
private room!: TSubscriptionModel;
|
||||||
|
|
||||||
private thread!: TThreadModel;
|
private thread!: TThreadModel;
|
||||||
|
@ -189,26 +164,6 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
|
||||||
this.selection = { start: 0, end: 0 };
|
this.selection = { start: 0, end: 0 };
|
||||||
this.focused = false;
|
this.focused = false;
|
||||||
|
|
||||||
const libPickerLabels = {
|
|
||||||
cropperChooseText: I18n.t('Choose'),
|
|
||||||
cropperCancelText: I18n.t('Cancel'),
|
|
||||||
loadingLabelText: I18n.t('Processing')
|
|
||||||
};
|
|
||||||
|
|
||||||
this.imagePickerConfig = {
|
|
||||||
...imagePickerConfig,
|
|
||||||
...libPickerLabels
|
|
||||||
};
|
|
||||||
|
|
||||||
this.libraryPickerConfig = {
|
|
||||||
...libraryPickerConfig,
|
|
||||||
...libPickerLabels
|
|
||||||
};
|
|
||||||
|
|
||||||
this.videoPickerConfig = {
|
|
||||||
...videoPickerConfig,
|
|
||||||
...libPickerLabels
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
|
@ -711,9 +666,8 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
|
||||||
takePhoto = async () => {
|
takePhoto = async () => {
|
||||||
logEvent(events.ROOM_BOX_ACTION_PHOTO);
|
logEvent(events.ROOM_BOX_ACTION_PHOTO);
|
||||||
try {
|
try {
|
||||||
let image = (await ImagePicker.openCamera(this.imagePickerConfig)) as Image;
|
const image = await pickImageFromCamera(true);
|
||||||
image = forceJpgExtension(image);
|
if (image && this.canUploadFile(image)) {
|
||||||
if (this.canUploadFile(image)) {
|
|
||||||
this.openShareView([image]);
|
this.openShareView([image]);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -724,8 +678,8 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
|
||||||
takeVideo = async () => {
|
takeVideo = async () => {
|
||||||
logEvent(events.ROOM_BOX_ACTION_VIDEO);
|
logEvent(events.ROOM_BOX_ACTION_VIDEO);
|
||||||
try {
|
try {
|
||||||
const video = await ImagePicker.openCamera(this.videoPickerConfig);
|
const video = await pickVideoFromCamera(true);
|
||||||
if (this.canUploadFile(video)) {
|
if (video && this.canUploadFile(video)) {
|
||||||
this.openShareView([video]);
|
this.openShareView([video]);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -736,10 +690,10 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
|
||||||
chooseFromLibrary = async () => {
|
chooseFromLibrary = async () => {
|
||||||
logEvent(events.ROOM_BOX_ACTION_LIBRARY);
|
logEvent(events.ROOM_BOX_ACTION_LIBRARY);
|
||||||
try {
|
try {
|
||||||
// The type can be video or photo, however the lib understands that it is just one of them.
|
const attachments = await pickImageAndVideoFromLibrary();
|
||||||
let attachments = (await ImagePicker.openPicker(this.libraryPickerConfig)) as unknown as ImageOrVideo[];
|
if (attachments) {
|
||||||
attachments = attachments.map(att => forceJpgExtension(att));
|
|
||||||
this.openShareView(attachments);
|
this.openShareView(attachments);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logEvent(events.ROOM_BOX_ACTION_LIBRARY_F);
|
logEvent(events.ROOM_BOX_ACTION_LIBRARY_F);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue