mirror of
https://git.rezel.net/LudoTech/traque.git
synced 2026-02-09 10:20:16 +01:00
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
import { useState } from 'react';
|
|
import { StyleSheet, View, Image, TouchableOpacity } from "react-native";
|
|
import ImageViewing from 'react-native-image-viewing';
|
|
|
|
export default function CustomImage({ source, canZoom, onPress }) {
|
|
// canZoom : boolean
|
|
const [isModalVisible, setIsModalVisible] = useState(false);
|
|
|
|
return (
|
|
<View style={styles.container}>
|
|
<TouchableOpacity onPress={canZoom ? () => setIsModalVisible(true) : onPress}>
|
|
<Image style={styles.image} resizeMode="contain" source={source}/>
|
|
</TouchableOpacity>
|
|
<ImageViewing
|
|
images={[source]}
|
|
visible={isModalVisible}
|
|
onRequestClose={() => setIsModalVisible(false)}
|
|
swipeToCloseEnabled={false}
|
|
doubleTapToZoomEnabled={false}
|
|
/>
|
|
</View>
|
|
);
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
container: {
|
|
width: "100%",
|
|
alignItems: "center",
|
|
justifyContent: "center"
|
|
},
|
|
image: {
|
|
width: "100%",
|
|
height: undefined,
|
|
aspectRatio: 1.5
|
|
}
|
|
});
|