mirror of
https://github.com/pezkuwichain/pezkuwi-mobile-app.git
synced 2026-04-28 00:57:56 +00:00
auto-commit for 32779d15-d550-44c7-a726-3b38d7937ed7
This commit is contained in:
@@ -8,13 +8,41 @@ import {
|
||||
ScrollView,
|
||||
Image,
|
||||
Dimensions,
|
||||
Alert,
|
||||
} from 'react-native';
|
||||
import { Ionicons } from '@expo/vector-icons';
|
||||
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
||||
import * as ImagePicker from 'expo-image-picker';
|
||||
import { useAuth } from '../contexts/AuthContext';
|
||||
|
||||
const { width } = Dimensions.get('window');
|
||||
|
||||
function HomeTab() {
|
||||
const { user } = useAuth();
|
||||
const [profileImage, setProfileImage] = useState<string | null>(null);
|
||||
|
||||
const pickImage = async () => {
|
||||
const permissionResult = await ImagePicker.requestMediaLibraryPermissionsAsync();
|
||||
|
||||
if (permissionResult.granted === false) {
|
||||
Alert.alert('Permission Required', 'Permission to access camera roll is required!');
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await ImagePicker.launchImageLibraryAsync({
|
||||
mediaTypes: ImagePicker.MediaTypeOptions.Images,
|
||||
allowsEditing: true,
|
||||
aspect: [1, 1],
|
||||
quality: 0.5,
|
||||
base64: true,
|
||||
});
|
||||
|
||||
if (!result.canceled && result.assets[0].base64) {
|
||||
const base64Image = `data:image/jpeg;base64,${result.assets[0].base64}`;
|
||||
setProfileImage(base64Image);
|
||||
// TODO: Save to backend
|
||||
}
|
||||
};
|
||||
return (
|
||||
<SafeAreaView style={styles.container}>
|
||||
<ScrollView showsVerticalScrollIndicator={false}>
|
||||
|
||||
Reference in New Issue
Block a user