2020-06-29 19:51:40 +02:00
|
|
|
import React from 'react';
|
2020-06-19 02:08:53 +02:00
|
|
|
import { bindActionCreators } from 'redux';
|
2020-07-29 20:15:55 +02:00
|
|
|
import { useSelector, useDispatch } from 'react-redux';
|
2020-06-18 20:49:31 +02:00
|
|
|
import styled from 'styled-components';
|
2020-06-18 20:39:55 +02:00
|
|
|
import Header from '../../components/mobile/Header';
|
2020-06-30 00:54:48 +02:00
|
|
|
import IconButton from '../../components/mobile/IconButton';
|
2020-06-18 21:29:46 +02:00
|
|
|
import PreviewFrame from '../IDE/components/PreviewFrame';
|
2020-06-18 20:39:55 +02:00
|
|
|
import Screen from '../../components/mobile/MobileScreen';
|
2020-07-15 22:44:47 +02:00
|
|
|
import Console from '../IDE/components/Console';
|
2020-06-19 02:08:53 +02:00
|
|
|
import * as ProjectActions from '../IDE/actions/project';
|
2020-06-19 03:00:24 +02:00
|
|
|
import * as IDEActions from '../IDE/actions/ide';
|
2020-06-19 03:52:25 +02:00
|
|
|
import * as PreferencesActions from '../IDE/actions/preferences';
|
|
|
|
import * as ConsoleActions from '../IDE/actions/console';
|
|
|
|
import * as FilesActions from '../IDE/actions/files';
|
2020-06-19 03:00:24 +02:00
|
|
|
|
2020-06-19 03:52:25 +02:00
|
|
|
import { getHTMLFile } from '../IDE/reducers/files';
|
2020-06-18 21:01:13 +02:00
|
|
|
|
2020-06-19 03:52:25 +02:00
|
|
|
import { ExitIcon } from '../../common/icons';
|
2020-06-18 21:01:13 +02:00
|
|
|
import { remSize } from '../../theme';
|
2020-07-15 22:44:47 +02:00
|
|
|
import Footer from '../../components/mobile/Footer';
|
2020-06-18 21:01:13 +02:00
|
|
|
|
|
|
|
const Content = styled.div`
|
|
|
|
z-index: 0;
|
2020-06-19 20:55:37 +02:00
|
|
|
margin-top: ${remSize(68)};
|
2020-06-18 21:01:13 +02:00
|
|
|
`;
|
2020-06-18 20:49:31 +02:00
|
|
|
|
2020-07-29 20:15:55 +02:00
|
|
|
const MobileSketchView = () => {
|
2020-07-17 20:36:38 +02:00
|
|
|
const { files, ide, preferences } = useSelector(state => state);
|
2020-06-18 21:29:46 +02:00
|
|
|
|
2020-07-17 20:36:38 +02:00
|
|
|
const htmlFile = useSelector(state => getHTMLFile(state.files));
|
|
|
|
const projectName = useSelector(state => state.project.name);
|
|
|
|
const selectedFile = useSelector(state => state.files.find(file => file.isSelectedFile) ||
|
|
|
|
state.files.find(file => file.name === 'sketch.js') ||
|
|
|
|
state.files.find(file => file.name !== 'root'));
|
2020-06-18 21:29:46 +02:00
|
|
|
|
2020-06-19 03:52:25 +02:00
|
|
|
const {
|
2020-07-17 20:36:38 +02:00
|
|
|
setTextOutput, setGridOutput, setSoundOutput, dispatchConsoleEvent,
|
|
|
|
endSketchRefresh, stopSketch, setBlobUrl, expandConsole, clearConsole
|
|
|
|
} = bindActionCreators({
|
|
|
|
...ProjectActions, ...IDEActions, ...PreferencesActions, ...ConsoleActions, ...FilesActions
|
|
|
|
}, useDispatch());
|
2020-06-19 03:00:24 +02:00
|
|
|
|
2020-06-18 20:39:55 +02:00
|
|
|
return (
|
2020-06-23 20:54:09 +02:00
|
|
|
<Screen fullscreen>
|
2020-07-01 00:11:48 +02:00
|
|
|
<Header
|
2020-07-17 20:36:38 +02:00
|
|
|
leftButton={<IconButton to="/mobile" icon={ExitIcon} aria-label="Return to original editor" />}
|
2020-07-01 00:11:48 +02:00
|
|
|
title={projectName}
|
|
|
|
/>
|
2020-06-18 21:01:13 +02:00
|
|
|
<Content>
|
2020-06-19 20:55:37 +02:00
|
|
|
<PreviewFrame
|
|
|
|
htmlFile={htmlFile}
|
|
|
|
files={files}
|
|
|
|
head={<link type="text/css" rel="stylesheet" href="/preview-styles.css" />}
|
|
|
|
|
|
|
|
content={selectedFile.content}
|
|
|
|
|
|
|
|
isPlaying
|
|
|
|
isAccessibleOutputPlaying={ide.isAccessibleOutputPlaying}
|
|
|
|
previewIsRefreshing={ide.previewIsRefreshing}
|
|
|
|
|
|
|
|
textOutput={preferences.textOutput}
|
|
|
|
gridOutput={preferences.gridOutput}
|
|
|
|
soundOutput={preferences.soundOutput}
|
|
|
|
autorefresh={preferences.autorefresh}
|
|
|
|
|
|
|
|
setTextOutput={setTextOutput}
|
|
|
|
setGridOutput={setGridOutput}
|
|
|
|
setSoundOutput={setSoundOutput}
|
|
|
|
dispatchConsoleEvent={dispatchConsoleEvent}
|
|
|
|
endSketchRefresh={endSketchRefresh}
|
|
|
|
stopSketch={stopSketch}
|
|
|
|
setBlobUrl={setBlobUrl}
|
|
|
|
expandConsole={expandConsole}
|
|
|
|
clearConsole={clearConsole}
|
|
|
|
/>
|
2020-06-18 21:01:13 +02:00
|
|
|
</Content>
|
2020-07-21 20:58:28 +02:00
|
|
|
<Footer>
|
|
|
|
<Console />
|
|
|
|
</Footer>
|
2020-06-18 20:39:55 +02:00
|
|
|
</Screen>);
|
|
|
|
};
|
2020-06-18 21:01:13 +02:00
|
|
|
|
2020-07-17 20:36:38 +02:00
|
|
|
export default MobileSketchView;
|