• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "core/components_ng/pattern/swiper/swiper_model_ng.h"
17 
18 #include <cstdint>
19 #include <functional>
20 #include <memory>
21 
22 #include "base/error/error_code.h"
23 #include "base/geometry/axis.h"
24 #include "base/memory/referenced.h"
25 #include "base/utils/utils.h"
26 #include "core/components/swiper/swiper_component.h"
27 #include "core/components_ng/base/frame_node.h"
28 #include "core/components_ng/base/view_stack_processor.h"
29 #include "core/components_ng/pattern/swiper/arc_swiper_pattern.h"
30 #include "core/components_ng/pattern/swiper/swiper_pattern.h"
31 #include "core/components_ng/pattern/swiper/swiper_node.h"
32 #include "core/components_ng/pattern/swiper_indicator/indicator_common/swiper_indicator_utils.h"
33 #include "core/common/resource/resource_parse_utils.h"
34 
35 namespace OHOS::Ace::NG {
36 typedef enum {
37     ARKUI_SWIPER_ARROW_HIDE = 0,
38     ARKUI_SWIPER_ARROW_SHOW,
39     ARKUI_SWIPER_ARROW_SHOW_ON_HOVER,
40 } SwiperArrow;
41 
42 constexpr float ARROW_SIZE_COEFFICIENT = 0.75f;
Create(bool isCreateArc)43 RefPtr<SwiperController> SwiperModelNG::Create(bool isCreateArc)
44 {
45     auto* stack = ViewStackProcessor::GetInstance();
46     CHECK_NULL_RETURN(stack, nullptr);
47     auto nodeId = stack->ClaimNodeId();
48     ACE_LAYOUT_SCOPED_TRACE("Create[%s][self:%d]", V2::SWIPER_ETS_TAG, nodeId);
49     RefPtr<FrameNode> swiperNode = nullptr;
50     if (isCreateArc) {
51         swiperNode = FrameNode::GetOrCreateFrameNode(
52             V2::SWIPER_ETS_TAG, nodeId, []() { return AceType::MakeRefPtr<ArcSwiperPattern>(); });
53     } else {
54         swiperNode = FrameNode::GetOrCreateFrameNode(
55             V2::SWIPER_ETS_TAG, nodeId, []() { return AceType::MakeRefPtr<SwiperPattern>(); });
56     }
57 
58     stack->Push(swiperNode);
59     auto pattern = swiperNode->GetPattern<SwiperPattern>();
60     CHECK_NULL_RETURN(pattern, nullptr);
61     return pattern->GetSwiperController();
62 }
63 
CreateFrameNode(int32_t nodeId)64 RefPtr<FrameNode> SwiperModelNG::CreateFrameNode(int32_t nodeId)
65 {
66     auto swiperNode = ElementRegister::GetInstance()->GetSpecificItemById<SwiperNode>(nodeId);
67     if (swiperNode) {
68         if (swiperNode->GetTag() == V2::SWIPER_ETS_TAG) {
69             return swiperNode;
70         }
71         ElementRegister::GetInstance()->RemoveItemSilently(nodeId);
72         auto parent = swiperNode->GetParent();
73         if (parent) {
74             parent->RemoveChild(swiperNode);
75         }
76     }
77     // adapt for capi
78     swiperNode = AceType::MakeRefPtr<SwiperNode>(V2::SWIPER_ETS_TAG, nodeId, AceType::MakeRefPtr<SwiperPattern>());
79     swiperNode->InitializePatternAndContext();
80     ElementRegister::GetInstance()->AddUINode(swiperNode);
81     return swiperNode;
82 }
83 
SetDirection(Axis axis)84 void SwiperModelNG::SetDirection(Axis axis)
85 {
86     ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, Direction, axis);
87 }
88 
SetIndex(uint32_t index)89 void SwiperModelNG::SetIndex(uint32_t index)
90 {
91     ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, Index, index);
92 }
93 
SetDisplayMode(SwiperDisplayMode displayMode)94 void SwiperModelNG::SetDisplayMode(SwiperDisplayMode displayMode)
95 {
96     ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, DisplayMode, displayMode);
97 }
98 
ResetDisplayMode()99 void SwiperModelNG::ResetDisplayMode()
100 {
101     ACE_RESET_LAYOUT_PROPERTY(SwiperLayoutProperty, DisplayMode);
102 }
103 
SetDisplayCount(int32_t displayCount)104 void SwiperModelNG::SetDisplayCount(int32_t displayCount)
105 {
106     if (displayCount <= 0) {
107         return;
108     }
109 
110     ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, DisplayCount, displayCount);
111 }
112 
ResetDisplayCount()113 void SwiperModelNG::ResetDisplayCount()
114 {
115     ACE_RESET_LAYOUT_PROPERTY(SwiperLayoutProperty, DisplayCount);
116 }
117 
SetMinSize(const Dimension & minSize)118 void SwiperModelNG::SetMinSize(const Dimension& minSize)
119 {
120     ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, MinSize, minSize);
121 }
122 
ResetMinSize()123 void SwiperModelNG::ResetMinSize()
124 {
125     ACE_RESET_LAYOUT_PROPERTY(SwiperLayoutProperty, MinSize);
126 }
127 
SetShowIndicator(bool showIndicator)128 void SwiperModelNG::SetShowIndicator(bool showIndicator)
129 {
130     ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, ShowIndicator, showIndicator);
131 }
132 
SetIndicatorType(SwiperIndicatorType indicatorType)133 void SwiperModelNG::SetIndicatorType(SwiperIndicatorType indicatorType)
134 {
135     ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, IndicatorType, indicatorType);
136 }
137 
SetItemSpace(const Dimension & itemSpace)138 void SwiperModelNG::SetItemSpace(const Dimension& itemSpace)
139 {
140     ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, ItemSpace, itemSpace);
141 }
142 
SetCachedCount(int32_t cachedCount)143 void SwiperModelNG::SetCachedCount(int32_t cachedCount)
144 {
145     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
146     CHECK_NULL_VOID(swiperNode);
147     auto pattern = swiperNode->GetPattern<SwiperPattern>();
148     CHECK_NULL_VOID(pattern);
149     pattern->SetCachedCount(cachedCount);
150 
151     ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, CachedCount, cachedCount);
152 }
153 
SetCachedIsShown(bool isShown)154 void SwiperModelNG::SetCachedIsShown(bool isShown)
155 {
156     ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, CachedIsShown, isShown);
157 }
158 
SetCachedIsShown(FrameNode * frameNode,bool isShown)159 void SwiperModelNG::SetCachedIsShown(FrameNode* frameNode, bool isShown)
160 {
161     ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, CachedIsShown, isShown, frameNode);
162 }
163 
SetIsIndicatorCustomSize(bool isCustomSize)164 void SwiperModelNG::SetIsIndicatorCustomSize(bool isCustomSize)
165 {
166     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
167     CHECK_NULL_VOID(swiperNode);
168     auto pattern = swiperNode->GetPattern<SwiperPattern>();
169     CHECK_NULL_VOID(pattern);
170     pattern->SetIsIndicatorCustomSize(isCustomSize);
171 }
172 
SetIndicatorInteractive(bool interactive)173 void SwiperModelNG::SetIndicatorInteractive(bool interactive)
174 {
175     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
176     CHECK_NULL_VOID(swiperNode);
177     auto pattern = swiperNode->GetPattern<SwiperPattern>();
178     CHECK_NULL_VOID(pattern);
179     pattern->SetIndicatorInteractive(interactive);
180 }
181 
SetAutoPlay(bool autoPlay)182 void SwiperModelNG::SetAutoPlay(bool autoPlay)
183 {
184     ACE_UPDATE_PAINT_PROPERTY(SwiperPaintProperty, AutoPlay, autoPlay);
185 }
186 
SetAutoPlayInterval(uint32_t interval)187 void SwiperModelNG::SetAutoPlayInterval(uint32_t interval)
188 {
189     ACE_UPDATE_PAINT_PROPERTY(SwiperPaintProperty, AutoPlayInterval, interval);
190 }
191 
SetDuration(uint32_t duration)192 void SwiperModelNG::SetDuration(uint32_t duration)
193 {
194     ACE_UPDATE_PAINT_PROPERTY(SwiperPaintProperty, Duration, duration);
195 }
196 
SetLoop(bool loop)197 void SwiperModelNG::SetLoop(bool loop)
198 {
199     ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, Loop, loop);
200 }
201 
SetEnabled(bool enabled)202 void SwiperModelNG::SetEnabled(bool enabled)
203 {
204     ACE_UPDATE_PAINT_PROPERTY(SwiperPaintProperty, Enabled, enabled);
205 }
206 
SetDisableSwipe(bool disableSwipe)207 void SwiperModelNG::SetDisableSwipe(bool disableSwipe)
208 {
209     ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, DisableSwipe, disableSwipe);
210 }
211 
SetEdgeEffect(EdgeEffect edgeEffect)212 void SwiperModelNG::SetEdgeEffect(EdgeEffect edgeEffect)
213 {
214     ACE_UPDATE_PAINT_PROPERTY(SwiperPaintProperty, EdgeEffect, edgeEffect);
215 }
216 
SetCurve(const RefPtr<Curve> & curve)217 void SwiperModelNG::SetCurve(const RefPtr<Curve>& curve)
218 {
219     ACE_UPDATE_PAINT_PROPERTY(SwiperPaintProperty, Curve, curve);
220 }
221 
SetOnChange(std::function<void (const BaseEventInfo * info)> && onChange)222 void SwiperModelNG::SetOnChange(std::function<void(const BaseEventInfo* info)>&& onChange)
223 {
224     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
225     CHECK_NULL_VOID(swiperNode);
226     auto pattern = swiperNode->GetPattern<SwiperPattern>();
227     CHECK_NULL_VOID(pattern);
228 
229     pattern->UpdateChangeEvent([event = std::move(onChange)](int32_t index) {
230         CHECK_NULL_VOID(event);
231         SwiperChangeEvent eventInfo(index);
232         event(&eventInfo);
233     });
234 }
235 
SetOnUnselected(std::function<void (const BaseEventInfo * info)> && onUnselected)236 void SwiperModelNG::SetOnUnselected(std::function<void(const BaseEventInfo* info)>&& onUnselected)
237 {
238     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
239     CHECK_NULL_VOID(swiperNode);
240     auto pattern = swiperNode->GetPattern<SwiperPattern>();
241     CHECK_NULL_VOID(pattern);
242     pattern->UpdateOnUnselectedEvent([event = std::move(onUnselected)](int32_t index) {
243         CHECK_NULL_VOID(event);
244         SwiperChangeEvent eventInfo(index);
245         event(&eventInfo);
246     });
247 }
248 
SetOnAnimationStart(AnimationStartEvent && onAnimationStart)249 void SwiperModelNG::SetOnAnimationStart(AnimationStartEvent&& onAnimationStart)
250 {
251     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
252     CHECK_NULL_VOID(swiperNode);
253     auto pattern = swiperNode->GetPattern<SwiperPattern>();
254     CHECK_NULL_VOID(pattern);
255 
256     pattern->UpdateAnimationStartEvent(
257         [event = std::move(onAnimationStart)](int32_t index, int32_t targetIndex, const AnimationCallbackInfo& info) {
258             CHECK_NULL_VOID(event);
259             event(index, targetIndex, info);
260         }
261     );
262 }
263 
SetOnAnimationEnd(AnimationEndEvent && onAnimationEnd)264 void SwiperModelNG::SetOnAnimationEnd(AnimationEndEvent&& onAnimationEnd)
265 {
266     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
267     CHECK_NULL_VOID(swiperNode);
268     auto pattern = swiperNode->GetPattern<SwiperPattern>();
269     CHECK_NULL_VOID(pattern);
270 
271     pattern->UpdateAnimationEndEvent(
272         [event = std::move(onAnimationEnd)](int32_t index, const AnimationCallbackInfo& info) {
273             CHECK_NULL_VOID(event);
274             event(index, info);
275         }
276     );
277 }
278 
SetOnGestureSwipe(GestureSwipeEvent && onGestureSwipe)279 void SwiperModelNG::SetOnGestureSwipe(GestureSwipeEvent&& onGestureSwipe)
280 {
281     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
282     CHECK_NULL_VOID(swiperNode);
283     auto eventHub = swiperNode->GetOrCreateEventHub<SwiperEventHub>();
284     CHECK_NULL_VOID(eventHub);
285 
286     eventHub->SetGestureSwipeEvent(
287         [event = std::move(onGestureSwipe)](int32_t index, const AnimationCallbackInfo& info) {
288             CHECK_NULL_VOID(event);
289             event(index, info);
290         }
291     );
292 }
293 
SetNestedScroll(FrameNode * frameNode,const int32_t nestedOpt)294 void SwiperModelNG::SetNestedScroll(FrameNode* frameNode, const int32_t nestedOpt)
295 {
296     CHECK_NULL_VOID(frameNode);
297     auto pattern = frameNode->GetPattern<SwiperPattern>();
298     CHECK_NULL_VOID(pattern);
299     NestedScrollOptions option;
300     option.forward = static_cast<NestedScrollMode>(nestedOpt);
301     option.backward = static_cast<NestedScrollMode>(nestedOpt);
302     pattern->SetNestedScroll(option);
303 }
304 
SetSwipeByGroup(FrameNode * frameNode,bool swipeByGroup)305 void SwiperModelNG::SetSwipeByGroup(FrameNode* frameNode, bool swipeByGroup)
306 {
307     ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, SwipeByGroup, swipeByGroup, frameNode);
308 }
309 
SetRemoteMessageEventId(RemoteCallback && remoteCallback)310 void SwiperModelNG::SetRemoteMessageEventId(RemoteCallback&& remoteCallback) {}
311 
SetIndicatorStyle(const SwiperParameters & swiperParameters)312 void SwiperModelNG::SetIndicatorStyle(const SwiperParameters& swiperParameters)
313 {
314     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
315     CHECK_NULL_VOID(swiperNode);
316     auto pattern = swiperNode->GetPattern<SwiperPattern>();
317     CHECK_NULL_VOID(pattern);
318     pattern->SetSwiperParameters(swiperParameters);
319 };
320 
SetArcDotIndicatorStyle(const SwiperArcDotParameters & swiperArcDotParameters)321 void SwiperModelNG::SetArcDotIndicatorStyle(const SwiperArcDotParameters& swiperArcDotParameters)
322 {
323     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
324     CHECK_NULL_VOID(swiperNode);
325     auto pattern = swiperNode->GetPattern<SwiperPattern>();
326     CHECK_NULL_VOID(pattern);
327     pattern->SetSwiperArcDotParameters(swiperArcDotParameters);
328 }
329 
SetDotIndicatorStyle(const SwiperParameters & swiperParameters)330 void SwiperModelNG::SetDotIndicatorStyle(const SwiperParameters& swiperParameters)
331 {
332     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
333     CHECK_NULL_VOID(swiperNode);
334     auto pattern = swiperNode->GetPattern<SwiperPattern>();
335     CHECK_NULL_VOID(pattern);
336     pattern->SetSwiperParameters(swiperParameters);
337     if (SystemProperties::ConfigChangePerform()) {
338         CreateDotWithResourceObj(swiperNode, swiperParameters);
339     }
340 };
341 
SetArcDotIndicatorStyle(FrameNode * frameNode,const SwiperArcDotParameters & swiperArcDotParameters)342 void SwiperModelNG::SetArcDotIndicatorStyle(FrameNode* frameNode, const SwiperArcDotParameters& swiperArcDotParameters)
343 {
344     CHECK_NULL_VOID(frameNode);
345     auto pattern = frameNode->GetPattern<SwiperPattern>();
346     CHECK_NULL_VOID(pattern);
347     pattern->SetSwiperArcDotParameters(swiperArcDotParameters);
348 }
349 
SetBindIndicator(bool bind)350 void SwiperModelNG::SetBindIndicator(bool bind)
351 {
352     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
353     CHECK_NULL_VOID(swiperNode);
354     auto pattern = swiperNode->GetPattern<SwiperPattern>();
355     CHECK_NULL_VOID(pattern);
356     pattern->SetBindIndicator(bind);
357 }
358 
SetJSIndicatorController(std::function<void ()> resetFunc)359 void SwiperModelNG::SetJSIndicatorController(std::function<void()> resetFunc)
360 {
361     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
362     CHECK_NULL_VOID(swiperNode);
363     auto pattern = swiperNode->GetPattern<SwiperPattern>();
364     CHECK_NULL_VOID(pattern);
365     pattern->SetJSIndicatorController(resetFunc);
366 }
367 
SetDigitIndicatorStyle(const SwiperDigitalParameters & swiperDigitalParameters)368 void SwiperModelNG::SetDigitIndicatorStyle(const SwiperDigitalParameters& swiperDigitalParameters)
369 {
370     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
371     CHECK_NULL_VOID(swiperNode);
372     auto pattern = swiperNode->GetPattern<SwiperPattern>();
373     CHECK_NULL_VOID(pattern);
374     pattern->SetSwiperDigitalParameters(swiperDigitalParameters);
375     if (SystemProperties::ConfigChangePerform()) {
376         CreateDigitWithResourceObj(swiperNode, swiperDigitalParameters);
377     }
378 };
379 
SetOnClick(std::function<void (const BaseEventInfo * info,const RefPtr<V2::InspectorFunctionImpl> & impl)> && value)380 void SwiperModelNG::SetOnClick(
381     std::function<void(const BaseEventInfo* info, const RefPtr<V2::InspectorFunctionImpl>& impl)>&& value)
382 {}
383 
SetMainSwiperSizeWidth()384 void SwiperModelNG::SetMainSwiperSizeWidth() {}
385 
SetMainSwiperSizeHeight()386 void SwiperModelNG::SetMainSwiperSizeHeight() {}
387 
SetPreviousMargin(const Dimension & prevMargin,bool ignoreBlank)388 void SwiperModelNG::SetPreviousMargin(const Dimension& prevMargin, bool ignoreBlank)
389 {
390     ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, PrevMargin, prevMargin);
391     ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, PrevMarginIgnoreBlank, ignoreBlank);
392     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
393     CHECK_NULL_VOID(swiperNode);
394     auto pattern = swiperNode->GetPattern<SwiperPattern>();
395     CHECK_NULL_VOID(pattern);
396     pattern->SetPrevMarginIgnoreBlank(ignoreBlank);
397 }
398 
SetNextMargin(const Dimension & nextMargin,bool ignoreBlank)399 void SwiperModelNG::SetNextMargin(const Dimension& nextMargin, bool ignoreBlank)
400 {
401     ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, NextMargin, nextMargin);
402     ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, NextMarginIgnoreBlank, ignoreBlank);
403     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
404     CHECK_NULL_VOID(swiperNode);
405     auto pattern = swiperNode->GetPattern<SwiperPattern>();
406     CHECK_NULL_VOID(pattern);
407     pattern->SetNextMarginIgnoreBlank(ignoreBlank);
408 }
409 
SetIndicatorInteractive(FrameNode * frameNode,bool interactive)410 void SwiperModelNG::SetIndicatorInteractive(FrameNode* frameNode, bool interactive)
411 {
412     CHECK_NULL_VOID(frameNode);
413     auto pattern = frameNode->GetPattern<SwiperPattern>();
414     CHECK_NULL_VOID(pattern);
415     pattern->SetIndicatorInteractive(interactive);
416 }
417 
SetOnChangeEvent(std::function<void (const BaseEventInfo * info)> && onChangeEvent)418 void SwiperModelNG::SetOnChangeEvent(std::function<void(const BaseEventInfo* info)>&& onChangeEvent)
419 {
420     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
421     CHECK_NULL_VOID(swiperNode);
422     auto pattern = swiperNode->GetPattern<SwiperPattern>();
423     CHECK_NULL_VOID(pattern);
424 
425     pattern->UpdateOnChangeEvent([event = std::move(onChangeEvent)](int32_t index) {
426         CHECK_NULL_VOID(event);
427         SwiperChangeEvent eventInfo(index);
428         event(&eventInfo);
429     });
430 }
431 
SetIndicatorIsBoolean(bool isBoolean)432 void SwiperModelNG::SetIndicatorIsBoolean(bool isBoolean)
433 {
434     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
435     CHECK_NULL_VOID(swiperNode);
436     auto pattern = swiperNode->GetPattern<SwiperPattern>();
437     CHECK_NULL_VOID(pattern);
438     pattern->SetIndicatorIsBoolean(isBoolean);
439 }
440 
SetAutoPlayOptions(const SwiperAutoPlayOptions & swiperAutoPlayOptions)441 void SwiperModelNG::SetAutoPlayOptions(const SwiperAutoPlayOptions& swiperAutoPlayOptions)
442 {
443     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
444     CHECK_NULL_VOID(swiperNode);
445     auto pattern = swiperNode->GetPattern<SwiperPattern>();
446     CHECK_NULL_VOID(pattern);
447     pattern->SetStopWhenTouched(swiperAutoPlayOptions.stopWhenTouched);
448 }
449 
GetAutoPlayOptions(FrameNode * frameNode)450 SwiperAutoPlayOptions SwiperModelNG::GetAutoPlayOptions(FrameNode* frameNode)
451 {
452     SwiperAutoPlayOptions swiperAutoPlayOptions;
453     CHECK_NULL_RETURN(frameNode, swiperAutoPlayOptions);
454     auto pattern = frameNode->GetPattern<SwiperPattern>();
455     CHECK_NULL_RETURN(pattern, swiperAutoPlayOptions);
456     swiperAutoPlayOptions.stopWhenTouched = pattern->IsStopWhenTouched();
457     return swiperAutoPlayOptions;
458 }
459 
SetArrowStyle(const SwiperArrowParameters & swiperArrowParameters)460 void SwiperModelNG::SetArrowStyle(const SwiperArrowParameters& swiperArrowParameters)
461 {
462     if (swiperArrowParameters.isShowBackground.has_value()) {
463         ACE_UPDATE_LAYOUT_PROPERTY(
464             SwiperLayoutProperty, IsShowBackground, swiperArrowParameters.isShowBackground.value());
465     }
466     if (swiperArrowParameters.backgroundSize.has_value()) {
467         ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, BackgroundSize, swiperArrowParameters.backgroundSize.value());
468     }
469     if (swiperArrowParameters.backgroundColor.has_value()) {
470         ACE_UPDATE_LAYOUT_PROPERTY(
471             SwiperLayoutProperty, BackgroundColor, swiperArrowParameters.backgroundColor.value());
472     }
473     if (swiperArrowParameters.arrowSize.has_value()) {
474         ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, ArrowSize, swiperArrowParameters.arrowSize.value());
475     }
476     if (swiperArrowParameters.arrowColor.has_value()) {
477         ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, ArrowColor, swiperArrowParameters.arrowColor.value());
478     }
479     if (swiperArrowParameters.isSidebarMiddle.has_value()) {
480         ACE_UPDATE_LAYOUT_PROPERTY(
481             SwiperLayoutProperty, IsSidebarMiddle, swiperArrowParameters.isSidebarMiddle.value());
482     }
483     if (SystemProperties::ConfigChangePerform()) {
484         auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
485         CHECK_NULL_VOID(swiperNode);
486         auto pattern = swiperNode->GetPattern<SwiperPattern>();
487         CHECK_NULL_VOID(pattern);
488         pattern->SetSwiperArrowParameters(swiperArrowParameters);
489         CreateArrowWithResourceObj(swiperArrowParameters);
490     }
491 }
492 
SetDisplayArrow(bool displayArrow)493 void SwiperModelNG::SetDisplayArrow(bool displayArrow)
494 {
495     ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, DisplayArrow, displayArrow);
496 }
497 
SetHoverShow(bool hoverShow)498 void SwiperModelNG::SetHoverShow(bool hoverShow)
499 {
500     ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, HoverShow, hoverShow);
501 }
502 
SetNestedScroll(const NestedScrollOptions & nestedOpt)503 void SwiperModelNG::SetNestedScroll(const NestedScrollOptions& nestedOpt)
504 {
505     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
506     CHECK_NULL_VOID(swiperNode);
507     auto pattern = swiperNode->GetPattern<SwiperPattern>();
508     CHECK_NULL_VOID(pattern);
509     pattern->SetNestedScroll(nestedOpt);
510 }
511 
SetSwipeByGroup(bool swipeByGroup)512 void SwiperModelNG::SetSwipeByGroup(bool swipeByGroup)
513 {
514     ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, SwipeByGroup, swipeByGroup);
515 }
516 
SetCustomContentTransition(SwiperContentAnimatedTransition & transition)517 void SwiperModelNG::SetCustomContentTransition(SwiperContentAnimatedTransition& transition)
518 {
519     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
520     CHECK_NULL_VOID(swiperNode);
521     auto pattern = swiperNode->GetPattern<SwiperPattern>();
522     CHECK_NULL_VOID(pattern);
523     pattern->SetSwiperCustomContentTransition(transition);
524 }
525 
SetCustomContentTransition(FrameNode * frameNode,SwiperContentAnimatedTransition & transition)526 void SwiperModelNG::SetCustomContentTransition(FrameNode* frameNode, SwiperContentAnimatedTransition& transition)
527 {
528     auto pattern = frameNode->GetPattern<SwiperPattern>();
529     CHECK_NULL_VOID(pattern);
530     pattern->SetSwiperCustomContentTransition(transition);
531 }
532 
SetOnContentDidScroll(ContentDidScrollEvent && onContentDidScroll)533 void SwiperModelNG::SetOnContentDidScroll(ContentDidScrollEvent&& onContentDidScroll)
534 {
535     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
536     CHECK_NULL_VOID(swiperNode);
537     auto pattern = swiperNode->GetPattern<SwiperPattern>();
538     CHECK_NULL_VOID(pattern);
539     pattern->SetOnContentDidScroll(std::move(onContentDidScroll));
540 }
541 
SetOnContentDidScroll(FrameNode * frameNode,ContentDidScrollEvent && onContentDidScroll)542 void SwiperModelNG::SetOnContentDidScroll(FrameNode* frameNode, ContentDidScrollEvent&& onContentDidScroll)
543 {
544     CHECK_NULL_VOID(frameNode);
545     auto pattern = frameNode->GetPattern<SwiperPattern>();
546     CHECK_NULL_VOID(pattern);
547     pattern->SetOnContentDidScroll(std::move(onContentDidScroll));
548 }
549 
SetIndicatorController(Framework::JSIndicatorController * controller)550 void SwiperModelNG::SetIndicatorController(Framework::JSIndicatorController *controller)
551 {
552     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
553     CHECK_NULL_VOID(swiperNode);
554     auto pattern = swiperNode->GetPattern<SwiperPattern>();
555     CHECK_NULL_VOID(pattern);
556     pattern->SetIndicatorController(controller);
557 }
558 
GetIndicatorController()559 Framework::JSIndicatorController* SwiperModelNG::GetIndicatorController()
560 {
561     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
562     CHECK_NULL_RETURN(swiperNode, nullptr);
563     auto pattern = swiperNode->GetPattern<SwiperPattern>();
564     CHECK_NULL_RETURN(pattern, nullptr);
565     return pattern->GetIndicatorController();
566 }
567 
SetOnContentWillScroll(ContentWillScrollEvent && onContentWillScroll)568 void SwiperModelNG::SetOnContentWillScroll(ContentWillScrollEvent&& onContentWillScroll)
569 {
570     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
571     CHECK_NULL_VOID(swiperNode);
572     auto pattern = swiperNode->GetPattern<SwiperPattern>();
573     CHECK_NULL_VOID(pattern);
574     pattern->SetOnContentWillScroll(std::move(onContentWillScroll));
575 }
576 
SetOnContentWillScroll(FrameNode * frameNode,ContentWillScrollEvent && onContentWillScroll)577 void SwiperModelNG::SetOnContentWillScroll(FrameNode* frameNode, ContentWillScrollEvent&& onContentWillScroll)
578 {
579     CHECK_NULL_VOID(frameNode);
580     auto pattern = frameNode->GetPattern<SwiperPattern>();
581     CHECK_NULL_VOID(pattern);
582     pattern->SetOnContentWillScroll(std::move(onContentWillScroll));
583 }
584 
SetPageFlipMode(int32_t pageFlipMode)585 void SwiperModelNG::SetPageFlipMode(int32_t pageFlipMode)
586 {
587     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
588     CHECK_NULL_VOID(swiperNode);
589     auto pattern = swiperNode->GetPattern<SwiperPattern>();
590     CHECK_NULL_VOID(pattern);
591     pattern->SetPageFlipMode(pageFlipMode);
592 }
593 
SetPageFlipMode(FrameNode * frameNode,int32_t options)594 void SwiperModelNG::SetPageFlipMode(FrameNode* frameNode, int32_t options)
595 {
596     CHECK_NULL_VOID(frameNode);
597     auto pattern = frameNode->GetPattern<SwiperPattern>();
598     CHECK_NULL_VOID(pattern);
599     pattern->SetPageFlipMode(options);
600 }
601 
GetPageFlipMode(FrameNode * frameNode)602 int32_t SwiperModelNG::GetPageFlipMode(FrameNode* frameNode)
603 {
604     CHECK_NULL_RETURN(frameNode, 0);
605     auto pattern = frameNode->GetPattern<SwiperPattern>();
606     CHECK_NULL_RETURN(pattern, 0);
607     return pattern->GetPageFlipMode();
608 }
609 
SetDisableTransitionAnimation(bool isDisable)610 void SwiperModelNG::SetDisableTransitionAnimation(bool isDisable)
611 {
612     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
613     CHECK_NULL_VOID(swiperNode);
614     auto pattern = swiperNode->GetPattern<SwiperPattern>();
615     CHECK_NULL_VOID(pattern);
616     pattern->SetDisableTransitionAnimation(isDisable);
617 }
618 
SetDigitalCrownSensitivity(int32_t sensitivity)619 void SwiperModelNG::SetDigitalCrownSensitivity(int32_t sensitivity)
620 {
621 #ifdef SUPPORT_DIGITAL_CROWN
622     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
623     CHECK_NULL_VOID(swiperNode);
624     auto pattern = swiperNode->GetPattern<SwiperPattern>();
625     CHECK_NULL_VOID(pattern);
626     pattern->SetDigitalCrownSensitivity(static_cast<CrownSensitivity>(sensitivity));
627 #endif
628 }
629 
SetNextMargin(FrameNode * frameNode,const Dimension & nextMargin,bool ignoreBlank)630 void SwiperModelNG::SetNextMargin(FrameNode* frameNode, const Dimension& nextMargin, bool ignoreBlank)
631 {
632     ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, NextMargin, nextMargin, frameNode);
633     ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, NextMarginIgnoreBlank, ignoreBlank, frameNode);
634     CHECK_NULL_VOID(frameNode);
635     auto pattern = frameNode->GetPattern<SwiperPattern>();
636     CHECK_NULL_VOID(pattern);
637     pattern->SetNextMarginIgnoreBlank(ignoreBlank);
638 }
639 
SetPreviousMargin(FrameNode * frameNode,const Dimension & prevMargin,bool ignoreBlank)640 void SwiperModelNG::SetPreviousMargin(FrameNode* frameNode, const Dimension& prevMargin, bool ignoreBlank)
641 {
642     ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, PrevMargin, prevMargin, frameNode);
643     ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, PrevMarginIgnoreBlank, ignoreBlank, frameNode);
644     CHECK_NULL_VOID(frameNode);
645     auto pattern = frameNode->GetPattern<SwiperPattern>();
646     CHECK_NULL_VOID(pattern);
647     pattern->SetPrevMarginIgnoreBlank(ignoreBlank);
648 }
649 
SetIndex(FrameNode * frameNode,uint32_t index)650 void SwiperModelNG::SetIndex(FrameNode* frameNode, uint32_t index)
651 {
652     ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, Index, index, frameNode);
653 }
654 
SetAutoPlayInterval(FrameNode * frameNode,uint32_t interval)655 void SwiperModelNG::SetAutoPlayInterval(FrameNode* frameNode, uint32_t interval)
656 {
657     ACE_UPDATE_NODE_PAINT_PROPERTY(SwiperPaintProperty, AutoPlayInterval, interval, frameNode);
658 }
659 
SetDuration(FrameNode * frameNode,uint32_t duration)660 void SwiperModelNG::SetDuration(FrameNode* frameNode, uint32_t duration)
661 {
662     ACE_UPDATE_NODE_PAINT_PROPERTY(SwiperPaintProperty, Duration, duration, frameNode);
663 }
664 
SetCachedCount(FrameNode * frameNode,int32_t cachedCount)665 void SwiperModelNG::SetCachedCount(FrameNode* frameNode, int32_t cachedCount)
666 {
667     CHECK_NULL_VOID(frameNode);
668     auto pattern = frameNode->GetPattern<SwiperPattern>();
669     CHECK_NULL_VOID(pattern);
670     pattern->SetCachedCount(cachedCount);
671 
672     ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, CachedCount, cachedCount, frameNode);
673 }
674 
GetCachedCount(FrameNode * frameNode)675 int32_t SwiperModelNG::GetCachedCount(FrameNode* frameNode)
676 {
677     int32_t cachedCount = 1;
678     ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE(SwiperLayoutProperty, CachedCount, cachedCount, frameNode, 1);
679     return cachedCount;
680 }
681 
GetCachedIsShown(FrameNode * frameNode)682 bool SwiperModelNG::GetCachedIsShown(FrameNode* frameNode)
683 {
684     bool isShown = false;
685     ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE(SwiperLayoutProperty, CachedIsShown, isShown, frameNode, false);
686     return isShown;
687 }
688 
SetAutoPlay(FrameNode * frameNode,bool autoPlay)689 void SwiperModelNG::SetAutoPlay(FrameNode* frameNode, bool autoPlay)
690 {
691     ACE_UPDATE_NODE_PAINT_PROPERTY(SwiperPaintProperty, AutoPlay, autoPlay, frameNode);
692 }
693 
SetLoop(FrameNode * frameNode,bool loop)694 void SwiperModelNG::SetLoop(FrameNode* frameNode, bool loop)
695 {
696     ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, Loop, loop, frameNode);
697 }
698 
SetDirection(FrameNode * frameNode,Axis axis)699 void SwiperModelNG::SetDirection(FrameNode* frameNode, Axis axis)
700 {
701     ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, Direction, axis, frameNode);
702 }
703 
SetDisableSwipe(FrameNode * frameNode,bool disableSwipe)704 void SwiperModelNG::SetDisableSwipe(FrameNode* frameNode, bool disableSwipe)
705 {
706     ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, DisableSwipe, disableSwipe, frameNode);
707 }
708 
SetItemSpace(FrameNode * frameNode,const Dimension & itemSpace)709 void SwiperModelNG::SetItemSpace(FrameNode* frameNode, const Dimension& itemSpace)
710 {
711     ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, ItemSpace, itemSpace, frameNode);
712 }
713 
SetDisplayMode(FrameNode * frameNode,SwiperDisplayMode displayMode)714 void SwiperModelNG::SetDisplayMode(FrameNode* frameNode, SwiperDisplayMode displayMode)
715 {
716     ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, DisplayMode, displayMode, frameNode);
717 }
718 
SetEdgeEffect(FrameNode * frameNode,EdgeEffect edgeEffect)719 void SwiperModelNG::SetEdgeEffect(FrameNode* frameNode, EdgeEffect edgeEffect)
720 {
721     ACE_UPDATE_NODE_PAINT_PROPERTY(SwiperPaintProperty, EdgeEffect, edgeEffect, frameNode);
722 }
723 
SetMinSize(FrameNode * frameNode,const Dimension & minSize)724 void SwiperModelNG::SetMinSize(FrameNode* frameNode, const Dimension& minSize)
725 {
726     ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, MinSize, minSize, frameNode);
727 }
728 
SetDisplayCount(FrameNode * frameNode,int32_t displayCount)729 void SwiperModelNG::SetDisplayCount(FrameNode* frameNode, int32_t displayCount)
730 {
731     if (displayCount <= 0) {
732         return;
733     }
734 
735     ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, DisplayCount, displayCount, frameNode);
736 }
737 
ResetDisplayCount(FrameNode * frameNode)738 void SwiperModelNG::ResetDisplayCount(FrameNode* frameNode)
739 {
740     ACE_RESET_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, DisplayCount, frameNode);
741 }
742 
SetCurve(FrameNode * frameNode,const RefPtr<Curve> & curve)743 void SwiperModelNG::SetCurve(FrameNode* frameNode, const RefPtr<Curve>& curve)
744 {
745     ACE_UPDATE_NODE_PAINT_PROPERTY(SwiperPaintProperty, Curve, curve, frameNode);
746 }
747 
SetAutoPlayOptions(FrameNode * frameNode,const SwiperAutoPlayOptions & swiperAutoPlayOptions)748 void SwiperModelNG::SetAutoPlayOptions(FrameNode* frameNode, const SwiperAutoPlayOptions& swiperAutoPlayOptions)
749 {
750     CHECK_NULL_VOID(frameNode);
751     auto pattern = frameNode->GetPattern<SwiperPattern>();
752     CHECK_NULL_VOID(pattern);
753     pattern->SetStopWhenTouched(swiperAutoPlayOptions.stopWhenTouched);
754 }
755 
SetArrowStyle(FrameNode * frameNode,const SwiperArrowParameters & swiperArrowParameters)756 void SwiperModelNG::SetArrowStyle(FrameNode* frameNode, const SwiperArrowParameters& swiperArrowParameters)
757 {
758     if (swiperArrowParameters.isShowBackground.has_value()) {
759         ACE_UPDATE_NODE_LAYOUT_PROPERTY(
760             SwiperLayoutProperty, IsShowBackground, swiperArrowParameters.isShowBackground.value(), frameNode);
761     }
762     if (swiperArrowParameters.backgroundSize.has_value()) {
763         ACE_UPDATE_NODE_LAYOUT_PROPERTY(
764             SwiperLayoutProperty, BackgroundSize, swiperArrowParameters.backgroundSize.value(), frameNode);
765     }
766     if (swiperArrowParameters.backgroundColor.has_value()) {
767         ACE_UPDATE_NODE_LAYOUT_PROPERTY(
768             SwiperLayoutProperty, BackgroundColor, swiperArrowParameters.backgroundColor.value(), frameNode);
769     }
770     if (swiperArrowParameters.arrowSize.has_value()) {
771         ACE_UPDATE_NODE_LAYOUT_PROPERTY(
772             SwiperLayoutProperty, ArrowSize, swiperArrowParameters.arrowSize.value(), frameNode);
773     }
774     if (swiperArrowParameters.arrowColor.has_value()) {
775         ACE_UPDATE_NODE_LAYOUT_PROPERTY(
776             SwiperLayoutProperty, ArrowColor, swiperArrowParameters.arrowColor.value(), frameNode);
777     }
778     if (swiperArrowParameters.isSidebarMiddle.has_value()) {
779         ACE_UPDATE_NODE_LAYOUT_PROPERTY(
780             SwiperLayoutProperty, IsSidebarMiddle, swiperArrowParameters.isSidebarMiddle.value(), frameNode);
781     }
782     if (SystemProperties::ConfigChangePerform()) {
783         CHECK_NULL_VOID(frameNode);
784         auto pattern = frameNode->GetPattern<SwiperPattern>();
785         CHECK_NULL_VOID(pattern);
786         pattern->SetSwiperArrowParameters(swiperArrowParameters);
787         CreateArrowWithResourceObj(swiperArrowParameters);
788     }
789 }
790 
SetDisplayArrow(FrameNode * frameNode,bool displayArrow)791 void SwiperModelNG::SetDisplayArrow(FrameNode* frameNode, bool displayArrow)
792 {
793     ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, DisplayArrow, displayArrow, frameNode);
794 }
795 
SetHoverShow(FrameNode * frameNode,bool hoverShow)796 void SwiperModelNG::SetHoverShow(FrameNode* frameNode, bool hoverShow)
797 {
798     ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, HoverShow, hoverShow, frameNode);
799 }
800 
SetShowIndicator(FrameNode * frameNode,bool showIndicator)801 void SwiperModelNG::SetShowIndicator(FrameNode* frameNode, bool showIndicator)
802 {
803     ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, ShowIndicator, showIndicator, frameNode);
804 }
805 
SetIndicatorIsBoolean(FrameNode * frameNode,bool isBoolean)806 void SwiperModelNG::SetIndicatorIsBoolean(FrameNode* frameNode, bool isBoolean)
807 {
808     CHECK_NULL_VOID(frameNode);
809     auto pattern = frameNode->GetPattern<SwiperPattern>();
810     CHECK_NULL_VOID(pattern);
811     pattern->SetIndicatorIsBoolean(isBoolean);
812 }
813 
SetDigitIndicatorStyle(FrameNode * frameNode,const SwiperDigitalParameters & swiperDigitalParameters)814 void SwiperModelNG::SetDigitIndicatorStyle(FrameNode* frameNode, const SwiperDigitalParameters& swiperDigitalParameters)
815 {
816     CHECK_NULL_VOID(frameNode);
817     auto pattern = frameNode->GetPattern<SwiperPattern>();
818     CHECK_NULL_VOID(pattern);
819     pattern->SetSwiperDigitalParameters(swiperDigitalParameters);
820     if (SystemProperties::ConfigChangePerform()) {
821         CreateDigitWithResourceObj(frameNode, swiperDigitalParameters);
822     }
823 }
824 
SetIndicatorType(FrameNode * frameNode,SwiperIndicatorType indicatorType)825 void SwiperModelNG::SetIndicatorType(FrameNode* frameNode, SwiperIndicatorType indicatorType)
826 {
827     ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, IndicatorType, indicatorType, frameNode);
828 }
829 
SetIsIndicatorCustomSize(FrameNode * frameNode,bool isCustomSize)830 void SwiperModelNG::SetIsIndicatorCustomSize(FrameNode* frameNode, bool isCustomSize)
831 {
832     CHECK_NULL_VOID(frameNode);
833     auto pattern = frameNode->GetPattern<SwiperPattern>();
834     CHECK_NULL_VOID(pattern);
835     pattern->SetIsIndicatorCustomSize(isCustomSize);
836 }
837 
SetDotIndicatorStyle(FrameNode * frameNode,const SwiperParameters & swiperParameters)838 void SwiperModelNG::SetDotIndicatorStyle(FrameNode* frameNode, const SwiperParameters& swiperParameters)
839 {
840     CHECK_NULL_VOID(frameNode);
841     auto pattern = frameNode->GetPattern<SwiperPattern>();
842     CHECK_NULL_VOID(pattern);
843     pattern->SetSwiperParameters(swiperParameters);
844     if (SystemProperties::ConfigChangePerform()) {
845         CreateDotWithResourceObj(frameNode, swiperParameters);
846     }
847 }
848 
SetBindIndicator(FrameNode * frameNode,bool bind)849 void SwiperModelNG::SetBindIndicator(FrameNode* frameNode, bool bind)
850 {
851     CHECK_NULL_VOID(frameNode);
852     auto pattern = frameNode->GetPattern<SwiperPattern>();
853     CHECK_NULL_VOID(pattern);
854     pattern->SetBindIndicator(bind);
855 }
856 
SetEnabled(FrameNode * frameNode,bool enabled)857 void SwiperModelNG::SetEnabled(FrameNode* frameNode, bool enabled)
858 {
859     ACE_UPDATE_NODE_PAINT_PROPERTY(SwiperPaintProperty, Enabled, enabled, frameNode);
860 }
861 
SetOnChange(FrameNode * frameNode,std::function<void (const BaseEventInfo * info)> && onChange)862 void SwiperModelNG::SetOnChange(FrameNode* frameNode, std::function<void(const BaseEventInfo* info)>&& onChange)
863 {
864     CHECK_NULL_VOID(frameNode);
865     auto pattern = frameNode->GetPattern<SwiperPattern>();
866     CHECK_NULL_VOID(pattern);
867     pattern->UpdateChangeEvent([event = std::move(onChange)](int32_t index) {
868         CHECK_NULL_VOID(event);
869         SwiperChangeEvent eventInfo(index);
870         event(&eventInfo);
871     });
872 }
873 
SetOnUnselected(FrameNode * frameNode,std::function<void (const BaseEventInfo * info)> && onUnselected)874 void SwiperModelNG::SetOnUnselected(FrameNode* frameNode, std::function<void(const BaseEventInfo* info)>&& onUnselected)
875 {
876     CHECK_NULL_VOID(frameNode);
877     auto pattern = frameNode->GetPattern<SwiperPattern>();
878     CHECK_NULL_VOID(pattern);
879     pattern->UpdateOnUnselectedEvent([event = std::move(onUnselected)](int32_t index) {
880         CHECK_NULL_VOID(event);
881         SwiperChangeEvent eventInfo(index);
882         event(&eventInfo);
883     });
884 }
885 
SetOnAnimationStart(FrameNode * frameNode,AnimationStartEvent && onAnimationStart)886 void SwiperModelNG::SetOnAnimationStart(FrameNode* frameNode, AnimationStartEvent&& onAnimationStart)
887 {
888     CHECK_NULL_VOID(frameNode);
889     auto pattern = frameNode->GetPattern<SwiperPattern>();
890     CHECK_NULL_VOID(pattern);
891     pattern->UpdateAnimationStartEvent(
892         [event = std::move(onAnimationStart)](int32_t index, int32_t targetIndex, const AnimationCallbackInfo& info) {
893             CHECK_NULL_VOID(event);
894             event(index, targetIndex, info);
895         }
896     );
897 }
898 
SetOnAnimationEnd(FrameNode * frameNode,AnimationEndEvent && onAnimationEnd)899 void SwiperModelNG::SetOnAnimationEnd(FrameNode* frameNode, AnimationEndEvent&& onAnimationEnd)
900 {
901     CHECK_NULL_VOID(frameNode);
902     auto pattern = frameNode->GetPattern<SwiperPattern>();
903     CHECK_NULL_VOID(pattern);
904     pattern->UpdateAnimationEndEvent(
905         [event = std::move(onAnimationEnd)](int32_t index, const AnimationCallbackInfo& info) {
906             CHECK_NULL_VOID(event);
907             event(index, info);
908         }
909     );
910 }
911 
SetOnGestureSwipe(FrameNode * frameNode,GestureSwipeEvent && onGestureSwipe)912 void SwiperModelNG::SetOnGestureSwipe(FrameNode* frameNode, GestureSwipeEvent&& onGestureSwipe)
913 {
914     CHECK_NULL_VOID(frameNode);
915     auto eventHub = frameNode->GetOrCreateEventHub<SwiperEventHub>();
916     CHECK_NULL_VOID(eventHub);
917     eventHub->SetGestureSwipeEvent(
918         [event = std::move(onGestureSwipe)](int32_t index, const AnimationCallbackInfo& info) {
919             CHECK_NULL_VOID(event);
920             event(index, info);
921         }
922     );
923 }
924 
GetLoop(FrameNode * frameNode)925 bool SwiperModelNG::GetLoop(FrameNode* frameNode)
926 {
927     bool value = true;
928     ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE(SwiperLayoutProperty, Loop, value, frameNode, value);
929     return value;
930 }
931 
GetAutoPlay(FrameNode * frameNode)932 bool SwiperModelNG::GetAutoPlay(FrameNode* frameNode)
933 {
934     bool value = false;
935     ACE_GET_NODE_PAINT_PROPERTY_WITH_DEFAULT_VALUE(SwiperPaintProperty, AutoPlay, value, frameNode, value);
936     return value;
937 }
938 
GetIndex(FrameNode * frameNode)939 int SwiperModelNG::GetIndex(FrameNode* frameNode)
940 {
941     int value = 0;
942     ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE(SwiperLayoutProperty, Index, value, frameNode, value);
943     return value;
944 }
945 
GetDirection(FrameNode * frameNode)946 Axis SwiperModelNG::GetDirection(FrameNode* frameNode)
947 {
948     Axis value = Axis::HORIZONTAL;
949     ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE(SwiperLayoutProperty, Direction, value, frameNode, value);
950     return value;
951 }
952 
GetDuration(FrameNode * frameNode)953 uint32_t SwiperModelNG::GetDuration(FrameNode* frameNode)
954 {
955     uint32_t value = SwiperAnimationStyle::DEFAULT_DURATION;
956     ACE_GET_NODE_PAINT_PROPERTY_WITH_DEFAULT_VALUE(SwiperPaintProperty, Duration, value, frameNode, value);
957     return value;
958 }
959 
GetDisplayCount(FrameNode * frameNode)960 int SwiperModelNG::GetDisplayCount(FrameNode* frameNode)
961 {
962     int value = 1;
963     ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE(SwiperLayoutProperty, DisplayCount, value, frameNode, value);
964     return value;
965 }
966 
GetAutoPlayInterval(FrameNode * frameNode)967 int SwiperModelNG::GetAutoPlayInterval(FrameNode* frameNode)
968 {
969     int value = SwiperAnimationStyle::DEFAULT_INTERVAL;
970     ACE_GET_NODE_PAINT_PROPERTY_WITH_DEFAULT_VALUE(SwiperPaintProperty, AutoPlayInterval, value, frameNode, value);
971     return value;
972 }
973 
GetCurve(FrameNode * frameNode)974 RefPtr<Curve> SwiperModelNG::GetCurve(FrameNode* frameNode)
975 {
976     RefPtr<Curve> value = OHOS::Ace::Curves::LINEAR;
977     ACE_GET_NODE_PAINT_PROPERTY_WITH_DEFAULT_VALUE(SwiperPaintProperty, Curve, value, frameNode, value);
978     return value;
979 }
980 
GetDisableSwipe(FrameNode * frameNode)981 bool SwiperModelNG::GetDisableSwipe(FrameNode* frameNode)
982 {
983     bool value = false;
984     ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE(SwiperLayoutProperty, DisableSwipe, value, frameNode, value);
985     return value;
986 }
987 
GetItemSpace(FrameNode * frameNode)988 float SwiperModelNG::GetItemSpace(FrameNode* frameNode)
989 {
990     Dimension value(0, DimensionUnit::VP);
991     ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE(SwiperLayoutProperty, ItemSpace, value, frameNode, value);
992     return value.Value();
993 }
994 
GetShowIndicator(FrameNode * frameNode)995 bool SwiperModelNG::GetShowIndicator(FrameNode* frameNode)
996 {
997     bool value = true;
998     ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE(SwiperLayoutProperty, ShowIndicator, value, frameNode, value);
999     return value;
1000 }
1001 
GetShowDisplayArrow(FrameNode * frameNode)1002 int SwiperModelNG::GetShowDisplayArrow(FrameNode* frameNode)
1003 {
1004     bool show = false;
1005     bool hoverShow = false;
1006     ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE(SwiperLayoutProperty, DisplayArrow, show, frameNode, show);
1007     ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE(SwiperLayoutProperty, HoverShow, hoverShow, frameNode, hoverShow);
1008     int ArrowType = 0;
1009     if (show && hoverShow) {
1010         return ArrowType = static_cast<int>(SwiperArrow::ARKUI_SWIPER_ARROW_SHOW_ON_HOVER);
1011     }
1012     if (show) {
1013         ArrowType = static_cast<int>(SwiperArrow::ARKUI_SWIPER_ARROW_SHOW);
1014     } else {
1015         ArrowType = static_cast<int>(SwiperArrow::ARKUI_SWIPER_ARROW_HIDE);
1016     }
1017     return ArrowType;
1018 }
1019 
GetEffectMode(FrameNode * frameNode)1020 EdgeEffect SwiperModelNG::GetEffectMode(FrameNode* frameNode)
1021 {
1022     EdgeEffect mode = EdgeEffect::SPRING;
1023     ACE_GET_NODE_PAINT_PROPERTY_WITH_DEFAULT_VALUE(SwiperPaintProperty, EdgeEffect, mode, frameNode, mode);
1024     return mode;
1025 }
1026 
GetNestedScroll(FrameNode * frameNode)1027 int32_t SwiperModelNG::GetNestedScroll(FrameNode* frameNode)
1028 {
1029     CHECK_NULL_RETURN(frameNode, ERROR_CODE_PARAM_INVALID);
1030     auto pattern = frameNode->GetPattern<SwiperPattern>();
1031     CHECK_NULL_RETURN(pattern, ERROR_CODE_PARAM_INVALID);
1032     return static_cast<int>(pattern->GetNestedScroll().forward);
1033 }
1034 
RealTotalCount(FrameNode * frameNode)1035 int32_t SwiperModelNG::RealTotalCount(FrameNode* frameNode)
1036 {
1037     CHECK_NULL_RETURN(frameNode, 0);
1038     auto pattern = frameNode->GetPattern<SwiperPattern>();
1039     CHECK_NULL_RETURN(pattern, 0);
1040     return pattern->RealTotalCount();
1041 }
1042 
SetSwiperToIndex(FrameNode * frameNode,int32_t index,bool useAnimation)1043 void SwiperModelNG::SetSwiperToIndex(FrameNode* frameNode, int32_t index, bool useAnimation)
1044 {
1045     CHECK_NULL_VOID(frameNode);
1046     auto pattern = frameNode->GetPattern<SwiperPattern>();
1047     CHECK_NULL_VOID(pattern);
1048     pattern->ChangeIndex(index, useAnimation);
1049 }
1050 
SetSwiperToIndex(FrameNode * frameNode,int32_t index,SwiperAnimationMode animationMode)1051 void SwiperModelNG::SetSwiperToIndex(FrameNode* frameNode, int32_t index, SwiperAnimationMode animationMode)
1052 {
1053     CHECK_NULL_VOID(frameNode);
1054     auto pattern = frameNode->GetPattern<SwiperPattern>();
1055     CHECK_NULL_VOID(pattern);
1056     pattern->ChangeIndex(index, animationMode);
1057 }
1058 
GetPreviousMargin(FrameNode * frameNode,int32_t unit,SwiperMarginOptions * options)1059 void SwiperModelNG::GetPreviousMargin(FrameNode* frameNode, int32_t unit, SwiperMarginOptions* options)
1060 {
1061     CHECK_NULL_VOID(frameNode);
1062     CHECK_NULL_VOID(options);
1063     Dimension prevMargin(0.0f, static_cast<DimensionUnit>(unit));
1064     ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE(
1065         SwiperLayoutProperty, PrevMargin, prevMargin, frameNode, prevMargin);
1066     options->margin = prevMargin.Value();
1067     auto pattern = frameNode->GetPattern<SwiperPattern>();
1068     CHECK_NULL_VOID(pattern);
1069     options->ignoreBlank = pattern->GetPrevMarginIgnoreBlank();
1070 }
1071 
GetNextMargin(FrameNode * frameNode,int32_t unit,SwiperMarginOptions * options)1072 void SwiperModelNG::GetNextMargin(FrameNode* frameNode, int32_t unit, SwiperMarginOptions* options)
1073 {
1074     CHECK_NULL_VOID(frameNode);
1075     CHECK_NULL_VOID(options);
1076     Dimension nextMargin(0.0f, static_cast<DimensionUnit>(unit));
1077     ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE(
1078         SwiperLayoutProperty, NextMargin, nextMargin, frameNode, nextMargin);
1079     options->margin = nextMargin.Value();
1080     auto pattern = frameNode->GetPattern<SwiperPattern>();
1081     CHECK_NULL_VOID(pattern);
1082     options->ignoreBlank = pattern->GetNextMarginIgnoreBlank();
1083 }
1084 
GetDotIndicator(FrameNode * frameNode)1085 std::shared_ptr<SwiperParameters> SwiperModelNG::GetDotIndicator(FrameNode* frameNode)
1086 {
1087     CHECK_NULL_RETURN(frameNode, nullptr);
1088     auto pattern = frameNode->GetPattern<SwiperPattern>();
1089     CHECK_NULL_RETURN(pattern, nullptr);
1090     return pattern->GetSwiperParameters();
1091 }
1092 
GetIndicatorType(FrameNode * frameNode)1093 int32_t SwiperModelNG::GetIndicatorType(FrameNode* frameNode)
1094 {
1095     CHECK_NULL_RETURN(frameNode, 0);
1096     SwiperIndicatorType value = SwiperIndicatorType::DOT;
1097     ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE(SwiperLayoutProperty, IndicatorType, value, frameNode, value);
1098     return static_cast<int32_t>(value);
1099 
1100 }
1101 
GetOrCreateSwiperController(FrameNode * frameNode)1102 RefPtr<SwiperController> SwiperModelNG::GetOrCreateSwiperController(FrameNode* frameNode)
1103 {
1104     CHECK_NULL_RETURN(frameNode, nullptr);
1105     auto pattern = frameNode->GetPattern<SwiperPattern>();
1106     CHECK_NULL_RETURN(pattern, nullptr);
1107     if (!pattern->GetSwiperController()) {
1108         auto controller = AceType::MakeRefPtr<SwiperController>();
1109         pattern->SetSwiperController(controller);
1110     }
1111     return pattern->GetSwiperController();
1112 }
1113 
GetSwiperController(FrameNode * frameNode)1114 RefPtr<SwiperController> SwiperModelNG::GetSwiperController(FrameNode* frameNode)
1115 {
1116     CHECK_NULL_RETURN(frameNode, nullptr);
1117     auto pattern = frameNode->GetPattern<SwiperPattern>();
1118     CHECK_NULL_RETURN(pattern, nullptr);
1119     return pattern->GetSwiperController();
1120 }
1121 
GetIndicatorInteractive(FrameNode * frameNode)1122 bool SwiperModelNG::GetIndicatorInteractive(FrameNode* frameNode)
1123 {
1124     CHECK_NULL_RETURN(frameNode, false);
1125     auto pattern = frameNode->GetPattern<SwiperPattern>();
1126     CHECK_NULL_RETURN(pattern, false);
1127     return pattern->IsIndicatorInteractive();
1128 }
1129 
SetOnSelected(std::function<void (const BaseEventInfo * info)> && onSelected)1130 void SwiperModelNG::SetOnSelected(std::function<void(const BaseEventInfo* info)>&& onSelected)
1131 {
1132     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1133     CHECK_NULL_VOID(swiperNode);
1134     auto pattern = swiperNode->GetPattern<SwiperPattern>();
1135     CHECK_NULL_VOID(pattern);
1136 
1137     pattern->UpdateOnSelectedEvent([event = std::move(onSelected)](int32_t index) {
1138         CHECK_NULL_VOID(event);
1139         SwiperChangeEvent eventInfo(index);
1140         event(&eventInfo);
1141     });
1142 }
1143 
SetOnSelected(FrameNode * frameNode,std::function<void (const BaseEventInfo * info)> && onSelected)1144 void SwiperModelNG::SetOnSelected(FrameNode* frameNode, std::function<void(const BaseEventInfo* info)>&& onSelected)
1145 {
1146     CHECK_NULL_VOID(frameNode);
1147     auto pattern = frameNode->GetPattern<SwiperPattern>();
1148     CHECK_NULL_VOID(pattern);
1149     pattern->UpdateOnSelectedEvent([event = std::move(onSelected)](int32_t index) {
1150         CHECK_NULL_VOID(event);
1151         SwiperChangeEvent eventInfo(index);
1152         event(&eventInfo);
1153     });
1154 }
1155 
GetArrowStyle(FrameNode * frameNode)1156 SwiperArrowParameters SwiperModelNG::GetArrowStyle(FrameNode* frameNode)
1157 {
1158     SwiperArrowParameters swiperArrowParameters;
1159     CHECK_NULL_RETURN(frameNode, swiperArrowParameters);
1160     auto castSwiperLayoutProperty = frameNode->GetLayoutPropertyPtr<SwiperLayoutProperty>();
1161     CHECK_NULL_RETURN(castSwiperLayoutProperty, swiperArrowParameters);
1162     swiperArrowParameters.isShowBackground = castSwiperLayoutProperty->GetIsShowBackground();
1163     swiperArrowParameters.isSidebarMiddle = castSwiperLayoutProperty->GetIsSidebarMiddle();
1164     swiperArrowParameters.backgroundSize = castSwiperLayoutProperty->GetBackgroundSize();
1165     swiperArrowParameters.backgroundColor = castSwiperLayoutProperty->GetBackgroundColor();
1166     swiperArrowParameters.arrowSize = castSwiperLayoutProperty->GetArrowSize();
1167     swiperArrowParameters.arrowColor = castSwiperLayoutProperty->GetArrowColor();
1168     return swiperArrowParameters;
1169 }
1170 
ResetArrowStyle(FrameNode * frameNode)1171 void SwiperModelNG::ResetArrowStyle(FrameNode* frameNode)
1172 {
1173     ACE_RESET_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, IsShowBackground, frameNode);
1174     ACE_RESET_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, BackgroundSize, frameNode);
1175     ACE_RESET_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, BackgroundColor, frameNode);
1176     ACE_RESET_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, ArrowSize, frameNode);
1177     ACE_RESET_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, ArrowColor, frameNode);
1178     ACE_RESET_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, IsSidebarMiddle, frameNode);
1179     if (SystemProperties::ConfigChangePerform()) {
1180         auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1181         CHECK_NULL_VOID(swiperNode);
1182         auto pattern = swiperNode->GetPattern<SwiperPattern>();
1183         CHECK_NULL_VOID(pattern);
1184         SwiperArrowParameters swiperArrowParameters;
1185         pattern->SetSwiperArrowParameters(swiperArrowParameters);
1186         CreateArrowWithResourceObj(swiperArrowParameters);
1187     }
1188 }
1189 
ResetIndicatorStyle(FrameNode * frameNode)1190 void SwiperModelNG::ResetIndicatorStyle(FrameNode* frameNode)
1191 {
1192     CHECK_NULL_VOID(frameNode);
1193     auto pattern = frameNode->GetPattern<SwiperPattern>();
1194     CHECK_NULL_VOID(pattern);
1195     pattern->ResetIndicatorParameters();
1196     frameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
1197     if (SystemProperties::ConfigChangePerform()) {
1198         static_cast<SwiperIndicatorType>(GetIndicatorType(frameNode)) == SwiperIndicatorType::DOT
1199             ? CreateDotWithResourceObj(frameNode, SwiperParameters())
1200             : CreateDigitWithResourceObj(frameNode, SwiperDigitalParameters());
1201     }
1202 }
1203 
GetSwipeByGroup(FrameNode * frameNode)1204 int SwiperModelNG::GetSwipeByGroup(FrameNode* frameNode)
1205 {
1206     bool value = false;
1207     ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE(SwiperLayoutProperty, SwipeByGroup, value, frameNode, value);
1208     return value;
1209 }
1210 
GetDisplayMode(FrameNode * frameNode)1211 SwiperDisplayMode SwiperModelNG::GetDisplayMode(FrameNode* frameNode)
1212 {
1213     SwiperDisplayMode displayMode = SwiperDisplayMode::STRETCH;
1214     ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE(
1215         SwiperLayoutProperty, DisplayMode, displayMode, frameNode, displayMode);
1216     return displayMode;
1217 }
1218 
GetMinSize(FrameNode * frameNode)1219 float SwiperModelNG::GetMinSize(FrameNode* frameNode)
1220 {
1221     Dimension value(0, DimensionUnit::VP);
1222     ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE(SwiperLayoutProperty, MinSize, value, frameNode, value);
1223     return value.Value();
1224 }
1225 
GetDigitIndicator(FrameNode * frameNode)1226 std::shared_ptr<SwiperDigitalParameters> SwiperModelNG::GetDigitIndicator(FrameNode* frameNode)
1227 {
1228     CHECK_NULL_RETURN(frameNode, nullptr);
1229     auto pattern = frameNode->GetPattern<SwiperPattern>();
1230     CHECK_NULL_RETURN(pattern, nullptr);
1231     return pattern->GetSwiperDigitalParameters();
1232 }
1233 
SetMaintainVisibleContentPosition(bool value)1234 void SwiperModelNG::SetMaintainVisibleContentPosition(bool value)
1235 {
1236     ACE_UPDATE_LAYOUT_PROPERTY(SwiperLayoutProperty, MaintainVisibleContentPosition, value);
1237 }
1238 
SetMaintainVisibleContentPosition(FrameNode * frameNode,bool value)1239 void SwiperModelNG::SetMaintainVisibleContentPosition(FrameNode* frameNode, bool value)
1240 {
1241     ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, MaintainVisibleContentPosition, value, frameNode);
1242 }
1243 
SetOnScrollStateChanged(std::function<void (const BaseEventInfo * info)> && onScrollStateChanged)1244 void SwiperModelNG::SetOnScrollStateChanged(
1245     std::function<void(const BaseEventInfo* info)>&& onScrollStateChanged)
1246 {
1247     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1248     CHECK_NULL_VOID(swiperNode);
1249     auto pattern = swiperNode->GetPattern<SwiperPattern>();
1250     CHECK_NULL_VOID(pattern);
1251     pattern->UpdateOnScrollStateChangedEvent([event = std::move(onScrollStateChanged)](int32_t index) {
1252         CHECK_NULL_VOID(event);
1253         SwiperChangeEvent eventInfo(index);
1254         event(&eventInfo);
1255     });
1256 }
1257 
SetOnScrollStateChanged(FrameNode * frameNode,std::function<void (const BaseEventInfo * info)> && onScrollStateChanged)1258 void SwiperModelNG::SetOnScrollStateChanged(
1259     FrameNode* frameNode, std::function<void(const BaseEventInfo* info)>&& onScrollStateChanged)
1260 {
1261     CHECK_NULL_VOID(frameNode);
1262     auto pattern = frameNode->GetPattern<SwiperPattern>();
1263     CHECK_NULL_VOID(pattern);
1264     pattern->UpdateOnScrollStateChangedEvent([event = std::move(onScrollStateChanged)](int32_t index) {
1265         CHECK_NULL_VOID(event);
1266         SwiperChangeEvent eventInfo(index);
1267         event(&eventInfo);
1268     });
1269 }
1270 
GetMaintainVisibleContentPosition(FrameNode * frameNode)1271 bool SwiperModelNG::GetMaintainVisibleContentPosition(FrameNode* frameNode)
1272 {
1273     bool value = false;
1274     ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE(
1275         SwiperLayoutProperty, MaintainVisibleContentPosition, value, frameNode, value);
1276     return value;
1277 }
1278 
ProcessDotPositionWithResourceObj(FrameNode * frameNode,const std::string & name,const RefPtr<ResourceObject> & resObj)1279 void SwiperModelNG::ProcessDotPositionWithResourceObj(FrameNode* frameNode, const std::string& name,
1280     const RefPtr<ResourceObject>& resObj)
1281 {
1282     CHECK_NULL_VOID(frameNode);
1283     auto pattern = frameNode->GetPattern<SwiperPattern>();
1284     CHECK_NULL_VOID(pattern);
1285     if (resObj) {
1286         auto&& updateFunc = [weak = AceType::WeakClaim(frameNode), name](const RefPtr<ResourceObject>& theObj) {
1287             auto node = weak.Upgrade();
1288             CHECK_NULL_VOID(node);
1289             auto pattern = node->GetPattern<SwiperPattern>();
1290             CHECK_NULL_VOID(pattern);
1291             CalcDimension result;
1292             bool parseOk = ResourceParseUtils::ParseResDimensionVpNG(theObj, result);
1293             result = parseOk && result.ConvertToPx() >= 0.0f ? result : 0.0_vp;
1294             auto params = pattern->GetSwiperParameters();
1295             CHECK_NULL_VOID(params);
1296             if (name == "dimLeft") {
1297                 params->dimLeft = result;
1298             } else if (name == "dimTop") {
1299                 params->dimTop = result;
1300             } else if (name == "dimRight") {
1301                 params->dimRight = result;
1302             } else if (name == "dimBottom") {
1303                 params->dimBottom = result;
1304             }
1305         };
1306         pattern->AddResObj("swiper." + name, resObj, std::move(updateFunc));
1307     } else {
1308         pattern->RemoveResObj("swiper." + name);
1309     }
1310 }
1311 
ProcessDotSizeWithResourceObj(FrameNode * frameNode,const std::string & name,const RefPtr<ResourceObject> & resObj)1312 void SwiperModelNG::ProcessDotSizeWithResourceObj(FrameNode* frameNode, const std::string& name,
1313     const RefPtr<ResourceObject>& resObj)
1314 {
1315     CHECK_NULL_VOID(frameNode);
1316     auto pattern = frameNode->GetPattern<SwiperPattern>();
1317     CHECK_NULL_VOID(pattern);
1318     if (resObj) {
1319         auto&& updateFunc = [weak = AceType::WeakClaim(frameNode), name](const RefPtr<ResourceObject>& theObj) {
1320             auto node = weak.Upgrade();
1321             CHECK_NULL_VOID(node);
1322             auto pattern = node->GetPattern<SwiperPattern>();
1323             CHECK_NULL_VOID(pattern);
1324             CalcDimension result;
1325             bool parseOk = ResourceParseUtils::ParseResDimensionVpNG(theObj, result);
1326             if (!(parseOk && result > 0.0_vp)) {
1327                 auto pipelineContext = node->GetContext();
1328                 CHECK_NULL_VOID(pipelineContext);
1329                 auto theme = pipelineContext->GetTheme<SwiperIndicatorTheme>();
1330                 CHECK_NULL_VOID(theme);
1331                 result = theme->GetSize();
1332             }
1333             auto param = pattern->GetSwiperParameters();
1334             CHECK_NULL_VOID(param);
1335             if (name == "itemWidth") {
1336                 param->itemWidth = result;
1337             } else if (name == "itemHeight") {
1338                 param->itemHeight = result;
1339             } else if (name == "selectedItemWidth") {
1340                 param->selectedItemWidth = result;
1341             } else if (name == "selectedItemHeight") {
1342                 param->selectedItemHeight = result;
1343             }
1344         };
1345         pattern->AddResObj("swiper." + name, resObj, std::move(updateFunc));
1346     } else {
1347         pattern->RemoveResObj("swiper." + name);
1348     }
1349 }
1350 
ProcessDotColorWithResourceObj(FrameNode * frameNode,const std::string & name,const RefPtr<ResourceObject> & resObj)1351 void SwiperModelNG::ProcessDotColorWithResourceObj(FrameNode* frameNode, const std::string& name,
1352     const RefPtr<ResourceObject>& resObj)
1353 {
1354     CHECK_NULL_VOID(frameNode);
1355     auto pattern = frameNode->GetPattern<SwiperPattern>();
1356     CHECK_NULL_VOID(pattern);
1357     if (resObj) {
1358         auto&& updateFunc = [weak = AceType::WeakClaim(frameNode), name](const RefPtr<ResourceObject>& theObj) {
1359             auto node = weak.Upgrade();
1360             CHECK_NULL_VOID(node);
1361             auto pattern = node->GetPattern<SwiperPattern>();
1362             CHECK_NULL_VOID(pattern);
1363             Color result;
1364             bool parseOk = ResourceParseUtils::ParseResColor(theObj, result);
1365             auto param = pattern->GetSwiperParameters();
1366             CHECK_NULL_VOID(param);
1367             if (!parseOk) {
1368                 param->parametersByUser.erase(name);
1369                 auto pipelineContext = node->GetContext();
1370                 CHECK_NULL_VOID(pipelineContext);
1371                 auto theme = pipelineContext->GetTheme<SwiperIndicatorTheme>();
1372                 CHECK_NULL_VOID(theme);
1373                 result = name == "colorVal" ? theme->GetColor() : theme->GetSelectedColor();
1374             } else {
1375                 param->parametersByUser.insert(name);
1376             }
1377             name == "colorVal" ? param->colorVal = result : param->selectedColorVal = result;
1378         };
1379         pattern->AddResObj("swiper." + name, resObj, std::move(updateFunc));
1380     } else {
1381         pattern->RemoveResObj("swiper." + name);
1382     }
1383 }
1384 
ProcessDigitalPositionWithResourceObj(FrameNode * frameNode,const std::string & name,const RefPtr<ResourceObject> & resObj)1385 void SwiperModelNG::ProcessDigitalPositionWithResourceObj(FrameNode* frameNode, const std::string& name,
1386     const RefPtr<ResourceObject>& resObj)
1387 {
1388     CHECK_NULL_VOID(frameNode);
1389     auto pattern = frameNode->GetPattern<SwiperPattern>();
1390     CHECK_NULL_VOID(pattern);
1391     if (resObj) {
1392         auto&& updateFunc = [weak = AceType::WeakClaim(frameNode), name](const RefPtr<ResourceObject>& theObj) {
1393             auto node = weak.Upgrade();
1394             CHECK_NULL_VOID(node);
1395             auto pattern = node->GetPattern<SwiperPattern>();
1396             CHECK_NULL_VOID(pattern);
1397             CalcDimension result;
1398             bool parseOk = ResourceParseUtils::ParseResDimensionVpNG(theObj, result);
1399             result = parseOk && result.ConvertToPx() >= 0.0f ? result : 0.0_vp;
1400             auto params = pattern->GetSwiperDigitalParameters();
1401             CHECK_NULL_VOID(params);
1402             if (name == "dimLeft") {
1403                 params->dimLeft = result;
1404             } else if (name == "dimTop") {
1405                 params->dimTop = result;
1406             } else if (name == "dimRight") {
1407                 params->dimRight = result;
1408             } else if (name == "dimBottom") {
1409                 params->dimBottom = result;
1410             }
1411         };
1412         pattern->AddResObj("swiper." + name, resObj, std::move(updateFunc));
1413     } else {
1414         pattern->RemoveResObj("swiper." + name);
1415     }
1416 }
1417 
ProcessDigitalFontSizeWithResourceObj(FrameNode * frameNode,const std::string & name,const RefPtr<ResourceObject> & resObj)1418 void SwiperModelNG::ProcessDigitalFontSizeWithResourceObj(FrameNode* frameNode, const std::string& name,
1419     const RefPtr<ResourceObject>& resObj)
1420 {
1421     CHECK_NULL_VOID(frameNode);
1422     auto pattern = frameNode->GetPattern<SwiperPattern>();
1423     CHECK_NULL_VOID(pattern);
1424     if (resObj) {
1425         auto&& updateFunc = [weak = AceType::WeakClaim(frameNode), name](const RefPtr<ResourceObject>& theObj) {
1426             auto node = weak.Upgrade();
1427             CHECK_NULL_VOID(node);
1428             auto pattern = node->GetPattern<SwiperPattern>();
1429             CHECK_NULL_VOID(pattern);
1430             CalcDimension result;
1431             bool parseOk = ResourceParseUtils::ParseResDimensionFpNG(theObj, result);
1432             if (!parseOk || LessOrEqual(result.Value(), 0.0) || result.Unit() == DimensionUnit::PERCENT) {
1433                 auto pipelineContext = node->GetContext();
1434                 CHECK_NULL_VOID(pipelineContext);
1435                 auto theme = pipelineContext->GetTheme<SwiperIndicatorTheme>();
1436                 CHECK_NULL_VOID(theme);
1437                 result = theme->GetDigitalIndicatorTextStyle().GetFontSize();
1438             }
1439             auto params = pattern->GetSwiperDigitalParameters();
1440             CHECK_NULL_VOID(params);
1441             if (name == "fontSize") {
1442                 params->fontSize = result;
1443             } else if (name == "selectedFontSize") {
1444                 params->selectedFontSize = result;
1445             }
1446         };
1447         pattern->AddResObj("swiper." + name, resObj, std::move(updateFunc));
1448     } else {
1449         pattern->RemoveResObj("swiper." + name);
1450     }
1451 }
1452 
ProcessDigitalColorWithResourceObj(FrameNode * frameNode,const std::string & name,const RefPtr<ResourceObject> & resObj)1453 void SwiperModelNG::ProcessDigitalColorWithResourceObj(FrameNode* frameNode, const std::string& name,
1454     const RefPtr<ResourceObject>& resObj)
1455 {
1456     CHECK_NULL_VOID(frameNode);
1457     auto pattern = frameNode->GetPattern<SwiperPattern>();
1458     CHECK_NULL_VOID(pattern);
1459     if (resObj) {
1460         auto&& updateFunc = [weak = AceType::WeakClaim(frameNode), name](const RefPtr<ResourceObject>& theObj) {
1461             auto node = weak.Upgrade();
1462             CHECK_NULL_VOID(node);
1463             auto pattern = node->GetPattern<SwiperPattern>();
1464             CHECK_NULL_VOID(pattern);
1465             Color result;
1466             bool parseOk = ResourceParseUtils::ParseResColor(theObj, result);
1467             auto params = pattern->GetSwiperDigitalParameters();
1468             CHECK_NULL_VOID(params);
1469             if (!parseOk) {
1470                 params->parametersByUser.erase(name);
1471                 auto pipelineContext = node->GetContext();
1472                 CHECK_NULL_VOID(pipelineContext);
1473                 auto theme = pipelineContext->GetTheme<SwiperIndicatorTheme>();
1474                 CHECK_NULL_VOID(theme);
1475                 result = theme->GetDigitalIndicatorTextStyle().GetTextColor();
1476             } else {
1477                 params->parametersByUser.insert(name);
1478             }
1479             if (name == "fontColor") {
1480                 params->fontColor = result;
1481             } else if (name == "selectedFontColor") {
1482                 params->selectedFontColor = result;
1483             }
1484         };
1485         pattern->AddResObj("swiper." + name, resObj, std::move(updateFunc));
1486     } else {
1487         pattern->RemoveResObj("swiper." + name);
1488     }
1489 }
1490 
ProcessArrowColorWithResourceObj(FrameNode * frameNode,const RefPtr<ResourceObject> & resObj)1491 void SwiperModelNG::ProcessArrowColorWithResourceObj(FrameNode* frameNode, const RefPtr<ResourceObject>& resObj)
1492 {
1493     CHECK_NULL_VOID(frameNode);
1494     auto pattern = frameNode->GetPattern<SwiperPattern>();
1495     CHECK_NULL_VOID(pattern);
1496     if (resObj) {
1497         auto&& updateFunc = [weak = AceType::WeakClaim(frameNode)](const RefPtr<ResourceObject>& theObj) {
1498             auto node = weak.Upgrade();
1499             CHECK_NULL_VOID(node);
1500             auto pattern = node->GetPattern<SwiperPattern>();
1501             CHECK_NULL_VOID(pattern);
1502             Color result;
1503             bool parseOk = ResourceParseUtils::ParseResColor(theObj, result);
1504             auto param = pattern->GetSwiperArrowParameters();
1505             CHECK_NULL_VOID(param);
1506             if (!parseOk) {
1507                 param->parametersByUser.erase("arrowColor");
1508                 auto pipelineContext = node->GetContext();
1509                 CHECK_NULL_VOID(pipelineContext);
1510                 auto theme = pipelineContext->GetTheme<SwiperIndicatorTheme>();
1511                 CHECK_NULL_VOID(theme);
1512                 result = param->isSidebarMiddle.value() ? theme->GetBigArrowColor() : theme->GetSmallArrowColor();
1513             } else {
1514                 param->parametersByUser.insert("arrowColor");
1515             }
1516             ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, ArrowColor, result, node);
1517         };
1518         pattern->AddResObj("swiper.ArrowColor", resObj, std::move(updateFunc));
1519     } else {
1520         pattern->RemoveResObj("swiper.ArrowColor");
1521     }
1522 }
1523 
ProcessArrowBackgroundColorWithResourceObj(FrameNode * frameNode,const RefPtr<ResourceObject> & resObj)1524 void SwiperModelNG::ProcessArrowBackgroundColorWithResourceObj(FrameNode* frameNode,
1525     const RefPtr<ResourceObject>& resObj)
1526 {
1527     CHECK_NULL_VOID(frameNode);
1528     auto pattern = frameNode->GetPattern<SwiperPattern>();
1529     CHECK_NULL_VOID(pattern);
1530     if (resObj) {
1531         auto&& updateFunc = [weak = AceType::WeakClaim(frameNode)](const RefPtr<ResourceObject>& theObj) {
1532             auto node = weak.Upgrade();
1533             CHECK_NULL_VOID(node);
1534             auto pattern = node->GetPattern<SwiperPattern>();
1535             CHECK_NULL_VOID(pattern);
1536             Color result;
1537             bool parseOk = ResourceParseUtils::ParseResColor(theObj, result);
1538             auto param = pattern->GetSwiperArrowParameters();
1539             CHECK_NULL_VOID(param);
1540             if (!parseOk) {
1541                 param->parametersByUser.erase("backgroundColor");
1542                 auto pipelineContext = node->GetContext();
1543                 CHECK_NULL_VOID(pipelineContext);
1544                 auto theme = pipelineContext->GetTheme<SwiperIndicatorTheme>();
1545                 CHECK_NULL_VOID(theme);
1546                 result = param->isSidebarMiddle.value() ? theme->GetBigArrowBackgroundColor()
1547                     : theme->GetSmallArrowBackgroundColor();
1548             } else {
1549                 param->parametersByUser.insert("backgroundColor");
1550             }
1551             ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, BackgroundColor, result, node);
1552         };
1553         pattern->AddResObj("swiper.BackgroundColor", resObj, std::move(updateFunc));
1554     } else {
1555         pattern->RemoveResObj("swiper.BackgroundColor");
1556     }
1557 }
1558 
ProcessArrowSizeWithResourceObj(FrameNode * frameNode,const RefPtr<ResourceObject> & resObj)1559 void SwiperModelNG::ProcessArrowSizeWithResourceObj(FrameNode* frameNode, const RefPtr<ResourceObject>& resObj)
1560 {
1561     CHECK_NULL_VOID(frameNode);
1562     auto pattern = frameNode->GetPattern<SwiperPattern>();
1563     CHECK_NULL_VOID(pattern);
1564     if (resObj) {
1565         auto&& updateFunc = [weak = AceType::WeakClaim(frameNode)](const RefPtr<ResourceObject>& resObj) {
1566             auto node = weak.Upgrade();
1567             CHECK_NULL_VOID(node);
1568             auto pattern = node->GetPattern<SwiperPattern>();
1569             CHECK_NULL_VOID(pattern);
1570             auto swiperArrowParameters = pattern->GetSwiperArrowParameters();
1571             CHECK_NULL_VOID(swiperArrowParameters);
1572             CalcDimension result;
1573             bool parseOk = ResourceParseUtils::ParseResDimensionVpNG(resObj, result);
1574             if (!parseOk || LessOrEqual(result.ConvertToVp(), 0.0) ||
1575                 (result.Unit() == DimensionUnit::PERCENT)) {
1576                     auto pipelineContext = node->GetContext();
1577                     CHECK_NULL_VOID(pipelineContext);
1578                     auto swiperIndicatorTheme = pipelineContext->GetTheme<SwiperIndicatorTheme>();
1579                     CHECK_NULL_VOID(swiperIndicatorTheme);
1580                     result = swiperArrowParameters->isSidebarMiddle.value()
1581                         ? swiperIndicatorTheme->GetBigArrowSize()
1582                         : swiperIndicatorTheme->GetSmallArrowSize();
1583             }
1584             swiperArrowParameters->arrowSize = result;
1585             if (swiperArrowParameters->isShowBackground.value()) {
1586                 swiperArrowParameters->arrowSize = swiperArrowParameters->backgroundSize.value()
1587                     * ARROW_SIZE_COEFFICIENT;
1588             } else {
1589                 swiperArrowParameters->backgroundSize = swiperArrowParameters->arrowSize;
1590                 ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, BackgroundSize,
1591                     swiperArrowParameters->backgroundSize.value(), node);
1592             }
1593             ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, ArrowSize,
1594                 swiperArrowParameters->arrowSize.value(), node);
1595         };
1596         pattern->AddResObj("swiper.ArrowSize", resObj, std::move(updateFunc));
1597     } else {
1598         pattern->RemoveResObj("swiper.ArrowSize");
1599     }
1600 }
1601 
ProcessBackgroundSizeWithResourceObj(FrameNode * frameNode,const RefPtr<ResourceObject> & resObj)1602 void SwiperModelNG::ProcessBackgroundSizeWithResourceObj(FrameNode* frameNode, const RefPtr<ResourceObject>& resObj)
1603 {
1604     CHECK_NULL_VOID(frameNode);
1605     auto pattern = frameNode->GetPattern<SwiperPattern>();
1606     CHECK_NULL_VOID(pattern);
1607     if (resObj) {
1608         auto&& updateFunc = [weak = AceType::WeakClaim(frameNode)](const RefPtr<ResourceObject>& resObj) {
1609             auto node = weak.Upgrade();
1610             CHECK_NULL_VOID(node);
1611             auto pattern = node->GetPattern<SwiperPattern>();
1612             CHECK_NULL_VOID(pattern);
1613             auto swiperArrowParameters = pattern->GetSwiperArrowParameters();
1614             CHECK_NULL_VOID(swiperArrowParameters);
1615             CalcDimension result;
1616             bool parseOk = ResourceParseUtils::ParseResDimensionVpNG(resObj, result);
1617             if (!parseOk || LessOrEqual(result.ConvertToVp(), 0.0) ||
1618                 (result.Unit() == DimensionUnit::PERCENT)) {
1619                     auto pipelineContext = node->GetContext();
1620                     CHECK_NULL_VOID(pipelineContext);
1621                     auto swiperIndicatorTheme = pipelineContext->GetTheme<SwiperIndicatorTheme>();
1622                     CHECK_NULL_VOID(swiperIndicatorTheme);
1623                     result = swiperArrowParameters->isSidebarMiddle.value()
1624                         ? swiperIndicatorTheme->GetBigArrowBackgroundSize()
1625                         : swiperIndicatorTheme->GetSmallArrowBackgroundSize();
1626             }
1627             swiperArrowParameters->backgroundSize = result;
1628             ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, BackgroundSize, result, node);
1629             if (swiperArrowParameters->isShowBackground.value()) {
1630                 swiperArrowParameters->arrowSize = swiperArrowParameters->backgroundSize.value()
1631                     * ARROW_SIZE_COEFFICIENT;
1632                 ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, ArrowSize,
1633                     swiperArrowParameters->arrowSize.value(), node);
1634             }
1635         };
1636         pattern->AddResObj("swiper.BackgroundSize", resObj, std::move(updateFunc));
1637     } else {
1638         pattern->RemoveResObj("swiper.BackgroundSize");
1639     }
1640 }
1641 
ProcessNextMarginWithResourceObj(const RefPtr<ResourceObject> & resObj)1642 void SwiperModelNG::ProcessNextMarginWithResourceObj(const RefPtr<ResourceObject>& resObj)
1643 {
1644     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1645     CHECK_NULL_VOID(frameNode);
1646     auto pattern = frameNode->GetPattern<SwiperPattern>();
1647     CHECK_NULL_VOID(pattern);
1648     if (resObj) {
1649         auto&& updateFunc = [weak = AceType::WeakClaim(frameNode)](const RefPtr<ResourceObject>& resObj) {
1650             auto node = weak.Upgrade();
1651             CHECK_NULL_VOID(node);
1652             auto pattern = node->GetPattern<SwiperPattern>();
1653             CHECK_NULL_VOID(pattern);
1654             CalcDimension result;
1655             if (!ResourceParseUtils::ParseResDimensionVpNG(resObj, result) || LessNotEqual(result.Value(), 0.0)) {
1656                 result.SetValue(0.0);
1657             }
1658             pattern->ResetOnForceMeasure();
1659             ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, NextMargin, result, node);
1660         };
1661         pattern->AddResObj("swiper.nextMargin", resObj, std::move(updateFunc));
1662     } else {
1663         pattern->RemoveResObj("swiper.nextMargin");
1664     }
1665 }
1666 
ProcessPreviousMarginWithResourceObj(const RefPtr<ResourceObject> & resObj)1667 void SwiperModelNG::ProcessPreviousMarginWithResourceObj(const RefPtr<ResourceObject>& resObj)
1668 {
1669     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1670     CHECK_NULL_VOID(frameNode);
1671     auto pattern = frameNode->GetPattern<SwiperPattern>();
1672     CHECK_NULL_VOID(pattern);
1673     if (resObj) {
1674         auto&& updateFunc = [weak = AceType::WeakClaim(frameNode)](const RefPtr<ResourceObject>& resObj) {
1675             auto node = weak.Upgrade();
1676             CHECK_NULL_VOID(node);
1677             auto pattern = node->GetPattern<SwiperPattern>();
1678             CHECK_NULL_VOID(pattern);
1679             CalcDimension result;
1680             if (!ResourceParseUtils::ParseResDimensionVpNG(resObj, result) || LessNotEqual(result.Value(), 0.0)) {
1681                 result.SetValue(0.0);
1682             }
1683             pattern->ResetOnForceMeasure();
1684             ACE_UPDATE_NODE_LAYOUT_PROPERTY(SwiperLayoutProperty, PrevMargin, result, node);
1685         };
1686         pattern->AddResObj("swiper.prevMargin", resObj, std::move(updateFunc));
1687     } else {
1688         pattern->RemoveResObj("swiper.prevMargin");
1689     }
1690 }
1691 
ProcessDotStyleSizeWithResourceObj(FrameNode * frameNode,const RefPtr<ResourceObject> & resObj)1692 void SwiperModelNG::ProcessDotStyleSizeWithResourceObj(FrameNode* frameNode, const RefPtr<ResourceObject>& resObj)
1693 {
1694     CHECK_NULL_VOID(frameNode);
1695     auto pattern = frameNode->GetPattern<SwiperPattern>();
1696     CHECK_NULL_VOID(pattern);
1697     if (resObj) {
1698         auto&& updateFunc = [weak = AceType::WeakClaim(frameNode)](const RefPtr<ResourceObject>& resObj) {
1699             auto node = weak.Upgrade();
1700             CHECK_NULL_VOID(node);
1701             auto pattern = node->GetPattern<SwiperPattern>();
1702             CHECK_NULL_VOID(pattern);
1703             CalcDimension result;
1704             if (!ResourceParseUtils::ParseResDimensionVpNG(resObj, result) ||
1705                 result.Unit() == DimensionUnit::PERCENT || LessNotEqual(result.Value(), 0.0)) {
1706                 auto pipelineContext = node->GetContext();
1707                 CHECK_NULL_VOID(pipelineContext);
1708                 auto swiperIndicatorTheme = pipelineContext->GetTheme<SwiperIndicatorTheme>();
1709                 CHECK_NULL_VOID(swiperIndicatorTheme);
1710                 result = swiperIndicatorTheme->GetSize();
1711             }
1712             auto params = pattern->GetSwiperParameters();
1713             CHECK_NULL_VOID(params);
1714             params->itemWidth = result;
1715             params->itemHeight = result;
1716             params->selectedItemWidth = result;
1717             params->selectedItemHeight = result;
1718         };
1719         pattern->AddResObj("swiper.ItemSize", resObj, std::move(updateFunc));
1720     } else {
1721         pattern->RemoveResObj("swiper.ItemSize");
1722     }
1723 }
1724 
CreateDotWithResourceObj(FrameNode * frameNode,const SwiperParameters & swiperParameters)1725 void SwiperModelNG::CreateDotWithResourceObj(FrameNode* frameNode, const SwiperParameters& swiperParameters)
1726 {
1727     CHECK_NULL_VOID(frameNode);
1728     auto pattern = frameNode->GetPattern<SwiperPattern>();
1729     CHECK_NULL_VOID(pattern);
1730     auto resObj = swiperParameters.resourceColorValueObject;
1731     ProcessDotColorWithResourceObj(frameNode, "colorVal", resObj);
1732     resObj = swiperParameters.resourceSelectedColorValueObject;
1733     ProcessDotColorWithResourceObj(frameNode, "selectedColorVal", resObj);
1734     resObj = swiperParameters.resourceItemWidthValueObject;
1735     ProcessDotSizeWithResourceObj(frameNode, "itemWidth", resObj);
1736     resObj = swiperParameters.resourceItemHeightValueObject;
1737     ProcessDotSizeWithResourceObj(frameNode, "itemHeight", resObj);
1738     resObj = swiperParameters.resourceSelectedItemWidthValueObject;
1739     ProcessDotSizeWithResourceObj(frameNode, "selectedItemWidth", resObj);
1740     resObj = swiperParameters.resourceSelectedItemHeightValueObject;
1741     ProcessDotSizeWithResourceObj(frameNode, "selectedItemHeight", resObj);
1742     resObj = swiperParameters.resourceDimLeftValueObject;
1743     ProcessDotPositionWithResourceObj(frameNode, "dimLeft", resObj);
1744     resObj = swiperParameters.resourceDimRightValueObject;
1745     ProcessDotPositionWithResourceObj(frameNode, "dimRight", resObj);
1746     resObj = swiperParameters.resourceDimTopValueObject;
1747     ProcessDotPositionWithResourceObj(frameNode, "dimTop", resObj);
1748     resObj = swiperParameters.resourceDimBottomValueObject;
1749     ProcessDotPositionWithResourceObj(frameNode, "dimBottom", resObj);
1750     resObj = swiperParameters.resourceItemSizeValueObject;
1751     ProcessDotStyleSizeWithResourceObj(frameNode, resObj);
1752 }
1753 
CreateDigitWithResourceObj(FrameNode * frameNode,const SwiperDigitalParameters & swiperDigitalParameters)1754 void SwiperModelNG::CreateDigitWithResourceObj(FrameNode* frameNode,
1755     const SwiperDigitalParameters& swiperDigitalParameters)
1756 {
1757     CHECK_NULL_VOID(frameNode);
1758     auto resObj = swiperDigitalParameters.resourceDimLeftValueObject;
1759     ProcessDigitalPositionWithResourceObj(frameNode, "dimLeft", resObj);
1760     resObj = swiperDigitalParameters.resourceDimRightValueObject;
1761     ProcessDigitalPositionWithResourceObj(frameNode, "dimRight", resObj);
1762     resObj = swiperDigitalParameters.resourceDimTopValueObject;
1763     ProcessDigitalPositionWithResourceObj(frameNode, "dimTop", resObj);
1764     resObj = swiperDigitalParameters.resourceDimBottomValueObject;
1765     ProcessDigitalPositionWithResourceObj(frameNode, "dimBottom", resObj);
1766     resObj = swiperDigitalParameters.resourceFontColorValueObject;
1767     ProcessDigitalColorWithResourceObj(frameNode, "fontColor", resObj);
1768     resObj = swiperDigitalParameters.resourceSelectedFontColorValueObject;
1769     ProcessDigitalColorWithResourceObj(frameNode, "selectedFontColor", resObj);
1770     resObj = swiperDigitalParameters.resourceFontSizeValueObject;
1771     ProcessDigitalFontSizeWithResourceObj(frameNode, "fontSize", resObj);
1772     resObj = swiperDigitalParameters.resourceSelectedFontSizeValueObject;
1773     ProcessDigitalFontSizeWithResourceObj(frameNode, "selectedFontSize", resObj);
1774 }
1775 
CreateArrowWithResourceObj(const SwiperArrowParameters & swiperArrowParameters)1776 void SwiperModelNG::CreateArrowWithResourceObj(const SwiperArrowParameters& swiperArrowParameters)
1777 {
1778     auto swiperNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1779     CHECK_NULL_VOID(swiperNode);
1780     auto pattern = swiperNode->GetPattern<SwiperPattern>();
1781     CHECK_NULL_VOID(pattern);
1782     auto resObj = swiperArrowParameters.resourceArrowColorValueObject;
1783     ProcessArrowColorWithResourceObj(swiperNode, resObj);
1784     resObj = swiperArrowParameters.resourceBackgroundColorValueObject;
1785     ProcessArrowBackgroundColorWithResourceObj(swiperNode, resObj);
1786     resObj = swiperArrowParameters.resourceArrowSizeValueObject;
1787     ProcessArrowSizeWithResourceObj(swiperNode, resObj);
1788     resObj = swiperArrowParameters.resourceBackgroundSizeValueObject;
1789     ProcessBackgroundSizeWithResourceObj(swiperNode, resObj);
1790 }
1791 } // namespace OHOS::Ace::NG
1792