@onekeyfe/react-native-scroll-guard 3.0.81 → 3.0.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/nitrogen/generated/android/c++/JHybridScrollGuardSpec.cpp +22 -21
- package/lib/nitrogen/generated/android/c++/JHybridScrollGuardSpec.hpp +20 -22
- package/lib/nitrogen/generated/android/c++/JScrollGuardDirection.hpp +5 -6
- package/lib/nitrogen/generated/android/c++/views/JHybridScrollGuardStateUpdater.cpp +17 -17
- package/lib/nitrogen/generated/android/c++/views/JHybridScrollGuardStateUpdater.hpp +4 -4
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/HybridScrollGuardSpec.kt +17 -19
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/ScrollGuardDirection.kt +3 -1
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/scrollguardOnLoad.kt +1 -1
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/views/HybridScrollGuardManager.kt +40 -10
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/views/HybridScrollGuardStateUpdater.kt +1 -1
- package/lib/nitrogen/generated/android/scrollguard+autolinking.cmake +1 -1
- package/lib/nitrogen/generated/android/scrollguard+autolinking.gradle +1 -1
- package/lib/nitrogen/generated/android/scrollguardOnLoad.cpp +28 -18
- package/lib/nitrogen/generated/android/scrollguardOnLoad.hpp +14 -5
- package/lib/nitrogen/generated/ios/ScrollGuard+autolinking.rb +2 -2
- package/lib/nitrogen/generated/ios/ScrollGuard-Swift-Cxx-Bridge.cpp +1 -1
- package/lib/nitrogen/generated/ios/ScrollGuard-Swift-Cxx-Bridge.hpp +2 -2
- package/lib/nitrogen/generated/ios/ScrollGuard-Swift-Cxx-Umbrella.hpp +1 -1
- package/lib/nitrogen/generated/ios/ScrollGuardAutolinking.mm +1 -1
- package/lib/nitrogen/generated/ios/ScrollGuardAutolinking.swift +9 -8
- package/lib/nitrogen/generated/ios/c++/HybridScrollGuardSpecSwift.cpp +1 -1
- package/lib/nitrogen/generated/ios/c++/HybridScrollGuardSpecSwift.hpp +7 -1
- package/lib/nitrogen/generated/ios/c++/views/HybridScrollGuardComponent.mm +27 -1
- package/lib/nitrogen/generated/ios/swift/HybridScrollGuardSpec.swift +3 -4
- package/lib/nitrogen/generated/ios/swift/HybridScrollGuardSpec_cxx.swift +18 -2
- package/lib/nitrogen/generated/ios/swift/ScrollGuardDirection.swift +1 -1
- package/lib/nitrogen/generated/shared/c++/HybridScrollGuardSpec.cpp +1 -1
- package/lib/nitrogen/generated/shared/c++/HybridScrollGuardSpec.hpp +1 -1
- package/lib/nitrogen/generated/shared/c++/ScrollGuardDirection.hpp +1 -1
- package/lib/nitrogen/generated/shared/c++/views/HybridScrollGuardComponent.cpp +7 -11
- package/lib/nitrogen/generated/shared/c++/views/HybridScrollGuardComponent.hpp +9 -6
- package/nitrogen/generated/android/c++/JHybridScrollGuardSpec.cpp +22 -21
- package/nitrogen/generated/android/c++/JHybridScrollGuardSpec.hpp +20 -22
- package/nitrogen/generated/android/c++/JScrollGuardDirection.hpp +5 -6
- package/nitrogen/generated/android/c++/views/JHybridScrollGuardStateUpdater.cpp +17 -17
- package/nitrogen/generated/android/c++/views/JHybridScrollGuardStateUpdater.hpp +4 -4
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/HybridScrollGuardSpec.kt +17 -19
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/ScrollGuardDirection.kt +3 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/scrollguardOnLoad.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/views/HybridScrollGuardManager.kt +40 -10
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/views/HybridScrollGuardStateUpdater.kt +1 -1
- package/nitrogen/generated/android/scrollguard+autolinking.cmake +1 -1
- package/nitrogen/generated/android/scrollguard+autolinking.gradle +1 -1
- package/nitrogen/generated/android/scrollguardOnLoad.cpp +28 -18
- package/nitrogen/generated/android/scrollguardOnLoad.hpp +14 -5
- package/nitrogen/generated/ios/ScrollGuard+autolinking.rb +2 -2
- package/nitrogen/generated/ios/ScrollGuard-Swift-Cxx-Bridge.cpp +1 -1
- package/nitrogen/generated/ios/ScrollGuard-Swift-Cxx-Bridge.hpp +2 -2
- package/nitrogen/generated/ios/ScrollGuard-Swift-Cxx-Umbrella.hpp +1 -1
- package/nitrogen/generated/ios/ScrollGuardAutolinking.mm +1 -1
- package/nitrogen/generated/ios/ScrollGuardAutolinking.swift +9 -8
- package/nitrogen/generated/ios/c++/HybridScrollGuardSpecSwift.cpp +1 -1
- package/nitrogen/generated/ios/c++/HybridScrollGuardSpecSwift.hpp +7 -1
- package/nitrogen/generated/ios/c++/views/HybridScrollGuardComponent.mm +27 -1
- package/nitrogen/generated/ios/swift/HybridScrollGuardSpec.swift +3 -4
- package/nitrogen/generated/ios/swift/HybridScrollGuardSpec_cxx.swift +18 -2
- package/nitrogen/generated/ios/swift/ScrollGuardDirection.swift +1 -1
- package/nitrogen/generated/shared/c++/HybridScrollGuardSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridScrollGuardSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/ScrollGuardDirection.hpp +1 -1
- package/nitrogen/generated/shared/c++/views/HybridScrollGuardComponent.cpp +7 -11
- package/nitrogen/generated/shared/c++/views/HybridScrollGuardComponent.hpp +9 -6
- package/package.json +4 -4
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// ScrollGuardAutolinking.mm
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#import <Foundation/Foundation.h>
|
|
@@ -2,19 +2,16 @@
|
|
|
2
2
|
/// ScrollGuardAutolinking.swift
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
// TODO: Use empty enums once Swift supports exporting them as namespaces
|
|
11
|
+
// See: https://github.com/swiftlang/swift/pull/83616
|
|
8
12
|
public final class ScrollGuardAutolinking {
|
|
9
13
|
public typealias bridge = margelo.nitro.scrollguard.bridge.swift
|
|
10
14
|
|
|
11
|
-
/**
|
|
12
|
-
* Creates an instance of a Swift class that implements `HybridScrollGuardSpec`,
|
|
13
|
-
* and wraps it in a Swift class that can directly interop with C++ (`HybridScrollGuardSpec_cxx`)
|
|
14
|
-
*
|
|
15
|
-
* This is generated by Nitrogen and will initialize the class specified
|
|
16
|
-
* in the `"autolinking"` property of `nitro.json` (in this case, `HybridScrollGuard`).
|
|
17
|
-
*/
|
|
18
15
|
public static func createScrollGuard() -> bridge.std__shared_ptr_HybridScrollGuardSpec_ {
|
|
19
16
|
let hybridObject = HybridScrollGuard()
|
|
20
17
|
return { () -> bridge.std__shared_ptr_HybridScrollGuardSpec_ in
|
|
@@ -22,4 +19,8 @@ public final class ScrollGuardAutolinking {
|
|
|
22
19
|
return __cxxWrapped.getCxxPart()
|
|
23
20
|
}()
|
|
24
21
|
}
|
|
22
|
+
|
|
23
|
+
public static func isScrollGuardRecyclable() -> Bool {
|
|
24
|
+
return HybridScrollGuard.self is any RecyclableView.Type
|
|
25
|
+
}
|
|
25
26
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// HybridScrollGuardSpecSwift.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include "HybridScrollGuardSpecSwift.hpp"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// HybridScrollGuardSpecSwift.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
@@ -49,6 +49,12 @@ namespace margelo::nitro::scrollguard {
|
|
|
49
49
|
inline size_t getExternalMemorySize() noexcept override {
|
|
50
50
|
return _swiftPart.getMemorySize();
|
|
51
51
|
}
|
|
52
|
+
bool equals(const std::shared_ptr<HybridObject>& other) override {
|
|
53
|
+
if (auto otherCast = std::dynamic_pointer_cast<HybridScrollGuardSpecSwift>(other)) {
|
|
54
|
+
return _swiftPart.equals(otherCast->_swiftPart);
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
52
58
|
void dispose() noexcept override {
|
|
53
59
|
_swiftPart.dispose();
|
|
54
60
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// HybridScrollGuardComponent.mm
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#import "HybridScrollGuardComponent.hpp"
|
|
@@ -17,6 +17,13 @@
|
|
|
17
17
|
#import "HybridScrollGuardSpecSwift.hpp"
|
|
18
18
|
#import "ScrollGuard-Swift-Cxx-Umbrella.hpp"
|
|
19
19
|
|
|
20
|
+
#if __has_include(<cxxreact/ReactNativeVersion.h>)
|
|
21
|
+
#include <cxxreact/ReactNativeVersion.h>
|
|
22
|
+
#if REACT_NATIVE_VERSION_MINOR >= 82
|
|
23
|
+
#define ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
|
|
24
|
+
#endif
|
|
25
|
+
#endif
|
|
26
|
+
|
|
20
27
|
using namespace facebook;
|
|
21
28
|
using namespace margelo::nitro::scrollguard;
|
|
22
29
|
using namespace margelo::nitro::scrollguard::views;
|
|
@@ -25,6 +32,7 @@ using namespace margelo::nitro::scrollguard::views;
|
|
|
25
32
|
* Represents the React Native View holder for the Nitro "ScrollGuard" HybridView.
|
|
26
33
|
*/
|
|
27
34
|
@interface HybridScrollGuardComponent: RCTViewComponentView
|
|
35
|
+
+ (BOOL)shouldBeRecycled;
|
|
28
36
|
@end
|
|
29
37
|
|
|
30
38
|
@implementation HybridScrollGuardComponent {
|
|
@@ -93,4 +101,22 @@ using namespace margelo::nitro::scrollguard::views;
|
|
|
93
101
|
[super updateProps:props oldProps:oldProps];
|
|
94
102
|
}
|
|
95
103
|
|
|
104
|
+
+ (BOOL)shouldBeRecycled {
|
|
105
|
+
return ScrollGuard::ScrollGuardAutolinking::isScrollGuardRecyclable();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
- (void)prepareForRecycle {
|
|
109
|
+
[super prepareForRecycle];
|
|
110
|
+
ScrollGuard::HybridScrollGuardSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
111
|
+
swiftPart.maybePrepareForRecycle();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
#ifdef ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
|
|
115
|
+
- (void)invalidate {
|
|
116
|
+
ScrollGuard::HybridScrollGuardSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
117
|
+
swiftPart.onDropView();
|
|
118
|
+
[super invalidate];
|
|
119
|
+
}
|
|
120
|
+
#endif
|
|
121
|
+
|
|
96
122
|
@end
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
/// HybridScrollGuardSpec.swift
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
|
-
import Foundation
|
|
9
8
|
import NitroModules
|
|
10
9
|
|
|
11
10
|
/// See ``HybridScrollGuardSpec``
|
|
@@ -30,14 +29,14 @@ open class HybridScrollGuardSpec_base {
|
|
|
30
29
|
public init() { }
|
|
31
30
|
public func getCxxWrapper() -> HybridScrollGuardSpec_cxx {
|
|
32
31
|
#if DEBUG
|
|
33
|
-
guard self is HybridScrollGuardSpec else {
|
|
32
|
+
guard self is any HybridScrollGuardSpec else {
|
|
34
33
|
fatalError("`self` is not a `HybridScrollGuardSpec`! Did you accidentally inherit from `HybridScrollGuardSpec_base` instead of `HybridScrollGuardSpec`?")
|
|
35
34
|
}
|
|
36
35
|
#endif
|
|
37
36
|
if let cxxWrapper = self.cxxWrapper {
|
|
38
37
|
return cxxWrapper
|
|
39
38
|
} else {
|
|
40
|
-
let cxxWrapper = HybridScrollGuardSpec_cxx(self as! HybridScrollGuardSpec)
|
|
39
|
+
let cxxWrapper = HybridScrollGuardSpec_cxx(self as! any HybridScrollGuardSpec)
|
|
41
40
|
self.cxxWrapper = cxxWrapper
|
|
42
41
|
return cxxWrapper
|
|
43
42
|
}
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
/// HybridScrollGuardSpec_cxx.swift
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
|
-
import Foundation
|
|
9
8
|
import NitroModules
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -96,6 +95,14 @@ open class HybridScrollGuardSpec_cxx {
|
|
|
96
95
|
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
97
96
|
}
|
|
98
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Compares this object with the given [other] object for reference equality.
|
|
100
|
+
*/
|
|
101
|
+
@inline(__always)
|
|
102
|
+
public func equals(other: HybridScrollGuardSpec_cxx) -> Bool {
|
|
103
|
+
return self.__implementation === other.__implementation
|
|
104
|
+
}
|
|
105
|
+
|
|
99
106
|
/**
|
|
100
107
|
* Call dispose() on the Swift class.
|
|
101
108
|
* This _may_ be called manually from JS.
|
|
@@ -143,4 +150,13 @@ open class HybridScrollGuardSpec_cxx {
|
|
|
143
150
|
public final func afterUpdate() {
|
|
144
151
|
__implementation.afterUpdate()
|
|
145
152
|
}
|
|
153
|
+
|
|
154
|
+
public final func maybePrepareForRecycle() {
|
|
155
|
+
guard let recyclable = __implementation as? any RecyclableView else { return }
|
|
156
|
+
recyclable.prepareForRecycle()
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
public final func onDropView() {
|
|
160
|
+
__implementation.onDropView()
|
|
161
|
+
}
|
|
146
162
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// HybridScrollGuardSpec.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include "HybridScrollGuardSpec.hpp"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// HybridScrollGuardComponent.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include "HybridScrollGuardComponent.hpp"
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
#include <utility>
|
|
13
13
|
#include <NitroModules/NitroDefines.hpp>
|
|
14
14
|
#include <NitroModules/JSIConverter.hpp>
|
|
15
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
15
16
|
#include <react/renderer/core/RawValue.h>
|
|
16
17
|
#include <react/renderer/core/ShadowNode.h>
|
|
17
18
|
#include <react/renderer/core/ComponentDescriptor.h>
|
|
@@ -40,17 +41,12 @@ namespace margelo::nitro::scrollguard::views {
|
|
|
40
41
|
const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
|
|
41
42
|
if (rawValue == nullptr) return sourceProps.hybridRef;
|
|
42
43
|
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
43
|
-
return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridScrollGuardSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.hybridRef);
|
|
44
|
+
return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridScrollGuardSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.hybridRef);
|
|
44
45
|
} catch (const std::exception& exc) {
|
|
45
46
|
throw std::runtime_error(std::string("ScrollGuard.hybridRef: ") + exc.what());
|
|
46
47
|
}
|
|
47
48
|
}()) { }
|
|
48
49
|
|
|
49
|
-
HybridScrollGuardProps::HybridScrollGuardProps(const HybridScrollGuardProps& other):
|
|
50
|
-
react::ViewProps(),
|
|
51
|
-
direction(other.direction),
|
|
52
|
-
hybridRef(other.hybridRef) { }
|
|
53
|
-
|
|
54
50
|
bool HybridScrollGuardProps::filterObjectKeys(const std::string& propName) {
|
|
55
51
|
switch (hashString(propName)) {
|
|
56
52
|
case hashString("direction"): return true;
|
|
@@ -76,10 +72,10 @@ namespace margelo::nitro::scrollguard::views {
|
|
|
76
72
|
void HybridScrollGuardComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
|
|
77
73
|
// This is called immediately after `ShadowNode` is created, cloned or in progress.
|
|
78
74
|
// On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
|
|
79
|
-
auto& concreteShadowNode =
|
|
80
|
-
const HybridScrollGuardProps
|
|
81
|
-
|
|
82
|
-
state
|
|
75
|
+
auto& concreteShadowNode = static_cast<HybridScrollGuardShadowNode&>(shadowNode);
|
|
76
|
+
const std::shared_ptr<const HybridScrollGuardProps>& constProps = concreteShadowNode.getConcreteSharedProps();
|
|
77
|
+
const std::shared_ptr<HybridScrollGuardProps>& props = std::const_pointer_cast<HybridScrollGuardProps>(constProps);
|
|
78
|
+
HybridScrollGuardState state{props};
|
|
83
79
|
concreteShadowNode.setStateData(std::move(state));
|
|
84
80
|
}
|
|
85
81
|
#endif
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// HybridScrollGuardComponent.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
@@ -37,7 +37,6 @@ namespace margelo::nitro::scrollguard::views {
|
|
|
37
37
|
class HybridScrollGuardProps final: public react::ViewProps {
|
|
38
38
|
public:
|
|
39
39
|
HybridScrollGuardProps() = default;
|
|
40
|
-
HybridScrollGuardProps(const HybridScrollGuardProps&);
|
|
41
40
|
HybridScrollGuardProps(const react::PropsParserContext& context,
|
|
42
41
|
const HybridScrollGuardProps& sourceProps,
|
|
43
42
|
const react::RawProps& rawProps);
|
|
@@ -56,10 +55,14 @@ namespace margelo::nitro::scrollguard::views {
|
|
|
56
55
|
class HybridScrollGuardState final {
|
|
57
56
|
public:
|
|
58
57
|
HybridScrollGuardState() = default;
|
|
58
|
+
explicit HybridScrollGuardState(const std::shared_ptr<HybridScrollGuardProps>& props):
|
|
59
|
+
_props(props) {}
|
|
59
60
|
|
|
60
61
|
public:
|
|
61
|
-
|
|
62
|
-
const std::
|
|
62
|
+
[[nodiscard]]
|
|
63
|
+
const std::shared_ptr<HybridScrollGuardProps>& getProps() const {
|
|
64
|
+
return _props;
|
|
65
|
+
}
|
|
63
66
|
|
|
64
67
|
public:
|
|
65
68
|
#ifdef ANDROID
|
|
@@ -73,7 +76,7 @@ namespace margelo::nitro::scrollguard::views {
|
|
|
73
76
|
#endif
|
|
74
77
|
|
|
75
78
|
private:
|
|
76
|
-
std::
|
|
79
|
+
std::shared_ptr<HybridScrollGuardProps> _props;
|
|
77
80
|
};
|
|
78
81
|
|
|
79
82
|
/**
|
|
@@ -89,7 +92,7 @@ namespace margelo::nitro::scrollguard::views {
|
|
|
89
92
|
*/
|
|
90
93
|
class HybridScrollGuardComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridScrollGuardShadowNode> {
|
|
91
94
|
public:
|
|
92
|
-
HybridScrollGuardComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
|
|
95
|
+
explicit HybridScrollGuardComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
|
|
93
96
|
|
|
94
97
|
public:
|
|
95
98
|
/**
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// JHybridScrollGuardSpec.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include "JHybridScrollGuardSpec.hpp"
|
|
@@ -16,40 +16,41 @@ namespace margelo::nitro::scrollguard { enum class ScrollGuardDirection; }
|
|
|
16
16
|
|
|
17
17
|
namespace margelo::nitro::scrollguard {
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
});
|
|
19
|
+
std::shared_ptr<JHybridScrollGuardSpec> JHybridScrollGuardSpec::JavaPart::getJHybridScrollGuardSpec() {
|
|
20
|
+
auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
|
|
21
|
+
auto castHybridObject = std::dynamic_pointer_cast<JHybridScrollGuardSpec>(hybridObject);
|
|
22
|
+
if (castHybridObject == nullptr) [[unlikely]] {
|
|
23
|
+
throw std::runtime_error("Failed to downcast JHybridObject to JHybridScrollGuardSpec!");
|
|
24
|
+
}
|
|
25
|
+
return castHybridObject;
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return method(_javaPart);
|
|
28
|
+
jni::local_ref<JHybridScrollGuardSpec::CxxPart::jhybriddata> JHybridScrollGuardSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
29
|
+
return makeCxxInstance(jThis);
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
std::shared_ptr<JHybridObject> JHybridScrollGuardSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
|
|
33
|
+
auto castJavaPart = jni::dynamic_ref_cast<JHybridScrollGuardSpec::JavaPart>(javaPart);
|
|
34
|
+
if (castJavaPart == nullptr) [[unlikely]] {
|
|
35
|
+
throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridScrollGuardSpec::JavaPart!");
|
|
36
|
+
}
|
|
37
|
+
return std::make_shared<JHybridScrollGuardSpec>(castJavaPart);
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
void JHybridScrollGuardSpec::CxxPart::registerNatives() {
|
|
41
|
+
registerHybrid({
|
|
42
|
+
makeNativeMethod("initHybrid", JHybridScrollGuardSpec::CxxPart::initHybrid),
|
|
43
|
+
});
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
// Properties
|
|
46
47
|
std::optional<ScrollGuardDirection> JHybridScrollGuardSpec::getDirection() {
|
|
47
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JScrollGuardDirection>()>("getDirection");
|
|
48
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JScrollGuardDirection>()>("getDirection");
|
|
48
49
|
auto __result = method(_javaPart);
|
|
49
50
|
return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt;
|
|
50
51
|
}
|
|
51
52
|
void JHybridScrollGuardSpec::setDirection(std::optional<ScrollGuardDirection> direction) {
|
|
52
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JScrollGuardDirection> /* direction */)>("setDirection");
|
|
53
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JScrollGuardDirection> /* direction */)>("setDirection");
|
|
53
54
|
method(_javaPart, direction.has_value() ? JScrollGuardDirection::fromCpp(direction.value()) : nullptr);
|
|
54
55
|
}
|
|
55
56
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// HybridScrollGuardSpec.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
@@ -18,33 +18,33 @@ namespace margelo::nitro::scrollguard {
|
|
|
18
18
|
|
|
19
19
|
using namespace facebook;
|
|
20
20
|
|
|
21
|
-
class JHybridScrollGuardSpec: public
|
|
22
|
-
public virtual HybridScrollGuardSpec {
|
|
21
|
+
class JHybridScrollGuardSpec: public virtual HybridScrollGuardSpec, public virtual JHybridObject {
|
|
23
22
|
public:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
HybridBase
|
|
33
|
-
|
|
23
|
+
struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/scrollguard/HybridScrollGuardSpec;";
|
|
25
|
+
std::shared_ptr<JHybridScrollGuardSpec> getJHybridScrollGuardSpec();
|
|
26
|
+
};
|
|
27
|
+
struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
|
|
28
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/scrollguard/HybridScrollGuardSpec$CxxPart;";
|
|
29
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
30
|
+
static void registerNatives();
|
|
31
|
+
using HybridBase::HybridBase;
|
|
32
|
+
protected:
|
|
33
|
+
std::shared_ptr<JHybridObject> createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) override;
|
|
34
|
+
};
|
|
34
35
|
|
|
35
36
|
public:
|
|
37
|
+
explicit JHybridScrollGuardSpec(const jni::local_ref<JHybridScrollGuardSpec::JavaPart>& javaPart):
|
|
38
|
+
HybridObject(HybridScrollGuardSpec::TAG),
|
|
39
|
+
JHybridObject(javaPart),
|
|
40
|
+
_javaPart(jni::make_global(javaPart)) {}
|
|
36
41
|
~JHybridScrollGuardSpec() override {
|
|
37
42
|
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
38
43
|
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
public:
|
|
42
|
-
|
|
43
|
-
void dispose() noexcept override;
|
|
44
|
-
std::string toString() override;
|
|
45
|
-
|
|
46
|
-
public:
|
|
47
|
-
inline const jni::global_ref<JHybridScrollGuardSpec::javaobject>& getJavaPart() const noexcept {
|
|
47
|
+
inline const jni::global_ref<JHybridScrollGuardSpec::JavaPart>& getJavaPart() const noexcept {
|
|
48
48
|
return _javaPart;
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -58,9 +58,7 @@ namespace margelo::nitro::scrollguard {
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
private:
|
|
61
|
-
|
|
62
|
-
using HybridBase::HybridBase;
|
|
63
|
-
jni::global_ref<JHybridScrollGuardSpec::javaobject> _javaPart;
|
|
61
|
+
jni::global_ref<JHybridScrollGuardSpec::JavaPart> _javaPart;
|
|
64
62
|
};
|
|
65
63
|
|
|
66
64
|
} // namespace margelo::nitro::scrollguard
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// JScrollGuardDirection.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
@@ -19,7 +19,7 @@ namespace margelo::nitro::scrollguard {
|
|
|
19
19
|
*/
|
|
20
20
|
struct JScrollGuardDirection final: public jni::JavaClass<JScrollGuardDirection> {
|
|
21
21
|
public:
|
|
22
|
-
static auto
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/scrollguard/ScrollGuardDirection;";
|
|
23
23
|
|
|
24
24
|
public:
|
|
25
25
|
/**
|
|
@@ -41,16 +41,15 @@ namespace margelo::nitro::scrollguard {
|
|
|
41
41
|
[[maybe_unused]]
|
|
42
42
|
static jni::alias_ref<JScrollGuardDirection> fromCpp(ScrollGuardDirection value) {
|
|
43
43
|
static const auto clazz = javaClassStatic();
|
|
44
|
-
static const auto fieldHORIZONTAL = clazz->getStaticField<JScrollGuardDirection>("HORIZONTAL");
|
|
45
|
-
static const auto fieldVERTICAL = clazz->getStaticField<JScrollGuardDirection>("VERTICAL");
|
|
46
|
-
static const auto fieldBOTH = clazz->getStaticField<JScrollGuardDirection>("BOTH");
|
|
47
|
-
|
|
48
44
|
switch (value) {
|
|
49
45
|
case ScrollGuardDirection::HORIZONTAL:
|
|
46
|
+
static const auto fieldHORIZONTAL = clazz->getStaticField<JScrollGuardDirection>("HORIZONTAL");
|
|
50
47
|
return clazz->getStaticFieldValue(fieldHORIZONTAL);
|
|
51
48
|
case ScrollGuardDirection::VERTICAL:
|
|
49
|
+
static const auto fieldVERTICAL = clazz->getStaticField<JScrollGuardDirection>("VERTICAL");
|
|
52
50
|
return clazz->getStaticFieldValue(fieldVERTICAL);
|
|
53
51
|
case ScrollGuardDirection::BOTH:
|
|
52
|
+
static const auto fieldBOTH = clazz->getStaticField<JScrollGuardDirection>("BOTH");
|
|
54
53
|
return clazz->getStaticFieldValue(fieldBOTH);
|
|
55
54
|
default:
|
|
56
55
|
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
/// JHybridScrollGuardStateUpdater.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include "JHybridScrollGuardStateUpdater.hpp"
|
|
9
9
|
#include "views/HybridScrollGuardComponent.hpp"
|
|
10
10
|
#include <NitroModules/NitroDefines.hpp>
|
|
11
|
+
#include <react/fabric/StateWrapperImpl.h>
|
|
11
12
|
|
|
12
13
|
namespace margelo::nitro::scrollguard::views {
|
|
13
14
|
|
|
@@ -15,41 +16,40 @@ using namespace facebook;
|
|
|
15
16
|
using ConcreteStateData = react::ConcreteState<HybridScrollGuardState>;
|
|
16
17
|
|
|
17
18
|
void JHybridScrollGuardStateUpdater::updateViewProps(jni::alias_ref<jni::JClass> /* class */,
|
|
18
|
-
jni::alias_ref<JHybridScrollGuardSpec::
|
|
19
|
+
jni::alias_ref<JHybridScrollGuardSpec::JavaPart> javaView,
|
|
19
20
|
jni::alias_ref<JStateWrapper::javaobject> stateWrapperInterface) {
|
|
20
|
-
JHybridScrollGuardSpec
|
|
21
|
+
std::shared_ptr<JHybridScrollGuardSpec> hybridView = javaView->getJHybridScrollGuardSpec();
|
|
21
22
|
|
|
22
23
|
// Get concrete StateWrapperImpl from passed StateWrapper interface object
|
|
23
24
|
jobject rawStateWrapper = stateWrapperInterface.get();
|
|
24
|
-
if (!stateWrapperInterface->isInstanceOf(react::StateWrapperImpl::javaClassStatic())) {
|
|
25
|
+
if (!stateWrapperInterface->isInstanceOf(react::StateWrapperImpl::javaClassStatic())) [[unlikely]] {
|
|
25
26
|
throw std::runtime_error("StateWrapper is not a StateWrapperImpl");
|
|
26
27
|
}
|
|
27
28
|
auto stateWrapper = jni::alias_ref<react::StateWrapperImpl::javaobject>{
|
|
28
29
|
static_cast<react::StateWrapperImpl::javaobject>(rawStateWrapper)};
|
|
29
|
-
|
|
30
30
|
std::shared_ptr<const react::State> state = stateWrapper->cthis()->getState();
|
|
31
|
-
auto concreteState = std::
|
|
31
|
+
auto concreteState = std::static_pointer_cast<const ConcreteStateData>(state);
|
|
32
32
|
const HybridScrollGuardState& data = concreteState->getData();
|
|
33
|
-
const std::
|
|
34
|
-
if (
|
|
33
|
+
const std::shared_ptr<HybridScrollGuardProps>& props = data.getProps();
|
|
34
|
+
if (props == nullptr) [[unlikely]] {
|
|
35
35
|
// Props aren't set yet!
|
|
36
36
|
throw std::runtime_error("HybridScrollGuardState's data doesn't contain any props!");
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
|
|
39
|
+
// Update all props if they are dirty
|
|
40
|
+
if (props->direction.isDirty) {
|
|
41
|
+
hybridView->setDirection(props->direction.value);
|
|
42
|
+
props->direction.isDirty = false;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
// Update hybridRef if it changed
|
|
45
|
-
if (props
|
|
46
|
+
if (props->hybridRef.isDirty) {
|
|
46
47
|
// hybridRef changed - call it with new this
|
|
47
|
-
const auto& maybeFunc = props
|
|
48
|
+
const auto& maybeFunc = props->hybridRef.value;
|
|
48
49
|
if (maybeFunc.has_value()) {
|
|
49
|
-
|
|
50
|
-
maybeFunc.value()(shared);
|
|
50
|
+
maybeFunc.value()(hybridView);
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
props->hybridRef.isDirty = false;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// JHybridScrollGuardStateUpdater.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
#endif
|
|
13
13
|
|
|
14
14
|
#include <fbjni/fbjni.h>
|
|
15
|
-
#include <react/fabric/StateWrapperImpl.h>
|
|
16
15
|
#include <react/fabric/CoreComponentsRegistry.h>
|
|
16
|
+
#include <react/fabric/StateWrapperImpl.h>
|
|
17
17
|
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
18
18
|
#include <NitroModules/NitroDefines.hpp>
|
|
19
19
|
#include <NitroModules/JStateWrapper.hpp>
|
|
@@ -24,13 +24,13 @@ namespace margelo::nitro::scrollguard::views {
|
|
|
24
24
|
|
|
25
25
|
using namespace facebook;
|
|
26
26
|
|
|
27
|
-
class JHybridScrollGuardStateUpdater: public jni::JavaClass<JHybridScrollGuardStateUpdater> {
|
|
27
|
+
class JHybridScrollGuardStateUpdater final: public jni::JavaClass<JHybridScrollGuardStateUpdater> {
|
|
28
28
|
public:
|
|
29
29
|
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/scrollguard/views/HybridScrollGuardStateUpdater;";
|
|
30
30
|
|
|
31
31
|
public:
|
|
32
32
|
static void updateViewProps(jni::alias_ref<jni::JClass> /* class */,
|
|
33
|
-
jni::alias_ref<JHybridScrollGuardSpec::
|
|
33
|
+
jni::alias_ref<JHybridScrollGuardSpec::JavaPart> view,
|
|
34
34
|
jni::alias_ref<JStateWrapper::javaobject> stateWrapperInterface);
|
|
35
35
|
|
|
36
36
|
public:
|