File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 7
7
PropInt
8
8
} from '../interfaces/Interfaces' ;
9
9
import { createHistory } from '../helperFunctions/createHistory' ;
10
+ import { initialApplicationState } from './initialState' ;
10
11
11
12
export const addProp = (
12
13
state : ApplicationStateInt ,
@@ -112,13 +113,23 @@ export const toggleCodeEdit = (state: ApplicationStateInt) => ({
112
113
} ) ;
113
114
114
115
export const toggleNative = ( state : ApplicationStateInt ) => {
115
- const components = cloneDeep ( state . components ) ;
116
- const app = components . find ( e => e . id === 1 ) ;
116
+ let check = window . confirm (
117
+ `Are you sure you want to switch to ${
118
+ state . native ? 'React Mode' : 'React Native Mode'
119
+ } ?\n\nSwitching to ${
120
+ state . native ? 'React Mode' : 'React Native Mode'
121
+ } will clear the workspace!\n\nMake sure to export your current code before changing modes!`
122
+ ) ;
123
+ if ( ! check ) {
124
+ return { ...state } ;
125
+ }
126
+ const components = cloneDeep ( initialApplicationState . components ) ;
127
+ const app = components . find ( ( e : ComponentInt ) => e . id === 1 ) ;
117
128
app . position . width = ! state . native ? 500 : 1200 ;
118
129
app . position . height = ! state . native ? 850 : 800 ;
119
130
120
131
return {
121
- ...state ,
132
+ ...initialApplicationState ,
122
133
native : ! state . native ,
123
134
components
124
135
} ;
Original file line number Diff line number Diff line change @@ -499,7 +499,11 @@ export const exportFilesError = (
499
499
loading : false
500
500
} ) ;
501
501
502
- //Reducer that toggles the component class
502
+ /*
503
+ Reducer that toggles the component class
504
+ lets the user choose whether the current
505
+ component is a class components or not
506
+ */
503
507
export const toggleComponentClass = (
504
508
state : ApplicationStateInt ,
505
509
{ id } : { id : number }
You can’t perform that action at this time.
0 commit comments