Skip to content

Commit 6a56a0c

Browse files
committed
feat: migrate to new rn architecture
1 parent 227c1f4 commit 6a56a0c

File tree

15 files changed

+3020
-110
lines changed

15 files changed

+3020
-110
lines changed

example/.eslintrc.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native-community',
4+
parser: '@typescript-eslint/parser',
5+
plugins: ['@typescript-eslint'],
6+
overrides: [
7+
{
8+
files: ['*.ts', '*.tsx'],
9+
rules: {
10+
'@typescript-eslint/no-shadow': ['error'],
11+
'no-shadow': 'off',
12+
'no-undef': 'off',
13+
},
14+
},
15+
],
16+
};

example/Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ GEM
33
specs:
44
CFPropertyList (3.0.5)
55
rexml
6-
activesupport (6.1.5.1)
6+
activesupport (6.1.5)
77
concurrent-ruby (~> 1.0, >= 1.0.2)
88
i18n (>= 1.6, < 2)
99
minitest (>= 5.1)
@@ -97,4 +97,4 @@ RUBY VERSION
9797
ruby 2.7.4p191
9898

9999
BUNDLED WITH
100-
2.1.4
100+
2.2.27

example/android/app/build.gradle

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import org.apache.tools.ant.taskdefs.condition.Os
1616
* // the name of the generated asset file containing your JS bundle
1717
* bundleAssetName: "index.android.bundle",
1818
*
19-
* // the entry file for bundle generation
19+
* // the entry file for bundle generation. If none specified and
20+
* // "index.android.js" exists, it will be used. Otherwise "index.js" is
21+
* // default. Can be overridden with ENTRY_FILE environment variable.
2022
* entryFile: "index.android.js",
2123
*
2224
* // https://reactnative.dev/docs/performance#enable-the-ram-format
@@ -38,7 +40,7 @@ import org.apache.tools.ant.taskdefs.condition.Os
3840
* // bundleInBeta: true,
3941
*
4042
* // whether to disable dev mode in custom build variants (by default only disabled in release)
41-
* // for BlobCourierExample: to disable dev mode in the staging build type (if configured)
43+
* // for example: to disable dev mode in the staging build type (if configured)
4244
* devDisabledInStaging: true,
4345
* // The configuration property can be in the following formats
4446
* // 'devDisabledIn${productFlavor}${buildType}'
@@ -65,7 +67,7 @@ import org.apache.tools.ant.taskdefs.condition.Os
6567
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
6668
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
6769
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
68-
* // for BlobCourierExample, you might want to remove it from here.
70+
* // for example, you might want to remove it from here.
6971
* inputExcludes: ["android/**", "ios/**"],
7072
*
7173
* // override which node gets called and with what additional arguments
@@ -78,7 +80,6 @@ import org.apache.tools.ant.taskdefs.condition.Os
7880

7981
project.ext.react = [
8082
enableHermes: false, // clean and rebuild if changing
81-
bundleInRelease: true, // whether to bundle JS and assets in release mode
8283
]
8384

8485
apply from: "../../node_modules/react-native/react.gradle"
@@ -101,7 +102,7 @@ def enableProguardInReleaseBuilds = false
101102
/**
102103
* The preferred build flavor of JavaScriptCore.
103104
*
104-
* For BlobCourierExample, to use the international variant, you can use:
105+
* For example, to use the international variant, you can use:
105106
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
106107
*
107108
* The international variant includes ICU i18n library and necessary data
@@ -133,11 +134,6 @@ android {
133134

134135
compileSdkVersion rootProject.ext.compileSdkVersion
135136

136-
compileOptions {
137-
sourceCompatibility JavaVersion.VERSION_11
138-
targetCompatibility JavaVersion.VERSION_11
139-
}
140-
141137
defaultConfig {
142138
applicationId "io.deckers.blob_courier_example"
143139
minSdkVersion rootProject.ext.minSdkVersion
@@ -220,8 +216,8 @@ android {
220216
}
221217

222218
lintOptions {
223-
abortOnError true
224-
checkReleaseBuilds true
219+
abortOnError true
220+
checkReleaseBuilds true
225221
}
226222

227223
splits {
@@ -252,11 +248,13 @@ android {
252248
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
253249
}
254250
}
251+
255252
// applicationVariants are e.g. debug, release
256253
applicationVariants.all { variant ->
257254
variant.outputs.each { output ->
258255
// For each separate APK per architecture, set a unique version code as described here:
259256
// https://developer.android.com/studio/build/configure-apk-splits.html
257+
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
260258
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
261259
def abi = output.getFilter(OutputFile.ABI)
262260
if (abi != null) { // null for the universal-debug, universal-release variants
@@ -268,24 +266,23 @@ android {
268266
}
269267
}
270268

271-
dependencyLocking {
272-
lockAllConfigurations()
273-
}
274-
275269
dependencies {
276270
implementation fileTree(dir: "libs", include: ["*.jar"])
277271

278272
//noinspection GradleDynamicVersion
279273
implementation "com.facebook.react:react-native:+" // From node_modules
280274

281275
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
276+
282277
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
283-
exclude group:'com.facebook.fbjni'
278+
exclude group:'com.facebook.fbjni'
284279
}
280+
285281
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
286282
exclude group:'com.facebook.flipper'
287283
exclude group:'com.squareup.okhttp3', module:'okhttp'
288284
}
285+
289286
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
290287
exclude group:'com.facebook.flipper'
291288
}

example/android/app/src/main/java/io/deckers/blob_courier_example/MainApplication.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
import android.content.Context;
55
import com.facebook.react.PackageList;
66
import com.facebook.react.ReactApplication;
7+
import com.facebook.react.ReactInstanceManager;
78
import com.facebook.react.ReactNativeHost;
89
import com.facebook.react.ReactPackage;
910
import com.facebook.react.config.ReactFeatureFlags;
10-
import com.facebook.react.ReactInstanceManager;
1111
import com.facebook.soloader.SoLoader;
1212
import io.deckers.blob_courier_example.newarchitecture.MainApplicationReactNativeHost;
1313
import java.lang.reflect.InvocationTargetException;
1414
import java.util.List;
1515

16-
import io.deckers.blob_courier.BlobCourierPackage;
16+
// import io.deckers.blob_courier.BlobCourierPackage;
1717

1818
public class MainApplication extends Application implements ReactApplication {
1919

@@ -28,10 +28,9 @@ public boolean getUseDeveloperSupport() {
2828
protected List<ReactPackage> getPackages() {
2929
@SuppressWarnings("UnnecessaryLocalVariable")
3030
List<ReactPackage> packages = new PackageList(this).getPackages();
31-
// Packages that cannot be autolinked yet can be added manually here, for BlobCourierExample:
31+
// Packages that cannot be autolinked yet can be added manually here, for example:
3232
// packages.add(new MyReactNativePackage());
33-
packages.add(new BlobCourierPackage());
34-
33+
// packages.add(new BlobCourierPackage());
3534
return packages;
3635
}
3736

@@ -59,15 +58,18 @@ public void onCreate() {
5958
// If you opted-in for the New Architecture, we enable the TurboModule system
6059
ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
6160
SoLoader.init(this, /* native exopackage */ false);
62-
initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); // Remove this line if you don't want Flipper enabled
61+
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
6362
}
6463

