|
|
@@ -1,8 +1,9 @@
|
|
|
import React from 'react';
|
|
|
-import { Modal, StyleSheet, View, TouchableOpacity, ActivityIndicator } from 'react-native';
|
|
|
+import { Modal, StyleSheet, View, TouchableOpacity, ActivityIndicator, Text } from 'react-native';
|
|
|
import ImageViewer from 'react-native-image-zoom-viewer';
|
|
|
import { Colors } from 'src/theme';
|
|
|
import CloseIcon from 'assets/icons/close.svg';
|
|
|
+import SaveIcon from 'assets/icons/travels-screens/save.svg';
|
|
|
|
|
|
interface Photo {
|
|
|
uri: string;
|
|
|
@@ -18,6 +19,8 @@ interface CustomImageViewerProps {
|
|
|
onImageIndexChange?: (index: number) => void;
|
|
|
renderFooter?: (currentIndex: number) => React.ReactElement;
|
|
|
loadingColor?: string;
|
|
|
+ withSaveButton?: boolean;
|
|
|
+ onRequestSave?: () => void;
|
|
|
}
|
|
|
|
|
|
export const CustomImageViewer: React.FC<CustomImageViewerProps> = ({
|
|
|
@@ -28,7 +31,9 @@ export const CustomImageViewer: React.FC<CustomImageViewerProps> = ({
|
|
|
backgroundColor = Colors.DARK_BLUE,
|
|
|
onImageIndexChange,
|
|
|
renderFooter,
|
|
|
- loadingColor = Colors.WHITE
|
|
|
+ loadingColor = Colors.WHITE,
|
|
|
+ withSaveButton = false,
|
|
|
+ onRequestSave = () => {}
|
|
|
}) => {
|
|
|
const [currentIndex, setCurrentIndex] = React.useState(imageIndex);
|
|
|
|
|
|
@@ -53,15 +58,30 @@ export const CustomImageViewer: React.FC<CustomImageViewerProps> = ({
|
|
|
: undefined;
|
|
|
|
|
|
const renderCloseButton = () => (
|
|
|
- <TouchableOpacity
|
|
|
- style={styles.closeButton}
|
|
|
- onPress={onRequestClose}
|
|
|
- hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
|
|
|
- >
|
|
|
- <View style={styles.closeIconContainer}>
|
|
|
- <CloseIcon fill={Colors.WHITE} height={16} width={16} />
|
|
|
- </View>
|
|
|
- </TouchableOpacity>
|
|
|
+ <View style={{ flex: 1 }}>
|
|
|
+ <TouchableOpacity
|
|
|
+ style={styles.closeButton}
|
|
|
+ onPress={onRequestClose}
|
|
|
+ hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
|
|
|
+ >
|
|
|
+ <View style={styles.closeIconContainer}>
|
|
|
+ <CloseIcon fill={Colors.WHITE} height={16} width={16} />
|
|
|
+ </View>
|
|
|
+ </TouchableOpacity>
|
|
|
+
|
|
|
+ {withSaveButton ? (
|
|
|
+ <TouchableOpacity
|
|
|
+ style={styles.saveButton}
|
|
|
+ onPress={onRequestSave}
|
|
|
+ hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
|
|
|
+ >
|
|
|
+ <View style={styles.saveIconContainer}>
|
|
|
+ <SaveIcon fill={Colors.WHITE} height={16} width={16} />
|
|
|
+ <Text style={styles.saveText}>Save</Text>
|
|
|
+ </View>
|
|
|
+ </TouchableOpacity>
|
|
|
+ ) : null}
|
|
|
+ </View>
|
|
|
);
|
|
|
|
|
|
const renderLoadingIndicator = () => (
|
|
|
@@ -99,6 +119,13 @@ const styles = StyleSheet.create({
|
|
|
width: '100%'
|
|
|
},
|
|
|
closeButton: {
|
|
|
+ position: 'absolute',
|
|
|
+ top: 50,
|
|
|
+ left: 6,
|
|
|
+ zIndex: 1000,
|
|
|
+ padding: 8
|
|
|
+ },
|
|
|
+ saveButton: {
|
|
|
position: 'absolute',
|
|
|
top: 50,
|
|
|
right: 6,
|
|
|
@@ -113,6 +140,21 @@ const styles = StyleSheet.create({
|
|
|
alignItems: 'center',
|
|
|
backgroundColor: 'rgba(15, 63, 79, 0.7)'
|
|
|
},
|
|
|
+ saveIconContainer: {
|
|
|
+ height: 46,
|
|
|
+ borderRadius: 23,
|
|
|
+ justifyContent: 'center',
|
|
|
+ flexDirection: 'row',
|
|
|
+ alignItems: 'center',
|
|
|
+ backgroundColor: 'rgba(15, 63, 79, 0.7)',
|
|
|
+ paddingHorizontal: 15,
|
|
|
+ gap: 6
|
|
|
+ },
|
|
|
+ saveText: {
|
|
|
+ color: Colors.WHITE,
|
|
|
+ fontWeight: '600',
|
|
|
+ fontSize: 14
|
|
|
+ },
|
|
|
loadingContainer: {
|
|
|
flex: 1,
|
|
|
justifyContent: 'center',
|