10 examples of 'react-native-image-picker npm' in JavaScript

Every line of 'react-native-image-picker npm' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
110async _onImagePicked(event) {
111 const file = event.target.files[0];
112 console.log(file);
113 const base64 = await toBase64(file);
114 await this.setStateAsync({ uploadedFileUrl: base64 });
115
116 this.setState({ open: true });
117}
41previewImage() {
42 shell.openExternal(this.value);
43}
59function _onImagePickerFinish(props: UiParams, data: Array<{uri: string}>) {
60 if (!data || data.length === 0) {
61 return;
62 }
63 const {imId, onDataChange} = props;
64 Delegate.func.uploadImages(data.map(i => i.uri))
65 .then(([url]) => Delegate.model.Group.changeAvatar(imId, url))
66 .then(() => {
67 onDataChange();
68 })
69 .catch(() => {
70 Toast.show(i18n.t('IMToastError', {
71 action: i18n.t('IMSettingGroupAvatarChange'),
72 }));
73 });
74}
93onImageClick(index: number) {
94 if (this.props.onImageClick) {
95 this.props.onImageClick(index, this.props.files);
96 }
97}
42componentDidMount () {
43 this.updateMediaItem(this.props.value);
44}
25cameraSuccess(imageData) {
26 const input = this.createInput;
27 input.value = imageData;
28 const event = new Event('input', {
29 bubbles: true
30 });
31 input.dispatchEvent(event);
32 this.setState({
33 inlineStyle: {
34 background: `url(data:image;base64,${imageData})`,
35 backgroundSize: 'cover'
36 }
37 });
38}
108function openFromGallery() {
109 require('/permissions').checkCameraPermission(success => {
110 if (!success) {
111 alert('No permissions!');
112 return;
113 }
114
115 Ti.Media.openPhotoGallery({
116 success: (e) => {
117 logger.log('Ti.Media', 'Image open successfully!');
118 processImage(e.media);
119 },
120 error: ({ error }) => {
121 logger.log('Ti.Media', 'Error opening image: ' + error);
122 },
123 cancel: () => {
124 logger.log('Ti.Media', 'Opening photo-gallery was cancelled');
125 }
126 });
127 });
128}
59selectVideoTapped() {
60 const options = {
61 title: 'Video Picker',
62 takePhotoButtonTitle: 'Take Video...',
63 mediaType: 'video',
64 videoQuality: 'medium',
65 };
66
67 ImagePicker.showImagePicker(options, response => {
68 console.log('Response = ', response);
69
70 if (response.didCancel) {
71 console.log('User cancelled video picker');
72 } else if (response.error) {
73 console.log('ImagePicker Error: ', response.error);
74 } else if (response.customButton) {
75 console.log('User tapped custom button: ', response.customButton);
76 } else {
77 this.setState({
78 videoSource: response.uri,
79 });
80 }
81 });
82}
63export function isIPhoneX(): boolean {
64 return (
65 Platform.OS === "ios" &&
66 ((Dimensions.get("window").height === X_HEIGHT &&
67 Dimensions.get("window").width === X_WIDTH) ||
68 (Dimensions.get("window").height === X_WIDTH &&
69 Dimensions.get("window").width === X_HEIGHT))
70 );
71}
58export function isIPhoneX(): boolean {
59 const X_WIDTH = 375;
60 const X_HEIGHT = 812;
61 return (
62 Platform.OS === "ios" &&
63 ((Dimensions.get("window").height === X_HEIGHT &&
64 Dimensions.get("window").width === X_WIDTH) ||
65 (Dimensions.get("window").height === X_WIDTH &&
66 Dimensions.get("window").width === X_HEIGHT))
67 );
68}

Related snippets