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