!36501 CAPI swiper 支持 IndicatorInteractive

Merge pull request !36501 from honzx/0626_swiper_capi
This commit is contained in:
openharmony_ci 2024-07-02 08:10:22 +00:00 committed by Gitee
commit b54658b99b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 66 additions and 5 deletions

View File

@ -853,4 +853,12 @@ RefPtr<SwiperController> SwiperModelNG::GetSwiperController(FrameNode* frameNode
CHECK_NULL_RETURN(pattern, nullptr);
return pattern->GetSwiperController();
}
bool SwiperModelNG::GetIndicatorInteractive(FrameNode* frameNode)
{
CHECK_NULL_RETURN(frameNode, false);
auto pattern = frameNode->GetPattern<SwiperPattern>();
CHECK_NULL_RETURN(pattern, false);
return pattern->IsIndicatorInteractive();
}
} // namespace OHOS::Ace::NG

View File

@ -140,6 +140,7 @@ public:
static void SetOnContentDidScroll(FrameNode* frameNode, ContentDidScrollEvent&& onContentDidScroll);
static void SetCustomContentTransition(FrameNode* frameNode, SwiperContentAnimatedTransition& transition);
static RefPtr<SwiperController> GetOrCreateSwiperController(FrameNode* frameNode);
static bool GetIndicatorInteractive(FrameNode* frameNode);
};
} // namespace OHOS::Ace::NG

View File

@ -2253,6 +2253,7 @@ struct ArkUISwiperModifier {
void (*resetSwiperOnGestureSwipe)(ArkUINodeHandle node);
void (*setSwiperOnContentDidScroll)(ArkUINodeHandle node, void* callback);
void (*resetSwiperOnContentDidScroll)(ArkUINodeHandle node);
ArkUI_Int32 (*getIndicatorInteractive)(ArkUINodeHandle node);
};
struct ArkUISwiperControllerModifier {

View File

@ -405,7 +405,19 @@ void SetIndicatorInteractive(ArkUINodeHandle node, ArkUI_Bool value)
SwiperModelNG::SetIndicatorInteractive(frameNode, static_cast<bool>(value));
}
void ResetIndicatorInteractive(ArkUINodeHandle node) {}
void ResetIndicatorInteractive(ArkUINodeHandle node)
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_VOID(frameNode);
SwiperModelNG::SetIndicatorInteractive(frameNode, true);
}
ArkUI_Int32 GetIndicatorInteractive(ArkUINodeHandle node)
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
return static_cast<ArkUI_Int32>(SwiperModelNG::GetIndicatorInteractive(frameNode));
}
void SetSwiperNextMargin(
ArkUINodeHandle node, ArkUI_Float32 nextMarginValue, ArkUI_Int32 nextMarginUnit, ArkUI_Bool ignoreBlank)
@ -1138,7 +1150,7 @@ const ArkUISwiperModifier* GetSwiperModifier()
GetSwiperNextMargin, SetSwiperIndicatorStyle, GetSwiperIndicator, GetSwiperController,
SetSwiperOnChange, ResetSwiperOnChange, SetSwiperOnAnimationStart, ResetSwiperOnAnimationStart,
SetSwiperOnAnimationEnd, ResetSwiperOnAnimationEnd, SetSwiperOnGestureSwipe, ResetSwiperOnGestureSwipe,
SetOnContentDidScroll, ResetOnContentDidScroll };
SetOnContentDidScroll, ResetOnContentDidScroll, GetIndicatorInteractive };
return &modifier;
}

View File

