@onekeyfe/react-native-scroll-guard 0.1.1
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/ScrollGuard.podspec +29 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +124 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/scrollguard/ScrollGuard.kt +117 -0
- package/android/src/main/java/com/margelo/nitro/scrollguard/ScrollGuardPackage.kt +27 -0
- package/android/src/main/java/com/margelo/nitro/scrollguard/ScrollGuardViewGroupManager.kt +48 -0
- package/ios/ScrollGuard.swift +243 -0
- package/lib/module/ScrollGuard.nitro.js +9 -0
- package/lib/module/ScrollGuard.nitro.js.map +1 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/nitrogen/generated/android/c++/JHybridScrollGuardSpec.cpp +59 -0
- package/lib/nitrogen/generated/android/c++/JHybridScrollGuardSpec.hpp +66 -0
- package/lib/nitrogen/generated/android/c++/JScrollGuardDirection.hpp +62 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridScrollGuardStateUpdater.cpp +56 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridScrollGuardStateUpdater.hpp +49 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/HybridScrollGuardSpec.kt +59 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/ScrollGuardDirection.kt +22 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/scrollguardOnLoad.kt +35 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/views/HybridScrollGuardManager.kt +50 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/views/HybridScrollGuardStateUpdater.kt +23 -0
- package/lib/nitrogen/generated/android/scrollguard+autolinking.cmake +83 -0
- package/lib/nitrogen/generated/android/scrollguard+autolinking.gradle +27 -0
- package/lib/nitrogen/generated/android/scrollguardOnLoad.cpp +46 -0
- package/lib/nitrogen/generated/android/scrollguardOnLoad.hpp +25 -0
- package/lib/nitrogen/generated/ios/ScrollGuard+autolinking.rb +60 -0
- package/lib/nitrogen/generated/ios/ScrollGuard-Swift-Cxx-Bridge.cpp +33 -0
- package/lib/nitrogen/generated/ios/ScrollGuard-Swift-Cxx-Bridge.hpp +59 -0
- package/lib/nitrogen/generated/ios/ScrollGuard-Swift-Cxx-Umbrella.hpp +45 -0
- package/lib/nitrogen/generated/ios/ScrollGuardAutolinking.mm +33 -0
- package/lib/nitrogen/generated/ios/ScrollGuardAutolinking.swift +25 -0
- package/lib/nitrogen/generated/ios/c++/HybridScrollGuardSpecSwift.cpp +11 -0
- package/lib/nitrogen/generated/ios/c++/HybridScrollGuardSpecSwift.hpp +77 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridScrollGuardComponent.mm +96 -0
- package/lib/nitrogen/generated/ios/swift/HybridScrollGuardSpec.swift +56 -0
- package/lib/nitrogen/generated/ios/swift/HybridScrollGuardSpec_cxx.swift +146 -0
- package/lib/nitrogen/generated/ios/swift/ScrollGuardDirection.swift +44 -0
- package/lib/nitrogen/generated/shared/c++/HybridScrollGuardSpec.cpp +22 -0
- package/lib/nitrogen/generated/shared/c++/HybridScrollGuardSpec.hpp +65 -0
- package/lib/nitrogen/generated/shared/c++/ScrollGuardDirection.hpp +80 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridScrollGuardComponent.cpp +87 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridScrollGuardComponent.hpp +108 -0
- package/lib/nitrogen/generated/shared/json/ScrollGuardConfig.json +10 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/ScrollGuard.nitro.d.ts +19 -0
- package/lib/typescript/src/ScrollGuard.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +5 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +17 -0
- package/nitrogen/generated/android/c++/JHybridScrollGuardSpec.cpp +59 -0
- package/nitrogen/generated/android/c++/JHybridScrollGuardSpec.hpp +66 -0
- package/nitrogen/generated/android/c++/JScrollGuardDirection.hpp +62 -0
- package/nitrogen/generated/android/c++/views/JHybridScrollGuardStateUpdater.cpp +56 -0
- package/nitrogen/generated/android/c++/views/JHybridScrollGuardStateUpdater.hpp +49 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/HybridScrollGuardSpec.kt +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/ScrollGuardDirection.kt +22 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/scrollguardOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/views/HybridScrollGuardManager.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/scrollguard/views/HybridScrollGuardStateUpdater.kt +23 -0
- package/nitrogen/generated/android/scrollguard+autolinking.cmake +83 -0
- package/nitrogen/generated/android/scrollguard+autolinking.gradle +27 -0
- package/nitrogen/generated/android/scrollguardOnLoad.cpp +46 -0
- package/nitrogen/generated/android/scrollguardOnLoad.hpp +25 -0
- package/nitrogen/generated/ios/ScrollGuard+autolinking.rb +60 -0
- package/nitrogen/generated/ios/ScrollGuard-Swift-Cxx-Bridge.cpp +33 -0
- package/nitrogen/generated/ios/ScrollGuard-Swift-Cxx-Bridge.hpp +59 -0
- package/nitrogen/generated/ios/ScrollGuard-Swift-Cxx-Umbrella.hpp +45 -0
- package/nitrogen/generated/ios/ScrollGuardAutolinking.mm +33 -0
- package/nitrogen/generated/ios/ScrollGuardAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridScrollGuardSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridScrollGuardSpecSwift.hpp +77 -0
- package/nitrogen/generated/ios/c++/views/HybridScrollGuardComponent.mm +96 -0
- package/nitrogen/generated/ios/swift/HybridScrollGuardSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridScrollGuardSpec_cxx.swift +146 -0
- package/nitrogen/generated/ios/swift/ScrollGuardDirection.swift +44 -0
- package/nitrogen/generated/shared/c++/HybridScrollGuardSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridScrollGuardSpec.hpp +65 -0
- package/nitrogen/generated/shared/c++/ScrollGuardDirection.hpp +80 -0
- package/nitrogen/generated/shared/c++/views/HybridScrollGuardComponent.cpp +87 -0
- package/nitrogen/generated/shared/c++/views/HybridScrollGuardComponent.hpp +108 -0
- package/nitrogen/generated/shared/json/ScrollGuardConfig.json +10 -0
- package/package.json +106 -0
- package/src/ScrollGuard.nitro.ts +25 -0
- package/src/index.tsx +11 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ScrollGuardDirection.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::scrollguard {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (ScrollGuardDirection).
|
|
30
|
+
*/
|
|
31
|
+
enum class ScrollGuardDirection {
|
|
32
|
+
HORIZONTAL SWIFT_NAME(horizontal) = 0,
|
|
33
|
+
VERTICAL SWIFT_NAME(vertical) = 1,
|
|
34
|
+
BOTH SWIFT_NAME(both) = 2,
|
|
35
|
+
} CLOSED_ENUM;
|
|
36
|
+
|
|
37
|
+
} // namespace margelo::nitro::scrollguard
|
|
38
|
+
|
|
39
|
+
namespace margelo::nitro {
|
|
40
|
+
|
|
41
|
+
// C++ ScrollGuardDirection <> JS ScrollGuardDirection (union)
|
|
42
|
+
template <>
|
|
43
|
+
struct JSIConverter<margelo::nitro::scrollguard::ScrollGuardDirection> final {
|
|
44
|
+
static inline margelo::nitro::scrollguard::ScrollGuardDirection fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
45
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
46
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
47
|
+
case hashString("horizontal"): return margelo::nitro::scrollguard::ScrollGuardDirection::HORIZONTAL;
|
|
48
|
+
case hashString("vertical"): return margelo::nitro::scrollguard::ScrollGuardDirection::VERTICAL;
|
|
49
|
+
case hashString("both"): return margelo::nitro::scrollguard::ScrollGuardDirection::BOTH;
|
|
50
|
+
default: [[unlikely]]
|
|
51
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum ScrollGuardDirection - invalid value!");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::scrollguard::ScrollGuardDirection arg) {
|
|
55
|
+
switch (arg) {
|
|
56
|
+
case margelo::nitro::scrollguard::ScrollGuardDirection::HORIZONTAL: return JSIConverter<std::string>::toJSI(runtime, "horizontal");
|
|
57
|
+
case margelo::nitro::scrollguard::ScrollGuardDirection::VERTICAL: return JSIConverter<std::string>::toJSI(runtime, "vertical");
|
|
58
|
+
case margelo::nitro::scrollguard::ScrollGuardDirection::BOTH: return JSIConverter<std::string>::toJSI(runtime, "both");
|
|
59
|
+
default: [[unlikely]]
|
|
60
|
+
throw std::invalid_argument("Cannot convert ScrollGuardDirection to JS - invalid value: "
|
|
61
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
65
|
+
if (!value.isString()) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
69
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
70
|
+
case hashString("horizontal"):
|
|
71
|
+
case hashString("vertical"):
|
|
72
|
+
case hashString("both"):
|
|
73
|
+
return true;
|
|
74
|
+
default:
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridScrollGuardComponent.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridScrollGuardComponent.hpp"
|
|
9
|
+
|
|
10
|
+
#include <string>
|
|
11
|
+
#include <exception>
|
|
12
|
+
#include <utility>
|
|
13
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
14
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
15
|
+
#include <react/renderer/core/RawValue.h>
|
|
16
|
+
#include <react/renderer/core/ShadowNode.h>
|
|
17
|
+
#include <react/renderer/core/ComponentDescriptor.h>
|
|
18
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
19
|
+
|
|
20
|
+
namespace margelo::nitro::scrollguard::views {
|
|
21
|
+
|
|
22
|
+
extern const char HybridScrollGuardComponentName[] = "ScrollGuard";
|
|
23
|
+
|
|
24
|
+
HybridScrollGuardProps::HybridScrollGuardProps(const react::PropsParserContext& context,
|
|
25
|
+
const HybridScrollGuardProps& sourceProps,
|
|
26
|
+
const react::RawProps& rawProps):
|
|
27
|
+
react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
|
|
28
|
+
direction([&]() -> CachedProp<std::optional<ScrollGuardDirection>> {
|
|
29
|
+
try {
|
|
30
|
+
const react::RawValue* rawValue = rawProps.at("direction", nullptr, nullptr);
|
|
31
|
+
if (rawValue == nullptr) return sourceProps.direction;
|
|
32
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
33
|
+
return CachedProp<std::optional<ScrollGuardDirection>>::fromRawValue(*runtime, value, sourceProps.direction);
|
|
34
|
+
} catch (const std::exception& exc) {
|
|
35
|
+
throw std::runtime_error(std::string("ScrollGuard.direction: ") + exc.what());
|
|
36
|
+
}
|
|
37
|
+
}()),
|
|
38
|
+
hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridScrollGuardSpec>& /* ref */)>>> {
|
|
39
|
+
try {
|
|
40
|
+
const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
|
|
41
|
+
if (rawValue == nullptr) return sourceProps.hybridRef;
|
|
42
|
+
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
|
+
} catch (const std::exception& exc) {
|
|
45
|
+
throw std::runtime_error(std::string("ScrollGuard.hybridRef: ") + exc.what());
|
|
46
|
+
}
|
|
47
|
+
}()) { }
|
|
48
|
+
|
|
49
|
+
HybridScrollGuardProps::HybridScrollGuardProps(const HybridScrollGuardProps& other):
|
|
50
|
+
react::ViewProps(),
|
|
51
|
+
direction(other.direction),
|
|
52
|
+
hybridRef(other.hybridRef) { }
|
|
53
|
+
|
|
54
|
+
bool HybridScrollGuardProps::filterObjectKeys(const std::string& propName) {
|
|
55
|
+
switch (hashString(propName)) {
|
|
56
|
+
case hashString("direction"): return true;
|
|
57
|
+
case hashString("hybridRef"): return true;
|
|
58
|
+
default: return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
HybridScrollGuardComponentDescriptor::HybridScrollGuardComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
|
|
63
|
+
: ConcreteComponentDescriptor(parameters,
|
|
64
|
+
react::RawPropsParser(/* enableJsiParser */ true)) {}
|
|
65
|
+
|
|
66
|
+
std::shared_ptr<const react::Props> HybridScrollGuardComponentDescriptor::cloneProps(const react::PropsParserContext& context,
|
|
67
|
+
const std::shared_ptr<const react::Props>& props,
|
|
68
|
+
react::RawProps rawProps) const {
|
|
69
|
+
// 1. Prepare raw props parser
|
|
70
|
+
rawProps.parse(rawPropsParser_);
|
|
71
|
+
// 2. Copy props with Nitro's cached copy constructor
|
|
72
|
+
return HybridScrollGuardShadowNode::Props(context, /* & */ rawProps, props);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
#ifdef ANDROID
|
|
76
|
+
void HybridScrollGuardComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
|
|
77
|
+
// This is called immediately after `ShadowNode` is created, cloned or in progress.
|
|
78
|
+
// On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
|
|
79
|
+
auto& concreteShadowNode = dynamic_cast<HybridScrollGuardShadowNode&>(shadowNode);
|
|
80
|
+
const HybridScrollGuardProps& props = concreteShadowNode.getConcreteProps();
|
|
81
|
+
HybridScrollGuardState state;
|
|
82
|
+
state.setProps(props);
|
|
83
|
+
concreteShadowNode.setStateData(std::move(state));
|
|
84
|
+
}
|
|
85
|
+
#endif
|
|
86
|
+
|
|
87
|
+
} // namespace margelo::nitro::scrollguard::views
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridScrollGuardComponent.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <optional>
|
|
11
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
12
|
+
#include <NitroModules/NitroHash.hpp>
|
|
13
|
+
#include <NitroModules/CachedProp.hpp>
|
|
14
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
15
|
+
#include <react/renderer/core/PropsParserContext.h>
|
|
16
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
17
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
18
|
+
|
|
19
|
+
#include "ScrollGuardDirection.hpp"
|
|
20
|
+
#include <optional>
|
|
21
|
+
#include <memory>
|
|
22
|
+
#include "HybridScrollGuardSpec.hpp"
|
|
23
|
+
#include <functional>
|
|
24
|
+
|
|
25
|
+
namespace margelo::nitro::scrollguard::views {
|
|
26
|
+
|
|
27
|
+
using namespace facebook;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The name of the actual native View.
|
|
31
|
+
*/
|
|
32
|
+
extern const char HybridScrollGuardComponentName[];
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Props for the "ScrollGuard" View.
|
|
36
|
+
*/
|
|
37
|
+
class HybridScrollGuardProps final: public react::ViewProps {
|
|
38
|
+
public:
|
|
39
|
+
HybridScrollGuardProps() = default;
|
|
40
|
+
HybridScrollGuardProps(const HybridScrollGuardProps&);
|
|
41
|
+
HybridScrollGuardProps(const react::PropsParserContext& context,
|
|
42
|
+
const HybridScrollGuardProps& sourceProps,
|
|
43
|
+
const react::RawProps& rawProps);
|
|
44
|
+
|
|
45
|
+
public:
|
|
46
|
+
CachedProp<std::optional<ScrollGuardDirection>> direction;
|
|
47
|
+
CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridScrollGuardSpec>& /* ref */)>>> hybridRef;
|
|
48
|
+
|
|
49
|
+
private:
|
|
50
|
+
static bool filterObjectKeys(const std::string& propName);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* State for the "ScrollGuard" View.
|
|
55
|
+
*/
|
|
56
|
+
class HybridScrollGuardState final {
|
|
57
|
+
public:
|
|
58
|
+
HybridScrollGuardState() = default;
|
|
59
|
+
|
|
60
|
+
public:
|
|
61
|
+
void setProps(const HybridScrollGuardProps& props) { _props.emplace(props); }
|
|
62
|
+
const std::optional<HybridScrollGuardProps>& getProps() const { return _props; }
|
|
63
|
+
|
|
64
|
+
public:
|
|
65
|
+
#ifdef ANDROID
|
|
66
|
+
HybridScrollGuardState(const HybridScrollGuardState& /* previousState */, folly::dynamic /* data */) {}
|
|
67
|
+
folly::dynamic getDynamic() const {
|
|
68
|
+
throw std::runtime_error("HybridScrollGuardState does not support folly!");
|
|
69
|
+
}
|
|
70
|
+
react::MapBuffer getMapBuffer() const {
|
|
71
|
+
throw std::runtime_error("HybridScrollGuardState does not support MapBuffer!");
|
|
72
|
+
};
|
|
73
|
+
#endif
|
|
74
|
+
|
|
75
|
+
private:
|
|
76
|
+
std::optional<HybridScrollGuardProps> _props;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The Shadow Node for the "ScrollGuard" View.
|
|
81
|
+
*/
|
|
82
|
+
using HybridScrollGuardShadowNode = react::ConcreteViewShadowNode<HybridScrollGuardComponentName /* "HybridScrollGuard" */,
|
|
83
|
+
HybridScrollGuardProps /* custom props */,
|
|
84
|
+
react::ViewEventEmitter /* default */,
|
|
85
|
+
HybridScrollGuardState /* custom state */>;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The Component Descriptor for the "ScrollGuard" View.
|
|
89
|
+
*/
|
|
90
|
+
class HybridScrollGuardComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridScrollGuardShadowNode> {
|
|
91
|
+
public:
|
|
92
|
+
HybridScrollGuardComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
|
|
93
|
+
|
|
94
|
+
public:
|
|
95
|
+
/**
|
|
96
|
+
* A faster path for cloning props - reuses the caching logic from `HybridScrollGuardProps`.
|
|
97
|
+
*/
|
|
98
|
+
std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
|
|
99
|
+
const std::shared_ptr<const react::Props>& props,
|
|
100
|
+
react::RawProps rawProps) const override;
|
|
101
|
+
#ifdef ANDROID
|
|
102
|
+
void adopt(react::ShadowNode& shadowNode) const override;
|
|
103
|
+
#endif
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/* The actual view for "ScrollGuard" needs to be implemented in platform-specific code. */
|
|
107
|
+
|
|
108
|
+
} // namespace margelo::nitro::scrollguard::views
|
package/package.json
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@onekeyfe/react-native-scroll-guard",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "A native view wrapper that prevents parent scrollable containers (PagerView/ViewPager2) from intercepting child scroll gestures",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"source": "./src/index.tsx",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"android",
|
|
19
|
+
"ios",
|
|
20
|
+
"cpp",
|
|
21
|
+
"nitrogen",
|
|
22
|
+
"nitro.json",
|
|
23
|
+
"*.podspec",
|
|
24
|
+
"react-native.config.js",
|
|
25
|
+
"!ios/build",
|
|
26
|
+
"!android/build",
|
|
27
|
+
"!android/gradle",
|
|
28
|
+
"!android/gradlew",
|
|
29
|
+
"!android/gradlew.bat",
|
|
30
|
+
"!android/local.properties",
|
|
31
|
+
"!**/__tests__",
|
|
32
|
+
"!**/__fixtures__",
|
|
33
|
+
"!**/__mocks__",
|
|
34
|
+
"!**/.*"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"clean": "del-cli android/build lib",
|
|
38
|
+
"prepare": "rm -rf lib && bob build && cp -r nitrogen lib/nitrogen",
|
|
39
|
+
"nitrogen": "nitrogen",
|
|
40
|
+
"typecheck": "tsc",
|
|
41
|
+
"release": "yarn nitrogen && yarn prepare && npm whoami && npm publish --access public"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"react-native",
|
|
45
|
+
"ios",
|
|
46
|
+
"android",
|
|
47
|
+
"gesture",
|
|
48
|
+
"scroll",
|
|
49
|
+
"pager"
|
|
50
|
+
],
|
|
51
|
+
"homepage": "https://github.com/OneKeyHQ/app-modules#readme",
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "git+https://github.com/OneKeyHQ/app-modules.git"
|
|
55
|
+
},
|
|
56
|
+
"author": "@onekeyfe <huanming@onekey.so> (https://github.com/OneKeyHQ/app-modules)",
|
|
57
|
+
"license": "MIT",
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"registry": "https://registry.npmjs.org/"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@react-native/babel-preset": "0.83.0",
|
|
63
|
+
"del-cli": "^6.0.0",
|
|
64
|
+
"nitrogen": "0.31.10",
|
|
65
|
+
"react": "19.2.0",
|
|
66
|
+
"react-native": "0.83.0",
|
|
67
|
+
"react-native-builder-bob": "^0.40.13",
|
|
68
|
+
"react-native-nitro-modules": "0.33.2",
|
|
69
|
+
"typescript": "^5.9.2"
|
|
70
|
+
},
|
|
71
|
+
"peerDependencies": {
|
|
72
|
+
"react": "*",
|
|
73
|
+
"react-native": "*",
|
|
74
|
+
"react-native-nitro-modules": "0.33.2"
|
|
75
|
+
},
|
|
76
|
+
"packageManager": "yarn@4.11.0",
|
|
77
|
+
"react-native-builder-bob": {
|
|
78
|
+
"source": "src",
|
|
79
|
+
"output": "lib",
|
|
80
|
+
"targets": [
|
|
81
|
+
[
|
|
82
|
+
"custom",
|
|
83
|
+
{
|
|
84
|
+
"script": "nitrogen",
|
|
85
|
+
"clean": "nitrogen/"
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
[
|
|
89
|
+
"module",
|
|
90
|
+
{
|
|
91
|
+
"esm": true
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
[
|
|
95
|
+
"typescript",
|
|
96
|
+
{
|
|
97
|
+
"project": "tsconfig.build.json"
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
"create-react-native-library": {
|
|
103
|
+
"type": "nitro-view",
|
|
104
|
+
"languages": "kotlin-swift"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
HybridView,
|
|
3
|
+
HybridViewMethods,
|
|
4
|
+
HybridViewProps,
|
|
5
|
+
} from 'react-native-nitro-modules';
|
|
6
|
+
|
|
7
|
+
export enum ScrollGuardDirection {
|
|
8
|
+
HORIZONTAL = 'horizontal',
|
|
9
|
+
VERTICAL = 'vertical',
|
|
10
|
+
BOTH = 'both',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ScrollGuardProps extends HybridViewProps {
|
|
14
|
+
/**
|
|
15
|
+
* The scroll direction to guard.
|
|
16
|
+
* - HORIZONTAL: block parent from intercepting horizontal gestures (default)
|
|
17
|
+
* - VERTICAL: block parent from intercepting vertical gestures
|
|
18
|
+
* - BOTH: block both directions
|
|
19
|
+
*/
|
|
20
|
+
direction?: ScrollGuardDirection;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ScrollGuardMethods extends HybridViewMethods {}
|
|
24
|
+
|
|
25
|
+
export type ScrollGuard = HybridView<ScrollGuardProps, ScrollGuardMethods>;
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getHostComponent } from 'react-native-nitro-modules';
|
|
2
|
+
const ScrollGuardConfig = require('../nitrogen/generated/shared/json/ScrollGuardConfig.json');
|
|
3
|
+
import type { ScrollGuardMethods, ScrollGuardProps } from './ScrollGuard.nitro';
|
|
4
|
+
export { ScrollGuardDirection } from './ScrollGuard.nitro';
|
|
5
|
+
|
|
6
|
+
export const ScrollGuardView = getHostComponent<
|
|
7
|
+
ScrollGuardProps,
|
|
8
|
+
ScrollGuardMethods
|
|
9
|
+
>('ScrollGuard', () => ScrollGuardConfig);
|
|
10
|
+
|
|
11
|
+
export type { ScrollGuardProps, ScrollGuardMethods };
|