6564
/**
66-
* Loads Flipper in React Native templates.
65+
* Loads Flipper in React Native templates. Call this in the onCreate method with something like
66+
* initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
6767
*
6868
* @param context
69+
* @param reactInstanceManager
6970
*/
70-
private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
71+
private static void initializeFlipper(
72+
Context context, ReactInstanceManager reactInstanceManager) {
7173
if (BuildConfig.DEBUG) {
7274
try {
7375
/*

example/android/app/src/main/java/io/deckers/blob_courier_example/newarchitecture/MainApplicationReactNativeHost.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
import com.facebook.react.fabric.EmptyReactNativeConfig;
2020
import com.facebook.react.fabric.FabricJSIModuleProvider;
2121
import com.facebook.react.uimanager.ViewManagerRegistry;
22-
import io.deckers.blob_courier.BuildConfig;
23-
import io.deckers.blob_courier.newarchitecture.components.MainComponentsRegistry;
24-
import io.deckers.blob_courier.newarchitecture.modules.MainApplicationTurboModuleManagerDelegate;
22+
import io.deckers.blob_courier_example.BuildConfig;
23+
import io.deckers.blob_courier_example.newarchitecture.components.MainComponentsRegistry;
24+
import io.deckers.blob_courier_example.newarchitecture.modules.MainApplicationTurboModuleManagerDelegate;
2525
import java.util.ArrayList;
2626
import java.util.List;
2727

example/android/app/src/main/java/io/deckers/blob_courier_example/newarchitecture/components/MainComponentsRegistry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.deckers.blob_courier.newarchitecture.components;
1+
package io.deckers.blob_courier_example.newarchitecture.components;
22

33
import com.facebook.jni.HybridData;
44
import com.facebook.proguard.annotations.DoNotStrip;

example/android/app/src/main/java/io/deckers/blob_courier_example/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.deckers.blob_courier.newarchitecture.modules;
1+
package io.deckers.blob_courier_example.newarchitecture.modules;
22

33
import com.facebook.jni.HybridData;
44
import com.facebook.react.ReactPackage;

example/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class MainApplicationTurboModuleManagerDelegate
1414
public:
1515
// Adapt it to the package you used for your Java class.
1616
static constexpr auto kJavaDescriptor =
17-
"Lcom/blob_courier_example/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate;";
17+
"Lio/deckers/blob_courier_example/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate;";
1818

1919
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject>);
2020

example/android/app/src/main/jni/MainComponentsRegistry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class MainComponentsRegistry
1313
public:
1414
// Adapt it to the package you used for your Java class.
1515
constexpr static auto kJavaDescriptor =
16-
"Lcom/blob_courier_example/newarchitecture/components/MainComponentsRegistry;";
16+
"Lio/deckers/blob_courier_example/newarchitecture/components/MainComponentsRegistry;";
1717

1818
static void registerNatives();
1919

example/android/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ buildscript {
2929
classpath("com.android.tools.build:gradle:7.0.4")
3030
classpath("com.facebook.react:react-native-gradle-plugin")
3131
classpath("de.undercouch:gradle-download-task:4.1.2")
32-
3332
// NOTE: Do not place your application dependencies here; they belong
3433
// in the individual module build.gradle files
3534
}

0 commit comments

Comments
 (0)