images from camera WIP

This commit is contained in:
2025-05-22 07:33:27 +02:00
parent 9733a9f4eb
commit 613a8753fa
3 changed files with 26 additions and 1 deletions

View File

@@ -27,7 +27,13 @@
"bundler": "metro"
},
"plugins": [
"expo-router"
"expo-router",
[
"expo-image-picker",
{
"photosPermission": "The app accesses your photos to let you share them with your friends."
}
]
]
}
}

View File

@@ -6,6 +6,7 @@ import {
ScrollView,
} from "react-native";
import { TextInput, Button, Snackbar } from "react-native-paper";
import { requestCameraPermissionsAsync, launchCameraAsync } from 'expo-image-picker';
import useLocationStore from "@/locationStore";
export default function FormScreen() {
@@ -59,6 +60,20 @@ export default function FormScreen() {
}
};
const takePicture = async () => {
const {status} = await requestCameraPermissionsAsync();
if (status !== 'granted') {
return;
}
const result = await launchCameraAsync({
allowsEditing: false,
});
if (!result.canceled && result.assets) {
setImage(result.assets.map(asset => asset.uri));
}
}
return (
<KeyboardAvoidingView
style={{ flex: 1 }}
@@ -124,6 +139,9 @@ export default function FormScreen() {
>
Dodaj
</Button>
<Button onPress={takePicture} style={{ margin: 10, width: "100%" }} icon="plus-circle-outline" mode={"contained"}>
Zrób zdjęcie
</Button>
</ScrollView>
</KeyboardAvoidingView>
);

View File

@@ -17,6 +17,7 @@
"expo-linking": "~7.1.4",
"expo-router": "~5.0.7",
"expo-status-bar": "~2.2.3",
"expo-image-picker": "~16.1.4",
"react": "19.0.0",
"react-dom": "19.0.0",
"react-native": "0.79.2",