@moamc/rn-cli 1.3.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moamc/rn-cli",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "Enterprise-grade Code Generation CLI for React Native Applications",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -45,7 +45,7 @@ const generateHookTemplate = (hookName, hasForm = false, formFields = [], eventN
45
45
  import { showToastNotification } from '../../../../helpers/common';${hasDate ? '\nimport moment from \'moment\';' : ''}
46
46
  import { validate${hookName} } from '../validation';
47
47
 
48
- export const use${hookName} = () => {
48
+ export const use${hookName} = ({ navigation }) => {
49
49
  \tconst [formData, setFormData] = useState({
50
50
  ${formFields.map(f => `\t\t${f.name}: '',`).join('\n')}
51
51
  \t});
@@ -121,9 +121,15 @@ export const use${hookName} = ({ navigation }) => {
121
121
  \t\t}
122
122
  \t}, [error]);
123
123
 
124
+ \tconst handleSubmit = () => {
125
+ \t\t// Add your submit logic here
126
+ \t\tshowToastNotification('Submit clicked');
127
+ \t};
128
+
124
129
  \treturn {
125
130
  \t\tloading: isLoading,
126
131
  \t\tdata,
132
+ \t\thandleSubmit,
127
133
  \t};
128
134
  };
129
135
  `;
@@ -50,9 +50,91 @@ const generateEnhancedTemplate = (screenName, featureName, hasForm = false, form
50
50
  const componentName = screenName;
51
51
  const hasDropdown = formFields.some(f => f.type === 'dropdown');
52
52
  const hasDate = formFields.some(f => f.type === 'date');
53
- const { headerImportPath } = detectProjectStructure();
53
+ const { headerImportPath, hasHeadersFolder } = detectProjectStructure();
54
+ const isDistributorStyle = !hasHeadersFolder;
54
55
 
55
- return `import React, { useState } from 'react';
56
+ if (isDistributorStyle) {
57
+ // Distributor app style with proper imports and styling
58
+ return `import React, { useState } from 'react';
59
+ import { Text, ScrollView, View, StyleSheet } from 'react-native';
60
+ import { colorConstant, fonts, utilities } from '../../../assets/styles';
61
+ import Container from '../../../components/common/Container';
62
+ import Header from '../../../components/common/Header';
63
+ import Footer from '../../../components/common/Footer';
64
+ import Loader from '../../../components/common/Loader';
65
+ import { FloatingTextInput, FormButton } from '../../../components/form';${hasDropdown ? '\nimport { BottomSheet } from \'../../../components/common\';\nimport DropDownReview from \'../../../components/common/DropDownReview\';' : ''}${hasDate ? '\nimport { DatePickerCustom } from \'../../../components/form/DatePicker\';\nimport moment from \'moment\';' : ''}
66
+ import { use${componentName} } from './hooks/use${componentName}';
67
+
68
+ const ${componentName} = ({ navigation }) => {
69
+ \tconst {
70
+ \t\tformData,
71
+ \t\terrors,
72
+ \t\ttouched,
73
+ \t\tloading,
74
+ \t\thandleChange,
75
+ \t\thandleSubmit${hasDropdown ? ',\n\t\topenBottomSheet,\n\t\tbottomSheetType' : ''}${hasDate ? ',\n\t\topenCalendar,\n\t\tsetOpenCalendar' : ''}
76
+ \t} = use${componentName}({ navigation });
77
+ \t${hasDropdown ? '\n\tconst [openBottomNote, setOpenBottomNote] = useState(false);' : ''}
78
+
79
+ \tif (loading) {
80
+ \t\treturn <Loader loaderText="Hang On..." />;
81
+ \t}
82
+
83
+ \treturn (
84
+ \t\t<>
85
+ \t\t\t<Container>
86
+ \t\t\t\t<Header redirect={() => navigation.goBack()} />
87
+ \t\t\t\t<ScrollView
88
+ \t\t\t\t\tshowsVerticalScrollIndicator={false}
89
+ \t\t\t\t\tcontentContainerStyle={[utilities.rowPadding24]}
90
+ \t\t\t\t>
91
+ \t\t\t\t\t<Text style={styles.heading}>${screenName}</Text>
92
+ ${generateFormFields(formFields)}
93
+ \t\t\t\t</ScrollView>
94
+ \t\t\t</Container>
95
+ \t\t\t<Footer isBottom={true}>
96
+ \t\t\t\t<FormButton title="Submit" onPress={handleSubmit} />
97
+ \t\t\t</Footer>${hasDropdown ? \`
98
+ \t\t\t<BottomSheet
99
+ \t\t\t\tmodalVisible={!!openBottomNote}
100
+ \t\t\t\tsetIsModalVisible={() => setOpenBottomNote(null)}
101
+ \t\t\t>
102
+ \t\t\t\t<DropDownReview
103
+ \t\t\t\t\tFundBuyType={/* Add options */[]}
104
+ \t\t\t\t\tselectValue={formData[bottomSheetType]}
105
+ \t\t\t\t\tonSelectValue={e => {
106
+ \t\t\t\t\t\thandleChange(e, bottomSheetType);
107
+ \t\t\t\t\t\tsetOpenBottomNote(null);
108
+ \t\t\t\t\t}}
109
+ \t\t\t\t\tlabel={bottomSheetType}
110
+ \t\t\t\t/>
111
+ \t\t\t</BottomSheet>\` : ''}${hasDate ? \`
112
+ \t\t\t<DatePickerCustom
113
+ \t\t\t\tmodalTransparent={true}
114
+ \t\t\t\tonDateChange={data => {
115
+ \t\t\t\t\thandleChange(moment(data).format('DD MMM YYYY'), 'dateField');
116
+ \t\t\t\t}}
117
+ \t\t\t\tsetModalVisible={() => setOpenCalendar(!openCalendar)}
118
+ \t\t\t\tmodalVisible={openCalendar}
119
+ \t\t\t\tminimumDate={new Date(1920, 0, 1)}
120
+ \t\t\t/>\` : ''}
121
+ \t\t</>
122
+ \t);
123
+ };
124
+
125
+ const styles = StyleSheet.create({
126
+ \theading: {
127
+ \t\t...fonts.fontWSSB18,
128
+ \t\tcolor: colorConstant.moBlack,
129
+ \t\tmarginVertical: 20,
130
+ \t},
131
+ });
132
+
133
+ export default ${componentName};
134
+ `;
135
+ } else {
136
+ // Investor app style - original template
137
+ return `import React, { useState } from 'react';
56
138
  import { Text, ScrollView, View } from 'react-native';
57
139
  import { TouchableRipple } from 'react-native-paper';
58
140
  import { colorConstant, utilities } from '../../../assets/styles';
@@ -91,7 +173,7 @@ ${generateFormFields(formFields)}
91
173
  \t\t\t</Container>
92
174
  \t\t\t<Footer style={styles.footerDesign}>
93
175
  \t\t\t\t<FormButton title="Submit" onPress={handleSubmit} />
94
- \t\t\t</Footer>${hasDropdown ? `
176
+ \t\t\t</Footer>${hasDropdown ? \`
95
177
  \t\t\t<BottomSheet
96
178
  \t\t\t\tmodalVisible={!!openBottomNote}
97
179
  \t\t\t\tsetIsModalVisible={() => setOpenBottomNote(null)}
@@ -105,7 +187,7 @@ ${generateFormFields(formFields)}
105
187
  \t\t\t\t\t}}
106
188
  \t\t\t\t\tlabel={bottomSheetType}
107
189
  \t\t\t\t/>
108
- \t\t\t</BottomSheet>` : ''}${hasDate ? `
190
+ \t\t\t</BottomSheet>\` : ''}${hasDate ? \`
109
191
  \t\t\t<DatePickerCustom
110
192
  \t\t\t\tmodalTransparent={true}
111
193
  \t\t\t\tonDateChange={data => {
@@ -114,13 +196,14 @@ ${generateFormFields(formFields)}
114
196
  \t\t\t\tsetModalVisible={() => setOpenCalendar(!openCalendar)}
115
197
  \t\t\t\tmodalVisible={openCalendar}
116
198
  \t\t\t\tminimumDate={new Date(1920, 0, 1)}
117
- \t\t\t/>` : ''}
199
+ \t\t\t/>\` : ''}
118
200
  \t\t</>
119
201
  \t);
120
202
  };
121
203
 
122
204
  export default ${componentName};
123
205
  `;
206
+ }
124
207
  };
