6
6
PropInt
7
7
} from '../interfaces/Interfaces' ;
8
8
import cloneDeep from '../helperFunctions/cloneDeep' ;
9
+ import { nativeComponentTypes } from '../reducers/initialState' ;
10
+ import importNativeNameGenerator from '../helperFunctions/importNativeGenerator' ;
9
11
10
12
const componentRender = (
11
13
component : ComponentInt ,
@@ -77,7 +79,7 @@ const componentRender = (
77
79
. props . map ( ( prop : PropInt ) => `${ prop . key } ={${ prop . value } }` )
78
80
. join ( ' ' ) ;
79
81
}
80
- if ( child . childType === 'HTML' ) {
82
+ if ( child . childType === 'HTML' || child . childType === 'NATIVE' ) {
81
83
const keys : string [ ] = Object . keys ( child . HTMLInfo ) ;
82
84
return keys
83
85
. map ( key => {
@@ -118,6 +120,11 @@ const componentRender = (
118
120
return 'p' ;
119
121
// REACT NATIVE COMPONENTS
120
122
// TO DO: UPDATE REDUCER LOGIC TO HAVE THESE COMPONENTS IN A SEPARATE FUNCTION
123
+ default :
124
+ return 'div' ;
125
+ }
126
+ } else if ( child . childType === 'NATIVE' ) {
127
+ switch ( child . componentName ) {
121
128
case 'RNView' :
122
129
return 'View' ;
123
130
case 'RNSafeAreaView' :
@@ -145,6 +152,7 @@ const componentRender = (
145
152
return child . componentName ;
146
153
}
147
154
}
155
+
148
156
// logic below consists of conditional that will render depending
149
157
// on the toggling of "state" and/or "class"
150
158
// class components can optioally have a state which will
@@ -157,10 +165,14 @@ const componentRender = (
157
165
158
166
${ childrenArray
159
167
. filter ( child => child . childType !== 'HTML' )
160
- . map (
161
- child =>
162
- `import ${ child . componentName } from './${ child . componentName } .tsx'`
163
- )
168
+ . map ( child => {
169
+ if ( child . childType === 'NATIVE' ) {
170
+ return `import {${ importNativeNameGenerator (
171
+ child
172
+ ) } } from 'react-native'`;
173
+ } else
174
+ `import ${ child . componentName } from './${ child . componentName } .tsx'` ;
175
+ } )
164
176
. reduce ( ( acc : Array < string > , child ) => {
165
177
if ( ! acc . includes ( child ) ) {
166
178
acc . push ( child ) ;
@@ -169,6 +181,8 @@ const componentRender = (
169
181
return acc ;
170
182
} , [ ] )
171
183
. join ( '\n' ) }
184
+
185
+
172
186
173
187
interface Props {
174
188
${ props . map ( prop => `${ prop . key } : ${ typeSwitcher ( prop . type ) } \n` ) }
@@ -212,9 +226,7 @@ const componentRender = (
212
226
return `
213
227
<${ componentNameGenerator ( child ) } ${ propDrillTextGenerator (
214
228
child
215
- ) } >${
216
- /*child.HTMLInfo.value*/ `GGGGGGG`
217
- } </${ componentNameGenerator ( child ) } >`;
229
+ ) } >${ child . HTMLInfo . value } </${ componentNameGenerator ( child ) } >`;
218
230
}
219
231
// code to be rendered for all self closing component/elements
220
232
else
0 commit comments