diff --git a/Common/cpp/TurboModule/REATurboCppModule.cpp b/Common/cpp/TurboModule/REATurboCppModule.cpp new file mode 100644 index 00000000000..d4b68bf7c46 --- /dev/null +++ b/Common/cpp/TurboModule/REATurboCppModule.cpp @@ -0,0 +1,25 @@ +#include "REATurboCppModule.h" +#include "NativeProxy.h" + +namespace facebook::react { + +REATurboCppModule::REATurboCppModule(std::shared_ptr jsInvoker) + : NativeREATurboCppModuleCxxSpec(std::move(jsInvoker)) {} + +bool REATurboCppModule::installBridgeless(jsi::Runtime& rt, jsi::String valueUnpackerCode) { + reanimated::bridgelessRnRuntime = &rt; + reanimated::bridgelessCallInvoker = jsInvoker_; +// RCTExecuteOnMainQueue(^{ + // id appDelegate = [[UIApplication sharedApplication] delegate]; + // RCTModuleRegistry *moduleRegistry = + // (RCTModuleRegistry *)[[appDelegate valueForKey:@"_reactHost"] valueForKey:@"_moduleRegistry"]; + // if (moduleRegistry) { + // REAModule *reaModule = [moduleRegistry moduleForName:"ReanimatedModule"]; + // [reaModule installBridgelessWithRuntime:&rt jsCallInvoker:jsInvoker_ valueUnpackerCode:std::move(valueUnpackerCode)]; + // } +// }); +// return YES; + return true; +} + +} // namespace facebook::react diff --git a/Common/cpp/TurboModule/REATurboCppModule.h b/Common/cpp/TurboModule/REATurboCppModule.h new file mode 100644 index 00000000000..5c14afb5384 --- /dev/null +++ b/Common/cpp/TurboModule/REATurboCppModule.h @@ -0,0 +1,22 @@ +#pragma once + +#if __has_include( \ + ) // CocoaPod headers on Apple +#include +#elif __has_include("rnreanimatedJSI.h") // CMake headers on Android +#include "rnreanimatedJSI.h" +#endif +#include +#include + +namespace facebook::react { + +class REATurboCppModule + : public NativeREATurboCppModuleCxxSpec { + public: + explicit REATurboCppModule(std::shared_ptr jsInvoker); + + bool installBridgeless(jsi::Runtime &rt, jsi::String valueUnpackerCode); +}; + +} // namespace facebook::react diff --git a/Common/cpp/TurboModule/REATurboCppModule.mm b/Common/cpp/TurboModule/REATurboCppModule.mm new file mode 100644 index 00000000000..7bfc7ef6392 --- /dev/null +++ b/Common/cpp/TurboModule/REATurboCppModule.mm @@ -0,0 +1,23 @@ +#include "REATurboCppModule.h" + + #include + +namespace facebook::react { + +REATurboCppModule::REATurboCppModule(std::shared_ptr jsInvoker) + : NativeREATurboCppModuleCxxSpec(std::move(jsInvoker)) {} + +bool REATurboCppModule::installBridgeless(jsi::Runtime& rt, jsi::String valueUnpackerCode) { +// RCTExecuteOnMainQueue(^{ + id appDelegate = [[UIApplication sharedApplication] delegate]; + RCTModuleRegistry *moduleRegistry = + (RCTModuleRegistry *)[[appDelegate valueForKey:@"_reactHost"] valueForKey:@"_moduleRegistry"]; + if (moduleRegistry) { + REAModule *reaModule = [moduleRegistry moduleForName:"ReanimatedModule"]; + [reaModule installBridgelessWithRuntime:&rt jsCallInvoker:jsInvoker_ valueUnpackerCode:std::move(valueUnpackerCode)]; + } +// }); + return YES; +} + +} // namespace facebook::react diff --git a/FabricExample/App.tsx b/FabricExample/App.tsx index 6d539778589..1606027b965 100644 --- a/FabricExample/App.tsx +++ b/FabricExample/App.tsx @@ -1,3 +1,48 @@ -import App from '../app'; +import Animated, { + useSharedValue, + withTiming, + useAnimatedStyle, + Easing, +} from 'react-native-reanimated'; +import {View, Button, StyleSheet} from 'react-native'; +import React from 'react'; -export default App; +export default function AnimatedStyleUpdateExample() { + const randomWidth = useSharedValue(10); + + const config = { + duration: 500, + easing: Easing.bezierFn(0.5, 0.01, 0, 1), + }; + + const style = useAnimatedStyle(() => { + return { + width: withTiming(randomWidth.value, config), + }; + }); + + return ( + + +