Skip to content

Commit a28823d

Browse files
authored
refactor:适配3.0.2版本 (#21)
Signed-off-by: wupingyuan <wupingyuan2@h-partners.com>
1 parent 9083ffe commit a28823d

21 files changed

+751
-989
lines changed

harmony/spring_scrollview/src/main/cpp/EventEmitters.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,52 @@ void RNCSpringScrollViewEventEmitter::onScrollBeginDrag() const {
107107
});
108108
}
109109

110+
111+
void RNCSpringScrollViewEventEmitter::onCustomScrollBeginDrag() const {
112+
dispatchEvent("customScrollBeginDrag", [](jsi::Runtime &runtime) {
113+
auto payload = jsi::Object(runtime);
114+
return payload;
115+
});
116+
}
117+
118+
void RNCSpringScrollViewEventEmitter::onCustomScrollEndDrag() const {
119+
dispatchEvent("customScrollEndDrag", [](jsi::Runtime &runtime) {
120+
auto payload = jsi::Object(runtime);
121+
return payload;
122+
});
123+
}
124+
125+
126+
void RNCSpringScrollViewEventEmitter::onCustomTouchBegin() const {
127+
dispatchEvent("customTouchBegin", [](jsi::Runtime &runtime) {
128+
auto payload = jsi::Object(runtime);
129+
return payload;
130+
});
131+
}
132+
133+
134+
void RNCSpringScrollViewEventEmitter::onCustomTouchEnd() const {
135+
dispatchEvent("customTouchEnd", [](jsi::Runtime &runtime) {
136+
auto payload = jsi::Object(runtime);
137+
return payload;
138+
});
139+
}
140+
141+
142+
void RNCSpringScrollViewEventEmitter::onCustomMomentumScrollBegin() const {
143+
dispatchEvent("customMomentumScrollBegin", [](jsi::Runtime &runtime) {
144+
auto payload = jsi::Object(runtime);
145+
return payload;
146+
});
147+
}
148+
149+
150+
void RNCSpringScrollViewEventEmitter::onCustomMomentumScrollEnd() const {
151+
dispatchEvent("customMomentumScrollEnd", [](jsi::Runtime &runtime) {
152+
auto payload = jsi::Object(runtime);
153+
return payload;
154+
});
155+
}
156+
110157
} // namespace react
111158
} // namespace facebook

harmony/spring_scrollview/src/main/cpp/EventEmitters.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ class JSI_EXPORT RNCSpringScrollViewEventEmitter : public ViewEventEmitter {
6767
void onSizeChange(OnSizeChange value) const;
6868
void onContentSizeChange(OnContentSizeChange value) const;
6969
void onScrollBeginDrag() const;
70+
void onCustomScrollBeginDrag() const;
71+
void onCustomScrollEndDrag() const;
72+
void onCustomTouchBegin() const;
73+
void onCustomTouchEnd() const;
74+
void onCustomMomentumScrollBegin() const;
75+
void onCustomMomentumScrollEnd() const;
7076
};
7177
} // namespace react
7278
} // namespace facebook

harmony/spring_scrollview/src/main/cpp/Props.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ RNCSpringScrollViewProps::RNCSpringScrollViewProps(const PropsParserContext &con
3434
const RNCSpringScrollViewProps &sourceProps,
3535
const RawProps &rawProps)
3636
: ViewProps(context, sourceProps, rawProps),
37-
initialContentOffset(convertRawProp(context, rawProps, "initialContentOffset", sourceProps.initialContentOffset,
37+
initialContentOffset(convertRawProp(context, rawProps, "initialContentOffset", sourceProps.initialContentOffset,
3838
Types::Offset(0.0f, 0.0f))),
3939
refreshHeaderHeight(
4040
convertRawProp(context, rawProps, "refreshHeaderHeight", sourceProps.refreshHeaderHeight, 1.0f)),
@@ -45,7 +45,11 @@ RNCSpringScrollViewProps::RNCSpringScrollViewProps(const PropsParserContext &con
4545
inverted(convertRawProp(context, rawProps, "inverted", sourceProps.inverted, false)),
4646
allLoaded(convertRawProp(context, rawProps, "allLoaded", sourceProps.allLoaded, false)),
4747
directionalLockEnabled(
48-
convertRawProp(context, rawProps, "directionalLockEnabled", sourceProps.directionalLockEnabled, false)) {}
48+
convertRawProp(context, rawProps, "directionalLockEnabled", sourceProps.directionalLockEnabled, false)),
49+
pagingEnabled(convertRawProp(context, rawProps, "pagingEnabled", sourceProps.pagingEnabled, false)),
50+
pageSize(convertRawProp(context, rawProps, "pageSize", sourceProps.pageSize, Types::Size(0.0f, 0.0f))),
51+
decelerationRate(
52+
convertRawProp(context, rawProps, "decelerationRate", sourceProps.decelerationRate, 1.0f)){}
4953

5054
void fromRawValue(const PropsParserContext &context, const RawValue &value, Types::Offset &result) {
5155
auto map = (butter::map<std::string, RawValue>)value;

harmony/spring_scrollview/src/main/cpp/Props.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,17 @@ class JSI_EXPORT RNCSpringScrollViewProps final : public ViewProps {
4545
void fromRawValue(const PropsParserContext &context, const RawValue &value, Types::EdgeInsets &result);
4646

4747
#pragma mark - Props
48-
Types::Offset initialContentOffset;
48+
Types::Offset initialContentOffset;
4949
float refreshHeaderHeight;
5050
float loadingFooterHeight;
5151
bool bounces;
5252
bool scrollEnabled;
5353
bool inverted;
5454
bool allLoaded;
5555
bool directionalLockEnabled;
56+
bool pagingEnabled;
57+
float decelerationRate;
58+
Types::Size pageSize;
5659
};
5760
} // namespace react
5861
} // namespace facebook

harmony/spring_scrollview/src/main/cpp/SpringScrollViewArkTsMessageHandler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ void SpringScrollViewArkTSMessageHandler::handleArkTSMessage(const Context &ctx)
4141
auto event = std::make_shared<SpringScrollViewEvent>(5);
4242
event->setAnimationValue(ctx.messagePayload["value"].asDouble());
4343
event->setEventType(ctx.messagePayload["type"].asString());
44+
event->setEventDirections(ctx.messagePayload["directions"].asBool());
4445
event->setMessageType("onUpdate");
4546
auto baseEvent = std::static_pointer_cast<EventBus::Event>(event);
4647
EventBus::EventBus::getInstance()->fire(baseEvent);
@@ -49,6 +50,8 @@ void SpringScrollViewArkTSMessageHandler::handleArkTSMessage(const Context &ctx)
4950
if (ctx.messageName == "onEnd") {
5051
auto event = std::make_shared<SpringScrollViewEvent>(5);
5152
event->setEventType(ctx.messagePayload["type"].asString());
53+
event->setEventDirections(ctx.messagePayload["directions"].asBool());
54+
event->setAnimationValue(ctx.messagePayload["value"].asDouble());
5255
event->setMessageType("onEnd");
5356
auto baseEvent = std::static_pointer_cast<EventBus::Event>(event);
5457
EventBus::EventBus::getInstance()->fire(baseEvent);

0 commit comments

Comments
 (0)