react-native-unistyles 3.0.0-alpha.35 → 3.0.0-alpha.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/CMakeLists.txt +31 -36
- package/android/build.gradle +2 -1
- package/android/src/main/cxx/NativeUnistylesModule.cpp +71 -0
- package/android/src/main/cxx/NativeUnistylesModule.h +42 -0
- package/android/src/main/cxx/cpp-adapter.cpp +8 -86
- package/android/src/main/java/com/unistyles/NativePlatform.kt +184 -0
- package/android/src/main/java/com/unistyles/UnistylesModule+insets.kt +8 -0
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +47 -0
- package/android/src/main/java/com/unistyles/UnistylesPackage.kt +16 -14
- package/cxx/NativePlatform.h +11 -0
- package/cxx/common/Helpers.h +1 -1
- package/cxx/core/Unistyle.h +1 -1
- package/cxx/core/UnistylesRegistry.h +1 -1
- package/cxx/hybridObjects/HybridNavigationBar.h +3 -3
- package/cxx/hybridObjects/HybridStatusBar.h +3 -3
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +4 -4
- package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -2
- package/lib/commonjs/components/useMedia.js.map +1 -1
- package/lib/commonjs/components/useMedia.web.js +43 -0
- package/lib/commonjs/components/useMedia.web.js.map +1 -0
- package/lib/commonjs/core/createUnistylesComponent.js +57 -4
- package/lib/commonjs/core/createUnistylesComponent.js.map +1 -1
- package/lib/commonjs/core/createUnistylesComponent.native.js +6 -5
- package/lib/commonjs/core/createUnistylesComponent.native.js.map +1 -1
- package/lib/commonjs/web/convert/index.js +16 -11
- package/lib/commonjs/web/convert/index.js.map +1 -1
- package/lib/commonjs/web/convert/object/boxShadow.js +58 -0
- package/lib/commonjs/web/convert/object/boxShadow.js.map +1 -0
- package/lib/commonjs/web/convert/object/filter.js +42 -0
- package/lib/commonjs/web/convert/object/filter.js.map +1 -0
- package/lib/commonjs/web/convert/object/index.js +39 -0
- package/lib/commonjs/web/convert/object/index.js.map +1 -0
- package/lib/commonjs/web/convert/object/objectStyle.js +55 -0
- package/lib/commonjs/web/convert/object/objectStyle.js.map +1 -0
- package/lib/commonjs/web/convert/object/transform.js +27 -0
- package/lib/commonjs/web/convert/object/transform.js.map +1 -0
- package/lib/commonjs/web/convert/{boxShadow.js → shadow/boxShadow.js} +9 -24
- package/lib/commonjs/web/convert/shadow/boxShadow.js.map +1 -0
- package/lib/commonjs/web/convert/shadow/getShadowBreakpoints.js +38 -0
- package/lib/commonjs/web/convert/shadow/getShadowBreakpoints.js.map +1 -0
- package/lib/commonjs/web/convert/shadow/index.js +28 -0
- package/lib/commonjs/web/convert/shadow/index.js.map +1 -0
- package/lib/commonjs/web/convert/{textShadow.js → shadow/textShadow.js} +9 -23
- package/lib/commonjs/web/convert/shadow/textShadow.js.map +1 -0
- package/lib/commonjs/web/convert/utils.js +7 -3
- package/lib/commonjs/web/convert/utils.js.map +1 -1
- package/lib/commonjs/web/listener.js +10 -0
- package/lib/commonjs/web/listener.js.map +1 -1
- package/lib/commonjs/web/registry.js +13 -26
- package/lib/commonjs/web/registry.js.map +1 -1
- package/lib/commonjs/web/runtime.js +3 -0
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js +79 -39
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/commonjs/web/utils/common.js +3 -33
- package/lib/commonjs/web/utils/common.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js +4 -1
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/module/components/useMedia.js.map +1 -1
- package/lib/module/components/useMedia.web.js +38 -0
- package/lib/module/components/useMedia.web.js.map +1 -0
- package/lib/module/core/createUnistylesComponent.js +55 -3
- package/lib/module/core/createUnistylesComponent.js.map +1 -1
- package/lib/module/core/createUnistylesComponent.native.js +6 -5
- package/lib/module/core/createUnistylesComponent.native.js.map +1 -1
- package/lib/module/web/convert/index.js +14 -9
- package/lib/module/web/convert/index.js.map +1 -1
- package/lib/module/web/convert/object/boxShadow.js +53 -0
- package/lib/module/web/convert/object/boxShadow.js.map +1 -0
- package/lib/module/web/convert/object/filter.js +37 -0
- package/lib/module/web/convert/object/filter.js.map +1 -0
- package/lib/module/web/convert/object/index.js +6 -0
- package/lib/module/web/convert/object/index.js.map +1 -0
- package/lib/module/web/convert/object/objectStyle.js +50 -0
- package/lib/module/web/convert/object/objectStyle.js.map +1 -0
- package/lib/module/web/convert/object/transform.js +22 -0
- package/lib/module/web/convert/object/transform.js.map +1 -0
- package/lib/module/web/convert/{boxShadow.js → shadow/boxShadow.js} +9 -24
- package/lib/module/web/convert/shadow/boxShadow.js.map +1 -0
- package/lib/module/web/convert/shadow/getShadowBreakpoints.js +33 -0
- package/lib/module/web/convert/shadow/getShadowBreakpoints.js.map +1 -0
- package/lib/module/web/convert/shadow/index.js +5 -0
- package/lib/module/web/convert/shadow/index.js.map +1 -0
- package/lib/module/web/convert/{textShadow.js → shadow/textShadow.js} +9 -23
- package/lib/module/web/convert/shadow/textShadow.js.map +1 -0
- package/lib/module/web/convert/utils.js +4 -2
- package/lib/module/web/convert/utils.js.map +1 -1
- package/lib/module/web/listener.js +10 -0
- package/lib/module/web/listener.js.map +1 -1
- package/lib/module/web/registry.js +14 -27
- package/lib/module/web/registry.js.map +1 -1
- package/lib/module/web/runtime.js +3 -0
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/shadowRegistry.js +80 -40
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/module/web/utils/common.js +1 -31
- package/lib/module/web/utils/common.js.map +1 -1
- package/lib/module/web/utils/unistyle.js +4 -1
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/typescript/src/components/useMedia.web.d.ts +6 -0
- package/lib/typescript/src/components/useMedia.web.d.ts.map +1 -0
- package/lib/typescript/src/core/createUnistylesComponent.d.ts +4 -3
- package/lib/typescript/src/core/createUnistylesComponent.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesComponent.native.d.ts +4 -3
- package/lib/typescript/src/core/createUnistylesComponent.native.d.ts.map +1 -1
- package/lib/typescript/src/types/common.d.ts +1 -0
- package/lib/typescript/src/types/common.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/boxShadow.d.ts +9 -0
- package/lib/typescript/src/web/convert/object/boxShadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/object/filter.d.ts +3 -0
- package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/object/index.d.ts +4 -0
- package/lib/typescript/src/web/convert/object/index.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/object/objectStyle.d.ts +5 -0
- package/lib/typescript/src/web/convert/object/objectStyle.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/object/transform.d.ts +3 -0
- package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/shadow/boxShadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts +2 -0
- package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/shadow/index.d.ts +3 -0
- package/lib/typescript/src/web/convert/shadow/index.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/shadow/textShadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/types.d.ts +7 -1
- package/lib/typescript/src/web/convert/types.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/utils.d.ts +8 -4
- package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/create.d.ts +8 -8
- package/lib/typescript/src/web/index.d.ts +8 -8
- package/lib/typescript/src/web/listener.d.ts +2 -0
- package/lib/typescript/src/web/listener.d.ts.map +1 -1
- package/lib/typescript/src/web/registry.d.ts +5 -9
- package/lib/typescript/src/web/registry.d.ts.map +1 -1
- package/lib/typescript/src/web/runtime.d.ts +1 -0
- package/lib/typescript/src/web/runtime.d.ts.map +1 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts +4 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/common.d.ts +1 -6
- package/lib/typescript/src/web/utils/common.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +6 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Dimensions.kt +1 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void.kt +1 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_std__vector_UnistyleDependency_.kt +1 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Insets.kt +1 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistylesNativeMiniRuntime.kt +1 -0
- package/nitrogen/generated/android/unistyles+autolinking.gradle +2 -0
- package/nitrogen/generated/ios/Unistyles+autolinking.rb +1 -1
- package/package.json +3 -3
- package/src/components/useMedia.ts +1 -1
- package/src/components/useMedia.web.ts +47 -0
- package/src/core/createUnistylesComponent.native.tsx +12 -10
- package/src/core/createUnistylesComponent.tsx +72 -6
- package/src/types/common.ts +1 -0
- package/src/web/convert/index.ts +16 -9
- package/src/web/convert/object/boxShadow.ts +54 -0
- package/src/web/convert/object/filter.ts +39 -0
- package/src/web/convert/object/index.ts +3 -0
- package/src/web/convert/object/objectStyle.ts +68 -0
- package/src/web/convert/object/transform.ts +24 -0
- package/src/web/convert/{boxShadow.ts → shadow/boxShadow.ts} +9 -30
- package/src/web/convert/shadow/getShadowBreakpoints.ts +34 -0
- package/src/web/convert/shadow/index.ts +2 -0
- package/src/web/convert/{textShadow.ts → shadow/textShadow.ts} +9 -29
- package/src/web/convert/types.ts +8 -1
- package/src/web/convert/utils.ts +11 -5
- package/src/web/listener.ts +10 -0
- package/src/web/registry.ts +10 -31
- package/src/web/runtime.ts +4 -0
- package/src/web/shadowRegistry.ts +85 -46
- package/src/web/utils/common.ts +1 -37
- package/src/web/utils/unistyle.ts +5 -1
- package/android/src/main/cxx/helpers.cpp +0 -105
- package/android/src/main/cxx/helpers.h +0 -16
- package/android/src/main/cxx/platform.cpp +0 -170
- package/android/src/main/cxx/platform.h +0 -20
- package/lib/commonjs/web/convert/boxShadow.js.map +0 -1
- package/lib/commonjs/web/convert/shadow.js +0 -68
- package/lib/commonjs/web/convert/shadow.js.map +0 -1
- package/lib/commonjs/web/convert/textShadow.js.map +0 -1
- package/lib/commonjs/web/convert/transform.js +0 -72
- package/lib/commonjs/web/convert/transform.js.map +0 -1
- package/lib/module/web/convert/boxShadow.js.map +0 -1
- package/lib/module/web/convert/shadow.js +0 -63
- package/lib/module/web/convert/shadow.js.map +0 -1
- package/lib/module/web/convert/textShadow.js.map +0 -1
- package/lib/module/web/convert/transform.js +0 -67
- package/lib/module/web/convert/transform.js.map +0 -1
- package/lib/typescript/src/web/convert/boxShadow.d.ts.map +0 -1
- package/lib/typescript/src/web/convert/shadow.d.ts +0 -2
- package/lib/typescript/src/web/convert/shadow.d.ts.map +0 -1
- package/lib/typescript/src/web/convert/textShadow.d.ts.map +0 -1
- package/lib/typescript/src/web/convert/transform.d.ts +0 -4
- package/lib/typescript/src/web/convert/transform.d.ts.map +0 -1
- package/src/web/convert/shadow.ts +0 -68
- package/src/web/convert/transform.ts +0 -88
- /package/lib/typescript/src/web/convert/{boxShadow.d.ts → shadow/boxShadow.d.ts} +0 -0
- /package/lib/typescript/src/web/convert/{textShadow.d.ts → shadow/textShadow.d.ts} +0 -0
package/android/CMakeLists.txt
CHANGED
|
@@ -2,28 +2,28 @@ cmake_minimum_required(VERSION 3.9.0)
|
|
|
2
2
|
|
|
3
3
|
project(unistyles)
|
|
4
4
|
|
|
5
|
+
file(GLOB_RECURSE CORE_SRC RELATIVE ${CMAKE_SOURCE_DIR} "../cxx/**/*.cpp")
|
|
6
|
+
file(GLOB_RECURSE PLATFORM_SRC RELATIVE ${CMAKE_SOURCE_DIR} "./src/main/cxx/*.cpp")
|
|
7
|
+
|
|
5
8
|
add_library(unistyles
|
|
6
9
|
SHARED
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
../cxx/HybridStatusBar.cpp
|
|
10
|
-
../cxx/HybridNavigationBar.cpp
|
|
11
|
-
../cxx/ShadowTreeTraverser.cpp
|
|
12
|
-
../cxx/StyleSheet.cpp
|
|
13
|
-
../cxx/StyleSheetImpl.cpp
|
|
14
|
-
../cxx/StyleSheetRegistry.cpp
|
|
15
|
-
../cxx/UnistylesImpl.cpp
|
|
16
|
-
../cxx/UnistylesModel.cpp
|
|
17
|
-
../cxx/UnistylesRuntime.cpp
|
|
18
|
-
./src/main/cxx/cpp-adapter.cpp
|
|
19
|
-
./src/main/cxx/helpers.cpp
|
|
20
|
-
./src/main/cxx/platform.cpp
|
|
10
|
+
${CORE_SRC}
|
|
11
|
+
${PLATFORM_SRC}
|
|
21
12
|
)
|
|
22
13
|
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
include("${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/unistyles+autolinking.cmake")
|
|
15
|
+
|
|
16
|
+
include_directories(
|
|
17
|
+
./src/main/cxx
|
|
18
|
+
../cxx
|
|
19
|
+
../cxx/common
|
|
20
|
+
../cxx/core
|
|
21
|
+
../cxx/hybridObjects
|
|
22
|
+
../cxx/parser
|
|
23
|
+
../cxx/shadowTree
|
|
24
|
+
)
|
|
25
25
|
|
|
26
|
-
string(APPEND CMAKE_CXX_FLAGS "
|
|
26
|
+
string(APPEND CMAKE_CXX_FLAGS "-DFOLLY_NO_CONFIG")
|
|
27
27
|
|
|
28
28
|
set_target_properties(unistyles PROPERTIES
|
|
29
29
|
CXX_STANDARD 20
|
|
@@ -32,22 +32,17 @@ set_target_properties(unistyles PROPERTIES
|
|
|
32
32
|
POSITION_INDEPENDENT_CODE ON
|
|
33
33
|
)
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
find_package(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
|
40
|
-
|
|
41
|
-
else()
|
|
42
|
-
target_link_libraries(unistyles
|
|
43
|
-
ReactAndroid::turbomodulejsijni
|
|
44
|
-
ReactAndroid::react_nativemodule_core
|
|
45
|
-
|
|
46
|
-
fbjni::fbjni
|
|
47
|
-
)
|
|
48
|
-
endif()
|
|
49
|
-
|
|
50
|
-
target_link_libraries(unistyles
|
|
51
|
-
ReactAndroid::jsi
|
|
52
|
-
fbjni::fbjni
|
|
53
|
-
)
|
|
35
|
+
# todo included by nitrogen
|
|
36
|
+
# find_package(ReactAndroid REQUIRED CONFIG)
|
|
37
|
+
# find_package(fbjni REQUIRED CONFIG)
|
|
38
|
+
|
|
39
|
+
#if (ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
|
40
|
+
# target_link_libraries(unistyles ReactAndroid::reactnative)
|
|
41
|
+
#else()
|
|
42
|
+
# target_link_libraries(unistyles
|
|
43
|
+
# ReactAndroid::turbomodulejsijni
|
|
44
|
+
# ReactAndroid::react_nativemodule_core
|
|
45
|
+
# android
|
|
46
|
+
# fbjni::fbjni
|
|
47
|
+
# )
|
|
48
|
+
#endif()
|
package/android/build.gradle
CHANGED
|
@@ -14,7 +14,7 @@ buildscript {
|
|
|
14
14
|
|
|
15
15
|
apply plugin: 'com.android.library'
|
|
16
16
|
apply plugin: 'org.jetbrains.kotlin.android'
|
|
17
|
-
apply from: '../nitrogen/generated/android/
|
|
17
|
+
apply from: '../nitrogen/generated/android/unistyles+autolinking.gradle'
|
|
18
18
|
|
|
19
19
|
def resolveBuildType() {
|
|
20
20
|
Gradle gradle = getGradle()
|
|
@@ -62,6 +62,7 @@ android {
|
|
|
62
62
|
"META-INF/**",
|
|
63
63
|
"**/libjsi.so",
|
|
64
64
|
"**/libc++_shared.so",
|
|
65
|
+
"**/libreactnative.so",
|
|
65
66
|
"**/libreact_nativemodule_core.so",
|
|
66
67
|
"**/libturbomodulejsijni.so",
|
|
67
68
|
"**/libfbjni.so"
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#include "NativeUnistylesModule.h"
|
|
2
|
+
#import <NitroModules/HybridObjectRegistry.hpp>
|
|
3
|
+
#import "HybridUnistylesRuntime.h"
|
|
4
|
+
#import "HybridStyleSheet.h"
|
|
5
|
+
#import "HybridShadowRegistry.h"
|
|
6
|
+
|
|
7
|
+
using namespace margelo::nitro::unistyles;
|
|
8
|
+
using namespace facebook::react;
|
|
9
|
+
|
|
10
|
+
UnistylesModule::UnistylesModule(
|
|
11
|
+
jni::alias_ref<UnistylesModule::jhybridobject> jThis,
|
|
12
|
+
jni::alias_ref<react::JRuntimeExecutor::javaobject> runtimeExecutorHolder,
|
|
13
|
+
jni::alias_ref<JFabricUIManager::javaobject> fabricUIManager,
|
|
14
|
+
jni::alias_ref<JHybridNativePlatformSpec::javaobject> nativePlatform
|
|
15
|
+
): _runtimeExecutor(runtimeExecutorHolder->cthis()->get()),
|
|
16
|
+
_uiManager(fabricUIManager->getBinding()->getScheduler()->getUIManager()),
|
|
17
|
+
_nativePlatform(nativePlatform->cthis()) {}
|
|
18
|
+
|
|
19
|
+
jni::local_ref<UnistylesModule::jhybriddata> UnistylesModule::initHybrid(
|
|
20
|
+
jni::alias_ref<UnistylesModule::jhybridobject> jThis,
|
|
21
|
+
jni::alias_ref<JRuntimeExecutor::javaobject> runtimeExecutorHolder,
|
|
22
|
+
jni::alias_ref<JFabricUIManager::javaobject> fabricUIManager,
|
|
23
|
+
jni::alias_ref<JHybridNativePlatformSpec::javaobject> nativePlatform
|
|
24
|
+
) {
|
|
25
|
+
return makeCxxInstance(jThis, runtimeExecutorHolder, fabricUIManager, nativePlatform);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
void UnistylesModule::registerNatives() {
|
|
29
|
+
javaClassStatic()->registerNatives({
|
|
30
|
+
makeNativeMethod("getBindingsInstaller", UnistylesModule::getBindingsInstaller),
|
|
31
|
+
makeNativeMethod("initHybrid", UnistylesModule::initHybrid)
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
jni::local_ref<BindingsInstallerHolder::javaobject> UnistylesModule::getBindingsInstaller(jni::alias_ref<UnistylesModule::javaobject> jobj) {
|
|
36
|
+
auto& runtimeExecutor = jobj->cthis()->_runtimeExecutor;
|
|
37
|
+
auto& uiManager = jobj->cthis()->_uiManager;
|
|
38
|
+
auto& nativePlatform = *jobj->cthis()->_nativePlatform;
|
|
39
|
+
|
|
40
|
+
return BindingsInstallerHolder::newObjectCxxArgs([&runtimeExecutor, uiManager, nativePlatform](jsi::Runtime& rt) {
|
|
41
|
+
// function is called on: first init and every live reload
|
|
42
|
+
// check if this is live reload, if so let's replace UnistylesRuntime with new runtime
|
|
43
|
+
auto hasUnistylesRuntime = HybridObjectRegistry::hasHybridObject("UnistylesRuntime");
|
|
44
|
+
|
|
45
|
+
if (hasUnistylesRuntime) {
|
|
46
|
+
HybridObjectRegistry::unregisterHybridObjectConstructor("UnistylesRuntime");
|
|
47
|
+
HybridObjectRegistry::unregisterHybridObjectConstructor("UnistylesStyleSheet");
|
|
48
|
+
HybridObjectRegistry::unregisterHybridObjectConstructor("UnistylesShadowRegistry");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
auto runOnJSThread = [&runtimeExecutor](std::function<void(jsi::Runtime&)>&& callback) {
|
|
52
|
+
runtimeExecutor([&](jsi::Runtime &rt) {
|
|
53
|
+
callback(rt);
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// init hybrids
|
|
58
|
+
auto unistylesRuntime = std::make_shared<HybridUnistylesRuntime>(nativePlatform, rt, runOnJSThread);
|
|
59
|
+
auto styleSheet = std::make_shared<HybridStyleSheet>(unistylesRuntime, uiManager);
|
|
60
|
+
|
|
61
|
+
HybridObjectRegistry::registerHybridObjectConstructor("UnistylesRuntime", [unistylesRuntime]() -> std::shared_ptr<HybridObject>{
|
|
62
|
+
return unistylesRuntime;
|
|
63
|
+
});
|
|
64
|
+
HybridObjectRegistry::registerHybridObjectConstructor("UnistylesStyleSheet", [styleSheet]() -> std::shared_ptr<HybridObject>{
|
|
65
|
+
return styleSheet;
|
|
66
|
+
});
|
|
67
|
+
HybridObjectRegistry::registerHybridObjectConstructor("UnistylesShadowRegistry", []() -> std::shared_ptr<HybridObject>{
|
|
68
|
+
return std::make_shared<HybridShadowRegistry>();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <ReactCommon/BindingsInstallerHolder.h>
|
|
4
|
+
#include <react/fabric/JFabricUIManager.h>
|
|
5
|
+
#include <react/jni/JRuntimeExecutor.h>
|
|
6
|
+
#include <react/renderer/scheduler/Scheduler.h>
|
|
7
|
+
#include <fbjni/fbjni.h>
|
|
8
|
+
#include <react/fabric/Binding.h>
|
|
9
|
+
#include "NativePlatform.h"
|
|
10
|
+
|
|
11
|
+
namespace margelo::nitro::unistyles {
|
|
12
|
+
|
|
13
|
+
using namespace facebook;
|
|
14
|
+
using namespace facebook::react;
|
|
15
|
+
|
|
16
|
+
struct UnistylesModule : public jni::HybridClass<UnistylesModule> {
|
|
17
|
+
static constexpr auto kJavaDescriptor = "Lcom/unistyles/UnistylesModule;";
|
|
18
|
+
|
|
19
|
+
explicit UnistylesModule(
|
|
20
|
+
jni::alias_ref<jhybridobject> jThis,
|
|
21
|
+
jni::alias_ref<react::JRuntimeExecutor::javaobject> runtimeExecutorHolder,
|
|
22
|
+
jni::alias_ref<JFabricUIManager::javaobject> fabricUIManager,
|
|
23
|
+
jni::alias_ref<JHybridNativePlatformSpec::javaobject> nativePlatform
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
static void registerNatives();
|
|
27
|
+
static jni::local_ref<jhybriddata> initHybrid(
|
|
28
|
+
jni::alias_ref<jhybridobject> jThis,
|
|
29
|
+
jni::alias_ref<JRuntimeExecutor::javaobject> runtimeExecutorHolder,
|
|
30
|
+
jni::alias_ref<JFabricUIManager::javaobject>,
|
|
31
|
+
jni::alias_ref<JHybridNativePlatformSpec::javaobject> nativePlatform
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
static jni::local_ref<BindingsInstallerHolder::javaobject> getBindingsInstaller(jni::alias_ref<UnistylesModule::javaobject> jThis);
|
|
35
|
+
|
|
36
|
+
private:
|
|
37
|
+
std::shared_ptr<UIManager> _uiManager;
|
|
38
|
+
RuntimeExecutor _runtimeExecutor;
|
|
39
|
+
Unistyles::HybridNativePlatformSpecCxx* _nativePlatform;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
}
|
|
@@ -1,88 +1,10 @@
|
|
|
1
|
-
#include <
|
|
2
|
-
|
|
3
|
-
#include
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
HybridObjectRegistry::registerHybridObjectConstructor("UnistylesRuntime", []() -> std::shared_ptr<HybridObject>{
|
|
10
|
-
return std::make_shared<HybridUnistylesRuntime>();
|
|
11
|
-
});
|
|
12
|
-
HybridObjectRegistry::registerHybridObjectConstructor("StatusBar", []() -> std::shared_ptr<HybridObject>{
|
|
13
|
-
return std::make_shared<HybridStatusBar>();
|
|
1
|
+
#include <fbjni/fbjni.h>
|
|
2
|
+
#include "unistylesOnLoad.hpp"
|
|
3
|
+
#include "NativeUnistylesModule.h"
|
|
4
|
+
|
|
5
|
+
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
|
|
6
|
+
return facebook::jni::initialize(vm, [=] {
|
|
7
|
+
margelo::nitro::unistyles::UnistylesModule::registerNatives();
|
|
8
|
+
margelo::nitro::unistyles::initialize(vm);
|
|
14
9
|
});
|
|
15
|
-
HybridObjectRegistry::registerHybridObjectConstructor("NavigationBar", []() -> std::shared_ptr<HybridObject>{
|
|
16
|
-
return std::make_shared<HybridNavigationBar>();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
return JNI_VERSION_1_2;
|
|
20
10
|
}
|
|
21
|
-
|
|
22
|
-
//using namespace facebook;
|
|
23
|
-
//
|
|
24
|
-
//static jobject unistylesModule = nullptr;
|
|
25
|
-
//std::shared_ptr<UnistylesRuntime> unistylesRuntime = nullptr;
|
|
26
|
-
//
|
|
27
|
-
//extern "C"
|
|
28
|
-
//JNIEXPORT void JNICALL
|
|
29
|
-
//Java_com_unistyles_UnistylesModule_nativeInstall(JNIEnv *env, jobject thiz, jlong jsi, jobject callInvokerHolder) {
|
|
30
|
-
// auto runtime = reinterpret_cast<jsi::Runtime *>(jsi);
|
|
31
|
-
// auto callInvoker{
|
|
32
|
-
// jni::alias_ref<react::CallInvokerHolder::javaobject>{ reinterpret_cast<react::CallInvokerHolder::javaobject>(callInvokerHolder)} -> cthis() ->getCallInvoker()
|
|
33
|
-
// };
|
|
34
|
-
//
|
|
35
|
-
// if (unistylesModule == nullptr) {
|
|
36
|
-
// unistylesModule = env->NewGlobalRef(thiz);
|
|
37
|
-
// }
|
|
38
|
-
//
|
|
39
|
-
// if (unistylesModule == nullptr) {
|
|
40
|
-
// return throwKotlinException(env, "Something went wrong while initializing UnistylesModule");
|
|
41
|
-
// }
|
|
42
|
-
//
|
|
43
|
-
// unistylesRuntime = std::make_shared<UnistylesRuntime>(*runtime, callInvoker);
|
|
44
|
-
// auto styleSheet = std::make_shared<StyleSheet>(*runtime, unistylesRuntime);
|
|
45
|
-
//
|
|
46
|
-
// makeShared(env, unistylesModule, unistylesRuntime);
|
|
47
|
-
//
|
|
48
|
-
// jsi::Object hostObject = jsi::Object::createFromHostObject(*runtime, unistylesRuntime);
|
|
49
|
-
// jsi::Object styleSheetHostObject = jsi::Object::createFromHostObject(*runtime, styleSheet);
|
|
50
|
-
// runtime->global().setProperty(*runtime, "__UNISTYLES__", std::move(hostObject));
|
|
51
|
-
// runtime->global().setProperty(*runtime, "__UNISTYLES__STYLESHEET__", std::move(styleSheetHostObject));
|
|
52
|
-
//}
|
|
53
|
-
//
|
|
54
|
-
//extern "C"
|
|
55
|
-
//JNIEXPORT void JNICALL
|
|
56
|
-
//Java_com_unistyles_UnistylesModule_nativeDestroy(JNIEnv *env, jobject thiz) {
|
|
57
|
-
// unistylesRuntime.reset();
|
|
58
|
-
// unistylesModule = nullptr;
|
|
59
|
-
//}
|
|
60
|
-
//
|
|
61
|
-
//extern "C"
|
|
62
|
-
//JNIEXPORT void JNICALL
|
|
63
|
-
//Java_com_unistyles_UnistylesModule_nativeOnOrientationChange(JNIEnv *env, jobject thiz, jobject screen, jobject insets, jobject statusBar, jobject navigationBar) {
|
|
64
|
-
// if (unistylesRuntime != nullptr) {
|
|
65
|
-
// Screen screenDimensions = jobjectToScreen(env, screen);
|
|
66
|
-
// Dimensions statusBarDimensions = jobjectToDimensions(env, statusBar);
|
|
67
|
-
// Insets screenInsets = jobjectToInsets(env, insets);
|
|
68
|
-
// Dimensions navigationBarDimensions = jobjectToDimensions(env, navigationBar);
|
|
69
|
-
//
|
|
70
|
-
// unistylesRuntime->handleScreenSizeChange(screenDimensions, screenInsets, statusBarDimensions, navigationBarDimensions);
|
|
71
|
-
// }
|
|
72
|
-
//}
|
|
73
|
-
//
|
|
74
|
-
//extern "C"
|
|
75
|
-
//JNIEXPORT void JNICALL
|
|
76
|
-
//Java_com_unistyles_UnistylesModule_nativeOnAppearanceChange(JNIEnv *env, jobject thiz, jstring colorScheme) {
|
|
77
|
-
// if (unistylesRuntime != nullptr) {
|
|
78
|
-
// unistylesRuntime->handleAppearanceChange(env->GetStringUTFChars(colorScheme, nullptr));
|
|
79
|
-
// }
|
|
80
|
-
//}
|
|
81
|
-
//
|
|
82
|
-
//extern "C"
|
|
83
|
-
//JNIEXPORT void JNICALL
|
|
84
|
-
//Java_com_unistyles_UnistylesModule_nativeOnContentSizeCategoryChange(JNIEnv *env, jobject thiz, jstring contentSizeCategory) {
|
|
85
|
-
// if (unistylesRuntime != nullptr) {
|
|
86
|
-
// unistylesRuntime->handleContentSizeCategoryChange(env->GetStringUTFChars(contentSizeCategory, nullptr));
|
|
87
|
-
// }
|
|
88
|
-
//}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
package com.unistyles
|
|
2
|
+
|
|
3
|
+
import UnistylesModuleInsets
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import android.content.res.Configuration
|
|
6
|
+
import android.os.Build
|
|
7
|
+
import android.util.DisplayMetrics
|
|
8
|
+
import android.view.WindowManager
|
|
9
|
+
import androidx.core.text.TextUtilsCompat
|
|
10
|
+
import androidx.core.view.ViewCompat
|
|
11
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
12
|
+
import com.margelo.nitro.unistyles.ColorScheme
|
|
13
|
+
import com.margelo.nitro.unistyles.Dimensions
|
|
14
|
+
import com.margelo.nitro.unistyles.HybridNativePlatformSpec
|
|
15
|
+
import com.margelo.nitro.unistyles.Insets
|
|
16
|
+
import com.margelo.nitro.unistyles.Orientation
|
|
17
|
+
import com.margelo.nitro.unistyles.UnistyleDependency
|
|
18
|
+
import com.margelo.nitro.unistyles.UnistylesNativeMiniRuntime
|
|
19
|
+
import java.util.Locale
|
|
20
|
+
|
|
21
|
+
class NativePlatform(private val reactContext: ReactApplicationContext): HybridNativePlatformSpec() {
|
|
22
|
+
private val _insets = UnistylesModuleInsets(reactContext)
|
|
23
|
+
|
|
24
|
+
override fun getInsets(): Insets {
|
|
25
|
+
return _insets.getInsets()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
override fun getColorScheme(): ColorScheme {
|
|
29
|
+
val uiMode = reactContext.resources.configuration.uiMode
|
|
30
|
+
|
|
31
|
+
val colorScheme = when (uiMode.and(Configuration.UI_MODE_NIGHT_MASK)) {
|
|
32
|
+
Configuration.UI_MODE_NIGHT_YES -> ColorScheme.DARK
|
|
33
|
+
Configuration.UI_MODE_NIGHT_NO -> ColorScheme.LIGHT
|
|
34
|
+
else -> ColorScheme.UNSPECIFIED
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return colorScheme
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
override fun getFontScale(): Double {
|
|
41
|
+
return reactContext.resources.configuration.fontScale.toDouble()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
override fun getPixelRatio(): Double {
|
|
45
|
+
return reactContext.resources.displayMetrics.density.toDouble()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
override fun getOrientation(): Orientation {
|
|
49
|
+
val orientation = when (reactContext.resources.configuration.orientation) {
|
|
50
|
+
Configuration.ORIENTATION_PORTRAIT -> Orientation.PORTRAIT
|
|
51
|
+
Configuration.ORIENTATION_LANDSCAPE -> Orientation.LANDSCAPE
|
|
52
|
+
else -> Orientation.PORTRAIT
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return orientation
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
override fun getContentSizeCategory(): String {
|
|
59
|
+
val fontScale = reactContext.resources.configuration.fontScale
|
|
60
|
+
|
|
61
|
+
val contentSizeCategory = when {
|
|
62
|
+
fontScale <= 0.85f -> "Small"
|
|
63
|
+
fontScale <= 1.0f -> "Default"
|
|
64
|
+
fontScale <= 1.15f -> "Large"
|
|
65
|
+
fontScale <= 1.3f -> "ExtraLarge"
|
|
66
|
+
fontScale <= 1.5f -> "Huge"
|
|
67
|
+
fontScale <= 1.8 -> "ExtraHuge"
|
|
68
|
+
else -> "ExtraExtraHuge"
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return contentSizeCategory
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
override fun getScreenDimensions(): Dimensions {
|
|
75
|
+
// function takes in count edge-to-edge layout
|
|
76
|
+
when {
|
|
77
|
+
Build.VERSION.SDK_INT < Build.VERSION_CODES.R -> {
|
|
78
|
+
val windowManager = reactContext.getSystemService(Context.WINDOW_SERVICE) as WindowManager
|
|
79
|
+
val metrics = DisplayMetrics()
|
|
80
|
+
|
|
81
|
+
windowManager.defaultDisplay.getRealMetrics(metrics)
|
|
82
|
+
|
|
83
|
+
val screenWidth = (metrics.widthPixels / metrics.density).toDouble()
|
|
84
|
+
val screenHeight = (metrics.heightPixels / metrics.density).toDouble()
|
|
85
|
+
|
|
86
|
+
return Dimensions(screenWidth, screenHeight)
|
|
87
|
+
}
|
|
88
|
+
else -> {
|
|
89
|
+
val displayMetrics = reactContext.resources.displayMetrics
|
|
90
|
+
|
|
91
|
+
reactContext.currentActivity?.windowManager?.currentWindowMetrics?.bounds?.let {
|
|
92
|
+
val boundsWidth = (it.width() / displayMetrics.density).toDouble()
|
|
93
|
+
val boundsHeight = (it.height() / displayMetrics.density).toDouble()
|
|
94
|
+
|
|
95
|
+
return Dimensions(boundsWidth, boundsHeight)
|
|
96
|
+
} ?: run {
|
|
97
|
+
val screenWidth = (displayMetrics.widthPixels / displayMetrics.density).toDouble()
|
|
98
|
+
val screenHeight = (displayMetrics.heightPixels / displayMetrics.density).toDouble()
|
|
99
|
+
|
|
100
|
+
return Dimensions(screenWidth, screenHeight)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
override fun getStatusBarDimensions(): Dimensions {
|
|
107
|
+
// todo
|
|
108
|
+
return Dimensions(0.0, 0.0)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
override fun getNavigationBarDimensions(): Dimensions {
|
|
112
|
+
// todo
|
|
113
|
+
return Dimensions(0.0, 0.0)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
override fun getPrefersRtlDirection(): Boolean {
|
|
117
|
+
// forced by React Native
|
|
118
|
+
val sharedPrefs = reactContext.getSharedPreferences(
|
|
119
|
+
"com.facebook.react.modules.i18nmanager.I18nUtil",
|
|
120
|
+
Context.MODE_PRIVATE
|
|
121
|
+
)
|
|
122
|
+
val hasForcedRtl = sharedPrefs.getBoolean("RCTI18nUtil_forceRTL", false)
|
|
123
|
+
// user preferences
|
|
124
|
+
val isRtl = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL
|
|
125
|
+
|
|
126
|
+
return hasForcedRtl || isRtl
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
override fun setRootViewBackgroundColor(color: Double) {
|
|
130
|
+
// todo
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
override fun setNavigationBarBackgroundColor(color: Double) {
|
|
134
|
+
// todo
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
override fun setNavigationBarHidden(isHidden: Boolean) {
|
|
138
|
+
// todo
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
override fun setStatusBarHidden(isHidden: Boolean) {
|
|
142
|
+
// todo
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
override fun setStatusBarBackgroundColor(color: Double) {
|
|
146
|
+
// todo
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
override fun setImmersiveMode(isEnabled: Boolean) {
|
|
150
|
+
this.setStatusBarHidden(isEnabled)
|
|
151
|
+
this.setNavigationBarHidden(isEnabled)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
override fun getMiniRuntime(): UnistylesNativeMiniRuntime {
|
|
155
|
+
return UnistylesNativeMiniRuntime(
|
|
156
|
+
colorScheme = this.getColorScheme(),
|
|
157
|
+
screen = this.getScreenDimensions(),
|
|
158
|
+
contentSizeCategory = this.getContentSizeCategory(),
|
|
159
|
+
insets = this.getInsets(),
|
|
160
|
+
pixelRatio = this.getPixelRatio(),
|
|
161
|
+
fontScale = this.getFontScale(),
|
|
162
|
+
rtl = this.getPrefersRtlDirection(),
|
|
163
|
+
statusBar = this.getStatusBarDimensions(),
|
|
164
|
+
navigationBar = this.getNavigationBarDimensions(),
|
|
165
|
+
isPortrait = this.getOrientation() == Orientation.PORTRAIT,
|
|
166
|
+
isLandscape = this.getOrientation() == Orientation.LANDSCAPE
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
override fun registerPlatformListener(callback: (dependencies: Array<UnistyleDependency>) -> Unit) {
|
|
171
|
+
// todo
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
override fun registerImeListener(callback: () -> Unit) {
|
|
175
|
+
// todo
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
override fun unregisterPlatformListeners() {
|
|
179
|
+
// todo
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
override val memorySize: Long
|
|
183
|
+
get() = 0
|
|
184
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
2
|
+
import com.margelo.nitro.unistyles.Insets
|
|
3
|
+
|
|
4
|
+
class UnistylesModuleInsets(private val reactContext: ReactApplicationContext) {
|
|
5
|
+
fun getInsets(): Insets {
|
|
6
|
+
return Insets(top = 0.0, bottom = 0.0, left = 0.0, right = 0.0, ime = 0.0)
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
package com.unistyles
|
|
2
|
+
|
|
3
|
+
import com.facebook.fbreact.specs.NativeTurboUnistylesSpec
|
|
4
|
+
import com.facebook.jni.HybridData
|
|
5
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
+
import com.facebook.react.bridge.RuntimeExecutor
|
|
8
|
+
import com.facebook.react.fabric.FabricUIManager
|
|
9
|
+
import com.facebook.react.turbomodule.core.interfaces.BindingsInstallerHolder
|
|
10
|
+
import com.facebook.react.turbomodule.core.interfaces.TurboModuleWithJSIBindings
|
|
11
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
12
|
+
import com.facebook.react.uimanager.common.UIManagerType
|
|
13
|
+
import com.margelo.nitro.unistyles.HybridNativePlatformSpec
|
|
14
|
+
|
|
15
|
+
@Suppress("KotlinJniMissingFunction")
|
|
16
|
+
class UnistylesModule(reactContext: ReactApplicationContext): NativeTurboUnistylesSpec(reactContext), TurboModuleWithJSIBindings {
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
private var mHybridData: HybridData?
|
|
19
|
+
private val _nativePlatform = NativePlatform(reactContext)
|
|
20
|
+
|
|
21
|
+
companion object {
|
|
22
|
+
const val NAME = NativeTurboUnistylesSpec.NAME
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
init {
|
|
26
|
+
mHybridData = initializeHybridData(reactContext)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private fun initializeHybridData(reactContext: ReactApplicationContext): HybridData {
|
|
30
|
+
val runtimeExecutor = reactContext.catalystInstance?.runtimeExecutor
|
|
31
|
+
?: throw IllegalStateException("Unistyles: React Native runtime executor is not available. Please follow installation guides.")
|
|
32
|
+
val fabricUIManager = UIManagerHelper.getUIManager(reactContext, UIManagerType.FABRIC) as? FabricUIManager
|
|
33
|
+
?: throw IllegalStateException("Unistyles: Fabric UI Manager is not available. Please follow installation guides.")
|
|
34
|
+
|
|
35
|
+
return initHybrid(runtimeExecutor, fabricUIManager, _nativePlatform)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@DoNotStrip
|
|
39
|
+
external override fun getBindingsInstaller(): BindingsInstallerHolder
|
|
40
|
+
|
|
41
|
+
@DoNotStrip
|
|
42
|
+
private external fun initHybrid(
|
|
43
|
+
runtimeExecutor: RuntimeExecutor,
|
|
44
|
+
fabricUIManager: FabricUIManager,
|
|
45
|
+
nativePlatform: HybridNativePlatformSpec
|
|
46
|
+
): HybridData
|
|
47
|
+
}
|
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
package com.unistyles
|
|
2
2
|
|
|
3
|
-
import android.util.Log
|
|
4
3
|
import com.facebook.react.TurboReactPackage
|
|
5
4
|
import com.facebook.react.bridge.NativeModule
|
|
6
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
7
7
|
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
8
8
|
|
|
9
9
|
class UnistylesPackage: TurboReactPackage() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
System.loadLibrary("unistyles")
|
|
16
|
-
Log.i(TAG, "Installed Unistyles \uD83E\uDD84!")
|
|
17
|
-
} catch (e: Throwable) {
|
|
18
|
-
Log.e(TAG, "Failed to load Unistyles C++ library! Is it properly linked?", e)
|
|
19
|
-
throw e
|
|
20
|
-
}
|
|
10
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
11
|
+
return if (name == UnistylesModule.NAME) {
|
|
12
|
+
UnistylesModule(reactContext)
|
|
13
|
+
} else {
|
|
14
|
+
null
|
|
21
15
|
}
|
|
22
16
|
}
|
|
23
17
|
|
|
24
|
-
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? = null
|
|
25
18
|
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
26
|
-
return ReactModuleInfoProvider {
|
|
19
|
+
return ReactModuleInfoProvider {
|
|
20
|
+
mapOf(UnistylesModule.NAME to ReactModuleInfo(
|
|
21
|
+
UnistylesModule.NAME,
|
|
22
|
+
UnistylesModule.NAME,
|
|
23
|
+
_canOverrideExistingModule = true,
|
|
24
|
+
_needsEagerInit = true,
|
|
25
|
+
isCxxModule = true,
|
|
26
|
+
isTurboModule = true
|
|
27
|
+
))
|
|
28
|
+
}
|
|
27
29
|
}
|
|
28
30
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#if __has_include("Unistyles-Swift-Cxx-Umbrella.hpp")
|
|
2
|
+
#include "Unistyles-Swift-Cxx-Umbrella.hpp"
|
|
3
|
+
#elif __has_include("JHybridNativePlatformSpec.hpp")
|
|
4
|
+
#include "JHybridNativePlatformSpec.hpp"
|
|
5
|
+
|
|
6
|
+
namespace Unistyles {
|
|
7
|
+
using HybridNativePlatformSpecCxx = margelo::nitro::unistyles::JHybridNativePlatformSpec;
|
|
8
|
+
}
|
|
9
|
+
#else
|
|
10
|
+
#error "Unistyles: Can't find platform specific header!"
|
|
11
|
+
#endif
|
package/cxx/common/Helpers.h
CHANGED
package/cxx/core/Unistyle.h
CHANGED
|
@@ -53,7 +53,7 @@ private:
|
|
|
53
53
|
std::unordered_map<jsi::Runtime*, std::unordered_map<const ShadowNodeFamily*, std::vector<std::shared_ptr<UnistyleData>>>> _shadowRegistry{};
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
UnistylesRegistry& UnistylesRegistry::get() {
|
|
56
|
+
inline UnistylesRegistry& UnistylesRegistry::get() {
|
|
57
57
|
static UnistylesRegistry cache;
|
|
58
58
|
|
|
59
59
|
return cache;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include "HybridUnistylesNavigationBarSpec.hpp"
|
|
4
|
-
#include "
|
|
4
|
+
#include "NativePlatform.h"
|
|
5
5
|
#include <optional>
|
|
6
6
|
|
|
7
7
|
using namespace margelo::nitro::unistyles;
|
|
8
8
|
|
|
9
9
|
struct HybridNavigationBar: public HybridUnistylesNavigationBarSpec {
|
|
10
10
|
HybridNavigationBar(Unistyles::HybridNativePlatformSpecCxx nativePlatform): HybridObject(TAG), _nativePlatform{nativePlatform} {}
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
void setBackgroundColor(double color) override;
|
|
13
13
|
void setHidden(bool isHidden) override;
|
|
14
14
|
double getWidth() override;
|
|
15
15
|
double getHeight() override;
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
private:
|
|
18
18
|
Unistyles::HybridNativePlatformSpecCxx _nativePlatform;
|
|
19
19
|
};
|