diff --git a/packages/react-native/ReactCxxPlatform/react/coremodules/AppStateModule.cpp b/packages/react-native/ReactCxxPlatform/react/coremodules/AppStateModule.cpp new file mode 100644 index 00000000000..9b940006362 --- /dev/null +++ b/packages/react-native/ReactCxxPlatform/react/coremodules/AppStateModule.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#include "AppStateModule.h" + +namespace facebook::react { + +AppStateConstants AppStateModule::getConstants(jsi::Runtime& /*rt*/) { + // TODO: T160890586 Wire up AppState implementation to use real data + return AppStateConstants{.initialAppState = ""}; +} + +void AppStateModule::getCurrentAppState( + jsi::Runtime& /*rt*/, + const AsyncCallback& /*success*/, + jsi::Function /*error*/) {} + +void AppStateModule::addListener( + jsi::Runtime& /*rt*/, + const std::string& /*eventName*/) {} + +void AppStateModule::removeListeners(jsi::Runtime& /*rt*/, double /*count*/) {} + +} // namespace facebook::react diff --git a/packages/react-native/ReactCxxPlatform/react/coremodules/AppStateModule.h b/packages/react-native/ReactCxxPlatform/react/coremodules/AppStateModule.h new file mode 100644 index 00000000000..c682ec2439e --- /dev/null +++ b/packages/react-native/ReactCxxPlatform/react/coremodules/AppStateModule.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include +#include +#include + +namespace facebook::react { + +using AppStateConstants = NativeAppStateAppStateConstants; + +template <> +struct Bridging + : NativeAppStateAppStateConstantsBridging {}; + +using AppState = NativeAppStateAppState; + +template <> +struct Bridging : NativeAppStateAppStateBridging {}; + +class AppStateModule : public NativeAppStateCxxSpec { + public: + explicit AppStateModule(std::shared_ptr jsInvoker) + : NativeAppStateCxxSpec(jsInvoker) {} + + AppStateConstants getConstants(jsi::Runtime& rt); + + void getCurrentAppState( + jsi::Runtime& rt, + const AsyncCallback& success, + jsi::Function error); + void addListener(jsi::Runtime& rt, const std::string& eventName); + + void removeListeners(jsi::Runtime& rt, double count); +}; + +} // namespace facebook::react diff --git a/packages/react-native/ReactCxxPlatform/react/coremodules/DeviceInfoModule.cpp b/packages/react-native/ReactCxxPlatform/react/coremodules/DeviceInfoModule.cpp new file mode 100644 index 00000000000..fd53acc0d79 --- /dev/null +++ b/packages/react-native/ReactCxxPlatform/react/coremodules/DeviceInfoModule.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#include "DeviceInfoModule.h" + +namespace facebook::react { + +DeviceInfoConstants DeviceInfoModule::getConstants(jsi::Runtime& /*rt*/) { + // TODO: Wire this to come from the actual app + // size (T161837708) + return DeviceInfoConstants{ + .Dimensions = + {.window = + DisplayMetrics{ + 1280, + 720, + }}, + }; +} + +} // namespace facebook::react diff --git a/packages/react-native/ReactCxxPlatform/react/coremodules/DeviceInfoModule.h b/packages/react-native/ReactCxxPlatform/react/coremodules/DeviceInfoModule.h new file mode 100644 index 00000000000..73775536972 --- /dev/null +++ b/packages/react-native/ReactCxxPlatform/react/coremodules/DeviceInfoModule.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include +#include + +namespace facebook::react { + +using DisplayMetrics = + NativeDeviceInfoDisplayMetrics; + +using DisplayMetricsAndroid = NativeDeviceInfoDisplayMetricsAndroid< + double, + double, + double, + double, + double>; + +using DimensionsPayload = NativeDeviceInfoDimensionsPayload< + std::optional, + std::optional, + std::optional, + std::optional>; + +using DeviceInfoConstants = + NativeDeviceInfoDeviceInfoConstants>; + +template <> +struct Bridging + : NativeDeviceInfoDisplayMetricsBridging {}; + +template <> +struct Bridging + : NativeDeviceInfoDisplayMetricsAndroidBridging {}; + +template <> +struct Bridging + : NativeDeviceInfoDimensionsPayloadBridging {}; + +template <> +struct Bridging + : NativeDeviceInfoDeviceInfoConstantsBridging {}; + +class DeviceInfoModule : public NativeDeviceInfoCxxSpec { + public: + explicit DeviceInfoModule(std::shared_ptr jsInvoker) + : NativeDeviceInfoCxxSpec(jsInvoker) {} + + DeviceInfoConstants getConstants(jsi::Runtime& rt); +}; + +} // namespace facebook::react diff --git a/packages/react-native/ReactCxxPlatform/react/coremodules/PlatformConstantsModule.cpp b/packages/react-native/ReactCxxPlatform/react/coremodules/PlatformConstantsModule.cpp new file mode 100644 index 00000000000..5182e167ee0 --- /dev/null +++ b/packages/react-native/ReactCxxPlatform/react/coremodules/PlatformConstantsModule.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#include "PlatformConstantsModule.h" + +namespace facebook::react { + +PlatformConstantsAndroid PlatformConstantsModule::getConstants( + jsi::Runtime& /*rt*/) { + return PlatformConstantsAndroid{ + .isTesting = false, + .isDisableAnimations = false, + .reactNativeVersion = + { + .major = 1000, + .minor = 0, + .patch = 0, + .prerelease = std::nullopt, + }, + .Version = 33, // Android 13 (API level 33) + .Release = "", + .Fingerprint = "", + .Model = "", + .ServerHost = "", + .uiMode = "", + .Brand = "", + .Manufacturer = "", + }; +} + +} // namespace facebook::react diff --git a/packages/react-native/ReactCxxPlatform/react/coremodules/PlatformConstantsModule.h b/packages/react-native/ReactCxxPlatform/react/coremodules/PlatformConstantsModule.h new file mode 100644 index 00000000000..04470366940 --- /dev/null +++ b/packages/react-native/ReactCxxPlatform/react/coremodules/PlatformConstantsModule.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include +#include + +namespace facebook::react { + +using ReactNativeVersionAndroid = + NativePlatformConstantsAndroidReactNativeVersionAndroid< + int, + int, + int, + std::optional>; + +template <> +struct Bridging + : NativePlatformConstantsAndroidReactNativeVersionAndroidBridging< + ReactNativeVersionAndroid> {}; + +using PlatformConstantsAndroid = + NativePlatformConstantsAndroidPlatformConstantsAndroid< + bool, + std::optional, + ReactNativeVersionAndroid, + int, + std::string, + std::string, + std::string, + std::string, + std::optional, + std::string, + std::string, + std::string>; + +template <> +struct Bridging + : NativePlatformConstantsAndroidPlatformConstantsAndroidBridging< + PlatformConstantsAndroid> {}; + +// T159303412: [RN] Metro: Need support for new target platform +class PlatformConstantsModule + : public NativePlatformConstantsAndroidCxxSpec { + public: + explicit PlatformConstantsModule(std::shared_ptr jsInvoker) + : NativePlatformConstantsAndroidCxxSpec(jsInvoker) {} + + std::string getAndroidID(jsi::Runtime& /*rt*/) { + return ""; + } + + PlatformConstantsAndroid getConstants(jsi::Runtime& rt); +}; + +} // namespace facebook::react