Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/create-react-native-library/src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const NATIVE_COMMON_EXAMPLE_FILES = path.resolve(
__dirname,
'../templates/native-common-example'
);
const NITRO_COMMON_FILES = path.resolve(__dirname, '../templates/nitro-common');

const NATIVE_FILES = {
module_new: path.resolve(__dirname, '../templates/native-library-new'),
Expand Down Expand Up @@ -211,11 +212,13 @@ export async function applyTemplates(
}

if (config.project.moduleConfig === 'nitro-modules') {
await applyTemplate(config, NITRO_COMMON_FILES, folder);
await applyTemplate(config, NATIVE_FILES['module_nitro'], folder);
return;
}

if (config.project.viewConfig === 'nitro-view') {
await applyTemplate(config, NITRO_COMMON_FILES, folder);
await applyTemplate(config, NATIVE_FILES['view_nitro'], folder);
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require('path');
const { getDefaultConfig } = require('@react-native/metro-config');
const { getDefaultConfig } = require('<% if (example === 'expo') { -%>@expo/metro-config<% } else { -%>@react-native/metro-config<% } -%>');
const { withMetroConfig } = require('react-native-monorepo-config');

const root = path.resolve(__dirname, '..');
Expand All @@ -10,7 +10,9 @@ const root = path.resolve(__dirname, '..');
*
* @type {import('metro-config').MetroConfig}
*/
module.exports = withMetroConfig(getDefaultConfig(__dirname), {
const config = withMetroConfig(getDefaultConfig(__dirname), {
root,
dirname: __dirname,
});

module.exports = config;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,10 @@ package com.<%- project.package %>
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.module.annotations.ReactModule

@ReactModule(name = <%- project.name -%>Module.NAME)
class <%- project.name -%>Module(reactContext: ReactApplicationContext) :
Native<%- project.name -%>Spec(reactContext) {

override fun getName(): String {
return NAME
}

// Example method
// See https://reactnative.dev/docs/native-modules-android
override fun multiply(a: Double, b: Double): Double {
return a * b
}

companion object {
const val NAME = "<%- project.name -%>"
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package com.<%- project.package %>

import com.facebook.react.ReactPackage
import com.facebook.react.BaseReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.module.model.ReactModuleInfoProvider
import com.facebook.react.uimanager.ViewManager
import java.util.ArrayList

class <%- project.name -%>ViewPackage : ReactPackage {
class <%- project.name -%>ViewPackage : BaseReactPackage() {
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
val viewManagers: MutableList<ViewManager<*, *>> = ArrayList()
viewManagers.add(<%- project.name -%>ViewManager())
return viewManagers
return listOf(<%- project.name -%>ViewManager())
}

override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
return emptyList()
}
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? = null

override fun getReactModuleInfoProvider(): ReactModuleInfoProvider = ReactModuleInfoProvider { emptyMap() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,35 +111,18 @@ android {
}
}

lintOptions {
lint {
disable "GradleCompatible"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

sourceSets {
main {
java.srcDirs += [
"generated/java",
"generated/jni"
]
}
}
}

repositories {
mavenCentral()
google()
}

def kotlin_version = getExtOrDefault("kotlinVersion")

dependencies {
implementation "com.facebook.react:react-android"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
<% if (project.moduleConfig === 'nitro-modules' || project.viewConfig === 'nitro-view') { -%>
implementation project(":react-native-nitro-modules")
<% } -%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
},
"autolinking": {
"<%- project.name -%>": {
"swift": "Hybrid<%- project.name -%>",
"kotlin": "Hybrid<%- project.name -%>"
"swift": "<% if (project.viewConfig === 'nitro-view') { -%>Hybrid<% } -%><%- project.name -%>",
"kotlin": "<% if (project.viewConfig === 'nitro-view') { -%>Hybrid<% } -%><%- project.name -%>"
}
},
"ignorePaths": ["node_modules"]
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ - (instancetype)initWithFrame:(CGRect)frame

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &oldViewProps = *std::static_pointer_cast<<%- project.name -%>ViewProps const>(_props);
const auto &oldViewProps = *std::static_pointer_cast<<%- project.name -%>ViewProps const>(oldProps);
const auto &newViewProps = *std::static_pointer_cast<<%- project.name -%>ViewProps const>(props);

if (oldViewProps.color != newViewProps.color) {
Expand Down