MainPanel.new 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. import React, { Component } from "react";
  2. import { render } from "react-dom";
  3. import { makeStyles, useTheme, withStyles } from '@material-ui/core/styles';
  4. import AppBar from '@material-ui/core/AppBar';
  5. import Toolbar from '@material-ui/core/Toolbar';
  6. import Typography from '@material-ui/core/Typography';
  7. import Button from '@material-ui/core/Button';
  8. import IconButton from '@material-ui/core/IconButton';
  9. import MenuIcon from '@material-ui/icons/Menu';
  10. import clsx from 'clsx';
  11. import Drawer from '@material-ui/core/Drawer';
  12. import List from '@material-ui/core/List';
  13. import CssBaseline from '@material-ui/core/CssBaseline';
  14. import Divider from '@material-ui/core/Divider';
  15. import ChevronLeftIcon from '@material-ui/icons/ChevronLeft';
  16. import ChevronRightIcon from '@material-ui/icons/ChevronRight';
  17. import ListItem from '@material-ui/core/ListItem';
  18. import ListItemIcon from '@material-ui/core/ListItemIcon';
  19. import ListItemText from '@material-ui/core/ListItemText';
  20. import InboxIcon from '@material-ui/icons/MoveToInbox';
  21. import MailIcon from '@material-ui/icons/Mail';
  22. import ImageList from './imageList';
  23. import PhotoIcon from '@material-ui/icons/Photo';
  24. import ShareIcon from '@material-ui/icons/Share';
  25. import PhotoAlbumIcon from '@material-ui/icons/PhotoAlbum';
  26. import LibraryAddCheckIcon from '@material-ui/icons/LibraryAddCheck';
  27. import Grid from '@material-ui/core/Grid';
  28. import DeleteIcon from '@material-ui/icons/Delete';
  29. import CloudUploadIcon from '@material-ui/icons/CloudUpload';
  30. import HelpOutlineIcon from '@material-ui/icons/HelpOutline';
  31. import SettingsIcon from '@material-ui/icons/Settings';
  32. import Avatar from '@material-ui/core/Avatar';
  33. import Icon from '@material-ui/core/Icon';
  34. import AddCircle from '@material-ui/icons/AddCircle';
  35. import CloudIcon from '@material-ui/icons/Cloud';
  36. import LinearProgress from '@material-ui/core/LinearProgress';
  37. import Modal from '@material-ui/core/Modal';
  38. import Backdrop from '@material-ui/core/Backdrop';
  39. import Fade from '@material-ui/core/Fade';
  40. import ListItemAvatar from '@material-ui/core/ListItemAvatar';
  41. import ImageIcon from '@material-ui/icons/Image';
  42. import WorkIcon from '@material-ui/icons/Work';
  43. import BeachAccessIcon from '@material-ui/icons/BeachAccess';
  44. import Paper from '@material-ui/core/Paper';
  45. import TodayIcon from '@material-ui/icons/Today';
  46. import CropOriginalIcon from '@material-ui/icons/CropOriginal';
  47. import CameraIcon from '@material-ui/icons/Camera';
  48. import LocationOnIcon from '@material-ui/icons/LocationOn';
  49. import CloseIcon from '@material-ui/icons/Close';
  50. import ListSubheader from '@material-ui/core/ListSubheader';
  51. import Fab from '@material-ui/core/Fab';
  52. import AddIcon from '@material-ui/icons/Add';
  53. import ArrowBackIosIcon from '@material-ui/icons/ArrowBackIos';
  54. import ArrowForwardIosIcon from '@material-ui/icons/ArrowForwardIos';
  55. import GridList from '@material-ui/core/GridList';
  56. import GridListTile from '@material-ui/core/GridListTile';
  57. const drawerWidth = 240;
  58. const BorderLinearProgress = withStyles((theme) => ({
  59. colorPrimary: {
  60. backgroundColor: theme.palette.grey[theme.palette.type === 'light' ? 200 : 700],
  61. },
  62. bar: {
  63. borderRadius: 5,
  64. backgroundColor: '#1a90ff',
  65. },
  66. }))(LinearProgress);
  67. const useStyles = makeStyles((theme) => ({
  68. root: {
  69. flexGrow: 1,
  70. },
  71. menuButton: {
  72. marginRight: theme.spacing(2),
  73. },
  74. title: {
  75. flexGrow: 1,
  76. },
  77. toolbar: {
  78. display: 'flex',
  79. alignItems: 'center',
  80. justifyContent: 'flex-end',
  81. padding: theme.spacing(0, 1),
  82. // necessary for content to be below app bar
  83. ...theme.mixins.toolbar,
  84. },
  85. root: {
  86. display: 'flex',
  87. },
  88. appBar: {
  89. zIndex: theme.zIndex.drawer + 1,
  90. transition: theme.transitions.create(['width', 'margin'], {
  91. easing: theme.transitions.easing.sharp,
  92. duration: theme.transitions.duration.leavingScreen,
  93. }),
  94. },
  95. appBarShift: {
  96. marginLeft: drawerWidth,
  97. width: `calc(100% - ${drawerWidth}px)`,
  98. transition: theme.transitions.create(['width', 'margin'], {
  99. easing: theme.transitions.easing.sharp,
  100. duration: theme.transitions.duration.enteringScreen,
  101. }),
  102. },
  103. menuButton: {
  104. marginRight: 36,
  105. },
  106. hide: {
  107. display: 'none',
  108. },
  109. drawer: {
  110. width: drawerWidth,
  111. flexShrink: 0,
  112. whiteSpace: 'nowrap',
  113. },
  114. drawerOpen: {
  115. width: drawerWidth,
  116. transition: theme.transitions.create('width', {
  117. easing: theme.transitions.easing.sharp,
  118. duration: theme.transitions.duration.enteringScreen,
  119. }),
  120. },
  121. drawerClose: {
  122. transition: theme.transitions.create('width', {
  123. easing: theme.transitions.easing.sharp,
  124. duration: theme.transitions.duration.leavingScreen,
  125. }),
  126. overflowX: 'hidden',
  127. width: theme.spacing(7) + 1,
  128. [theme.breakpoints.up('sm')]: {
  129. width: theme.spacing(9) + 1,
  130. },
  131. },
  132. toolbar: {
  133. display: 'flex',
  134. alignItems: 'center',
  135. justifyContent: 'flex-end',
  136. padding: theme.spacing(0, 1),
  137. // necessary for content to be below app bar
  138. ...theme.mixins.toolbar,
  139. },
  140. content: {
  141. flexGrow: 1,
  142. padding: theme.spacing(3),
  143. },
  144. modal: {
  145. display: 'flex',
  146. alignItems: 'center',
  147. justifyContent: 'center',
  148. },
  149. paper: {
  150. backgroundColor: theme.palette.background.paper,
  151. width: '100%',
  152. height: '100%',
  153. //boxShadow: theme.shadows[5],
  154. //padding: theme.spacing(2, 4, 3),
  155. },
  156. fabL: {
  157. position: 'absolute',
  158. bottom: '50%',
  159. left: theme.spacing(2),
  160. },
  161. fabR: {
  162. position: 'absolute',
  163. bottom: '50%',
  164. //left: `calc(95% - ${theme.spacing(2)}px)`,
  165. //right: theme.spacing(2),
  166. right: `calc(${theme.spacing(2)}px + ( 100vw / 4 ))`,
  167. Mcontainer: {
  168. display: "flex",
  169. flexWrap: "wrap",
  170. position: "absolute",
  171. top: 0,
  172. left: 0,
  173. height: "100%",
  174. width: "100%",
  175. alignItems: "center"
  176. },
  177. },
  178. }));
  179. class MainPanel extends Component {
  180. constructor() {
  181. super();
  182. this.state = {
  183. name: "React",
  184. showHideDemo1: false,
  185. showHideDemo2: false,
  186. showHideDemo3: false
  187. };
  188. this.hideComponent = this.hideComponent.bind(this);
  189. }
  190. hideComponent(name) {
  191. console.log(name);
  192. switch (name) {
  193. case "showHideDemo1":
  194. this.setState({ showHideDemo1: !this.state.showHideDemo1 });
  195. break;
  196. case "showHideDemo2":
  197. this.setState({ showHideDemo2: !this.state.showHideDemo2 });
  198. break;
  199. case "showHideDemo3":
  200. this.setState({ showHideDemo3: !this.state.showHideDemo3 });
  201. break;
  202. }
  203. }
  204. render() {
  205. //const classes = useStyles();
  206. //const theme = useTheme();
  207. const { classes } = this.props;
  208. const { theme } = this.props;
  209. const [open, setOpen] = this.useState(false);
  210. const { showHideDemo1, showHideDemo2, showHideDemo3 } = this.state;
  211. const handleDrawerOpen = () => {
  212. setOpen(true);
  213. };
  214. const handleDrawerClose = () => {
  215. setOpen(false);
  216. };
  217. const [Imageopen, setImageOpen] = React.useState(false);
  218. const handleImageOpen = () => {
  219. setImageOpen(true);
  220. };
  221. const handleImageClose = () => {
  222. setImageOpen(false);
  223. };
  224. return (
  225. <div className={classes.root}>
  226. <AppBar position="fixed" style={{ background: '#2196f3' }} className={
  227. clsx(classes.appBar, {
  228. [classes.appBarShift]: open,
  229. })
  230. }>
  231. <Toolbar >
  232. <IconButton edge="start" onClick={handleDrawerOpen} className={
  233. clsx(classes.menuButton, {
  234. [classes.hide]: open,
  235. })
  236. } className={classes.menuButton} color="inherit" aria-label="menu">
  237. <MenuIcon />
  238. </IconButton>
  239. <Typography variant="h6" className={classes.title}>
  240. 谷狗相薄
  241. </Typography>
  242. <Button variant="contained" startIcon={<CloudUploadIcon />} type="button" onClick={handleImageOpen}>上載</Button>
  243. <IconButton style={{ color: '#ffffff' }} aria-label="delete">
  244. <HelpOutlineIcon />
  245. </IconButton>
  246. <IconButton style={{ color: '#ffffff' }} aria-label="delete">
  247. <SettingsIcon />
  248. </IconButton>
  249. <Avatar alt="Remy Sharp" src="/static/images/avatar/1.jpg" />
  250. </Toolbar>
  251. </AppBar>
  252. <Drawer
  253. variant="permanent"
  254. className={
  255. clsx(classes.drawer, {
  256. [classes.drawerOpen]: open,
  257. [classes.drawerClose]: !open,
  258. })
  259. }
  260. classes={
  261. {
  262. paper: clsx({
  263. [classes.drawerOpen]: open,
  264. [classes.drawerClose]: !open,
  265. }),
  266. }
  267. }>
  268. <div className={classes.toolbar}>
  269. <IconButton onClick={handleDrawerClose}>
  270. {theme.direction === 'ltr' ? <ChevronLeftIcon /> : <ChevronRightIcon />}
  271. </IconButton>
  272. </div>
  273. <Divider />
  274. <List>
  275. {['相片', '共享', '相簿', '實用工具'].map((text, index) => (
  276. <ListItem button key={text} onClick={() => this.hideComponent("showHideDemo1")}>
  277. <ListItemIcon>{index == 0 ? < PhotoIcon /> : index == 1 ? < ShareIcon /> : index == 2 ? < PhotoAlbumIcon /> : < LibraryAddCheckIcon />}</ListItemIcon>
  278. <ListItemText primary={text} />
  279. </ListItem>
  280. ))}
  281. </List>
  282. <Divider />
  283. <List>
  284. {['儲存空間'].map((text, index) => (
  285. <ListItem button key={text}>
  286. <ListItemIcon>{< CloudIcon />}</ListItemIcon>
  287. <ListItemText primary={text} secondary={<BorderLinearProgress variant="determinate" value={50} />} />
  288. </ListItem>
  289. ))}
  290. </List>
  291. </Drawer>
  292. <main className={classes.content}>
  293. <div className={classes.toolbar} />
  294. {showHideDemo1 && <ImageList />}
  295. <hr />
  296. {showHideDemo2 && <ImageList />}
  297. <hr />
  298. {showHideDemo3 && <ImageList />}
  299. <hr />
  300. <div>
  301. <button onClick={() => this.hideComponent("showHideDemo1")}>
  302. Click to hide Demo1 component
  303. </button>
  304. <button onClick={() => this.hideComponent("showHideDemo2")}>
  305. Click to hide Demo2 component
  306. </button>
  307. <button onClick={() => this.hideComponent("showHideDemo3")}>
  308. Click to hide Demo3 component
  309. </button>
  310. </div>
  311. </main>
  312. <Modal
  313. aria-labelledby="transition-modal-title"
  314. aria-describedby="transition-modal-description"
  315. className={classes.modal}
  316. open={Imageopen}
  317. onClose={handleImageClose}
  318. closeAfterTransition
  319. BackdropComponent={Backdrop}
  320. BackdropProps={{
  321. timeout: 500,
  322. }}
  323. >
  324. <Fade in={Imageopen}>
  325. <div className={classes.paper}>
  326. <Grid container spacing={0}>
  327. <Grid item xs={9}
  328. style={{
  329. alignItems: 'center',
  330. alignContent: 'center',
  331. backgroundColor: 'black',
  332. height: '100vh',
  333. }}
  334. align="center"
  335. justify="center"
  336. direction="column"
  337. >
  338. <Grid
  339. container
  340. spacing={0}
  341. direction="column"
  342. alignItems="center"
  343. justify="center"
  344. style={{ minHeight: '100vh' }}
  345. >
  346. <Grid item xs={12}>
  347. <img src="./images/Q1_PHYS.jpeg"
  348. style={{
  349. margin: "auto",
  350. maxHeight: "100vh",
  351. maxWidth: "100%",
  352. }}
  353. ></img>
  354. </Grid>
  355. </Grid>
  356. <Fab color="inherit" aria-label="add" className={classes.fabL}>
  357. <ArrowBackIosIcon />
  358. </Fab>
  359. <Fab color="inherit" aria-label="add" className={classes.fabR}>
  360. <ArrowForwardIosIcon />
  361. </Fab>
  362. </Grid>
  363. <Grid item xs={3}>
  364. <Typography component="h5">
  365. <IconButton aria-label="delete" type="button" onClick={handleImageClose}>
  366. <CloseIcon />
  367. </IconButton>
  368. 資訊
  369. </Typography>
  370. <List
  371. subheader={
  372. <ListSubheader component="div" id="nested-list-subheader">
  373. 詳細資料
  374. </ListSubheader>
  375. }
  376. >
  377. <ListItem>
  378. <ListItemIcon>
  379. <TodayIcon />
  380. </ListItemIcon>
  381. <ListItemText primary="2016年7月14日" secondary="週六 下午5:43 GMT+08:00" />
  382. </ListItem>
  383. <ListItem>
  384. <ListItemIcon>
  385. <CropOriginalIcon />
  386. </ListItemIcon>
  387. <ListItemText primary="IMG_20160716_174348.jpg" secondary="12.8MP 3096×4128 1.6MB" />
  388. </ListItem>
  389. <ListItem>
  390. <ListItemIcon>
  391. <CameraIcon />
  392. </ListItemIcon>
  393. <ListItemText primary="Samsung GT-I9505" secondary="ƒ/2.2 1/33 4.2mm ISO125" />
  394. </ListItem>
  395. <ListItem>
  396. <ListItemIcon>
  397. <LocationOnIcon />
  398. </ListItemIcon>
  399. <ListItemText primary="中國广东省廣州市" secondary="概估位置" />
  400. </ListItem>
  401. </List>
  402. </Grid>
  403. </Grid>
  404. </div>
  405. </Fade>
  406. </Modal>
  407. </div>
  408. );
  409. }
  410. }
  411. export default MainPanel;