11import React from 'react' ;
22import PropTypes from 'prop-types' ;
33import styled from 'styled-components' ;
4- import { Link } from 'react-router' ;
4+ // import { Link } from 'react-router';
5+ import { connect } from 'react-redux' ;
6+ import { withRouter } from 'react-router' ;
7+ import { useState } from 'react' ;
58
9+ // Imports to be Refactored
10+ import { bindActionCreators } from 'redux' ;
11+ import * as FileActions from '../actions/files' ;
12+ import * as IDEActions from '../actions/ide' ;
13+ import * as ProjectActions from '../actions/project' ;
14+ import * as EditorAccessibilityActions from '../actions/editorAccessibility' ;
15+ import * as PreferencesActions from '../actions/preferences' ;
16+ import * as UserActions from '../../User/actions' ;
17+ import * as ToastActions from '../actions/toast' ;
18+ import * as ConsoleActions from '../actions/console' ;
19+ import { getHTMLFile } from '../reducers/files' ;
20+
21+ // Local Imports
22+ import Editor from '../components/Editor' ;
623import { prop , remSize } from '../../../theme' ;
724
25+
826const background = prop ( 'Button.default.background' ) ;
927const textColor = prop ( 'primaryTextColor' ) ;
1028
1129const Header = styled . div `
30+ position: fixed;
1231 width: 100%;
1332 background-color: ${ background } ;
1433 color: ${ textColor } ;
@@ -17,13 +36,18 @@ const Header = styled.div`
1736
1837const Footer = styled . div `
1938 width: 100%;
20- position: absolute ;
39+ position: fixed ;
2140 bottom: 0;
2241 background: ${ background } ;
2342 color: ${ textColor } ;
2443 padding-left: ${ remSize ( 32 ) } ;
2544` ;
2645
46+ const Content = styled . div `
47+ ` ;
48+
49+ const f = x => x ;
50+
2751const Screen = ( { children } ) => (
2852 < div className = "fullscreen-preview" >
2953 { children }
@@ -33,16 +57,201 @@ Screen.propTypes = {
3357 children : PropTypes . node . isRequired
3458} ;
3559
36- export default ( ) => (
37- < Screen >
38- < Header > < h1 > Mobile View</ h1 > </ Header >
60+ const IDEViewMobile = ( props ) => {
61+ // const
62+ // const {
63+ // preferences, ide, editorAccessibility, project, updateLintMessage, clearLintMessage, selectedFile, updateFileContent, files, closeEditorOptions, showEditorOptions, showKeyboardShortcutModal, setUnsavedChanges, startRefreshSketch, stopSketch, expandSidebar, collapseSidebar, clearConsole, console, showRuntimeErrorWarning, hideRuntimeErrorWarning
64+ // } = props;
3965
66+ const [ tmController , setTmController ] = useState ( null ) ;
4067
41- < h3 >
42- < br /> This page is under construction.
43- < br /> < Link to = "/" > Click here</ Link > to return to the regular editor
44- </ h3 >
68+ return (
69+ < Screen >
70+ < Header > < h1 > Mobile View</ h1 > </ Header >
71+ { /* <div>
72+ { [preferences, ide, editorAccessibility, project, updateLintMessage, clearLintMessage, selectedFile, updateFileContent, files, closeEditorOptions, showEditorOptions, showKeyboardShortcutModal, setUnsavedChanges, startRefreshSketch, stopSketch, expandSidebar, collapseSidebar, clearConsole, console, showRuntimeErrorWarning, hideRuntimeErrorWarning]
73+ .map(pr => <h5>{pr.toString()}</h5>) }
74+ </div> */ }
4575
46- < Footer > < h1 > Bottom Bar</ h1 > </ Footer >
47- </ Screen >
48- ) ;
76+ < Editor
77+ lintWarning = { props . preferences . lintWarning }
78+ linewrap = { props . preferences . linewrap }
79+ lintMessages = { props . editorAccessibility . lintMessages }
80+ updateLintMessage = { props . updateLintMessage }
81+ clearLintMessage = { props . clearLintMessage }
82+ file = { props . selectedFile }
83+ updateFileContent = { props . updateFileContent }
84+ fontSize = { props . preferences . fontSize }
85+ lineNumbers = { props . preferences . lineNumbers }
86+ files = { props . files }
87+ editorOptionsVisible = { props . ide . editorOptionsVisible }
88+ showEditorOptions = { props . showEditorOptions }
89+ closeEditorOptions = { props . closeEditorOptions }
90+ showKeyboardShortcutModal = { props . showKeyboardShortcutModal }
91+ setUnsavedChanges = { props . setUnsavedChanges }
92+ isPlaying = { props . ide . isPlaying }
93+ theme = { props . preferences . theme }
94+ startRefreshSketch = { props . startRefreshSketch }
95+ stopSketch = { props . stopSketch }
96+ autorefresh = { props . preferences . autorefresh }
97+ unsavedChanges = { props . ide . unsavedChanges }
98+ projectSavedTime = { props . project . updatedAt }
99+ isExpanded = { props . ide . sidebarIsExpanded }
100+ expandSidebar = { props . expandSidebar }
101+ collapseSidebar = { props . collapseSidebar }
102+ isUserOwner = { setTmController }
103+ clearConsole = { props . clearConsole }
104+ consoleEvents = { props . console }
105+ showRuntimeErrorWarning = { props . showRuntimeErrorWarning }
106+ hideRuntimeErrorWarning = { props . hideRuntimeErrorWarning }
107+ runtimeErrorWarningVisible = { props . ide . runtimeErrorWarningVisible }
108+ provideController = { setTmController }
109+ />
110+
111+ < Footer > < h1 > Bottom Bar</ h1 > </ Footer >
112+ </ Screen >
113+ ) ;
114+ } ;
115+
116+
117+ IDEViewMobile . propTypes = {
118+
119+ preferences : PropTypes . shape ( {
120+ fontSize : PropTypes . number . isRequired ,
121+ autosave : PropTypes . bool . isRequired ,
122+ linewrap : PropTypes . bool . isRequired ,
123+ lineNumbers : PropTypes . bool . isRequired ,
124+ lintWarning : PropTypes . bool . isRequired ,
125+ textOutput : PropTypes . bool . isRequired ,
126+ gridOutput : PropTypes . bool . isRequired ,
127+ soundOutput : PropTypes . bool . isRequired ,
128+ theme : PropTypes . string . isRequired ,
129+ autorefresh : PropTypes . bool . isRequired
130+ } ) . isRequired ,
131+
132+ ide : PropTypes . shape ( {
133+ isPlaying : PropTypes . bool . isRequired ,
134+ isAccessibleOutputPlaying : PropTypes . bool . isRequired ,
135+ consoleEvent : PropTypes . array ,
136+ modalIsVisible : PropTypes . bool . isRequired ,
137+ sidebarIsExpanded : PropTypes . bool . isRequired ,
138+ consoleIsExpanded : PropTypes . bool . isRequired ,
139+ preferencesIsVisible : PropTypes . bool . isRequired ,
140+ projectOptionsVisible : PropTypes . bool . isRequired ,
141+ newFolderModalVisible : PropTypes . bool . isRequired ,
142+ shareModalVisible : PropTypes . bool . isRequired ,
143+ shareModalProjectId : PropTypes . string . isRequired ,
144+ shareModalProjectName : PropTypes . string . isRequired ,
145+ shareModalProjectUsername : PropTypes . string . isRequired ,
146+ editorOptionsVisible : PropTypes . bool . isRequired ,
147+ keyboardShortcutVisible : PropTypes . bool . isRequired ,
148+ unsavedChanges : PropTypes . bool . isRequired ,
149+ infiniteLoop : PropTypes . bool . isRequired ,
150+ previewIsRefreshing : PropTypes . bool . isRequired ,
151+ infiniteLoopMessage : PropTypes . string . isRequired ,
152+ projectSavedTime : PropTypes . string ,
153+ previousPath : PropTypes . string . isRequired ,
154+ justOpenedProject : PropTypes . bool . isRequired ,
155+ errorType : PropTypes . string ,
156+ runtimeErrorWarningVisible : PropTypes . bool . isRequired ,
157+ uploadFileModalVisible : PropTypes . bool . isRequired
158+ } ) . isRequired ,
159+
160+ editorAccessibility : PropTypes . shape ( {
161+ lintMessages : PropTypes . array . isRequired ,
162+ } ) . isRequired ,
163+
164+ project : PropTypes . shape ( {
165+ id : PropTypes . string ,
166+ name : PropTypes . string . isRequired ,
167+ owner : PropTypes . shape ( {
168+ username : PropTypes . string ,
169+ id : PropTypes . string
170+ } ) ,
171+ updatedAt : PropTypes . string
172+ } ) . isRequired ,
173+
174+ updateLintMessage : PropTypes . func . isRequired ,
175+
176+ clearLintMessage : PropTypes . func . isRequired ,
177+
178+ selectedFile : PropTypes . shape ( {
179+ id : PropTypes . string . isRequired ,
180+ content : PropTypes . string . isRequired ,
181+ name : PropTypes . string . isRequired
182+ } ) . isRequired ,
183+
184+ updateFileContent : PropTypes . func . isRequired ,
185+
186+ files : PropTypes . arrayOf ( PropTypes . shape ( {
187+ id : PropTypes . string . isRequired ,
188+ name : PropTypes . string . isRequired ,
189+ content : PropTypes . string . isRequired
190+ } ) ) . isRequired ,
191+
192+ closeEditorOptions : PropTypes . func . isRequired ,
193+
194+ showEditorOptions : PropTypes . func . isRequired ,
195+
196+ showKeyboardShortcutModal : PropTypes . func . isRequired ,
197+
198+ setUnsavedChanges : PropTypes . func . isRequired ,
199+
200+ startRefreshSketch : PropTypes . func . isRequired ,
201+
202+ stopSketch : PropTypes . func . isRequired ,
203+
204+ expandSidebar : PropTypes . func . isRequired ,
205+
206+ collapseSidebar : PropTypes . func . isRequired ,
207+
208+ clearConsole : PropTypes . func . isRequired ,
209+
210+ console : PropTypes . arrayOf ( PropTypes . shape ( {
211+ method : PropTypes . string . isRequired ,
212+ args : PropTypes . arrayOf ( PropTypes . string )
213+ } ) ) . isRequired ,
214+
215+ showRuntimeErrorWarning : PropTypes . func . isRequired ,
216+
217+ hideRuntimeErrorWarning : PropTypes . func . isRequired ,
218+
219+ } ;
220+
221+
222+ function mapStateToProps ( state ) {
223+ return {
224+ files : state . files ,
225+ selectedFile : state . files . find ( file => file . isSelectedFile ) ||
226+ state . files . find ( file => file . name === 'sketch.js' ) ||
227+ state . files . find ( file => file . name !== 'root' ) ,
228+ htmlFile : getHTMLFile ( state . files ) ,
229+ ide : state . ide ,
230+ preferences : state . preferences ,
231+ editorAccessibility : state . editorAccessibility ,
232+ user : state . user ,
233+ project : state . project ,
234+ toast : state . toast ,
235+ console : state . console
236+ } ;
237+ }
238+
239+ function mapDispatchToProps ( dispatch ) {
240+ return bindActionCreators (
241+ Object . assign (
242+ { } ,
243+ EditorAccessibilityActions ,
244+ FileActions ,
245+ ProjectActions ,
246+ IDEActions ,
247+ PreferencesActions ,
248+ UserActions ,
249+ ToastActions ,
250+ ConsoleActions
251+ ) ,
252+ dispatch
253+ ) ;
254+ }
255+
256+
257+ export default withRouter ( connect ( mapStateToProps , mapDispatchToProps ) ( IDEViewMobile ) ) ;
0 commit comments