images from camera WIP
This commit is contained in:
8
app.json
8
app.json
@@ -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."
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user