mirror of
https://github.com/zoriya/react-native-omni.git
synced 2026-08-13 09:29:00 +00:00
Init using create-nitro-module
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
</manifest>
|
||||
@@ -0,0 +1,9 @@
|
||||
#include <jni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include "OmniOnLoad.hpp"
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
|
||||
return facebook::jni::initialize(vm, []() {
|
||||
margelo::nitro::omni::registerAllNatives();
|
||||
});
|
||||
}
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
package com.omni
|
||||
|
||||
import android.graphics.Color
|
||||
import android.view.View
|
||||
import androidx.annotation.Keep
|
||||
import com.facebook.proguard.annotations.DoNotStrip
|
||||
import com.facebook.react.uimanager.ThemedReactContext
|
||||
import com.margelo.nitro.omni.HybridOmniSpec
|
||||
|
||||
@Keep
|
||||
@DoNotStrip
|
||||
class HybridOmni(val context: ThemedReactContext): HybridOmniSpec() {
|
||||
// View
|
||||
override val view: View = View(context)
|
||||
|
||||
// Props
|
||||
private var _isRed = false
|
||||
override var isRed: Boolean
|
||||
get() = _isRed
|
||||
set(value) {
|
||||
_isRed = value
|
||||
view.setBackgroundColor(
|
||||
if (value) Color.RED
|
||||
else Color.BLACK
|
||||
)
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.omni;
|
||||
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
||||
import com.facebook.react.BaseReactPackage;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
import com.margelo.nitro.omni.*;
|
||||
import com.margelo.nitro.omni.views.*;
|
||||
|
||||
|
||||
public class OmniPackage : BaseReactPackage() {
|
||||
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? = null
|
||||
|
||||
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider = ReactModuleInfoProvider { emptyMap() }
|
||||
|
||||
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
||||
val viewManagers = ArrayList<ViewManager<*, *>>()
|
||||
viewManagers.add(HybridOmniManager())
|
||||
return viewManagers
|
||||
}
|
||||
|
||||
companion object {
|
||||
init {
|
||||
OmniOnLoad.initializeNative()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user