show image
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
Platform,
|
||||
KeyboardAvoidingView,
|
||||
ScrollView,
|
||||
Image,
|
||||
} from "react-native";
|
||||
import { TextInput, Button, Snackbar } from "react-native-paper";
|
||||
import { requestCameraPermissionsAsync, launchCameraAsync } from 'expo-image-picker';
|
||||
@@ -19,6 +20,7 @@ export default function FormScreen() {
|
||||
});
|
||||
const [message, setMessage] = useState("");
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [picture, setPicture] = useState(null);
|
||||
|
||||
const addLocation = useLocationStore((state) => state.addLocation);
|
||||
|
||||
@@ -69,8 +71,8 @@ export default function FormScreen() {
|
||||
allowsEditing: false,
|
||||
});
|
||||
|
||||
if (!result.canceled && result.assets) {
|
||||
setImage(result.assets.map(asset => asset.uri));
|
||||
if (!result.canceled && result.assets && result.assets.length > 0) {
|
||||
setPicture(result.assets[0].uri);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,6 +144,12 @@ export default function FormScreen() {
|
||||
<Button onPress={takePicture} style={{ margin: 10, width: "100%" }} icon="plus-circle-outline" mode={"contained"}>
|
||||
Zrób zdjęcie
|
||||
</Button>
|
||||
{picture && (
|
||||
<Image
|
||||
source={{ uri: picture.uri }}
|
||||
style={styles.image}
|
||||
/>
|
||||
)}
|
||||
</ScrollView>
|
||||
</KeyboardAvoidingView>
|
||||
);
|
||||
@@ -154,4 +162,11 @@ const styles = StyleSheet.create({
|
||||
justifyContent: "flex-start",
|
||||
alignItems: "center",
|
||||
},
|
||||
image: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
borderStyle: "solid",
|
||||
borderColor: "#fff",
|
||||
borderWidth: 1,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user