import { Button, Text as NBText, Thumbnail, View } from "native-base"; import React, { useState } from "react"; import { Alert, FlatList, Modal, SafeAreaView, StyleSheet, Text, TouchableOpacity, } from "react-native"; import ImageViewer from "react-native-image-zoom-viewer"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { removeAllPhotos, uploadAllPhotos, } from "../../redux/photos/photos.actions"; import { selectPhotos } from "../../redux/photos/photos.selectors"; const mapStateToProps = createStructuredSelector({ photos: selectPhotos, }); const mapDispatchToProps = (dispatch) => ({ removeAllPhotos: () => dispatch(removeAllPhotos()), uploadAllphotos: () => dispatch(uploadAllPhotos()), }); export function ScreenMediaCache({ photos, removeAllPhotos, uploadAllphotos }) { const [previewVisible, setPreviewVisible] = useState(false); const [imgIndex, setImgIndex] = useState(0); return ( item.id} numColumns={5} renderItem={(object) => object.item.video ? ( Video ) : ( { setImgIndex(object.index); setPreviewVisible(true); }} > ) } /> {`${photos.length} Photos`} { Alert.alert("Modal has been closed."); }} visible={previewVisible} transparent={true} > setPreviewVisible(false)} index={imgIndex} onChange={(index) => setImgIndex(index)} style={{ display: "flex" }} renderFooter={(index) => ( {index} This is the thing. )} enableSwipeDown enablePreload imageUrls={photos.map((p) => { return { url: p.uri }; })} /> ); } const styles = StyleSheet.create({ container: { flex: 1, }, actions: { display: "flex", flexDirection: "row", justifyContent: "space-evenly", }, listContentContainer: { flex: 1, }, thumbnail: { width: 10, height: 10, backgroundColor: "tomato", }, }); export default connect(mapStateToProps, mapDispatchToProps)(ScreenMediaCache);