-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d99d0e
commit d3cb474
Showing
26 changed files
with
1,154 additions
and
491 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module.exports = { | ||
arrowParens: 'avoid', | ||
bracketSameLine: true, | ||
bracketSpacing: false, | ||
jsxBracketSameLine: true, | ||
singleQuote: true, | ||
trailingComma: 'all', | ||
arrowParens: 'avoid', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.7.4 | ||
2.7.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
source 'https://rubygems.org' | ||
|
||
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version | ||
ruby '2.7.4' | ||
ruby '2.7.5' | ||
|
||
gem 'cocoapods', '~> 1.11', '>= 1.11.2' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
...c/main/java/app/esteem/mobile/android/newarchitecture/MainApplicationReactNativeHost.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package app.esteem.mobile.android.newarchitecture; | ||
|
||
import android.app.Application; | ||
import androidx.annotation.NonNull; | ||
import com.facebook.react.PackageList; | ||
import com.facebook.react.ReactInstanceManager; | ||
import com.facebook.react.ReactNativeHost; | ||
import com.facebook.react.ReactPackage; | ||
import com.facebook.react.ReactPackageTurboModuleManagerDelegate; | ||
import com.facebook.react.bridge.JSIModulePackage; | ||
import com.facebook.react.bridge.JSIModuleProvider; | ||
import com.facebook.react.bridge.JSIModuleSpec; | ||
import com.facebook.react.bridge.JSIModuleType; | ||
import com.facebook.react.bridge.JavaScriptContextHolder; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.bridge.UIManager; | ||
import com.facebook.react.fabric.ComponentFactory; | ||
import com.facebook.react.fabric.CoreComponentsRegistry; | ||
import com.facebook.react.fabric.FabricJSIModuleProvider; | ||
import com.facebook.react.fabric.ReactNativeConfig; | ||
import com.facebook.react.uimanager.ViewManagerRegistry; | ||
import app.esteem.mobile.android.BuildConfig; | ||
import app.esteem.mobile.android.newarchitecture.components.MainComponentsRegistry; | ||
import app.esteem.mobile.android.newarchitecture.modules.MainApplicationTurboModuleManagerDelegate; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* A {@link ReactNativeHost} that helps you load everything needed for the New Architecture, both | ||
* TurboModule delegates and the Fabric Renderer. | ||
* | ||
* <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the | ||
* `newArchEnabled` property). Is ignored otherwise. | ||
*/ | ||
public class MainApplicationReactNativeHost extends ReactNativeHost { | ||
public MainApplicationReactNativeHost(Application application) { | ||
super(application); | ||
} | ||
|
||
@Override | ||
public boolean getUseDeveloperSupport() { | ||
return BuildConfig.DEBUG; | ||
} | ||
|
||
@Override | ||
protected List<ReactPackage> getPackages() { | ||
List<ReactPackage> packages = new PackageList(this).getPackages(); | ||
// Packages that cannot be autolinked yet can be added manually here, for example: | ||
// packages.add(new MyReactNativePackage()); | ||
// TurboModules must also be loaded here providing a valid TurboReactPackage implementation: | ||
// packages.add(new TurboReactPackage() { ... }); | ||
// If you have custom Fabric Components, their ViewManagers should also be loaded here | ||
// inside a ReactPackage. | ||
return packages; | ||
} | ||
|
||
@Override | ||
protected String getJSMainModuleName() { | ||
return "index"; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
protected ReactPackageTurboModuleManagerDelegate.Builder | ||
getReactPackageTurboModuleManagerDelegateBuilder() { | ||
// Here we provide the ReactPackageTurboModuleManagerDelegate Builder. This is necessary | ||
// for the new architecture and to use TurboModules correctly. | ||
return new MainApplicationTurboModuleManagerDelegate.Builder(); | ||
} | ||
|
||
@Override | ||
protected JSIModulePackage getJSIModulePackage() { | ||
return new JSIModulePackage() { | ||
@Override | ||
public List<JSIModuleSpec> getJSIModules( | ||
final ReactApplicationContext reactApplicationContext, | ||
final JavaScriptContextHolder jsContext) { | ||
final List<JSIModuleSpec> specs = new ArrayList<>(); | ||
|
||
// Here we provide a new JSIModuleSpec that will be responsible of providing the | ||
// custom Fabric Components. | ||
specs.add( | ||
new JSIModuleSpec() { | ||
@Override | ||
public JSIModuleType getJSIModuleType() { | ||
return JSIModuleType.UIManager; | ||
} | ||
|
||
@Override | ||
public JSIModuleProvider<UIManager> getJSIModuleProvider() { | ||
final ComponentFactory componentFactory = new ComponentFactory(); | ||
CoreComponentsRegistry.register(componentFactory); | ||
|
||
// Here we register a Components Registry. | ||
// The one that is generated with the template contains no components | ||
// and just provides you the one from React Native core. | ||
MainComponentsRegistry.register(componentFactory); | ||
|
||
final ReactInstanceManager reactInstanceManager = getReactInstanceManager(); | ||
|
||
ViewManagerRegistry viewManagerRegistry = | ||
new ViewManagerRegistry( | ||
reactInstanceManager.getOrCreateViewManagers(reactApplicationContext)); | ||
|
||
return new FabricJSIModuleProvider( | ||
reactApplicationContext, | ||
componentFactory, | ||
ReactNativeConfig.DEFAULT_CONFIG, | ||
viewManagerRegistry); | ||
} | ||
}); | ||
return specs; | ||
} | ||
}; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...ain/java/app/esteem/mobile/android/newarchitecture/components/MainComponentsRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package app.esteem.mobile.android.newarchitecture.components; | ||
|
||
import com.facebook.jni.HybridData; | ||
import com.facebook.proguard.annotations.DoNotStrip; | ||
import com.facebook.react.fabric.ComponentFactory; | ||
import com.facebook.soloader.SoLoader; | ||
|
||
/** | ||
* Class responsible to load the custom Fabric Components. This class has native methods and needs a | ||
* corresponding C++ implementation/header file to work correctly (already placed inside the jni/ | ||
* folder for you). | ||
* | ||
* <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the | ||
* `newArchEnabled` property). Is ignored otherwise. | ||
*/ | ||
@DoNotStrip | ||
public class MainComponentsRegistry { | ||
static { | ||
SoLoader.loadLibrary("fabricjni"); | ||
} | ||
|
||
@DoNotStrip private final HybridData mHybridData; | ||
|
||
@DoNotStrip | ||
private native HybridData initHybrid(ComponentFactory componentFactory); | ||
|
||
@DoNotStrip | ||
private MainComponentsRegistry(ComponentFactory componentFactory) { | ||
mHybridData = initHybrid(componentFactory); | ||
} | ||
|
||
@DoNotStrip | ||
public static MainComponentsRegistry register(ComponentFactory componentFactory) { | ||
return new MainComponentsRegistry(componentFactory); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...eem/mobile/android/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package app.esteem.mobile.android.newarchitecture.modules; | ||
|
||
import com.facebook.jni.HybridData; | ||
import com.facebook.react.ReactPackage; | ||
import com.facebook.react.ReactPackageTurboModuleManagerDelegate; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.soloader.SoLoader; | ||
import java.util.List; | ||
|
||
/** | ||
* Class responsible to load the TurboModules. This class has native methods and needs a | ||
* corresponding C++ implementation/header file to work correctly (already placed inside the jni/ | ||
* folder for you). | ||
* | ||
* <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the | ||
* `newArchEnabled` property). Is ignored otherwise. | ||
*/ | ||
public class MainApplicationTurboModuleManagerDelegate | ||
extends ReactPackageTurboModuleManagerDelegate { | ||
|
||
private static volatile boolean sIsSoLibraryLoaded; | ||
|
||
protected MainApplicationTurboModuleManagerDelegate( | ||
ReactApplicationContext reactApplicationContext, List<ReactPackage> packages) { | ||
super(reactApplicationContext, packages); | ||
} | ||
|
||
protected native HybridData initHybrid(); | ||
|
||
native boolean canCreateTurboModule(String moduleName); | ||
|
||
public static class Builder extends ReactPackageTurboModuleManagerDelegate.Builder { | ||
protected MainApplicationTurboModuleManagerDelegate build( | ||
ReactApplicationContext context, List<ReactPackage> packages) { | ||
return new MainApplicationTurboModuleManagerDelegate(context, packages); | ||
} | ||
} | ||
|
||
@Override | ||
protected synchronized void maybeLoadOtherSoLibraries() { | ||
if (!sIsSoLibraryLoaded) { | ||
// If you change the name of your application .so file in the Android.mk file, | ||
// make sure you update the name here as well. | ||
SoLoader.loadLibrary("rndiffapp_appmodules"); | ||
sIsSoLibraryLoaded = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmake_minimum_required(VERSION 3.13) | ||
|
||
# Define the library name here. | ||
project(rndiffapp_appmodules) | ||
|
||
# This file includes all the necessary to let you build your application with the New Architecture. | ||
include(${REACT_ANDROID_DIR}/cmake-utils/ReactNative-application.cmake) |
32 changes: 32 additions & 0 deletions
32
android/app/src/main/jni/MainApplicationModuleProvider.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "MainApplicationModuleProvider.h" | ||
|
||
#include <rncli.h> | ||
#include <rncore.h> | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
std::shared_ptr<TurboModule> MainApplicationModuleProvider( | ||
const std::string &moduleName, | ||
const JavaTurboModule::InitParams ¶ms) { | ||
// Here you can provide your own module provider for TurboModules coming from | ||
// either your application or from external libraries. The approach to follow | ||
// is similar to the following (for a library called `samplelibrary`: | ||
// | ||
// auto module = samplelibrary_ModuleProvider(moduleName, params); | ||
// if (module != nullptr) { | ||
// return module; | ||
// } | ||
// return rncore_ModuleProvider(moduleName, params); | ||
|
||
// Module providers autolinked by RN CLI | ||
auto rncli_module = rncli_ModuleProvider(moduleName, params); | ||
if (rncli_module != nullptr) { | ||
return rncli_module; | ||
} | ||
|
||
return rncore_ModuleProvider(moduleName, params); | ||
} | ||
|
||
} // namespace react | ||
} // namespace facebook |
Oops, something went wrong.