@@ -53,47 +53,13 @@ class ViewProperty {
5353
5454 template <typename PlatformContext>
5555 ViewProperty (jsi::Runtime &runtime, const jsi::Value &value,
56- PlatformContext platformContext, size_t nativeId) {
57- // Set the onSize callback with all the necessary context
58- auto runtimeGuard = std::make_shared<RuntimeAwareRuntimeGuard>(runtime);
59- _value = std::function<void (int , int )>(
60- [runtimeGuard, platformContext, nativeId](int width, int height) {
61- auto runtimePtr = runtimeGuard->getRuntime ();
62- if (runtimePtr == nullptr ) {
63- return ;
64- }
65-
66- jsi::Runtime &runtime = *runtimePtr;
67- jsi::Object size (runtime);
68- auto pd = platformContext->getPixelDensity ();
69- size.setProperty (runtime, " width" , jsi::Value (width / pd));
70- size.setProperty (runtime, " height" , jsi::Value (height / pd));
71-
72- // Get the stored shared value from global
73- std::string globalKey =
74- " __onSize_" + std::to_string (static_cast <int >(nativeId));
75- auto globalProp =
76- runtime.global ().getProperty (runtime, globalKey.c_str ());
77- if (!globalProp.isUndefined ()) {
78- globalProp.asObject (runtime).setProperty (runtime, " value" , size);
79- }
80- });
81- }
56+ PlatformContext platformContext, size_t nativeId) {}
8257
8358 bool isNull () { return std::holds_alternative<std::nullptr_t >(_value); }
8459
8560 sk_sp<SkPicture> getPicture () { return std::get<sk_sp<SkPicture>>(_value); }
8661
87- std::variant<std::nullptr_t , std::function<void (int , int )>>
88- getOnSize () const {
89- if (std::holds_alternative<std::function<void (int , int )>>(_value)) {
90- return std::get<std::function<void (int , int )>>(_value);
91- }
92- return nullptr ;
93- }
94-
9562private:
96- std::variant<std::nullptr_t , sk_sp<SkPicture>, std::function<void (int , int )>>
97- _value = nullptr ;
63+ std::variant<std::nullptr_t , sk_sp<SkPicture>> _value = nullptr ;
9864};
9965} // namespace RNJsi
0 commit comments