From 0c57fa4dc0520127249662d18e47154d0060a87a Mon Sep 17 00:00:00 2001 From: medomy Date: Tue, 31 Jan 2023 01:11:17 +0200 Subject: [PATCH] img picker done --- android/app/src/main/AndroidManifest.xml | 4 ++-- package-lock.json | 16 ++++++++++++++++ package.json | 1 + .../profileComponents/profileCircle/index.tsx | 19 +++++++++++++------ 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index a7f1a81..fe3e62a 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,8 +1,8 @@ - - + diff --git a/package-lock.json b/package-lock.json index 2e0a540..929e355 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "react": "18.2.0", "react-native": "0.71.1", "react-native-image-crop-picker": "^0.39.0", + "react-native-image-picker": "^5.0.1", "react-native-safe-area-context": "^4.5.0", "react-native-screens": "^3.19.0", "react-native-splash-screen": "^3.3.0", @@ -13113,6 +13114,15 @@ "react-native": ">=0.40.0" } }, + "node_modules/react-native-image-picker": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/react-native-image-picker/-/react-native-image-picker-5.0.1.tgz", + "integrity": "sha512-+poQTHOnEGrbxJnut591XA9006svFOyfPg/i5bv+fLuwoSHh5HW0E/PVhvT8lbX0Z5C108vh3DAsnrfFFnPBGw==", + "peerDependencies": { + "react": "*", + "react-native": "*" + } + }, "node_modules/react-native-safe-area-context": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/react-native-safe-area-context/-/react-native-safe-area-context-4.5.0.tgz", @@ -24984,6 +24994,12 @@ "integrity": "sha512-4aANbQMrmU6zN/4b0rVBA7SbaZ3aa5JESm3Xk751sINybZMt1yz/9h95LkO7U0pbslHDo3ofXjG75PmQRP6a/w==", "requires": {} }, + "react-native-image-picker": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/react-native-image-picker/-/react-native-image-picker-5.0.1.tgz", + "integrity": "sha512-+poQTHOnEGrbxJnut591XA9006svFOyfPg/i5bv+fLuwoSHh5HW0E/PVhvT8lbX0Z5C108vh3DAsnrfFFnPBGw==", + "requires": {} + }, "react-native-safe-area-context": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/react-native-safe-area-context/-/react-native-safe-area-context-4.5.0.tgz", diff --git a/package.json b/package.json index 2053fe4..23a98d9 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "react": "18.2.0", "react-native": "0.71.1", "react-native-image-crop-picker": "^0.39.0", + "react-native-image-picker": "^5.0.1", "react-native-safe-area-context": "^4.5.0", "react-native-screens": "^3.19.0", "react-native-splash-screen": "^3.3.0", diff --git a/src/components/profileComponents/profileCircle/index.tsx b/src/components/profileComponents/profileCircle/index.tsx index 7b05406..b294264 100644 --- a/src/components/profileComponents/profileCircle/index.tsx +++ b/src/components/profileComponents/profileCircle/index.tsx @@ -3,6 +3,7 @@ import React from 'react' import { COLORS, SIZES } from '../../../constants' import Icon from 'react-native-vector-icons/FontAwesome' import ImagePicker from 'react-native-image-crop-picker'; +import { launchCamera, launchImageLibrary } from 'react-native-image-picker'; interface props { profilePic: string, changeProfilePic: (uri: string) => void, @@ -11,12 +12,18 @@ const ProfileCircle = ({ profilePic, changeProfilePic }: props) => { const openImgPicker = async () => { try { - const img = await ImagePicker.openPicker({ - width: 300, - height: 300, - cropping: true - }) - changeProfilePic(img.path); + // const img = await ImagePicker.openPicker({ + // width: 300, + // height: 300, + // cropping: true + // }) + // changeProfilePic(img.path); + const result = await launchImageLibrary({ + mediaType: "photo" + }); + if (result.assets) { + changeProfilePic(result!.assets[0]!.uri!) + } } catch (err) { console.warn(err) } } return (