From d5a91092be2a3bdfb3a9ad81f8da9b2e184dacad Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Sat, 10 Sep 2022 14:27:54 +0200 Subject: [PATCH 01/35] chore: update codegen config configuration in main package.json --- package.json | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 455eecd9f2..53002b4978 100644 --- a/package.json +++ b/package.json @@ -132,12 +132,11 @@ "lib/" ], "codegenConfig": { - "libraries": [ - { - "name": "rnscreens", - "type": "components", - "jsSrcsDir": "./src/fabric" - } - ] + "name": "rnscreens", + "type": "components", + "jsSrcsDir": "./src/fabric", + "android": { + "javaPackageName": "com.swmansion.rnscreens" + } } } From 4f84579f937a2ec439eee95a487102338d8db320 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Sat, 10 Sep 2022 15:41:41 +0200 Subject: [PATCH 02/35] chore: remove files with custom autolinking C++ code --- android/src/main/jni/Android.mk | 44 ------------- android/src/main/jni/OnLoad.cpp | 9 --- .../main/jni/RNScreensComponentsRegistry.cpp | 66 ------------------- .../main/jni/RNScreensComponentsRegistry.h | 34 ---------- 4 files changed, 153 deletions(-) delete mode 100644 android/src/main/jni/Android.mk delete mode 100644 android/src/main/jni/OnLoad.cpp delete mode 100644 android/src/main/jni/RNScreensComponentsRegistry.cpp delete mode 100644 android/src/main/jni/RNScreensComponentsRegistry.h diff --git a/android/src/main/jni/Android.mk b/android/src/main/jni/Android.mk deleted file mode 100644 index 7684d3b893..0000000000 --- a/android/src/main/jni/Android.mk +++ /dev/null @@ -1,44 +0,0 @@ -SCREENS_MAIN_THIS_DIR := $(call my-dir) - -include $(REACT_ANDROID_DIR)/Android-prebuilt.mk - -include $(SCREENS_MAIN_THIS_DIR)/../../../build/generated/source/codegen/jni/Android.mk -include $(SCREENS_MAIN_THIS_DIR)/../../../../common/cpp/Android.mk - -include $(CLEAR_VARS) - -LOCAL_PATH := $(SCREENS_MAIN_THIS_DIR) -LOCAL_MODULE := rnscreens_modules - -LOCAL_C_INCLUDES := $(LOCAL_PATH) $(GENERATED_SRC_DIR)/codegen/jni -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(GENERATED_SRC_DIR)/codegen/jni/*.cpp) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(GENERATED_SRC_DIR)/codegen/jni - -# Please note as one of the library listed is libreact_codegen_samplelibrary -# This name will be generated as libreact_codegen_ -# where is the one you specified in the Gradle configuration -LOCAL_SHARED_LIBRARIES := libjsi \ - libfbjni \ - libglog \ - libfolly_runtime \ - libyoga \ - libreact_nativemodule_core \ - libturbomodulejsijni \ - librrc_view \ - libreact_render_core \ - libreact_render_graphics \ - libfabricjni \ - libreact_debug \ - libreact_render_componentregistry \ - libreact_render_debug \ - libruntimeexecutor \ - libreact_render_mapbuffer \ - libreact_codegen_rncore \ - libreact_codegen_rnscreens \ - librnscreens_common - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"ReactNative\" -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) diff --git a/android/src/main/jni/OnLoad.cpp b/android/src/main/jni/OnLoad.cpp deleted file mode 100644 index 8bafb73571..0000000000 --- a/android/src/main/jni/OnLoad.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include - -#include "RNScreensComponentsRegistry.h" - -JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) { - return facebook::jni::initialize(vm, [] { - facebook::react::RNScreensComponentsRegistry::registerNatives(); - }); -} diff --git a/android/src/main/jni/RNScreensComponentsRegistry.cpp b/android/src/main/jni/RNScreensComponentsRegistry.cpp deleted file mode 100644 index 6659a0c6e2..0000000000 --- a/android/src/main/jni/RNScreensComponentsRegistry.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "RNScreensComponentsRegistry.h" - -#include -#include -#include -#include -#include -#include -#include - -namespace facebook { -namespace react { - -RNScreensComponentsRegistry::RNScreensComponentsRegistry( - ComponentFactory *delegate) - : delegate_(delegate) {} - -std::shared_ptr -RNScreensComponentsRegistry::sharedProviderRegistry() { - auto providerRegistry = CoreComponentsRegistry::sharedProviderRegistry(); - - // Screens - providerRegistry->add(concreteComponentDescriptorProvider()); - providerRegistry->add(concreteComponentDescriptorProvider()); - providerRegistry->add(concreteComponentDescriptorProvider()); - providerRegistry->add(concreteComponentDescriptorProvider()); - - return providerRegistry; -} - -jni::local_ref -RNScreensComponentsRegistry::initHybrid( - jni::alias_ref, - ComponentFactory *delegate) { - auto instance = makeCxxInstance(delegate); - - auto buildRegistryFunction = - [](EventDispatcher::Weak const &eventDispatcher, - ContextContainer::Shared const &contextContainer) - -> ComponentDescriptorRegistry::Shared { - auto registry = RNScreensComponentsRegistry::sharedProviderRegistry() - ->createComponentDescriptorRegistry( - {eventDispatcher, contextContainer}); - - return registry; - }; - - delegate->buildRegistryFunction = buildRegistryFunction; - return instance; -} - -void RNScreensComponentsRegistry::registerNatives() { - registerHybrid({ - makeNativeMethod("initHybrid", RNScreensComponentsRegistry::initHybrid), - }); - // This is a temporary solution that allows components exported by the screens - // library to be added to the main component registry. This code is triggered - // when c++ screens library is initialized and is needed because RN's autolinking - // does not currently support Fabric components. As a consequence, users would need - // to manually put library initialization calls in their ReactNativeHost implementation - // which is undesirable. - sharedProviderRegistry(); -} - -} // namespace react -} // namespace facebook diff --git a/android/src/main/jni/RNScreensComponentsRegistry.h b/android/src/main/jni/RNScreensComponentsRegistry.h deleted file mode 100644 index 63f92d070b..0000000000 --- a/android/src/main/jni/RNScreensComponentsRegistry.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -namespace facebook { -namespace react { - -class RNScreensComponentsRegistry - : public facebook::jni::HybridClass { - public: - constexpr static auto kJavaDescriptor = - "Lcom/swmansion/rnscreens/RNScreensComponentsRegistry;"; - - static void registerNatives(); - - RNScreensComponentsRegistry(ComponentFactory *delegate); - - private: - friend HybridBase; - - static std::shared_ptr sharedProviderRegistry(); - - const ComponentFactory *delegate_; - - static jni::local_ref initHybrid( - jni::alias_ref, - ComponentFactory *delegate); -}; - -} // namespace react -} // namespace facebook From da0faed8269b9800ffa63f9d0d6620f275578f73 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Sat, 10 Sep 2022 15:43:45 +0200 Subject: [PATCH 03/35] chore: remove custom linking code from gradle build --- android/build.gradle | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 4ee29300f4..58fe0e43d4 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -55,23 +55,6 @@ android { versionCode 1 versionName "1.0" buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() - if (isNewArchitectureEnabled()) { - var appProject = rootProject.allprojects.find {it.plugins.hasPlugin('com.android.application')} - externalNativeBuild { - ndkBuild { - arguments "APP_PLATFORM=android-21", - "APP_STL=c++_shared", - "NDK_TOOLCHAIN_VERSION=clang", - "GENERATED_SRC_DIR=${appProject.buildDir}/generated/source", - "PROJECT_BUILD_DIR=${appProject.buildDir}", - "REACT_ANDROID_DIR=${appProject.rootDir}/../node_modules/react-native/ReactAndroid", - "REACT_ANDROID_BUILD_DIR=${appProject.rootDir}/../node_modules/react-native/ReactAndroid/build" - cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1" - cppFlags "-std=c++17" - targets "rnscreens_modules" - } - } - } ndk { abiFilters (*reactNativeArchitectures()) } @@ -83,13 +66,6 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } - if (isNewArchitectureEnabled()) { - externalNativeBuild { - ndkBuild { - path "src/main/jni/Android.mk" - } - } - } packagingOptions { // For some reason gradle only complains about the duplicated version of libreact_render libraries // while there are more libraries copied in intermediates folder of the lib build directory, we exlude @@ -139,13 +115,3 @@ dependencies { implementation 'com.google.android.material:material:1.1.0' implementation "androidx.core:core-ktx:1.5.0" } - -if (isNewArchitectureEnabled()) { - react { - reactRoot = rootProject.file("../node_modules/react-native/") - jsRootDir = file("../src/fabric/") - codegenDir = rootProject.file("../node_modules/react-native-codegen/") - libraryName = "rnscreens" - codegenJavaPackageName = "com.swmansion.rnscreens" - } -} From e177bf49dba36b0eda5ed33b2fd55f5b5c5e50e7 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Mon, 12 Sep 2022 11:15:41 +0200 Subject: [PATCH 04/35] chore: apply recomended directory structure to common cpp code --- .../renderer/components}/rnscreens/RNSScreenComponentDescriptor.h | 0 .../renderer/components}/rnscreens/RNSScreenShadowNode.cpp | 0 .../renderer/components}/rnscreens/RNSScreenShadowNode.h | 0 .../{ => react/renderer/components}/rnscreens/RNSScreenState.cpp | 0 .../{ => react/renderer/components}/rnscreens/RNSScreenState.h | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename common/cpp/{ => react/renderer/components}/rnscreens/RNSScreenComponentDescriptor.h (100%) rename common/cpp/{ => react/renderer/components}/rnscreens/RNSScreenShadowNode.cpp (100%) rename common/cpp/{ => react/renderer/components}/rnscreens/RNSScreenShadowNode.h (100%) rename common/cpp/{ => react/renderer/components}/rnscreens/RNSScreenState.cpp (100%) rename common/cpp/{ => react/renderer/components}/rnscreens/RNSScreenState.h (100%) diff --git a/common/cpp/rnscreens/RNSScreenComponentDescriptor.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenComponentDescriptor.h similarity index 100% rename from common/cpp/rnscreens/RNSScreenComponentDescriptor.h rename to common/cpp/react/renderer/components/rnscreens/RNSScreenComponentDescriptor.h diff --git a/common/cpp/rnscreens/RNSScreenShadowNode.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp similarity index 100% rename from common/cpp/rnscreens/RNSScreenShadowNode.cpp rename to common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp diff --git a/common/cpp/rnscreens/RNSScreenShadowNode.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.h similarity index 100% rename from common/cpp/rnscreens/RNSScreenShadowNode.h rename to common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.h diff --git a/common/cpp/rnscreens/RNSScreenState.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenState.cpp similarity index 100% rename from common/cpp/rnscreens/RNSScreenState.cpp rename to common/cpp/react/renderer/components/rnscreens/RNSScreenState.cpp diff --git a/common/cpp/rnscreens/RNSScreenState.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenState.h similarity index 100% rename from common/cpp/rnscreens/RNSScreenState.h rename to common/cpp/react/renderer/components/rnscreens/RNSScreenState.h From d3b7f733876052ef60766114aeff8106bf8b2ca4 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Mon, 12 Sep 2022 11:17:48 +0200 Subject: [PATCH 05/35] chore: copy codegened implementation of cpp code for RNSScreen For now it is only partially filtered (there is also code for other components for now). I'm not sure whether I should leave all the codegened code or leave only the RNSScreen part. --- .../rnscreens/ComponentDescriptors.h | 22 +++ .../rnscreens/RNSScreenEventEmitters.cpp | 80 +++++++++ .../rnscreens/RNSScreenEventEmitters.h | 74 ++++++++ .../components/rnscreens/RNSScreenProps.cpp | 47 +++++ .../components/rnscreens/RNSScreenProps.h | 168 ++++++++++++++++++ .../components/rnscreens/ShadowNodes.cpp | 26 +++ .../components/rnscreens/ShadowNodes.h | 97 ++++++++++ 7 files changed, 514 insertions(+) create mode 100644 common/cpp/react/renderer/components/rnscreens/ComponentDescriptors.h create mode 100644 common/cpp/react/renderer/components/rnscreens/RNSScreenEventEmitters.cpp create mode 100644 common/cpp/react/renderer/components/rnscreens/RNSScreenEventEmitters.h create mode 100644 common/cpp/react/renderer/components/rnscreens/RNSScreenProps.cpp create mode 100644 common/cpp/react/renderer/components/rnscreens/RNSScreenProps.h create mode 100644 common/cpp/react/renderer/components/rnscreens/ShadowNodes.cpp create mode 100644 common/cpp/react/renderer/components/rnscreens/ShadowNodes.h diff --git a/common/cpp/react/renderer/components/rnscreens/ComponentDescriptors.h b/common/cpp/react/renderer/components/rnscreens/ComponentDescriptors.h new file mode 100644 index 0000000000..4a56e13143 --- /dev/null +++ b/common/cpp/react/renderer/components/rnscreens/ComponentDescriptors.h @@ -0,0 +1,22 @@ + +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateComponentDescriptorH.js + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using RNSScreenComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenEventEmitters.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenEventEmitters.cpp new file mode 100644 index 0000000000..f7ef071247 --- /dev/null +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenEventEmitters.cpp @@ -0,0 +1,80 @@ + +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterCpp.js + */ + +#include + +namespace facebook { +namespace react { + + + +void RNSScreenEventEmitter::onAppear(OnAppear event) const { + dispatchEvent("appear", [event=std::move(event)](jsi::Runtime &runtime) { + auto payload = jsi::Object(runtime); + + return payload; + }); +} +void RNSScreenEventEmitter::onDisappear(OnDisappear event) const { + dispatchEvent("disappear", [event=std::move(event)](jsi::Runtime &runtime) { + auto payload = jsi::Object(runtime); + + return payload; + }); +} +void RNSScreenEventEmitter::onDismissed(OnDismissed event) const { + dispatchEvent("dismissed", [event=std::move(event)](jsi::Runtime &runtime) { + auto payload = jsi::Object(runtime); + payload.setProperty(runtime, "dismissCount", event.dismissCount); + return payload; + }); +} +void RNSScreenEventEmitter::onNativeDismissCancelled(OnNativeDismissCancelled event) const { + dispatchEvent("nativeDismissCancelled", [event=std::move(event)](jsi::Runtime &runtime) { + auto payload = jsi::Object(runtime); + payload.setProperty(runtime, "dismissCount", event.dismissCount); + return payload; + }); +} +void RNSScreenEventEmitter::onWillAppear(OnWillAppear event) const { + dispatchEvent("willAppear", [event=std::move(event)](jsi::Runtime &runtime) { + auto payload = jsi::Object(runtime); + + return payload; + }); +} +void RNSScreenEventEmitter::onWillDisappear(OnWillDisappear event) const { + dispatchEvent("willDisappear", [event=std::move(event)](jsi::Runtime &runtime) { + auto payload = jsi::Object(runtime); + + return payload; + }); +} +void RNSScreenEventEmitter::onTransitionProgress(OnTransitionProgress event) const { + dispatchEvent("transitionProgress", [event=std::move(event)](jsi::Runtime &runtime) { + auto payload = jsi::Object(runtime); + payload.setProperty(runtime, "progress", event.progress); +payload.setProperty(runtime, "closing", event.closing); +payload.setProperty(runtime, "goingForward", event.goingForward); + return payload; + }); +} +void RNSScreenEventEmitter::onHeaderBackButtonClicked(OnHeaderBackButtonClicked event) const { + dispatchEvent("headerBackButtonClicked", [event=std::move(event)](jsi::Runtime &runtime) { + auto payload = jsi::Object(runtime); + + return payload; + }); +} + + + +} // namespace react +} // namespace facebook diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenEventEmitters.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenEventEmitters.h new file mode 100644 index 0000000000..857531999b --- /dev/null +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenEventEmitters.h @@ -0,0 +1,74 @@ + +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateEventEmitterH.js + */ +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +class JSI_EXPORT RNSScreenEventEmitter : public ViewEventEmitter { + public: + using ViewEventEmitter::ViewEventEmitter; + + struct OnAppear { + + }; + + struct OnDisappear { + + }; + + struct OnDismissed { + int dismissCount; + }; + + struct OnNativeDismissCancelled { + int dismissCount; + }; + + struct OnWillAppear { + + }; + + struct OnWillDisappear { + + }; + + struct OnTransitionProgress { + double progress; + int closing; + int goingForward; + }; + + struct OnHeaderBackButtonClicked { + + }; + + void onAppear(OnAppear value) const; + + void onDisappear(OnDisappear value) const; + + void onDismissed(OnDismissed value) const; + + void onNativeDismissCancelled(OnNativeDismissCancelled value) const; + + void onWillAppear(OnWillAppear value) const; + + void onWillDisappear(OnWillDisappear value) const; + + void onTransitionProgress(OnTransitionProgress value) const; + + void onHeaderBackButtonClicked(OnHeaderBackButtonClicked value) const; +}; + +} // namespace react +} // namespace facebook diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenProps.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenProps.cpp new file mode 100644 index 0000000000..4835642f35 --- /dev/null +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenProps.cpp @@ -0,0 +1,47 @@ + +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsCpp.js + */ + +#include +#include +#include + +namespace facebook { +namespace react { + +RNSScreenProps::RNSScreenProps( + const PropsParserContext &context, + const RNSScreenProps &sourceProps, + const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), + + customAnimationOnSwipe(convertRawProp(context, rawProps, "customAnimationOnSwipe", sourceProps.customAnimationOnSwipe, {false})), + fullScreenSwipeEnabled(convertRawProp(context, rawProps, "fullScreenSwipeEnabled", sourceProps.fullScreenSwipeEnabled, {false})), + homeIndicatorHidden(convertRawProp(context, rawProps, "homeIndicatorHidden", sourceProps.homeIndicatorHidden, {false})), + preventNativeDismiss(convertRawProp(context, rawProps, "preventNativeDismiss", sourceProps.preventNativeDismiss, {false})), + gestureEnabled(convertRawProp(context, rawProps, "gestureEnabled", sourceProps.gestureEnabled, {true})), + statusBarColor(convertRawProp(context, rawProps, "statusBarColor", sourceProps.statusBarColor, {})), + statusBarHidden(convertRawProp(context, rawProps, "statusBarHidden", sourceProps.statusBarHidden, {false})), + screenOrientation(convertRawProp(context, rawProps, "screenOrientation", sourceProps.screenOrientation, {})), + statusBarAnimation(convertRawProp(context, rawProps, "statusBarAnimation", sourceProps.statusBarAnimation, {})), + statusBarStyle(convertRawProp(context, rawProps, "statusBarStyle", sourceProps.statusBarStyle, {})), + statusBarTranslucent(convertRawProp(context, rawProps, "statusBarTranslucent", sourceProps.statusBarTranslucent, {false})), + gestureResponseDistance(convertRawProp(context, rawProps, "gestureResponseDistance", sourceProps.gestureResponseDistance, {})), + stackPresentation(convertRawProp(context, rawProps, "stackPresentation", sourceProps.stackPresentation, {RNSScreenStackPresentation::Push})), + stackAnimation(convertRawProp(context, rawProps, "stackAnimation", sourceProps.stackAnimation, {RNSScreenStackAnimation::Default})), + transitionDuration(convertRawProp(context, rawProps, "transitionDuration", sourceProps.transitionDuration, {350})), + replaceAnimation(convertRawProp(context, rawProps, "replaceAnimation", sourceProps.replaceAnimation, {RNSScreenReplaceAnimation::Pop})), + swipeDirection(convertRawProp(context, rawProps, "swipeDirection", sourceProps.swipeDirection, {RNSScreenSwipeDirection::Horizontal})), + hideKeyboardOnSwipe(convertRawProp(context, rawProps, "hideKeyboardOnSwipe", sourceProps.hideKeyboardOnSwipe, {false})), + activityState(convertRawProp(context, rawProps, "activityState", sourceProps.activityState, {-1.0})), + navigationBarColor(convertRawProp(context, rawProps, "navigationBarColor", sourceProps.navigationBarColor, {})), + navigationBarHidden(convertRawProp(context, rawProps, "navigationBarHidden", sourceProps.navigationBarHidden, {false})), + nativeBackButtonDismissalEnabled(convertRawProp(context, rawProps, "nativeBackButtonDismissalEnabled", sourceProps.nativeBackButtonDismissalEnabled, {false})) + {} +} // namespace react +} // namespace facebook diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenProps.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenProps.h new file mode 100644 index 0000000000..9dc11844d9 --- /dev/null +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenProps.h @@ -0,0 +1,168 @@ + +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GeneratePropsH.js + */ +#pragma once + +#include +#include +#include +#include +#include + +namespace facebook { +namespace react { + +enum class RNSScreenStackPresentation { Push, Modal, TransparentModal, FullScreenModal, FormSheet, ContainedModal, ContainedTransparentModal }; + +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNSScreenStackPresentation &result) { + auto string = (std::string)value; + if (string == "push") { result = RNSScreenStackPresentation::Push; return; } + if (string == "modal") { result = RNSScreenStackPresentation::Modal; return; } + if (string == "transparentModal") { result = RNSScreenStackPresentation::TransparentModal; return; } + if (string == "fullScreenModal") { result = RNSScreenStackPresentation::FullScreenModal; return; } + if (string == "formSheet") { result = RNSScreenStackPresentation::FormSheet; return; } + if (string == "containedModal") { result = RNSScreenStackPresentation::ContainedModal; return; } + if (string == "containedTransparentModal") { result = RNSScreenStackPresentation::ContainedTransparentModal; return; } + abort(); +} + +static inline std::string toString(const RNSScreenStackPresentation &value) { + switch (value) { + case RNSScreenStackPresentation::Push: return "push"; + case RNSScreenStackPresentation::Modal: return "modal"; + case RNSScreenStackPresentation::TransparentModal: return "transparentModal"; + case RNSScreenStackPresentation::FullScreenModal: return "fullScreenModal"; + case RNSScreenStackPresentation::FormSheet: return "formSheet"; + case RNSScreenStackPresentation::ContainedModal: return "containedModal"; + case RNSScreenStackPresentation::ContainedTransparentModal: return "containedTransparentModal"; + } +} +enum class RNSScreenStackAnimation { Default, Flip, Simple_push, None, Fade, Slide_from_right, Slide_from_left, Slide_from_bottom, Fade_from_bottom }; + +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNSScreenStackAnimation &result) { + auto string = (std::string)value; + if (string == "default") { result = RNSScreenStackAnimation::Default; return; } + if (string == "flip") { result = RNSScreenStackAnimation::Flip; return; } + if (string == "simple_push") { result = RNSScreenStackAnimation::Simple_push; return; } + if (string == "none") { result = RNSScreenStackAnimation::None; return; } + if (string == "fade") { result = RNSScreenStackAnimation::Fade; return; } + if (string == "slide_from_right") { result = RNSScreenStackAnimation::Slide_from_right; return; } + if (string == "slide_from_left") { result = RNSScreenStackAnimation::Slide_from_left; return; } + if (string == "slide_from_bottom") { result = RNSScreenStackAnimation::Slide_from_bottom; return; } + if (string == "fade_from_bottom") { result = RNSScreenStackAnimation::Fade_from_bottom; return; } + abort(); +} + +static inline std::string toString(const RNSScreenStackAnimation &value) { + switch (value) { + case RNSScreenStackAnimation::Default: return "default"; + case RNSScreenStackAnimation::Flip: return "flip"; + case RNSScreenStackAnimation::Simple_push: return "simple_push"; + case RNSScreenStackAnimation::None: return "none"; + case RNSScreenStackAnimation::Fade: return "fade"; + case RNSScreenStackAnimation::Slide_from_right: return "slide_from_right"; + case RNSScreenStackAnimation::Slide_from_left: return "slide_from_left"; + case RNSScreenStackAnimation::Slide_from_bottom: return "slide_from_bottom"; + case RNSScreenStackAnimation::Fade_from_bottom: return "fade_from_bottom"; + } +} +enum class RNSScreenReplaceAnimation { Pop, Push }; + +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNSScreenReplaceAnimation &result) { + auto string = (std::string)value; + if (string == "pop") { result = RNSScreenReplaceAnimation::Pop; return; } + if (string == "push") { result = RNSScreenReplaceAnimation::Push; return; } + abort(); +} + +static inline std::string toString(const RNSScreenReplaceAnimation &value) { + switch (value) { + case RNSScreenReplaceAnimation::Pop: return "pop"; + case RNSScreenReplaceAnimation::Push: return "push"; + } +} +enum class RNSScreenSwipeDirection { Vertical, Horizontal }; + +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNSScreenSwipeDirection &result) { + auto string = (std::string)value; + if (string == "vertical") { result = RNSScreenSwipeDirection::Vertical; return; } + if (string == "horizontal") { result = RNSScreenSwipeDirection::Horizontal; return; } + abort(); +} + +static inline std::string toString(const RNSScreenSwipeDirection &value) { + switch (value) { + case RNSScreenSwipeDirection::Vertical: return "vertical"; + case RNSScreenSwipeDirection::Horizontal: return "horizontal"; + } +} +struct RNSScreenGestureResponseDistanceStruct { + Float start; + Float end; + Float top; + Float bottom; +}; + +static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNSScreenGestureResponseDistanceStruct &result) { + auto map = (butter::map)value; + + auto tmp_start = map.find("start"); + if (tmp_start != map.end()) { + fromRawValue(context, tmp_start->second, result.start); + } + auto tmp_end = map.find("end"); + if (tmp_end != map.end()) { + fromRawValue(context, tmp_end->second, result.end); + } + auto tmp_top = map.find("top"); + if (tmp_top != map.end()) { + fromRawValue(context, tmp_top->second, result.top); + } + auto tmp_bottom = map.find("bottom"); + if (tmp_bottom != map.end()) { + fromRawValue(context, tmp_bottom->second, result.bottom); + } +} + +static inline std::string toString(const RNSScreenGestureResponseDistanceStruct &value) { + return "[Object RNSScreenGestureResponseDistanceStruct]"; +} +class JSI_EXPORT RNSScreenProps final : public ViewProps { + public: + RNSScreenProps() = default; + RNSScreenProps(const PropsParserContext& context, const RNSScreenProps &sourceProps, const RawProps &rawProps); + +#pragma mark - Props + + bool customAnimationOnSwipe{false}; + bool fullScreenSwipeEnabled{false}; + bool homeIndicatorHidden{false}; + bool preventNativeDismiss{false}; + bool gestureEnabled{true}; + SharedColor statusBarColor{}; + bool statusBarHidden{false}; + std::string screenOrientation{}; + std::string statusBarAnimation{}; + std::string statusBarStyle{}; + bool statusBarTranslucent{false}; + RNSScreenGestureResponseDistanceStruct gestureResponseDistance{}; + RNSScreenStackPresentation stackPresentation{RNSScreenStackPresentation::Push}; + RNSScreenStackAnimation stackAnimation{RNSScreenStackAnimation::Default}; + int transitionDuration{350}; + RNSScreenReplaceAnimation replaceAnimation{RNSScreenReplaceAnimation::Pop}; + RNSScreenSwipeDirection swipeDirection{RNSScreenSwipeDirection::Horizontal}; + bool hideKeyboardOnSwipe{false}; + Float activityState{-1.0}; + SharedColor navigationBarColor{}; + bool navigationBarHidden{false}; + bool nativeBackButtonDismissalEnabled{false}; +}; + +} // namespace react +} // namespace facebook diff --git a/common/cpp/react/renderer/components/rnscreens/ShadowNodes.cpp b/common/cpp/react/renderer/components/rnscreens/ShadowNodes.cpp new file mode 100644 index 0000000000..24dc876756 --- /dev/null +++ b/common/cpp/react/renderer/components/rnscreens/ShadowNodes.cpp @@ -0,0 +1,26 @@ + +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeCpp.js + */ + +#include + +namespace facebook { +namespace react { + +extern const char RNSFullWindowOverlayComponentName[] = "RNSFullWindowOverlay"; +extern const char RNSScreenContainerComponentName[] = "RNSScreenContainer"; +extern const char RNSScreenComponentName[] = "RNSScreen"; +extern const char RNSScreenNavigationContainerComponentName[] = "RNSScreenNavigationContainer"; +extern const char RNSScreenStackHeaderConfigComponentName[] = "RNSScreenStackHeaderConfig"; +extern const char RNSScreenStackHeaderSubviewComponentName[] = "RNSScreenStackHeaderSubview"; +extern const char RNSScreenStackComponentName[] = "RNSScreenStack"; +extern const char RNSSearchBarComponentName[] = "RNSSearchBar"; + +} // namespace react +} // namespace facebook diff --git a/common/cpp/react/renderer/components/rnscreens/ShadowNodes.h b/common/cpp/react/renderer/components/rnscreens/ShadowNodes.h new file mode 100644 index 0000000000..4a14526c8c --- /dev/null +++ b/common/cpp/react/renderer/components/rnscreens/ShadowNodes.h @@ -0,0 +1,97 @@ + +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateShadowNodeH.js + */ + +#pragma once + +#include +#include +#include +#include + +namespace facebook { +namespace react { + +JSI_EXPORT extern const char RNSFullWindowOverlayComponentName[]; + +/* + * `ShadowNode` for component. + */ +using RNSFullWindowOverlayShadowNode = ConcreteViewShadowNode< + RNSFullWindowOverlayComponentName, + RNSFullWindowOverlayProps>; + +JSI_EXPORT extern const char RNSScreenContainerComponentName[]; + +/* + * `ShadowNode` for component. + */ +using RNSScreenContainerShadowNode = ConcreteViewShadowNode< + RNSScreenContainerComponentName, + RNSScreenContainerProps>; + +JSI_EXPORT extern const char RNSScreenComponentName[]; + +/* + * `ShadowNode` for component. + */ +using RNSScreenShadowNode = ConcreteViewShadowNode< + RNSScreenComponentName, + RNSScreenProps, +RNSScreenEventEmitter>; + +JSI_EXPORT extern const char RNSScreenNavigationContainerComponentName[]; + +/* + * `ShadowNode` for component. + */ +using RNSScreenNavigationContainerShadowNode = ConcreteViewShadowNode< + RNSScreenNavigationContainerComponentName, + RNSScreenNavigationContainerProps>; + +JSI_EXPORT extern const char RNSScreenStackHeaderConfigComponentName[]; + +/* + * `ShadowNode` for component. + */ +using RNSScreenStackHeaderConfigShadowNode = ConcreteViewShadowNode< + RNSScreenStackHeaderConfigComponentName, + RNSScreenStackHeaderConfigProps>; + +JSI_EXPORT extern const char RNSScreenStackHeaderSubviewComponentName[]; + +/* + * `ShadowNode` for component. + */ +using RNSScreenStackHeaderSubviewShadowNode = ConcreteViewShadowNode< + RNSScreenStackHeaderSubviewComponentName, + RNSScreenStackHeaderSubviewProps>; + +JSI_EXPORT extern const char RNSScreenStackComponentName[]; + +/* + * `ShadowNode` for component. + */ +using RNSScreenStackShadowNode = ConcreteViewShadowNode< + RNSScreenStackComponentName, + RNSScreenStackProps, +RNSScreenStackEventEmitter>; + +JSI_EXPORT extern const char RNSSearchBarComponentName[]; + +/* + * `ShadowNode` for component. + */ +using RNSSearchBarShadowNode = ConcreteViewShadowNode< + RNSSearchBarComponentName, + RNSSearchBarProps, +RNSSearchBarEventEmitter>; + +} // namespace react +} // namespace facebook From da63061dc5bc74c9676dfa749314cf6f6417831d Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Mon, 12 Sep 2022 11:26:06 +0200 Subject: [PATCH 06/35] chore: remove ComponentsDescriptors.h As we provide custom implementation --- .../rnscreens/ComponentDescriptors.h | 22 ------------------- 1 file changed, 22 deletions(-) delete mode 100644 common/cpp/react/renderer/components/rnscreens/ComponentDescriptors.h diff --git a/common/cpp/react/renderer/components/rnscreens/ComponentDescriptors.h b/common/cpp/react/renderer/components/rnscreens/ComponentDescriptors.h deleted file mode 100644 index 4a56e13143..0000000000 --- a/common/cpp/react/renderer/components/rnscreens/ComponentDescriptors.h +++ /dev/null @@ -1,22 +0,0 @@ - -/** - * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). - * - * Do not edit this file as changes may cause incorrect behavior and will be lost - * once the code is regenerated. - * - * @generated by codegen project: GenerateComponentDescriptorH.js - */ - -#pragma once - -#include -#include - -namespace facebook { -namespace react { - -using RNSScreenComponentDescriptor = ConcreteComponentDescriptor; - -} // namespace react -} // namespace facebook From 7963fd02ff8abfb5e90d838ef98339789ecdef68 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Mon, 12 Sep 2022 11:35:25 +0200 Subject: [PATCH 07/35] chore: remove ShadowNodes{.cpp,.h} as we provide custom implementation --- .../components/rnscreens/ShadowNodes.cpp | 26 ----- .../components/rnscreens/ShadowNodes.h | 97 ------------------- 2 files changed, 123 deletions(-) delete mode 100644 common/cpp/react/renderer/components/rnscreens/ShadowNodes.cpp delete mode 100644 common/cpp/react/renderer/components/rnscreens/ShadowNodes.h diff --git a/common/cpp/react/renderer/components/rnscreens/ShadowNodes.cpp b/common/cpp/react/renderer/components/rnscreens/ShadowNodes.cpp deleted file mode 100644 index 24dc876756..0000000000 --- a/common/cpp/react/renderer/components/rnscreens/ShadowNodes.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -/** - * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). - * - * Do not edit this file as changes may cause incorrect behavior and will be lost - * once the code is regenerated. - * - * @generated by codegen project: GenerateShadowNodeCpp.js - */ - -#include - -namespace facebook { -namespace react { - -extern const char RNSFullWindowOverlayComponentName[] = "RNSFullWindowOverlay"; -extern const char RNSScreenContainerComponentName[] = "RNSScreenContainer"; -extern const char RNSScreenComponentName[] = "RNSScreen"; -extern const char RNSScreenNavigationContainerComponentName[] = "RNSScreenNavigationContainer"; -extern const char RNSScreenStackHeaderConfigComponentName[] = "RNSScreenStackHeaderConfig"; -extern const char RNSScreenStackHeaderSubviewComponentName[] = "RNSScreenStackHeaderSubview"; -extern const char RNSScreenStackComponentName[] = "RNSScreenStack"; -extern const char RNSSearchBarComponentName[] = "RNSSearchBar"; - -} // namespace react -} // namespace facebook diff --git a/common/cpp/react/renderer/components/rnscreens/ShadowNodes.h b/common/cpp/react/renderer/components/rnscreens/ShadowNodes.h deleted file mode 100644 index 4a14526c8c..0000000000 --- a/common/cpp/react/renderer/components/rnscreens/ShadowNodes.h +++ /dev/null @@ -1,97 +0,0 @@ - -/** - * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). - * - * Do not edit this file as changes may cause incorrect behavior and will be lost - * once the code is regenerated. - * - * @generated by codegen project: GenerateShadowNodeH.js - */ - -#pragma once - -#include -#include -#include -#include - -namespace facebook { -namespace react { - -JSI_EXPORT extern const char RNSFullWindowOverlayComponentName[]; - -/* - * `ShadowNode` for component. - */ -using RNSFullWindowOverlayShadowNode = ConcreteViewShadowNode< - RNSFullWindowOverlayComponentName, - RNSFullWindowOverlayProps>; - -JSI_EXPORT extern const char RNSScreenContainerComponentName[]; - -/* - * `ShadowNode` for component. - */ -using RNSScreenContainerShadowNode = ConcreteViewShadowNode< - RNSScreenContainerComponentName, - RNSScreenContainerProps>; - -JSI_EXPORT extern const char RNSScreenComponentName[]; - -/* - * `ShadowNode` for component. - */ -using RNSScreenShadowNode = ConcreteViewShadowNode< - RNSScreenComponentName, - RNSScreenProps, -RNSScreenEventEmitter>; - -JSI_EXPORT extern const char RNSScreenNavigationContainerComponentName[]; - -/* - * `ShadowNode` for component. - */ -using RNSScreenNavigationContainerShadowNode = ConcreteViewShadowNode< - RNSScreenNavigationContainerComponentName, - RNSScreenNavigationContainerProps>; - -JSI_EXPORT extern const char RNSScreenStackHeaderConfigComponentName[]; - -/* - * `ShadowNode` for component. - */ -using RNSScreenStackHeaderConfigShadowNode = ConcreteViewShadowNode< - RNSScreenStackHeaderConfigComponentName, - RNSScreenStackHeaderConfigProps>; - -JSI_EXPORT extern const char RNSScreenStackHeaderSubviewComponentName[]; - -/* - * `ShadowNode` for component. - */ -using RNSScreenStackHeaderSubviewShadowNode = ConcreteViewShadowNode< - RNSScreenStackHeaderSubviewComponentName, - RNSScreenStackHeaderSubviewProps>; - -JSI_EXPORT extern const char RNSScreenStackComponentName[]; - -/* - * `ShadowNode` for component. - */ -using RNSScreenStackShadowNode = ConcreteViewShadowNode< - RNSScreenStackComponentName, - RNSScreenStackProps, -RNSScreenStackEventEmitter>; - -JSI_EXPORT extern const char RNSSearchBarComponentName[]; - -/* - * `ShadowNode` for component. - */ -using RNSSearchBarShadowNode = ConcreteViewShadowNode< - RNSSearchBarComponentName, - RNSSearchBarProps, -RNSSearchBarEventEmitter>; - -} // namespace react -} // namespace facebook From 882f032fb9bd68411a41a32f75af48e14b4afb62 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Mon, 12 Sep 2022 11:56:00 +0200 Subject: [PATCH 08/35] chore: add JSI_EXPORT macros to shadow node decl --- .../renderer/components/rnscreens/RNSScreenShadowNode.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.h index 890d4769fa..ef25dd16de 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.h +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.h @@ -4,13 +4,14 @@ #include #include #include +#include namespace facebook { namespace react { -extern const char RNSScreenComponentName[]; +JSI_EXPORT extern const char RNSScreenComponentName[]; -class RNSScreenShadowNode final : public ConcreteViewShadowNode< +class JSI_EXPORT RNSScreenShadowNode final : public ConcreteViewShadowNode< RNSScreenComponentName, RNSScreenProps, RNSScreenEventEmitter, From 57f33467a96a30a1f9d89d821d17f26ebe79289b Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Mon, 12 Sep 2022 11:56:41 +0200 Subject: [PATCH 09/35] chore: add module provider cpp code --- common/cpp/rnscreens.cpp | 23 +++++++++++++++++++++++ common/cpp/rnscreens.h | 25 +++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 common/cpp/rnscreens.cpp create mode 100644 common/cpp/rnscreens.h diff --git a/common/cpp/rnscreens.cpp b/common/cpp/rnscreens.cpp new file mode 100644 index 0000000000..3e1acf9225 --- /dev/null +++ b/common/cpp/rnscreens.cpp @@ -0,0 +1,23 @@ +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleJniCpp.js + */ + +#include "rnscreens.h" + +namespace facebook { +namespace react { + + + +std::shared_ptr rnscreens_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) { + + return nullptr; +} + +} // namespace react +} // namespace facebook diff --git a/common/cpp/rnscreens.h b/common/cpp/rnscreens.h new file mode 100644 index 0000000000..189975914a --- /dev/null +++ b/common/cpp/rnscreens.h @@ -0,0 +1,25 @@ +/** + * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + * @generated by codegen project: GenerateModuleJniH.js + */ + +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + + + +JSI_EXPORT +std::shared_ptr rnscreens_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms); + +} // namespace react +} // namespace facebook From d54857f721043d3e7fabfe85a06f430afca89602 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Mon, 12 Sep 2022 11:57:15 +0200 Subject: [PATCH 10/35] chore: add custom RN CLI config --- react-native.config.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 react-native.config.js diff --git a/react-native.config.js b/react-native.config.js new file mode 100644 index 0000000000..585d751cca --- /dev/null +++ b/react-native.config.js @@ -0,0 +1,10 @@ +module.exports = { + dependency: { + platforms: { + android: { + componentDescriptors: ['RNSScreenComponentDescriptor'], + androidMkPath: "common/cpp/Android.mk" + }, + }, + }, +} From 0ccc2eaeb22e8bc76b3783f8d91b91c89e03b312 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Mon, 12 Sep 2022 14:12:36 +0200 Subject: [PATCH 11/35] fix: add all components descriptors & specify cmakeListsPath Setting `componentDescriptors` causes RNCLI to not search for autogenerated ones -> we need to specify all of them manually --- react-native.config.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/react-native.config.js b/react-native.config.js index 585d751cca..38719d83ee 100644 --- a/react-native.config.js +++ b/react-native.config.js @@ -2,8 +2,18 @@ module.exports = { dependency: { platforms: { android: { - componentDescriptors: ['RNSScreenComponentDescriptor'], - androidMkPath: "common/cpp/Android.mk" + componentDescriptors: [ + "RNSFullWindowOverlayComponentDescriptor", + "RNSScreenContainerComponentDescriptor", + "RNSScreenNavigationContainerComponentDescriptor", + "RNSScreenStackHeaderConfigComponentDescriptor", + "RNSScreenStackHeaderSubviewComponentDescriptor", + "RNSScreenStackComponentDescriptor", + "RNSSearchBarComponentDescriptor", + 'RNSScreenComponentDescriptor' + ], + androidMkPath: "../common/cpp/Android.mk", + cmakeListsPath: "../common/cpp/CMakeLists.txt" }, }, }, From b8ccfa3419ab1c78d852a6aa8f5679902c7c2252 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Mon, 12 Sep 2022 15:27:59 +0200 Subject: [PATCH 12/35] chore: build custom & generated code with cmake This CMake builds both custom cpp code & generated one. It seems to me, that it must be done this way as project name recognized by autogenerated RN CLI cmake is `react_codegen_rnscreens` and we can not change that => only this library is included in final build. --- common/cpp/CMakeLists.txt | 71 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 common/cpp/CMakeLists.txt diff --git a/common/cpp/CMakeLists.txt b/common/cpp/CMakeLists.txt new file mode 100644 index 0000000000..d5f83b9e9e --- /dev/null +++ b/common/cpp/CMakeLists.txt @@ -0,0 +1,71 @@ +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +set(RNS_GENERATED_DIR "/Users/kacperkafara/workspace/swm/kkafar@screens/android/build/generated") +set(RNS_GENERATED_JNI_DIR ${RNS_GENERATED_DIR}/source/codegen/jni) +set(RNS_GENERATED_REACT_DIR ${RNS_GENERATED_JNI_DIR}/react/renderer/components/rnscreens) + + +message(DEBUG "VARIABLES SET") +message(DEBUG "RNS_GENERATED_DIR ${RNS_GENERATED_DIR}") +message(DEBUG "RNS_GENERATED_JNI_DIR ${RNS_GENERATED_JNI_DIR}") +message(DEBUG "RNS_GENERATED_REACT_DIR ${RNS_GENERATED_REACT_DIR}") +message(DEBUG "PROJECT_SOURCE_DIR ${PROJECT_SOURCE_DIR}") + + +# include(${RNS_GENERATED_JNI_DIR}/CMakeLists.txt) + +add_compile_options( + -fexceptions + -frtti + -std=c++17 + -Wall + -Wpedantic + -Wno-gnu-zero-variadic-macro-arguments) + +file(GLOB rnscreens_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/rnscreens/*.cpp) +file(GLOB rnscreens_codegen_SRCS CONFIGURE_DEPENDS ${RNS_GENERATED_JNI_DIR}/*.cpp ${RNS_GENERATED_REACT_DIR}/*cpp) + +add_library( + react_codegen_rnscreens + SHARED + ${rnscreens_SRCS} + ${rnscreens_codegen_SRCS} +) + +target_include_directories( + react_codegen_rnscreens + PUBLIC + . + react/renderer/components/rnscreens + ${RNS_GENERATED_JNI_DIR} + ${RNS_GENERATED_REACT_DIR} +) + +target_link_libraries( + react_codegen_rnscreens + fbjni + folly_runtime + glog + jsi + react_codegen_rncore + react_debug + react_nativemodule_core + react_render_core + react_render_debug + react_render_graphics + react_render_mapbuffer + rrc_view + turbomodulejsijni + yoga +) + +target_compile_options( + react_codegen_rnscreens + PRIVATE + -DLOG_TAG=\"ReactNative\" + -fexceptions + -frtti + -std=c++17 + -Wall +) \ No newline at end of file From 1a00f6a056e0ed4c79e8f763947990b5b34fd2a9 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Tue, 13 Sep 2022 12:14:18 +0200 Subject: [PATCH 13/35] chore: add some debug statements to custom Cmake --- common/cpp/CMakeLists.txt | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/common/cpp/CMakeLists.txt b/common/cpp/CMakeLists.txt index d5f83b9e9e..b8e1f35e19 100644 --- a/common/cpp/CMakeLists.txt +++ b/common/cpp/CMakeLists.txt @@ -5,27 +5,26 @@ set(RNS_GENERATED_DIR "/Users/kacperkafara/workspace/swm/kkafar@screens/android/ set(RNS_GENERATED_JNI_DIR ${RNS_GENERATED_DIR}/source/codegen/jni) set(RNS_GENERATED_REACT_DIR ${RNS_GENERATED_JNI_DIR}/react/renderer/components/rnscreens) - message(DEBUG "VARIABLES SET") message(DEBUG "RNS_GENERATED_DIR ${RNS_GENERATED_DIR}") message(DEBUG "RNS_GENERATED_JNI_DIR ${RNS_GENERATED_JNI_DIR}") message(DEBUG "RNS_GENERATED_REACT_DIR ${RNS_GENERATED_REACT_DIR}") message(DEBUG "PROJECT_SOURCE_DIR ${PROJECT_SOURCE_DIR}") - -# include(${RNS_GENERATED_JNI_DIR}/CMakeLists.txt) - add_compile_options( - -fexceptions - -frtti - -std=c++17 - -Wall - -Wpedantic - -Wno-gnu-zero-variadic-macro-arguments) + -fexceptions + -frtti + -std=c++17 + -Wall + -Wpedantic + -Wno-gnu-zero-variadic-macro-arguments +) file(GLOB rnscreens_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/rnscreens/*.cpp) file(GLOB rnscreens_codegen_SRCS CONFIGURE_DEPENDS ${RNS_GENERATED_JNI_DIR}/*.cpp ${RNS_GENERATED_REACT_DIR}/*cpp) +message(DEBUG "SOURCES ${rnscreens_SRCS} ${rnscreens_codegen_SRCS}") + add_library( react_codegen_rnscreens SHARED From e1d5f3ed5290ee382861947f801c1983f9273572 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Tue, 13 Sep 2022 12:15:01 +0200 Subject: [PATCH 14/35] chore: rename custom file with component descriptors & add there all CDs --- ...ScreenComponentDescriptor.h => ComponentDescriptors.h} | 8 ++++++++ 1 file changed, 8 insertions(+) rename common/cpp/react/renderer/components/rnscreens/{RNSScreenComponentDescriptor.h => ComponentDescriptors.h} (62%) diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenComponentDescriptor.h b/common/cpp/react/renderer/components/rnscreens/ComponentDescriptors.h similarity index 62% rename from common/cpp/react/renderer/components/rnscreens/RNSScreenComponentDescriptor.h rename to common/cpp/react/renderer/components/rnscreens/ComponentDescriptors.h index 40a3c0ad57..333830fef7 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenComponentDescriptor.h +++ b/common/cpp/react/renderer/components/rnscreens/ComponentDescriptors.h @@ -6,6 +6,14 @@ namespace facebook { namespace react { + +using RNSFullWindowOverlayComponentDescriptor = ConcreteComponentDescriptor; +using RNSScreenContainerComponentDescriptor = ConcreteComponentDescriptor; +using RNSScreenNavigationContainerComponentDescriptor = ConcreteComponentDescriptor; +using RNSScreenStackHeaderConfigComponentDescriptor = ConcreteComponentDescriptor; +using RNSScreenStackHeaderSubviewComponentDescriptor = ConcreteComponentDescriptor; +using RNSScreenStackComponentDescriptor = ConcreteComponentDescriptor; +using RNSSearchBarComponentDescriptor = ConcreteComponentDescriptor; class RNSScreenComponentDescriptor final : public ConcreteComponentDescriptor { From ba5252be625c2f094c6f81cb688e3be186819978 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Tue, 13 Sep 2022 22:55:15 +0200 Subject: [PATCH 15/35] fix: rename component descriptor file --- ...ponentDescriptors.h => RNSScreenComponentDescriptor.h} | 8 -------- 1 file changed, 8 deletions(-) rename common/cpp/react/renderer/components/rnscreens/{ComponentDescriptors.h => RNSScreenComponentDescriptor.h} (63%) diff --git a/common/cpp/react/renderer/components/rnscreens/ComponentDescriptors.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenComponentDescriptor.h similarity index 63% rename from common/cpp/react/renderer/components/rnscreens/ComponentDescriptors.h rename to common/cpp/react/renderer/components/rnscreens/RNSScreenComponentDescriptor.h index 333830fef7..0af0a94ff6 100644 --- a/common/cpp/react/renderer/components/rnscreens/ComponentDescriptors.h +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenComponentDescriptor.h @@ -7,14 +7,6 @@ namespace facebook { namespace react { -using RNSFullWindowOverlayComponentDescriptor = ConcreteComponentDescriptor; -using RNSScreenContainerComponentDescriptor = ConcreteComponentDescriptor; -using RNSScreenNavigationContainerComponentDescriptor = ConcreteComponentDescriptor; -using RNSScreenStackHeaderConfigComponentDescriptor = ConcreteComponentDescriptor; -using RNSScreenStackHeaderSubviewComponentDescriptor = ConcreteComponentDescriptor; -using RNSScreenStackComponentDescriptor = ConcreteComponentDescriptor; -using RNSSearchBarComponentDescriptor = ConcreteComponentDescriptor; - class RNSScreenComponentDescriptor final : public ConcreteComponentDescriptor { public: From de99905d8b4eec2d95af906fb6d925bb31636cfc Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Tue, 13 Sep 2022 22:55:48 +0200 Subject: [PATCH 16/35] chore: make main project use custom rnscreens.h file --- common/cpp/CMakeLists.txt | 18 ++++++++++++------ common/cpp/rnscreens.h | 3 +-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/common/cpp/CMakeLists.txt b/common/cpp/CMakeLists.txt index b8e1f35e19..b24751c5a8 100644 --- a/common/cpp/CMakeLists.txt +++ b/common/cpp/CMakeLists.txt @@ -5,11 +5,11 @@ set(RNS_GENERATED_DIR "/Users/kacperkafara/workspace/swm/kkafar@screens/android/ set(RNS_GENERATED_JNI_DIR ${RNS_GENERATED_DIR}/source/codegen/jni) set(RNS_GENERATED_REACT_DIR ${RNS_GENERATED_JNI_DIR}/react/renderer/components/rnscreens) -message(DEBUG "VARIABLES SET") -message(DEBUG "RNS_GENERATED_DIR ${RNS_GENERATED_DIR}") -message(DEBUG "RNS_GENERATED_JNI_DIR ${RNS_GENERATED_JNI_DIR}") -message(DEBUG "RNS_GENERATED_REACT_DIR ${RNS_GENERATED_REACT_DIR}") -message(DEBUG "PROJECT_SOURCE_DIR ${PROJECT_SOURCE_DIR}") +message(WARNING "VARIABLES SET") +message(WARNING "RNS_GENERATED_DIR ${RNS_GENERATED_DIR}") +message(WARNING "RNS_GENERATED_JNI_DIR ${RNS_GENERATED_JNI_DIR}") +message(WARNING "RNS_GENERATED_REACT_DIR ${RNS_GENERATED_REACT_DIR}") +message(WARNING "PROJECT_SOURCE_DIR ${PROJECT_SOURCE_DIR}") add_compile_options( -fexceptions @@ -23,7 +23,7 @@ add_compile_options( file(GLOB rnscreens_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/rnscreens/*.cpp) file(GLOB rnscreens_codegen_SRCS CONFIGURE_DEPENDS ${RNS_GENERATED_JNI_DIR}/*.cpp ${RNS_GENERATED_REACT_DIR}/*cpp) -message(DEBUG "SOURCES ${rnscreens_SRCS} ${rnscreens_codegen_SRCS}") +message(WARNING "SOURCES ${rnscreens_SRCS} ${rnscreens_codegen_SRCS}") add_library( react_codegen_rnscreens @@ -67,4 +67,10 @@ target_compile_options( -frtti -std=c++17 -Wall +) + +target_include_directories( + ${CMAKE_PROJECT_NAME} + PUBLIC + "/Users/kacperkafara/workspace/swm/kkafar@screens/common/cpp" ) \ No newline at end of file diff --git a/common/cpp/rnscreens.h b/common/cpp/rnscreens.h index 189975914a..a24ee9ff64 100644 --- a/common/cpp/rnscreens.h +++ b/common/cpp/rnscreens.h @@ -12,12 +12,11 @@ #include #include #include +#include "react/renderer/components/rnscreens/RNSScreenComponentDescriptor.h" namespace facebook { namespace react { - - JSI_EXPORT std::shared_ptr rnscreens_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms); From 449316f70c71d0aab5ffc0fe549d52ef553a2988 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Wed, 14 Sep 2022 13:48:38 +0200 Subject: [PATCH 17/35] chore: remove debug messages from cmakelists.txt --- common/cpp/CMakeLists.txt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/common/cpp/CMakeLists.txt b/common/cpp/CMakeLists.txt index b24751c5a8..a195be0250 100644 --- a/common/cpp/CMakeLists.txt +++ b/common/cpp/CMakeLists.txt @@ -5,12 +5,6 @@ set(RNS_GENERATED_DIR "/Users/kacperkafara/workspace/swm/kkafar@screens/android/ set(RNS_GENERATED_JNI_DIR ${RNS_GENERATED_DIR}/source/codegen/jni) set(RNS_GENERATED_REACT_DIR ${RNS_GENERATED_JNI_DIR}/react/renderer/components/rnscreens) -message(WARNING "VARIABLES SET") -message(WARNING "RNS_GENERATED_DIR ${RNS_GENERATED_DIR}") -message(WARNING "RNS_GENERATED_JNI_DIR ${RNS_GENERATED_JNI_DIR}") -message(WARNING "RNS_GENERATED_REACT_DIR ${RNS_GENERATED_REACT_DIR}") -message(WARNING "PROJECT_SOURCE_DIR ${PROJECT_SOURCE_DIR}") - add_compile_options( -fexceptions -frtti @@ -23,7 +17,6 @@ add_compile_options( file(GLOB rnscreens_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/rnscreens/*.cpp) file(GLOB rnscreens_codegen_SRCS CONFIGURE_DEPENDS ${RNS_GENERATED_JNI_DIR}/*.cpp ${RNS_GENERATED_REACT_DIR}/*cpp) -message(WARNING "SOURCES ${rnscreens_SRCS} ${rnscreens_codegen_SRCS}") add_library( react_codegen_rnscreens From 29bd6515e9b7998c058ca081a59fac2002f09b50 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Wed, 14 Sep 2022 13:57:25 +0200 Subject: [PATCH 18/35] chore: do not take rnscreens-generated.cpp source file --- common/cpp/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/cpp/CMakeLists.txt b/common/cpp/CMakeLists.txt index a195be0250..b96ecff53a 100644 --- a/common/cpp/CMakeLists.txt +++ b/common/cpp/CMakeLists.txt @@ -15,8 +15,7 @@ add_compile_options( ) file(GLOB rnscreens_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/rnscreens/*.cpp) -file(GLOB rnscreens_codegen_SRCS CONFIGURE_DEPENDS ${RNS_GENERATED_JNI_DIR}/*.cpp ${RNS_GENERATED_REACT_DIR}/*cpp) - +file(GLOB rnscreens_codegen_SRCS CONFIGURE_DEPENDS ${RNS_GENERATED_REACT_DIR}/*cpp) add_library( react_codegen_rnscreens From 8e011e7d6c68161674d16da7bc9f8a86feef850a Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Wed, 14 Sep 2022 13:58:34 +0200 Subject: [PATCH 19/35] chore: add common/cpp as include directory for application project IMPORTANT: this causes our custom `rnscreens.h` header to take precedence over its codegened counterpart when imported in following way in `rncli.cpp`: ```c++ ``` This is important beacuse it allows us to inject `RNSScreenComponentDescriptor` symbol into `rncli.cpp` translation unit scope. --- common/cpp/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/cpp/CMakeLists.txt b/common/cpp/CMakeLists.txt index b96ecff53a..c367ca3709 100644 --- a/common/cpp/CMakeLists.txt +++ b/common/cpp/CMakeLists.txt @@ -62,7 +62,7 @@ target_compile_options( ) target_include_directories( - ${CMAKE_PROJECT_NAME} - PUBLIC - "/Users/kacperkafara/workspace/swm/kkafar@screens/common/cpp" -) \ No newline at end of file + ${CMAKE_PROJECT_NAME} + PUBLIC + "/Users/kacperkafara/workspace/swm/kkafar@screens/common/cpp" +) From 81b86ad282ef75fdbbc290401eb7ecdc97f74910 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Wed, 14 Sep 2022 14:10:55 +0200 Subject: [PATCH 20/35] chore: do not manually load rnscreens_modules shared library We no longer build this target as we want to rely on new Android autolinking. --- .../rnscreens/RNScreensComponentsRegistry.java | 3 --- .../com/swmansion/rnscreens/RNScreensPackage.kt | 13 ++----------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/android/src/fabric/java/com/swmansion/rnscreens/RNScreensComponentsRegistry.java b/android/src/fabric/java/com/swmansion/rnscreens/RNScreensComponentsRegistry.java index 75a56ad784..f06d6d954a 100644 --- a/android/src/fabric/java/com/swmansion/rnscreens/RNScreensComponentsRegistry.java +++ b/android/src/fabric/java/com/swmansion/rnscreens/RNScreensComponentsRegistry.java @@ -7,9 +7,6 @@ @DoNotStrip public class RNScreensComponentsRegistry { - static { - SoLoader.loadLibrary("rnscreens_modules"); - } @DoNotStrip private final HybridData mHybridData; diff --git a/android/src/main/java/com/swmansion/rnscreens/RNScreensPackage.kt b/android/src/main/java/com/swmansion/rnscreens/RNScreensPackage.kt index d363350e5f..a13dd3ce28 100644 --- a/android/src/main/java/com/swmansion/rnscreens/RNScreensPackage.kt +++ b/android/src/main/java/com/swmansion/rnscreens/RNScreensPackage.kt @@ -4,19 +4,10 @@ import com.facebook.react.ReactPackage import com.facebook.react.bridge.NativeModule import com.facebook.react.bridge.ReactApplicationContext import com.facebook.react.uimanager.ViewManager -import com.facebook.soloader.SoLoader class RNScreensPackage : ReactPackage { - override fun createNativeModules(reactContext: ReactApplicationContext): List { - if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { - // For Fabric, we load c++ native library here, this triggers screen's Fabric - // component registration which is necessary in order to avoid asking users - // to manually add init calls in their application code. - // This should no longer be needed if RN's autolink mechanism has Fabric support - SoLoader.loadLibrary("rnscreens_modules") - } - return emptyList() - } + override fun createNativeModules(reactContext: ReactApplicationContext): List = + emptyList() override fun createViewManagers(reactContext: ReactApplicationContext) = listOf>( From 4b56ca798ff3cc9679ec7be02052de0ea6cc7800 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Wed, 14 Sep 2022 14:14:00 +0200 Subject: [PATCH 21/35] chore: remove all RNSScreen code that is & can be autogenerated by codegen --- .../rnscreens/RNSScreenEventEmitters.cpp | 80 --------- .../rnscreens/RNSScreenEventEmitters.h | 74 -------- .../components/rnscreens/RNSScreenProps.cpp | 47 ----- .../components/rnscreens/RNSScreenProps.h | 168 ------------------ 4 files changed, 369 deletions(-) delete mode 100644 common/cpp/react/renderer/components/rnscreens/RNSScreenEventEmitters.cpp delete mode 100644 common/cpp/react/renderer/components/rnscreens/RNSScreenEventEmitters.h delete mode 100644 common/cpp/react/renderer/components/rnscreens/RNSScreenProps.cpp delete mode 100644 common/cpp/react/renderer/components/rnscreens/RNSScreenProps.h diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenEventEmitters.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenEventEmitters.cpp deleted file mode 100644 index f7ef071247..0000000000 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenEventEmitters.cpp +++ /dev/null @@ -1,80 +0,0 @@ - -/** - * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). - * - * Do not edit this file as changes may cause incorrect behavior and will be lost - * once the code is regenerated. - * - * @generated by codegen project: GenerateEventEmitterCpp.js - */ - -#include - -namespace facebook { -namespace react { - - - -void RNSScreenEventEmitter::onAppear(OnAppear event) const { - dispatchEvent("appear", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - - return payload; - }); -} -void RNSScreenEventEmitter::onDisappear(OnDisappear event) const { - dispatchEvent("disappear", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - - return payload; - }); -} -void RNSScreenEventEmitter::onDismissed(OnDismissed event) const { - dispatchEvent("dismissed", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "dismissCount", event.dismissCount); - return payload; - }); -} -void RNSScreenEventEmitter::onNativeDismissCancelled(OnNativeDismissCancelled event) const { - dispatchEvent("nativeDismissCancelled", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "dismissCount", event.dismissCount); - return payload; - }); -} -void RNSScreenEventEmitter::onWillAppear(OnWillAppear event) const { - dispatchEvent("willAppear", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - - return payload; - }); -} -void RNSScreenEventEmitter::onWillDisappear(OnWillDisappear event) const { - dispatchEvent("willDisappear", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - - return payload; - }); -} -void RNSScreenEventEmitter::onTransitionProgress(OnTransitionProgress event) const { - dispatchEvent("transitionProgress", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - payload.setProperty(runtime, "progress", event.progress); -payload.setProperty(runtime, "closing", event.closing); -payload.setProperty(runtime, "goingForward", event.goingForward); - return payload; - }); -} -void RNSScreenEventEmitter::onHeaderBackButtonClicked(OnHeaderBackButtonClicked event) const { - dispatchEvent("headerBackButtonClicked", [event=std::move(event)](jsi::Runtime &runtime) { - auto payload = jsi::Object(runtime); - - return payload; - }); -} - - - -} // namespace react -} // namespace facebook diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenEventEmitters.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenEventEmitters.h deleted file mode 100644 index 857531999b..0000000000 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenEventEmitters.h +++ /dev/null @@ -1,74 +0,0 @@ - -/** - * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). - * - * Do not edit this file as changes may cause incorrect behavior and will be lost - * once the code is regenerated. - * - * @generated by codegen project: GenerateEventEmitterH.js - */ -#pragma once - -#include -#include - -namespace facebook { -namespace react { - -class JSI_EXPORT RNSScreenEventEmitter : public ViewEventEmitter { - public: - using ViewEventEmitter::ViewEventEmitter; - - struct OnAppear { - - }; - - struct OnDisappear { - - }; - - struct OnDismissed { - int dismissCount; - }; - - struct OnNativeDismissCancelled { - int dismissCount; - }; - - struct OnWillAppear { - - }; - - struct OnWillDisappear { - - }; - - struct OnTransitionProgress { - double progress; - int closing; - int goingForward; - }; - - struct OnHeaderBackButtonClicked { - - }; - - void onAppear(OnAppear value) const; - - void onDisappear(OnDisappear value) const; - - void onDismissed(OnDismissed value) const; - - void onNativeDismissCancelled(OnNativeDismissCancelled value) const; - - void onWillAppear(OnWillAppear value) const; - - void onWillDisappear(OnWillDisappear value) const; - - void onTransitionProgress(OnTransitionProgress value) const; - - void onHeaderBackButtonClicked(OnHeaderBackButtonClicked value) const; -}; - -} // namespace react -} // namespace facebook diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenProps.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenProps.cpp deleted file mode 100644 index 4835642f35..0000000000 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenProps.cpp +++ /dev/null @@ -1,47 +0,0 @@ - -/** - * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). - * - * Do not edit this file as changes may cause incorrect behavior and will be lost - * once the code is regenerated. - * - * @generated by codegen project: GeneratePropsCpp.js - */ - -#include -#include -#include - -namespace facebook { -namespace react { - -RNSScreenProps::RNSScreenProps( - const PropsParserContext &context, - const RNSScreenProps &sourceProps, - const RawProps &rawProps): ViewProps(context, sourceProps, rawProps), - - customAnimationOnSwipe(convertRawProp(context, rawProps, "customAnimationOnSwipe", sourceProps.customAnimationOnSwipe, {false})), - fullScreenSwipeEnabled(convertRawProp(context, rawProps, "fullScreenSwipeEnabled", sourceProps.fullScreenSwipeEnabled, {false})), - homeIndicatorHidden(convertRawProp(context, rawProps, "homeIndicatorHidden", sourceProps.homeIndicatorHidden, {false})), - preventNativeDismiss(convertRawProp(context, rawProps, "preventNativeDismiss", sourceProps.preventNativeDismiss, {false})), - gestureEnabled(convertRawProp(context, rawProps, "gestureEnabled", sourceProps.gestureEnabled, {true})), - statusBarColor(convertRawProp(context, rawProps, "statusBarColor", sourceProps.statusBarColor, {})), - statusBarHidden(convertRawProp(context, rawProps, "statusBarHidden", sourceProps.statusBarHidden, {false})), - screenOrientation(convertRawProp(context, rawProps, "screenOrientation", sourceProps.screenOrientation, {})), - statusBarAnimation(convertRawProp(context, rawProps, "statusBarAnimation", sourceProps.statusBarAnimation, {})), - statusBarStyle(convertRawProp(context, rawProps, "statusBarStyle", sourceProps.statusBarStyle, {})), - statusBarTranslucent(convertRawProp(context, rawProps, "statusBarTranslucent", sourceProps.statusBarTranslucent, {false})), - gestureResponseDistance(convertRawProp(context, rawProps, "gestureResponseDistance", sourceProps.gestureResponseDistance, {})), - stackPresentation(convertRawProp(context, rawProps, "stackPresentation", sourceProps.stackPresentation, {RNSScreenStackPresentation::Push})), - stackAnimation(convertRawProp(context, rawProps, "stackAnimation", sourceProps.stackAnimation, {RNSScreenStackAnimation::Default})), - transitionDuration(convertRawProp(context, rawProps, "transitionDuration", sourceProps.transitionDuration, {350})), - replaceAnimation(convertRawProp(context, rawProps, "replaceAnimation", sourceProps.replaceAnimation, {RNSScreenReplaceAnimation::Pop})), - swipeDirection(convertRawProp(context, rawProps, "swipeDirection", sourceProps.swipeDirection, {RNSScreenSwipeDirection::Horizontal})), - hideKeyboardOnSwipe(convertRawProp(context, rawProps, "hideKeyboardOnSwipe", sourceProps.hideKeyboardOnSwipe, {false})), - activityState(convertRawProp(context, rawProps, "activityState", sourceProps.activityState, {-1.0})), - navigationBarColor(convertRawProp(context, rawProps, "navigationBarColor", sourceProps.navigationBarColor, {})), - navigationBarHidden(convertRawProp(context, rawProps, "navigationBarHidden", sourceProps.navigationBarHidden, {false})), - nativeBackButtonDismissalEnabled(convertRawProp(context, rawProps, "nativeBackButtonDismissalEnabled", sourceProps.nativeBackButtonDismissalEnabled, {false})) - {} -} // namespace react -} // namespace facebook diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenProps.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenProps.h deleted file mode 100644 index 9dc11844d9..0000000000 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenProps.h +++ /dev/null @@ -1,168 +0,0 @@ - -/** - * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). - * - * Do not edit this file as changes may cause incorrect behavior and will be lost - * once the code is regenerated. - * - * @generated by codegen project: GeneratePropsH.js - */ -#pragma once - -#include -#include -#include -#include -#include - -namespace facebook { -namespace react { - -enum class RNSScreenStackPresentation { Push, Modal, TransparentModal, FullScreenModal, FormSheet, ContainedModal, ContainedTransparentModal }; - -static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNSScreenStackPresentation &result) { - auto string = (std::string)value; - if (string == "push") { result = RNSScreenStackPresentation::Push; return; } - if (string == "modal") { result = RNSScreenStackPresentation::Modal; return; } - if (string == "transparentModal") { result = RNSScreenStackPresentation::TransparentModal; return; } - if (string == "fullScreenModal") { result = RNSScreenStackPresentation::FullScreenModal; return; } - if (string == "formSheet") { result = RNSScreenStackPresentation::FormSheet; return; } - if (string == "containedModal") { result = RNSScreenStackPresentation::ContainedModal; return; } - if (string == "containedTransparentModal") { result = RNSScreenStackPresentation::ContainedTransparentModal; return; } - abort(); -} - -static inline std::string toString(const RNSScreenStackPresentation &value) { - switch (value) { - case RNSScreenStackPresentation::Push: return "push"; - case RNSScreenStackPresentation::Modal: return "modal"; - case RNSScreenStackPresentation::TransparentModal: return "transparentModal"; - case RNSScreenStackPresentation::FullScreenModal: return "fullScreenModal"; - case RNSScreenStackPresentation::FormSheet: return "formSheet"; - case RNSScreenStackPresentation::ContainedModal: return "containedModal"; - case RNSScreenStackPresentation::ContainedTransparentModal: return "containedTransparentModal"; - } -} -enum class RNSScreenStackAnimation { Default, Flip, Simple_push, None, Fade, Slide_from_right, Slide_from_left, Slide_from_bottom, Fade_from_bottom }; - -static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNSScreenStackAnimation &result) { - auto string = (std::string)value; - if (string == "default") { result = RNSScreenStackAnimation::Default; return; } - if (string == "flip") { result = RNSScreenStackAnimation::Flip; return; } - if (string == "simple_push") { result = RNSScreenStackAnimation::Simple_push; return; } - if (string == "none") { result = RNSScreenStackAnimation::None; return; } - if (string == "fade") { result = RNSScreenStackAnimation::Fade; return; } - if (string == "slide_from_right") { result = RNSScreenStackAnimation::Slide_from_right; return; } - if (string == "slide_from_left") { result = RNSScreenStackAnimation::Slide_from_left; return; } - if (string == "slide_from_bottom") { result = RNSScreenStackAnimation::Slide_from_bottom; return; } - if (string == "fade_from_bottom") { result = RNSScreenStackAnimation::Fade_from_bottom; return; } - abort(); -} - -static inline std::string toString(const RNSScreenStackAnimation &value) { - switch (value) { - case RNSScreenStackAnimation::Default: return "default"; - case RNSScreenStackAnimation::Flip: return "flip"; - case RNSScreenStackAnimation::Simple_push: return "simple_push"; - case RNSScreenStackAnimation::None: return "none"; - case RNSScreenStackAnimation::Fade: return "fade"; - case RNSScreenStackAnimation::Slide_from_right: return "slide_from_right"; - case RNSScreenStackAnimation::Slide_from_left: return "slide_from_left"; - case RNSScreenStackAnimation::Slide_from_bottom: return "slide_from_bottom"; - case RNSScreenStackAnimation::Fade_from_bottom: return "fade_from_bottom"; - } -} -enum class RNSScreenReplaceAnimation { Pop, Push }; - -static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNSScreenReplaceAnimation &result) { - auto string = (std::string)value; - if (string == "pop") { result = RNSScreenReplaceAnimation::Pop; return; } - if (string == "push") { result = RNSScreenReplaceAnimation::Push; return; } - abort(); -} - -static inline std::string toString(const RNSScreenReplaceAnimation &value) { - switch (value) { - case RNSScreenReplaceAnimation::Pop: return "pop"; - case RNSScreenReplaceAnimation::Push: return "push"; - } -} -enum class RNSScreenSwipeDirection { Vertical, Horizontal }; - -static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNSScreenSwipeDirection &result) { - auto string = (std::string)value; - if (string == "vertical") { result = RNSScreenSwipeDirection::Vertical; return; } - if (string == "horizontal") { result = RNSScreenSwipeDirection::Horizontal; return; } - abort(); -} - -static inline std::string toString(const RNSScreenSwipeDirection &value) { - switch (value) { - case RNSScreenSwipeDirection::Vertical: return "vertical"; - case RNSScreenSwipeDirection::Horizontal: return "horizontal"; - } -} -struct RNSScreenGestureResponseDistanceStruct { - Float start; - Float end; - Float top; - Float bottom; -}; - -static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, RNSScreenGestureResponseDistanceStruct &result) { - auto map = (butter::map)value; - - auto tmp_start = map.find("start"); - if (tmp_start != map.end()) { - fromRawValue(context, tmp_start->second, result.start); - } - auto tmp_end = map.find("end"); - if (tmp_end != map.end()) { - fromRawValue(context, tmp_end->second, result.end); - } - auto tmp_top = map.find("top"); - if (tmp_top != map.end()) { - fromRawValue(context, tmp_top->second, result.top); - } - auto tmp_bottom = map.find("bottom"); - if (tmp_bottom != map.end()) { - fromRawValue(context, tmp_bottom->second, result.bottom); - } -} - -static inline std::string toString(const RNSScreenGestureResponseDistanceStruct &value) { - return "[Object RNSScreenGestureResponseDistanceStruct]"; -} -class JSI_EXPORT RNSScreenProps final : public ViewProps { - public: - RNSScreenProps() = default; - RNSScreenProps(const PropsParserContext& context, const RNSScreenProps &sourceProps, const RawProps &rawProps); - -#pragma mark - Props - - bool customAnimationOnSwipe{false}; - bool fullScreenSwipeEnabled{false}; - bool homeIndicatorHidden{false}; - bool preventNativeDismiss{false}; - bool gestureEnabled{true}; - SharedColor statusBarColor{}; - bool statusBarHidden{false}; - std::string screenOrientation{}; - std::string statusBarAnimation{}; - std::string statusBarStyle{}; - bool statusBarTranslucent{false}; - RNSScreenGestureResponseDistanceStruct gestureResponseDistance{}; - RNSScreenStackPresentation stackPresentation{RNSScreenStackPresentation::Push}; - RNSScreenStackAnimation stackAnimation{RNSScreenStackAnimation::Default}; - int transitionDuration{350}; - RNSScreenReplaceAnimation replaceAnimation{RNSScreenReplaceAnimation::Pop}; - RNSScreenSwipeDirection swipeDirection{RNSScreenSwipeDirection::Horizontal}; - bool hideKeyboardOnSwipe{false}; - Float activityState{-1.0}; - SharedColor navigationBarColor{}; - bool navigationBarHidden{false}; - bool nativeBackButtonDismissalEnabled{false}; -}; - -} // namespace react -} // namespace facebook From 05de5a55aa6033050d71c5ee2f7dd5e3e0ff7959 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Wed, 14 Sep 2022 14:15:22 +0200 Subject: [PATCH 22/35] fix: enforce non-local visibility of getDynamic symbol of libreact_codegen_rnscreens.so library This symbol for some, unknown yet reason, is not visible during linking of lib.so (exactly during linking rncli.cpp.o file). We enforce desired visibility with compiler attributte. Note however that this solution should be only temporary as the exact reason should be tracked down and the issue shall be fixed with more generic approach. --- common/cpp/react/renderer/components/rnscreens/RNSScreenState.h | 1 + 1 file changed, 1 insertion(+) diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenState.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenState.h index d1a93d4717..1a8e9222fd 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenState.h +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenState.h @@ -32,6 +32,7 @@ class RNSScreenState final { const Size frameSize{}; #ifdef ANDROID + __attribute__((visibility("default"))) folly::dynamic getDynamic() const; MapBuffer getMapBuffer() const { return MapBufferBuilder::EMPTY(); From b573d775f651326adef829f6963f2e4ea0069768 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Wed, 14 Sep 2022 14:19:50 +0200 Subject: [PATCH 23/35] style: remove codegend comments & format cpp code --- common/cpp/rnscreens.cpp | 11 ----------- common/cpp/rnscreens.h | 9 --------- 2 files changed, 20 deletions(-) diff --git a/common/cpp/rnscreens.cpp b/common/cpp/rnscreens.cpp index 3e1acf9225..1e7b9a915d 100644 --- a/common/cpp/rnscreens.cpp +++ b/common/cpp/rnscreens.cpp @@ -1,21 +1,10 @@ -/** - * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). - * - * Do not edit this file as changes may cause incorrect behavior and will be lost - * once the code is regenerated. - * - * @generated by codegen project: GenerateModuleJniCpp.js - */ - #include "rnscreens.h" namespace facebook { namespace react { - std::shared_ptr rnscreens_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) { - return nullptr; } diff --git a/common/cpp/rnscreens.h b/common/cpp/rnscreens.h index a24ee9ff64..095efe0b5d 100644 --- a/common/cpp/rnscreens.h +++ b/common/cpp/rnscreens.h @@ -1,12 +1,3 @@ -/** - * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). - * - * Do not edit this file as changes may cause incorrect behavior and will be lost - * once the code is regenerated. - * - * @generated by codegen project: GenerateModuleJniH.js - */ - #pragma once #include From 7bd60c46db7fa46fa4f604bf9ba460c33ba50876 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Wed, 14 Sep 2022 14:20:51 +0200 Subject: [PATCH 24/35] chore: remove unused common/cpp/Android.mk file This file is not only no longer used, but also it does not contain valid configuration for our library. This file was replaced with common/cpp/CMakeLists.txt as we migrated to CMake build system. --- common/cpp/Android.mk | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 common/cpp/Android.mk diff --git a/common/cpp/Android.mk b/common/cpp/Android.mk deleted file mode 100644 index 454e4ff712..0000000000 --- a/common/cpp/Android.mk +++ /dev/null @@ -1,37 +0,0 @@ -SCREENS_COMMON_THIS_DIR := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_PATH := $(SCREENS_COMMON_THIS_DIR) -LOCAL_MODULE := rnscreens_common - -LOCAL_C_INCLUDES := $(LOCAL_PATH) $(GENERATED_SRC_DIR)/codegen/jni -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/**/*.cpp) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(GENERATED_SRC_DIR)/codegen/jni - -# Please note as one of the library listed is libreact_codegen_samplelibrary -# This name will be generated as libreact_codegen_ -# where is the one you specified in the Gradle configuration -LOCAL_SHARED_LIBRARIES := libjsi \ - libfbjni \ - libglog \ - libfolly_runtime \ - libyoga \ - libreact_nativemodule_core \ - libturbomodulejsijni \ - librrc_view \ - libreact_render_core \ - libreact_render_graphics \ - libfabricjni \ - libreact_debug \ - libreact_render_componentregistry \ - libreact_render_debug \ - libruntimeexecutor \ - libreact_codegen_rncore \ - libreact_codegen_rnscreens - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"ReactNative\" -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) From e2a4909d2f3012966c8d0c4be20b048491264377 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Wed, 14 Sep 2022 14:24:03 +0200 Subject: [PATCH 25/35] chore: update RNCLI configuration as common/cpp/Android.mk no longer exists --- react-native.config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/react-native.config.js b/react-native.config.js index 38719d83ee..bc691b0af9 100644 --- a/react-native.config.js +++ b/react-native.config.js @@ -12,7 +12,6 @@ module.exports = { "RNSSearchBarComponentDescriptor", 'RNSScreenComponentDescriptor' ], - androidMkPath: "../common/cpp/Android.mk", cmakeListsPath: "../common/cpp/CMakeLists.txt" }, }, From 007895b6fd447b685d3df61c8b1a13b108ca7bd8 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Thu, 15 Sep 2022 11:32:05 +0200 Subject: [PATCH 26/35] chore: generalise path resolution in CMake Up to this point, some paths were hardcoded, this is no longer the case. --- common/cpp/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/cpp/CMakeLists.txt b/common/cpp/CMakeLists.txt index c367ca3709..c4a2515817 100644 --- a/common/cpp/CMakeLists.txt +++ b/common/cpp/CMakeLists.txt @@ -1,7 +1,8 @@ cmake_minimum_required(VERSION 3.13) set(CMAKE_VERBOSE_MAKEFILE on) -set(RNS_GENERATED_DIR "/Users/kacperkafara/workspace/swm/kkafar@screens/android/build/generated") +set(RNS_ANDROID_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../android) +set(RNS_GENERATED_DIR ${RNS_ANDROID_DIR}/build/generated) set(RNS_GENERATED_JNI_DIR ${RNS_GENERATED_DIR}/source/codegen/jni) set(RNS_GENERATED_REACT_DIR ${RNS_GENERATED_JNI_DIR}/react/renderer/components/rnscreens) @@ -64,5 +65,5 @@ target_compile_options( target_include_directories( ${CMAKE_PROJECT_NAME} PUBLIC - "/Users/kacperkafara/workspace/swm/kkafar@screens/common/cpp" + ${CMAKE_CURRENT_SOURCE_DIR} ) From c94c6e85b3296170927fa5eb62d22d00600606f9 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Thu, 15 Sep 2022 15:51:25 +0200 Subject: [PATCH 27/35] fix: iOS build This is temporary workaround as `rnscreens.{h,cpp}` files are not part of common cpp code - they are android specific I believe. They must be moved to android JNI directory along with CMakeLists.txt --- RNScreens.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RNScreens.podspec b/RNScreens.podspec index 40101a2548..ed1aa0a5de 100644 --- a/RNScreens.podspec +++ b/RNScreens.podspec @@ -39,7 +39,7 @@ Pod::Spec.new do |s| s.dependency "ReactCommon/turbomodule/core" s.subspec "common" do |ss| - ss.source_files = "common/cpp/**/*.{cpp,h}" + ss.source_files = "common/cpp/react/**/*.{cpp,h}" ss.header_dir = "rnscreens" ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/common/cpp\"" } end From 5d4912cc5439bc61675617c1a0db1de6ed28d621 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Thu, 15 Sep 2022 16:13:12 +0200 Subject: [PATCH 28/35] chore: move Android specific configuration & cpp files to Android specific directory These files are not shared between iOS & Android platforms. --- RNScreens.podspec | 2 +- {common/cpp => android/src/main/jni}/CMakeLists.txt | 7 ++++--- {common/cpp => android/src/main/jni}/rnscreens.cpp | 0 {common/cpp => android/src/main/jni}/rnscreens.h | 2 +- react-native.config.js | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) rename {common/cpp => android/src/main/jni}/CMakeLists.txt (81%) rename {common/cpp => android/src/main/jni}/rnscreens.cpp (100%) rename {common/cpp => android/src/main/jni}/rnscreens.h (81%) diff --git a/RNScreens.podspec b/RNScreens.podspec index ed1aa0a5de..40101a2548 100644 --- a/RNScreens.podspec +++ b/RNScreens.podspec @@ -39,7 +39,7 @@ Pod::Spec.new do |s| s.dependency "ReactCommon/turbomodule/core" s.subspec "common" do |ss| - ss.source_files = "common/cpp/react/**/*.{cpp,h}" + ss.source_files = "common/cpp/**/*.{cpp,h}" ss.header_dir = "rnscreens" ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/common/cpp\"" } end diff --git a/common/cpp/CMakeLists.txt b/android/src/main/jni/CMakeLists.txt similarity index 81% rename from common/cpp/CMakeLists.txt rename to android/src/main/jni/CMakeLists.txt index c4a2515817..4f10aad885 100644 --- a/common/cpp/CMakeLists.txt +++ b/android/src/main/jni/CMakeLists.txt @@ -1,7 +1,8 @@ cmake_minimum_required(VERSION 3.13) set(CMAKE_VERBOSE_MAKEFILE on) -set(RNS_ANDROID_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../android) +set(RNS_ANDROID_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) +set(RNS_COMMON_DIR ${RNS_ANDROID_DIR}/../common/cpp) set(RNS_GENERATED_DIR ${RNS_ANDROID_DIR}/build/generated) set(RNS_GENERATED_JNI_DIR ${RNS_GENERATED_DIR}/source/codegen/jni) set(RNS_GENERATED_REACT_DIR ${RNS_GENERATED_JNI_DIR}/react/renderer/components/rnscreens) @@ -15,7 +16,7 @@ add_compile_options( -Wno-gnu-zero-variadic-macro-arguments ) -file(GLOB rnscreens_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/rnscreens/*.cpp) +file(GLOB rnscreens_SRCS CONFIGURE_DEPENDS *.cpp ${RNS_COMMON_DIR}/react/renderer/components/rnscreens/*.cpp) file(GLOB rnscreens_codegen_SRCS CONFIGURE_DEPENDS ${RNS_GENERATED_REACT_DIR}/*cpp) add_library( @@ -29,7 +30,7 @@ target_include_directories( react_codegen_rnscreens PUBLIC . - react/renderer/components/rnscreens + ${RNS_COMMON_DIR}/react/renderer/components/rnscreens ${RNS_GENERATED_JNI_DIR} ${RNS_GENERATED_REACT_DIR} ) diff --git a/common/cpp/rnscreens.cpp b/android/src/main/jni/rnscreens.cpp similarity index 100% rename from common/cpp/rnscreens.cpp rename to android/src/main/jni/rnscreens.cpp diff --git a/common/cpp/rnscreens.h b/android/src/main/jni/rnscreens.h similarity index 81% rename from common/cpp/rnscreens.h rename to android/src/main/jni/rnscreens.h index 095efe0b5d..da3aaf133e 100644 --- a/common/cpp/rnscreens.h +++ b/android/src/main/jni/rnscreens.h @@ -3,7 +3,7 @@ #include #include #include -#include "react/renderer/components/rnscreens/RNSScreenComponentDescriptor.h" +#include namespace facebook { namespace react { diff --git a/react-native.config.js b/react-native.config.js index bc691b0af9..969928780a 100644 --- a/react-native.config.js +++ b/react-native.config.js @@ -12,7 +12,7 @@ module.exports = { "RNSSearchBarComponentDescriptor", 'RNSScreenComponentDescriptor' ], - cmakeListsPath: "../common/cpp/CMakeLists.txt" + cmakeListsPath: "../android/src/main/jni/CMakeLists.txt" }, }, }, From 48630ecb2a574c5e5376cf8c0f2b945f3881421f Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Thu, 15 Sep 2022 16:26:49 +0200 Subject: [PATCH 29/35] fix: include path --- android/src/main/jni/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/jni/CMakeLists.txt b/android/src/main/jni/CMakeLists.txt index 4f10aad885..e9805ac0b1 100644 --- a/android/src/main/jni/CMakeLists.txt +++ b/android/src/main/jni/CMakeLists.txt @@ -30,7 +30,7 @@ target_include_directories( react_codegen_rnscreens PUBLIC . - ${RNS_COMMON_DIR}/react/renderer/components/rnscreens + ${RNS_COMMON_DIR} ${RNS_GENERATED_JNI_DIR} ${RNS_GENERATED_REACT_DIR} ) From 2cfe611a7fc27467286f2733ea1f3a87d1958dcf Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Fri, 16 Sep 2022 14:23:59 +0200 Subject: [PATCH 30/35] chore: use JSI_EXPORT macro instead of setting compiler attribute explicitly This is better as it also handles Windows C++ compilers. --- .../cpp/react/renderer/components/rnscreens/RNSScreenState.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenState.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenState.h index 1a8e9222fd..8d1641c2e5 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenState.h +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenState.h @@ -13,7 +13,7 @@ namespace facebook { namespace react { -class RNSScreenState final { +class JSI_EXPORT RNSScreenState final { public: using Shared = std::shared_ptr; @@ -32,7 +32,6 @@ class RNSScreenState final { const Size frameSize{}; #ifdef ANDROID - __attribute__((visibility("default"))) folly::dynamic getDynamic() const; MapBuffer getMapBuffer() const { return MapBufferBuilder::EMPTY(); From 8ce7490631c62a489487f48e72824dbe8ff83622 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Fri, 16 Sep 2022 14:29:03 +0200 Subject: [PATCH 31/35] style: remove trailing whitespace --- .../components/rnscreens/RNSScreenComponentDescriptor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenComponentDescriptor.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenComponentDescriptor.h index 0af0a94ff6..40a3c0ad57 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenComponentDescriptor.h +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenComponentDescriptor.h @@ -6,7 +6,7 @@ namespace facebook { namespace react { - + class RNSScreenComponentDescriptor final : public ConcreteComponentDescriptor { public: From 0d9f573eb2d6a133ba0b505032d9643476695a05 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Fri, 16 Sep 2022 14:35:43 +0200 Subject: [PATCH 32/35] fix: add mising dot in glob pattern for cpp sources --- android/src/main/jni/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/jni/CMakeLists.txt b/android/src/main/jni/CMakeLists.txt index e9805ac0b1..63f5b39e1c 100644 --- a/android/src/main/jni/CMakeLists.txt +++ b/android/src/main/jni/CMakeLists.txt @@ -17,7 +17,7 @@ add_compile_options( ) file(GLOB rnscreens_SRCS CONFIGURE_DEPENDS *.cpp ${RNS_COMMON_DIR}/react/renderer/components/rnscreens/*.cpp) -file(GLOB rnscreens_codegen_SRCS CONFIGURE_DEPENDS ${RNS_GENERATED_REACT_DIR}/*cpp) +file(GLOB rnscreens_codegen_SRCS CONFIGURE_DEPENDS ${RNS_GENERATED_REACT_DIR}/*.cpp) add_library( react_codegen_rnscreens From 213e59226c5d93ea2f1de078f3836072e3ea6ae1 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Fri, 16 Sep 2022 14:36:40 +0200 Subject: [PATCH 33/35] style: use uppercase for CMake constants --- android/src/main/jni/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/jni/CMakeLists.txt b/android/src/main/jni/CMakeLists.txt index 63f5b39e1c..d2a544301d 100644 --- a/android/src/main/jni/CMakeLists.txt +++ b/android/src/main/jni/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.13) -set(CMAKE_VERBOSE_MAKEFILE on) +set(CMAKE_VERBOSE_MAKEFILE ON) set(RNS_ANDROID_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) set(RNS_COMMON_DIR ${RNS_ANDROID_DIR}/../common/cpp) From 9c00515e39d09543920c0abd13e3a81fc9ff7ce5 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Fri, 16 Sep 2022 14:46:33 +0200 Subject: [PATCH 34/35] chore: parametrize library target name in cmake --- android/src/main/jni/CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/android/src/main/jni/CMakeLists.txt b/android/src/main/jni/CMakeLists.txt index d2a544301d..d7715e6b43 100644 --- a/android/src/main/jni/CMakeLists.txt +++ b/android/src/main/jni/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required(VERSION 3.13) set(CMAKE_VERBOSE_MAKEFILE ON) +set(LIB_LITERAL rnscreens) +set(LIB_TARGET_NAME react_codegen_${LIB_LITERAL}) + set(RNS_ANDROID_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) set(RNS_COMMON_DIR ${RNS_ANDROID_DIR}/../common/cpp) set(RNS_GENERATED_DIR ${RNS_ANDROID_DIR}/build/generated) @@ -20,14 +23,14 @@ file(GLOB rnscreens_SRCS CONFIGURE_DEPENDS *.cpp ${RNS_COMMON_DIR}/react/rendere file(GLOB rnscreens_codegen_SRCS CONFIGURE_DEPENDS ${RNS_GENERATED_REACT_DIR}/*.cpp) add_library( - react_codegen_rnscreens + ${LIB_TARGET_NAME} SHARED ${rnscreens_SRCS} ${rnscreens_codegen_SRCS} ) target_include_directories( - react_codegen_rnscreens + ${LIB_TARGET_NAME} PUBLIC . ${RNS_COMMON_DIR} @@ -36,7 +39,7 @@ target_include_directories( ) target_link_libraries( - react_codegen_rnscreens + ${LIB_TARGET_NAME} fbjni folly_runtime glog @@ -54,7 +57,7 @@ target_link_libraries( ) target_compile_options( - react_codegen_rnscreens + ${LIB_TARGET_NAME} PRIVATE -DLOG_TAG=\"ReactNative\" -fexceptions From 3afe846fc22888b9ab5df24d7347d7ad8c941f99 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Fri, 16 Sep 2022 14:57:48 +0200 Subject: [PATCH 35/35] refact: generalize variable names --- android/src/main/jni/CMakeLists.txt | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/android/src/main/jni/CMakeLists.txt b/android/src/main/jni/CMakeLists.txt index d7715e6b43..3b388b4d99 100644 --- a/android/src/main/jni/CMakeLists.txt +++ b/android/src/main/jni/CMakeLists.txt @@ -4,11 +4,10 @@ set(CMAKE_VERBOSE_MAKEFILE ON) set(LIB_LITERAL rnscreens) set(LIB_TARGET_NAME react_codegen_${LIB_LITERAL}) -set(RNS_ANDROID_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) -set(RNS_COMMON_DIR ${RNS_ANDROID_DIR}/../common/cpp) -set(RNS_GENERATED_DIR ${RNS_ANDROID_DIR}/build/generated) -set(RNS_GENERATED_JNI_DIR ${RNS_GENERATED_DIR}/source/codegen/jni) -set(RNS_GENERATED_REACT_DIR ${RNS_GENERATED_JNI_DIR}/react/renderer/components/rnscreens) +set(LIB_ANDROID_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) +set(LIB_COMMON_DIR ${LIB_ANDROID_DIR}/../common/cpp) +set(LIB_ANDROID_GENERATED_JNI_DIR ${LIB_ANDROID_DIR}/build/generated/source/codegen/jni) +set(LIB_ANDROID_GENERATED_COMPONENTS_DIR ${LIB_ANDROID_GENERATED_JNI_DIR}/react/renderer/components/${LIB_LITERAL}) add_compile_options( -fexceptions @@ -19,23 +18,23 @@ add_compile_options( -Wno-gnu-zero-variadic-macro-arguments ) -file(GLOB rnscreens_SRCS CONFIGURE_DEPENDS *.cpp ${RNS_COMMON_DIR}/react/renderer/components/rnscreens/*.cpp) -file(GLOB rnscreens_codegen_SRCS CONFIGURE_DEPENDS ${RNS_GENERATED_REACT_DIR}/*.cpp) +file(GLOB LIB_CUSTOM_SRCS CONFIGURE_DEPENDS *.cpp ${LIB_COMMON_DIR}/react/renderer/components/${LIB_LITERAL}/*.cpp) +file(GLOB LIB_CODEGEN_SRCS CONFIGURE_DEPENDS ${LIB_ANDROID_GENERATED_COMPONENTS_DIR}/*.cpp) add_library( ${LIB_TARGET_NAME} SHARED - ${rnscreens_SRCS} - ${rnscreens_codegen_SRCS} + ${LIB_CUSTOM_SRCS} + ${LIB_CODEGEN_SRCS} ) target_include_directories( ${LIB_TARGET_NAME} PUBLIC . - ${RNS_COMMON_DIR} - ${RNS_GENERATED_JNI_DIR} - ${RNS_GENERATED_REACT_DIR} + ${LIB_COMMON_DIR} + ${LIB_ANDROID_GENERATED_JNI_DIR} + ${LIB_ANDROID_GENERATED_COMPONENTS_DIR} ) target_link_libraries(