imageList.old 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. import React from 'react';
  2. import { makeStyles } from '@material-ui/core/styles';
  3. import GridList from '@material-ui/core/GridList';
  4. import GridListTile from '@material-ui/core/GridListTile';
  5. import GridListTileBar from '@material-ui/core/GridListTileBar';
  6. import ListSubheader from '@material-ui/core/ListSubheader';
  7. import IconButton from '@material-ui/core/IconButton';
  8. import InfoIcon from '@material-ui/icons/Info';
  9. import tileData from './tileData';
  10. import Modal from '@material-ui/core/Modal';
  11. import Backdrop from '@material-ui/core/Backdrop';
  12. import Fade from '@material-ui/core/Fade';
  13. import Grid from '@material-ui/core/Grid';
  14. import Fab from '@material-ui/core/Fab';
  15. import AddIcon from '@material-ui/icons/Add';
  16. import ArrowBackIosIcon from '@material-ui/icons/ArrowBackIos';
  17. import ArrowForwardIosIcon from '@material-ui/icons/ArrowForwardIos';
  18. import CloseIcon from '@material-ui/icons/Close';
  19. import TodayIcon from '@material-ui/icons/Today';
  20. import CropOriginalIcon from '@material-ui/icons/CropOriginal';
  21. import CameraIcon from '@material-ui/icons/Camera';
  22. import LocationOnIcon from '@material-ui/icons/LocationOn'
  23. import Typography from '@material-ui/core/Typography';
  24. import ListItem from '@material-ui/core/ListItem';
  25. import ListItemIcon from '@material-ui/core/ListItemIcon';
  26. import ListItemText from '@material-ui/core/ListItemText';
  27. import List from '@material-ui/core/List';
  28. import Paper from '@material-ui/core/Paper';
  29. import Lightbox from 'react-image-lightbox';
  30. import 'react-image-lightbox/style.css'; // This only needs to be imported once in your app
  31. const useStyles = makeStyles((theme) => ({
  32. root: {
  33. display: 'flex',
  34. flexWrap: 'wrap',
  35. justifyContent: 'space-around',
  36. overflow: 'hidden',
  37. },
  38. gridList: {
  39. width: '100%',
  40. height: '100%',
  41. },
  42. icon: {
  43. color: 'rgba(255, 255, 255, 0.54)',
  44. },
  45. modal: {
  46. display: 'flex',
  47. alignItems: 'center',
  48. justifyContent: 'center',
  49. },
  50. paper: {
  51. backgroundColor: theme.palette.background.paper,
  52. width: '100%',
  53. height: '100%',
  54. //boxShadow: theme.shadows[5],
  55. //padding: theme.spacing(2, 4, 3),
  56. },
  57. fabL: {
  58. position: 'absolute',
  59. bottom: '50%',
  60. left: theme.spacing(2),
  61. },
  62. fabR: {
  63. position: 'absolute',
  64. bottom: '50%',
  65. //left: `calc(95% - ${theme.spacing(2)}px)`,
  66. //right: theme.spacing(2),
  67. right: `calc(${theme.spacing(2)}px + ( 100vw / 4 ))`,
  68. Mcontainer: {
  69. display: "flex",
  70. flexWrap: "wrap",
  71. position: "absolute",
  72. top: 0,
  73. left: 0,
  74. height: "100%",
  75. width: "100%",
  76. alignItems: "center"
  77. },
  78. },
  79. }));
  80. var Imagesrc = 0;
  81. var FabL = false;
  82. var FabR = false;
  83. var Open = false;
  84. export default function TitlebarGridList() {
  85. const classes = useStyles();
  86. const [Imageopen, setImageOpen] = React.useState(false);
  87. const TDLength = tileData.length;
  88. //const { photoIndex, isOpen } = this.state;
  89. const handleClick = (index) => () => {
  90. Imagesrc = index;
  91. if (index == 0) {
  92. FabL = false;
  93. } else {
  94. FabL = true;
  95. }
  96. if (TDLength == index + 1) {
  97. FabR = false;
  98. } else {
  99. FabR = true;
  100. }
  101. console.log(FabL + " " + FabR);
  102. setImageOpen(true);
  103. }
  104. const moveFw = () => {
  105. Imagesrc++;
  106. setImageOpen(false);
  107. setImageOpen(true);
  108. }
  109. const moveBw = () => {
  110. Imagesrc--;
  111. setImageOpen(false);
  112. setImageOpen(true);
  113. }
  114. const handleImageClose = () => {
  115. setImageOpen(false);
  116. };
  117. return (
  118. <div className={classes.root}>
  119. <GridList cellHeight={180} cols={5} className={classes.gridList}>
  120. <GridListTile key="Subheader" cols={5} style={{ height: 'auto' }}>
  121. <ListSubheader component="div">December</ListSubheader>
  122. </GridListTile>
  123. {tileData.map((tile, index) => (
  124. <GridListTile key={tile.img} onClick={handleClick(index)}>
  125. <img src={tile.img} alt={tile.title} />
  126. </GridListTile>
  127. ))}
  128. </GridList>
  129. <Modal
  130. aria-labelledby="transition-modal-title"
  131. aria-describedby="transition-modal-description"
  132. className={classes.modal}
  133. open={Imageopen}
  134. onClose={handleImageClose}
  135. closeAfterTransition
  136. BackdropComponent={Backdrop}
  137. BackdropProps={{
  138. timeout: 500,
  139. }}
  140. >
  141. <Fade in={Imageopen}>
  142. <div className={classes.paper}>
  143. <Grid container spacing={0}>
  144. <Grid item xs={9}
  145. style={{
  146. alignItems: 'center',
  147. alignContent: 'center',
  148. backgroundColor: 'black',
  149. height: '100vh',
  150. }}
  151. align="center"
  152. justify="center"
  153. direction="column"
  154. >
  155. <Grid
  156. container
  157. spacing={0}
  158. direction="column"
  159. alignItems="center"
  160. justify="center"
  161. style={{ minHeight: '100vh' }}
  162. >
  163. <Grid item xs={12}>
  164. <img src={tileData[this.state.Imagesrc].img}
  165. style={{
  166. margin: "auto",
  167. maxHeight: "100vh",
  168. maxWidth: "100%",
  169. }}
  170. ></img>
  171. </Grid>
  172. </Grid>
  173. {FabL === true ? <Fab color="inherit" aria-label="add" onClick={moveBw} className={classes.fabL}>
  174. <ArrowBackIosIcon />
  175. </Fab> : ""}
  176. {console.log(FabL + " " + FabR)}
  177. {FabR === true ? <Fab color="inherit" aria-label="add" onClick={moveFw} className={classes.fabR}>
  178. <ArrowForwardIosIcon />
  179. </Fab> : ""}
  180. </Grid>
  181. <Grid item xs={3}>
  182. <Typography component="h5">
  183. <IconButton aria-label="delete" type="button" onClick={handleImageClose}>
  184. <CloseIcon />
  185. </IconButton>
  186. 資訊
  187. </Typography>
  188. <List
  189. subheader={
  190. <ListSubheader component="div" id="nested-list-subheader">
  191. 詳細資料
  192. </ListSubheader>
  193. }
  194. >
  195. <ListItem>
  196. <ListItemIcon>
  197. <TodayIcon />
  198. </ListItemIcon>
  199. <ListItemText primary="2016年7月14日" secondary="週六 下午5:43 GMT+08:00" />
  200. </ListItem>
  201. <ListItem>
  202. <ListItemIcon>
  203. <CropOriginalIcon />
  204. </ListItemIcon>
  205. <ListItemText primary="IMG_20160716_174348.jpg" secondary="12.8MP 3096×4128 1.6MB" />
  206. </ListItem>
  207. <ListItem>
  208. <ListItemIcon>
  209. <CameraIcon />
  210. </ListItemIcon>
  211. <ListItemText primary="Samsung GT-I9505" secondary="ƒ/2.2 1/33 4.2mm ISO125" />
  212. </ListItem>
  213. <ListItem>
  214. <ListItemIcon>
  215. <LocationOnIcon />
  216. </ListItemIcon>
  217. <ListItemText primary="中國广东省廣州市" secondary="概估位置" />
  218. </ListItem>
  219. </List>
  220. </Grid>
  221. </Grid>
  222. </div>
  223. </Fade>
  224. </Modal>
  225. </div>
  226. );
  227. }