@ -4535,6 +4535,18 @@ typedef enum {
*/
NODE_SWIPER_SWIPE_TO_INDEX,
/**
* @brief Set to disable component navigation point interactions.
*
* Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n
* .value[0].i32: Set to disable component navigation point interaction, set to true to indicate the navigation point
* is interactive, default value is true.\n
* \n
* The return value of the attribute acquisition method {@link ArkUI_AttributeItem} format: \n
* .value[0].i32: Set to disable component navigation point interactions. \n
*/
NODE_SWIPER_INDICATOR_INTERACTIVE,
/**
* @brief: Set the delineation component of the ListItem, supporting property settings, property resets, and
* property acquisition interfaces.

View File

@ -7245,6 +7245,32 @@ const ArkUI_AttributeItem* GetSwiperIndicator(ArkUI_NodeHandle node)
return &g_attributeItem;
}
int32_t SetSwiperIndicatorInteractive(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
{
auto actualSize = CheckAttributeItemArray(item, REQUIRED_ONE_PARAM);
if (actualSize < 0) {
return ERROR_CODE_PARAM_INVALID;
}
auto* fullImpl = GetFullImpl();
fullImpl->getNodeModifiers()->getSwiperModifier()->setIndicatorInteractive(node->uiNodeHandle,
static_cast<bool>(item->value[0].i32));
return ERROR_CODE_NO_ERROR;
}
void ResetSwiperIndicatorInteractive(ArkUI_NodeHandle node)
{
auto* fullImpl = GetFullImpl();
fullImpl->getNodeModifiers()->getSwiperModifier()->resetIndicatorInteractive(node->uiNodeHandle);
}
const ArkUI_AttributeItem* GetSwiperIndicatorInteractive(ArkUI_NodeHandle node)
{
ArkUI_Int32 value = GetFullImpl()->getNodeModifiers()->getSwiperModifier()->
getIndicatorInteractive(node->uiNodeHandle);
g_numberValues[0].i32 = value;
return &g_attributeItem;
}
int32_t SetTextFontFamily(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
{
if (item->string == nullptr) {
@ -13514,7 +13540,7 @@ int32_t SetSwiperAttribute(ArkUI_NodeHandle node, int32_t subTypeId, const ArkUI
SetSwiperVertical, SetSwiperDuration, SetSwiperCurve, SetSwiperItemSpace, SetSwiperIndex, SetSwiperDisplayCount,
SetSwiperDisableSwipe, SetSwiperShowDisplayArrow, SetSwiperEffectMode, SetSwiperNodeAdapter,
SetSwiperCachedCount, SetSwiperPrevMargin, SetSwiperNextMargin, SetSwiperIndicator, SetSwiperNestedScroll,
SetSwiperToIndex };
SetSwiperToIndex, SetSwiperIndicatorInteractive };
if (subTypeId >= sizeof(setters) / sizeof(Setter*)) {
TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "swiper node attribute: %{public}d NOT IMPLEMENT", subTypeId);
return ERROR_CODE_NATIVE_IMPL_TYPE_NOT_SUPPORTED;
@ -13528,7 +13554,8 @@ void ResetSwiperAttribute(ArkUI_NodeHandle node, int32_t subTypeId)
ResetSwiperInterval, ResetSwiperVertical, ResetSwiperDuration, ResetSwiperCurve, ResetSwiperItemSpace,
ResetSwiperIndex, ResetSwiperDisplayCount, ResetSwiperDisableSwipe, ResetSwiperShowDisplayArrow,
ResetSwiperEffectMode, ResetSwiperNodeAdapter, ResetSwiperCachedCount, ResetSwiperPrevMargin,
ResetSwiperNextMargin, ResetSwiperIndicator, ResetSwiperNestedScroll, nullptr };
ResetSwiperNextMargin, ResetSwiperIndicator, ResetSwiperNestedScroll, nullptr,
ResetSwiperIndicatorInteractive };
if (static_cast<uint32_t>(subTypeId) >= sizeof(resetters) / sizeof(Resetter*)) {
TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "swiper node attribute: %{public}d NOT IMPLEMENT", subTypeId);
return;
@ -13542,7 +13569,7 @@ const ArkUI_AttributeItem* GetSwiperAttribute(ArkUI_NodeHandle node, int32_t sub
GetSwiperVertical, GetSwiperDuration, GetSwiperCurve, GetSwiperItemSpace, GetSwiperIndex, GetSwiperDisplayCount,
GetSwiperDisableSwipe, GetSwiperShowDisplayArrow, GetSwiperEffectMode, GetSwiperNodeAdapter,
GetSwiperCachedCount, GetSwiperPrevMargin, GetSwiperNextMargin, GetSwiperIndicator, GetSwiperNestedScroll,
nullptr };
nullptr, GetSwiperIndicatorInteractive };
if (subTypeId >= sizeof(getters) / sizeof(Getter*)) {
TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "swiper node attribute: %{public}d NOT IMPLEMENT", subTypeId);
return nullptr;