Skip to content

Commit e4ad75b

Browse files
Combine native and native-view into native-common
1 parent f542741 commit e4ad75b

File tree

12 files changed

+29
-382
lines changed

12 files changed

+29
-382
lines changed

packages/create-react-native-library/src/index.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,10 @@ const JS_FILES = path.resolve(__dirname, '../templates/js-library');
1616
const EXPO_FILES = path.resolve(__dirname, '../templates/expo-library');
1717
const CPP_FILES = path.resolve(__dirname, '../templates/cpp-library');
1818
const EXAMPLE_FILES = path.resolve(__dirname, '../templates/example');
19-
20-
// Common native library template files
21-
const NATIVE_FILES = (moduleType: ModuleType) => {
22-
switch (moduleType) {
23-
case 'module':
24-
return path.resolve(__dirname, '../templates/native-library');
25-
case 'view':
26-
return path.resolve(__dirname, '../templates/native-view-library');
27-
}
28-
};
19+
const NATIVE_COMMON_FILES = path.resolve(
20+
__dirname,
21+
'../templates/native-common'
22+
);
2923

3024
// Java
3125
const JAVA_FILES = (moduleType: ModuleType) => {
@@ -442,7 +436,7 @@ async function create(argv: yargs.Arguments<any>) {
442436
path.join(folder, 'example')
443437
);
444438

445-
await copyDir(NATIVE_FILES(moduleType), folder);
439+
await copyDir(NATIVE_COMMON_FILES, folder);
446440

447441
if (options.project.cpp) {
448442
await copyDir(CPP_FILES, folder);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<% if (project.moduleType === "view") { -%>
2+
import { requireNativeComponent, ViewStyle } from 'react-native';
3+
4+
type <%- project.name %>Props = {
5+
color: string;
6+
style: ViewStyle;
7+
};
8+
9+
export const <%- project.name %>ViewManager = requireNativeComponent<<%- project.name %>Props>(
10+
'<%- project.name %>View'
11+
);
12+
13+
export default <%- project.name %>ViewManager;
14+
<% } else { -%>
15+
import { NativeModules } from 'react-native';
16+
17+
type <%- project.name %>Type = {
18+
multiply(a: number, b: number): Promise<number>;
19+
};
20+
21+
const { <%- project.name %> } = NativeModules;
22+
23+
export default <%- project.name %> as <%- project.name %>Type;
24+
<% } -%>

packages/create-react-native-library/templates/native-library/src/index.tsx

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/create-react-native-library/templates/native-view-library/android/src/main/AndroidManifest.xml

Lines changed: 0 additions & 4 deletions
This file was deleted.

packages/create-react-native-library/templates/native-view-library/ios/{%- project.name %}.xcodeproj/project.pbxproj

Lines changed: 0 additions & 317 deletions
This file was deleted.

packages/create-react-native-library/templates/native-view-library/ios/{%- project.name %}.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)