125
208
 
126
209
  const generateScreenTemplate = (screenName, featureName, hasForm = false, formFields = []) => {
@@ -131,9 +214,64 @@ const generateScreenTemplate = (screenName, featureName, hasForm = false, formFi
131
214
 
132
215
  // Simple screen template
133
216
  const componentName = screenName;
134
- const { headerImportPath } = detectProjectStructure();
217
+ const { headerImportPath, hasHeadersFolder } = detectProjectStructure();
218
+ const isDistributorStyle = !hasHeadersFolder;
135
219
 
136
- return `import React from 'react';
220
+ if (isDistributorStyle) {
221
+ // Distributor app style - with Header, Footer, and FormButton
222
+ return `import React from 'react';
223
+ import { View, Text, ScrollView, StyleSheet } from 'react-native';
224
+ import { colorConstant, fonts, utilities } from '../../../assets/styles';
225
+ import Container from '../../../components/common/Container';
226
+ import Header from '../../../components/common/Header';
227
+ import Footer from '../../../components/common/Footer';
228
+ import Loader from '../../../components/common/Loader';
229
+ import { FormButton } from '../../../components/form';
230
+ import { use${componentName} } from './hooks/use${componentName}';
231
+
232
+ const ${componentName} = ({ navigation }) => {
233
+ \tconst {
234
+ \t\tloading,
235
+ \t\tdata,
236
+ \t\thandleSubmit,
237
+ \t} = use${componentName}({ navigation });
238
+
239
+ \tif (loading) {
240
+ \t\treturn <Loader loaderText="Hang On..." />;
241
+ \t}
242
+
243
+ \treturn (
244
+ \t\t<>
245
+ \t\t\t<Container>
246
+ \t\t\t\t<Header redirect={() => navigation.goBack()} />
247
+ \t\t\t\t<ScrollView
248
+ \t\t\t\t\tshowsVerticalScrollIndicator={false}
249
+ \t\t\t\t\tcontentContainerStyle={[utilities.rowPadding24]}
250
+ \t\t\t\t>
251
+ \t\t\t\t\t<Text style={styles.heading}>${screenName}</Text>
252
+ \t\t\t\t\t{/* Add your content here */}
253
+ \t\t\t\t</ScrollView>
254
+ \t\t\t</Container>
255
+ \t\t\t<Footer isBottom={true}>
256
+ \t\t\t\t<FormButton title="Submit" onPress={handleSubmit} />
257
+ \t\t\t</Footer>
258
+ \t\t</>
259
+ \t);
260
+ };
261
+
262
+ const styles = StyleSheet.create({
263
+ \theading: {
264
+ \t\t...fonts.fontWSSB18,
265
+ \t\tcolor: colorConstant.moBlack,
266
+ \t\tmarginVertical: 20,
267
+ \t},
268
+ });
269
+
270
+ export default ${componentName};
271
+ `;
272
+ } else {
273
+ // Investor app style - original template
274
+ return `import React from 'react';
137
275
  import { View, Text, ScrollView } from 'react-native';
138
276
  import { Container, Loader } from '../../../components/common';
139
277
  import { Header } from '${headerImportPath}';
@@ -164,6 +302,7 @@ const ${componentName} = ({ navigation }) => {
164
302
 
165
303
  export default ${componentName};
166
304
  `;
305
+ }
167
306
  };
168
307
 
169
308
  module.exports = { generateScreenTemplate };