Skip to content

Commit

Permalink
Combine native and native-view into native-common
Browse files Browse the repository at this point in the history
  • Loading branch information
friederbluemle committed Mar 3, 2021
1 parent f542741 commit e4ad75b
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 382 deletions.
16 changes: 5 additions & 11 deletions packages/create-react-native-library/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,10 @@ const JS_FILES = path.resolve(__dirname, '../templates/js-library');
const EXPO_FILES = path.resolve(__dirname, '../templates/expo-library');
const CPP_FILES = path.resolve(__dirname, '../templates/cpp-library');
const EXAMPLE_FILES = path.resolve(__dirname, '../templates/example');

// Common native library template files
const NATIVE_FILES = (moduleType: ModuleType) => {
switch (moduleType) {
case 'module':
return path.resolve(__dirname, '../templates/native-library');
case 'view':
return path.resolve(__dirname, '../templates/native-view-library');
}
};
const NATIVE_COMMON_FILES = path.resolve(
__dirname,
'../templates/native-common'
);

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

await copyDir(NATIVE_FILES(moduleType), folder);
await copyDir(NATIVE_COMMON_FILES, folder);

if (options.project.cpp) {
await copyDir(CPP_FILES, folder);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<% if (project.moduleType === "view") { -%>
import { requireNativeComponent, ViewStyle } from 'react-native';

type <%- project.name %>Props = {
color: string;
style: ViewStyle;
};

export const <%- project.name %>ViewManager = requireNativeComponent<<%- project.name %>Props>(
'<%- project.name %>View'
);

export default <%- project.name %>ViewManager;
<% } else { -%>
import { NativeModules } from 'react-native';

type <%- project.name %>Type = {
multiply(a: number, b: number): Promise<number>;
};

const { <%- project.name %> } = NativeModules;

export default <%- project.name %> as <%- project.name %>Type;
<% } -%>

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit e4ad75b

Please sign in to comment.