• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 #include "bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_alphabet_indexer_bridge.h"
16 #include "ui/base/ace_type.h"
17 
18 #include "core/interfaces/native/node/node_api.h"
19 #include "bridge/declarative_frontend/jsview/models/indexer_model_impl.h"
20 #include "frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_utils.h"
21 #include "frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_common_bridge.h"
22 namespace OHOS::Ace::NG {
23 namespace {
24 constexpr int NUM_0 = 0;
25 constexpr int NUM_1 = 1;
26 constexpr int NUM_2 = 2;
27 constexpr int NUM_3 = 3;
28 constexpr int NUM_4 = 4;
29 const std::string FORMAT_FONT = "%s|%s|%s";
30 const std::string DEFAULT_FAMILY = "HarmonyOS Sans";
31 constexpr double DEFAULT_POPUP_ITEM_FONT_SIZE = 24.0;
32 constexpr Dimension DEFAULT_FONT_SIZE_VAL = 12.0_fp;
33 const std::string DEFAULT_POPUP_ITEM_FONT_WEIGHT = "medium";
34 constexpr Dimension DEFAULT_POPUP_POSITION_X = 60.0_vp;
35 constexpr Dimension DEFAULT_POPUP_POSITION_Y = 48.0_vp;
36 constexpr double RADIUS_OFFSET = 4.0;
37 } // namespace
38 
SetPopupItemFont(ArkUIRuntimeCallInfo * runtimeCallInfo)39 ArkUINativeModuleValue AlphabetIndexerBridge::SetPopupItemFont(ArkUIRuntimeCallInfo* runtimeCallInfo)
40 {
41     EcmaVM* vm = runtimeCallInfo->GetVM();
42     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
43     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
44     Local<JSValueRef> fontSizeArg = runtimeCallInfo->GetCallArgRef(NUM_1);
45     Local<JSValueRef> weightArg = runtimeCallInfo->GetCallArgRef(NUM_2);
46     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
47     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
48     CalcDimension fontSize;
49     RefPtr<ResourceObject> resObj;
50     if (!fontSizeArg->IsNull()) {
51         CalcDimension fontSizeData;
52         if (ArkTSUtils::ParseJsDimensionFp(vm, fontSizeArg, fontSizeData, resObj) && !fontSizeData.IsNegative() &&
53             fontSizeData.Unit() != DimensionUnit::PERCENT) {
54             fontSize = fontSizeData;
55         }
56     }
57     std::string weight = DEFAULT_POPUP_ITEM_FONT_WEIGHT;
58     if (!weightArg->IsNull() && !weightArg->IsUndefined()) {
59         if (weightArg->IsNumber()) {
60             weight = std::to_string(weightArg->Int32Value(vm));
61         } else {
62             if (!ArkTSUtils::ParseJsString(vm, weightArg, weight) || weight.empty()) {
63                 weight = DEFAULT_POPUP_ITEM_FONT_WEIGHT;
64             }
65         }
66     }
67     if (SystemProperties::ConfigChangePerform()) {
68         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(nativeNode,
69             static_cast<int32_t>(IndexerJsResourceType::POPUP_ITEM_FONT_SIZE),
70             reinterpret_cast<void*>(AceType::RawPtr(resObj)));
71     }
72     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setPopupItemFont(
73         nativeNode, fontSize.Value(), static_cast<int>(fontSize.Unit()), weight.c_str());
74     return panda::JSValueRef::Undefined(vm);
75 }
76 
ResetPopupItemFont(ArkUIRuntimeCallInfo * runtimeCallInfo)77 ArkUINativeModuleValue AlphabetIndexerBridge::ResetPopupItemFont(ArkUIRuntimeCallInfo* runtimeCallInfo)
78 {
79     EcmaVM* vm = runtimeCallInfo->GetVM();
80     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
81     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
82     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
83     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
84     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetPopupItemFont(nativeNode);
85     if (SystemProperties::ConfigChangePerform()) {
86         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(
87             nativeNode, static_cast<int32_t>(IndexerJsResourceType::POPUP_ITEM_FONT_SIZE), nullptr);
88     }
89     return panda::JSValueRef::Undefined(vm);
90 }
91 
SetSelectedFont(ArkUIRuntimeCallInfo * runtimeCallInfo)92 ArkUINativeModuleValue AlphabetIndexerBridge::SetSelectedFont(ArkUIRuntimeCallInfo* runtimeCallInfo)
93 {
94     EcmaVM* vm = runtimeCallInfo->GetVM();
95     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
96     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
97     Local<JSValueRef> fontSizeArg = runtimeCallInfo->GetCallArgRef(NUM_1);
98     Local<JSValueRef> weightArg = runtimeCallInfo->GetCallArgRef(NUM_2);
99     Local<JSValueRef> fontFamilyArg = runtimeCallInfo->GetCallArgRef(NUM_3);
100     Local<JSValueRef> styleValArg = runtimeCallInfo->GetCallArgRef(NUM_4);
101     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
102     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
103     bool isUndefinedValue = (fontSizeArg->IsNull() || fontSizeArg->IsUndefined()) &&
104                             (weightArg->IsNull() || weightArg->IsUndefined()) &&
105                             (fontFamilyArg->IsNull() || fontFamilyArg->IsUndefined()) &&
106                             (styleValArg->IsNull() || styleValArg->IsUndefined());
107     if (isUndefinedValue) {
108         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetSelectedFont(nativeNode);
109     }
110     CalcDimension fontSizeData(DEFAULT_FONT_SIZE_VAL);
111     std::string fontSize = fontSizeData.ToString();
112     RefPtr<ResourceObject> FontSizeResObj;
113     if (!fontSizeArg->IsNull() && !fontSizeArg->IsUndefined() &&
114         ArkTSUtils::ParseJsDimensionFp(vm, fontSizeArg, fontSizeData, FontSizeResObj) && !fontSizeData.IsNegative() &&
115         fontSizeData.Unit() != DimensionUnit::PERCENT) {
116         fontSize = fontSizeData.ToString();
117     }
118     std::string weight = "normal";
119     if (!weightArg->IsNull() && !weightArg->IsUndefined() && (weightArg->IsString(vm) || weightArg->IsNumber())) {
120         weight = weightArg->ToString(vm)->ToString(vm);
121     }
122     std::string fontFamily;
123     RefPtr<ResourceObject> fontFamilyResObj;
124     if (!ArkTSUtils::ParseJsFontFamiliesToString(vm, fontFamilyArg, fontFamily, fontFamilyResObj) ||
125         fontFamily.empty()) {
126         fontFamily = DEFAULT_FAMILY;
127     }
128     int32_t styleVal = 0;
129     if (!styleValArg->IsNull() && !styleValArg->IsUndefined() && styleValArg->IsNumber()) {
130         styleVal = styleValArg->Int32Value(vm);
131     }
132     std::string fontInfo =
133         StringUtils::FormatString(FORMAT_FONT.c_str(), fontSize.c_str(), weight.c_str(), fontFamily.c_str());
134     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setSelectedFont(nativeNode, fontInfo.c_str(), styleVal);
135     if (SystemProperties::ConfigChangePerform()) {
136         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(nativeNode,
137             static_cast<int32_t>(IndexerJsResourceType::SELECTED_FONT_SIZE),
138             reinterpret_cast<void*>(AceType::RawPtr(FontSizeResObj)));
139         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(nativeNode,
140             static_cast<int32_t>(IndexerJsResourceType::SELECTED_FONT_FAMILY),
141             reinterpret_cast<void*>(AceType::RawPtr(fontFamilyResObj)));
142     }
143     return panda::JSValueRef::Undefined(vm);
144 }
145 
ResetSelectedFont(ArkUIRuntimeCallInfo * runtimeCallInfo)146 ArkUINativeModuleValue AlphabetIndexerBridge::ResetSelectedFont(ArkUIRuntimeCallInfo* runtimeCallInfo)
147 {
148     EcmaVM* vm = runtimeCallInfo->GetVM();
149     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
150     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
151     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
152     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
153     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetSelectedFont(nativeNode);
154     if (SystemProperties::ConfigChangePerform()) {
155         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(
156             nativeNode, static_cast<int32_t>(IndexerJsResourceType::SELECTED_FONT_SIZE), nullptr);
157         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(
158             nativeNode, static_cast<int32_t>(IndexerJsResourceType::SELECTED_FONT_FAMILY), nullptr);
159     }
160     return panda::JSValueRef::Undefined(vm);
161 }
162 
SetPopupFont(ArkUIRuntimeCallInfo * runtimeCallInfo)163 ArkUINativeModuleValue AlphabetIndexerBridge::SetPopupFont(ArkUIRuntimeCallInfo* runtimeCallInfo)
164 {
165     EcmaVM* vm = runtimeCallInfo->GetVM();
166     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
167     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
168     Local<JSValueRef> fontSizeArg = runtimeCallInfo->GetCallArgRef(NUM_1);
169     Local<JSValueRef> weightArg = runtimeCallInfo->GetCallArgRef(NUM_2);
170     Local<JSValueRef> fontFamilyArg = runtimeCallInfo->GetCallArgRef(NUM_3);
171     Local<JSValueRef> styleValArg = runtimeCallInfo->GetCallArgRef(NUM_4);
172     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
173     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
174     bool isUndefinedValue = (fontSizeArg->IsNull() || fontSizeArg->IsUndefined()) &&
175                             (weightArg->IsNull() || weightArg->IsUndefined()) &&
176                             (fontFamilyArg->IsNull() || fontFamilyArg->IsUndefined()) &&
177                             (styleValArg->IsNull() || styleValArg->IsUndefined());
178     if (isUndefinedValue) {
179         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetPopupFont(nativeNode);
180     }
181     CalcDimension fontSizeData(Dimension(DEFAULT_POPUP_ITEM_FONT_SIZE, DimensionUnit::FP));
182     std::string fontSize = fontSizeData.ToString();
183     RefPtr<ResourceObject> fontSizeResObj;
184     if (!fontSizeArg->IsNull() && !fontSizeArg->IsUndefined() &&
185         ArkTSUtils::ParseJsDimensionFp(vm, fontSizeArg, fontSizeData, fontSizeResObj) && !fontSizeData.IsNegative() &&
186         fontSizeData.Unit() != DimensionUnit::PERCENT) {
187         fontSize = fontSizeData.ToString();
188     }
189     std::string weight = "normal";
190     if (!weightArg->IsNull() && !weightArg->IsUndefined() && (weightArg->IsString(vm) || weightArg->IsNumber())) {
191         weight = weightArg->ToString(vm)->ToString(vm);
192     }
193     std::string fontFamily;
194     RefPtr<ResourceObject> fontFamilyResObj;
195     if (!ArkTSUtils::ParseJsFontFamiliesToString(vm, fontFamilyArg, fontFamily, fontFamilyResObj) ||
196         fontFamily.empty()) {
197         fontFamily = DEFAULT_FAMILY;
198     }
199     int32_t styleVal = 0;
200     if (!styleValArg->IsNull() && !styleValArg->IsUndefined() && styleValArg->IsNumber()) {
201         styleVal = styleValArg->Int32Value(vm);
202     }
203     std::string fontInfo =
204         StringUtils::FormatString(FORMAT_FONT.c_str(), fontSize.c_str(), weight.c_str(), fontFamily.c_str());
205     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setPopupFont(nativeNode, fontInfo.c_str(), styleVal);
206     if (SystemProperties::ConfigChangePerform()) {
207         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(nativeNode,
208             static_cast<int32_t>(IndexerJsResourceType::POPUP_FONT_SIZE),
209             reinterpret_cast<void*>(AceType::RawPtr(fontSizeResObj)));
210         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(nativeNode,
211             static_cast<int32_t>(IndexerJsResourceType::POPUP_FONT_FAMILY),
212             reinterpret_cast<void*>(AceType::RawPtr(fontFamilyResObj)));
213     }
214     return panda::JSValueRef::Undefined(vm);
215 }
216 
ResetPopupFont(ArkUIRuntimeCallInfo * runtimeCallInfo)217 ArkUINativeModuleValue AlphabetIndexerBridge::ResetPopupFont(ArkUIRuntimeCallInfo* runtimeCallInfo)
218 {
219     EcmaVM* vm = runtimeCallInfo->GetVM();
220     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
221     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
222     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
223     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
224     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetPopupFont(nativeNode);
225     if (SystemProperties::ConfigChangePerform()) {
226         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(
227             nativeNode, static_cast<int32_t>(IndexerJsResourceType::POPUP_FONT_SIZE), nullptr);
228         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(
229             nativeNode, static_cast<int32_t>(IndexerJsResourceType::POPUP_FONT_FAMILY), nullptr);
230     }
231     return panda::JSValueRef::Undefined(vm);
232 }
233 
SetFont(ArkUIRuntimeCallInfo * runtimeCallInfo)234 ArkUINativeModuleValue AlphabetIndexerBridge::SetFont(ArkUIRuntimeCallInfo* runtimeCallInfo)
235 {
236     EcmaVM* vm = runtimeCallInfo->GetVM();
237     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
238     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
239     Local<JSValueRef> fontSizeArg = runtimeCallInfo->GetCallArgRef(NUM_1);
240     Local<JSValueRef> weightArg = runtimeCallInfo->GetCallArgRef(NUM_2);
241     Local<JSValueRef> fontFamilyArg = runtimeCallInfo->GetCallArgRef(NUM_3);
242     Local<JSValueRef> styleValArg = runtimeCallInfo->GetCallArgRef(NUM_4);
243     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
244     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
245     bool isUndefinedValue = (fontSizeArg->IsNull() || fontSizeArg->IsUndefined()) &&
246                             (weightArg->IsNull() || weightArg->IsUndefined()) &&
247                             (fontFamilyArg->IsNull() || fontFamilyArg->IsUndefined()) &&
248                             (styleValArg->IsNull() || styleValArg->IsUndefined());
249     if (isUndefinedValue) {
250         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetAlphabetIndexerFont(nativeNode);
251     }
252     CalcDimension fontSizeData(DEFAULT_FONT_SIZE_VAL);
253     std::string fontSize = fontSizeData.ToString();
254     RefPtr<ResourceObject> fontSizeResObj;
255     if (!fontSizeArg->IsNull() && !fontSizeArg->IsUndefined() &&
256         ArkTSUtils::ParseJsDimensionFp(vm, fontSizeArg, fontSizeData, fontSizeResObj) && !fontSizeData.IsNegative() &&
257         fontSizeData.Unit() != DimensionUnit::PERCENT) {
258         fontSize = fontSizeData.ToString();
259     }
260     std::string weight = "normal";
261     if (!weightArg->IsNull() && !weightArg->IsUndefined() && (weightArg->IsString(vm) || weightArg->IsNumber())) {
262         weight = weightArg->ToString(vm)->ToString(vm);
263     }
264     std::string fontFamily;
265     RefPtr<ResourceObject> fontFamilyResObj;
266     if (!ArkTSUtils::ParseJsFontFamiliesToString(vm, fontFamilyArg, fontFamily, fontFamilyResObj) ||
267         fontFamily.empty()) {
268         fontFamily = DEFAULT_FAMILY;
269     }
270     int32_t styleVal = 0;
271     if (!styleValArg->IsNull() && !styleValArg->IsUndefined() && styleValArg->IsNumber()) {
272         styleVal = styleValArg->Int32Value(vm);
273     }
274     std::string fontInfo =
275         StringUtils::FormatString(FORMAT_FONT.c_str(), fontSize.c_str(), weight.c_str(), fontFamily.c_str());
276     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setAlphabetIndexerFont(
277         nativeNode, fontInfo.c_str(), styleVal);
278     if (SystemProperties::ConfigChangePerform()) {
279         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(nativeNode,
280             static_cast<int32_t>(IndexerJsResourceType::FONT_SIZE),
281             reinterpret_cast<void*>(AceType::RawPtr(fontSizeResObj)));
282         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(nativeNode,
283             static_cast<int32_t>(IndexerJsResourceType::FONT_FAMILY),
284             reinterpret_cast<void*>(AceType::RawPtr(fontFamilyResObj)));
285     }
286     return panda::JSValueRef::Undefined(vm);
287 }
288 
ResetFont(ArkUIRuntimeCallInfo * runtimeCallInfo)289 ArkUINativeModuleValue AlphabetIndexerBridge::ResetFont(ArkUIRuntimeCallInfo* runtimeCallInfo)
290 {
291     EcmaVM* vm = runtimeCallInfo->GetVM();
292     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
293     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
294     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
295     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
296     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetAlphabetIndexerFont(nativeNode);
297     if (SystemProperties::ConfigChangePerform()) {
298         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(
299             nativeNode, static_cast<int32_t>(IndexerJsResourceType::FONT_SIZE), nullptr);
300         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(
301             nativeNode, static_cast<int32_t>(IndexerJsResourceType::FONT_FAMILY), nullptr);
302     }
303     return panda::JSValueRef::Undefined(vm);
304 }
305 
SetPopupItemBackgroundColor(ArkUIRuntimeCallInfo * runtimeCallInfo)306 ArkUINativeModuleValue AlphabetIndexerBridge::SetPopupItemBackgroundColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
307 {
308     EcmaVM* vm = runtimeCallInfo->GetVM();
309     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
310     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
311     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
312     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
313     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
314     Color color;
315     RefPtr<ResourceObject> resObj;
316     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
317     if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color, resObj, nodeInfo)) {
318         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetPopupItemBackgroundColor(nativeNode);
319     } else {
320         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setPopupItemBackgroundColor(
321             nativeNode, color.GetValue());
322     }
323     if (SystemProperties::ConfigChangePerform()) {
324         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(nativeNode,
325             static_cast<int32_t>(IndexerJsResourceType::POPUP_ITEM_BACKGROUND_COLOR),
326             reinterpret_cast<void*>(AceType::RawPtr(resObj)));
327     }
328     return panda::JSValueRef::Undefined(vm);
329 }
330 
ResetPopupItemBackgroundColor(ArkUIRuntimeCallInfo * runtimeCallInfo)331 ArkUINativeModuleValue AlphabetIndexerBridge::ResetPopupItemBackgroundColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
332 {
333     EcmaVM* vm = runtimeCallInfo->GetVM();
334     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
335     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
336     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
337     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
338     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetPopupItemBackgroundColor(nativeNode);
339     if (SystemProperties::ConfigChangePerform()) {
340         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(
341             nativeNode, static_cast<int32_t>(IndexerJsResourceType::POPUP_ITEM_BACKGROUND_COLOR), nullptr);
342     }
343     return panda::JSValueRef::Undefined(vm);
344 }
345 
SetColor(ArkUIRuntimeCallInfo * runtimeCallInfo)346 ArkUINativeModuleValue AlphabetIndexerBridge::SetColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
347 {
348     EcmaVM* vm = runtimeCallInfo->GetVM();
349     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
350     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
351     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
352     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
353     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
354     Color color;
355     RefPtr<ResourceObject> resObj;
356     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
357     if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color, resObj, nodeInfo)) {
358         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetAlphabetIndexerColor(nativeNode);
359     } else {
360         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setAlphabetIndexerColor(nativeNode, color.GetValue());
361     }
362     if (SystemProperties::ConfigChangePerform()) {
363         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(nativeNode,
364             static_cast<int32_t>(IndexerJsResourceType::COLOR),
365             reinterpret_cast<void*>(AceType::RawPtr(resObj)));
366     }
367     return panda::JSValueRef::Undefined(vm);
368 }
369 
ResetColor(ArkUIRuntimeCallInfo * runtimeCallInfo)370 ArkUINativeModuleValue AlphabetIndexerBridge::ResetColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
371 {
372     EcmaVM* vm = runtimeCallInfo->GetVM();
373     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
374     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
375     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
376     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
377     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetAlphabetIndexerColor(nativeNode);
378     return panda::JSValueRef::Undefined(vm);
379 }
380 
SetPopupColor(ArkUIRuntimeCallInfo * runtimeCallInfo)381 ArkUINativeModuleValue AlphabetIndexerBridge::SetPopupColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
382 {
383     EcmaVM* vm = runtimeCallInfo->GetVM();
384     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
385     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
386     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
387     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
388     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
389     Color color;
390     RefPtr<ResourceObject> resObj;
391     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
392     if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color, resObj, nodeInfo)) {
393         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetPopupColor(nativeNode);
394     } else {
395         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setPopupColor(nativeNode, color.GetValue());
396     }
397     if (SystemProperties::ConfigChangePerform()) {
398         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(nativeNode,
399             static_cast<int32_t>(IndexerJsResourceType::POPUP_COLOR),
400             reinterpret_cast<void*>(AceType::RawPtr(resObj)));
401     }
402     return panda::JSValueRef::Undefined(vm);
403 }
404 
ResetPopupColor(ArkUIRuntimeCallInfo * runtimeCallInfo)405 ArkUINativeModuleValue AlphabetIndexerBridge::ResetPopupColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
406 {
407     EcmaVM* vm = runtimeCallInfo->GetVM();
408     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
409     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
410     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
411     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
412     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetPopupColor(nativeNode);
413     if (SystemProperties::ConfigChangePerform()) {
414         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(
415             nativeNode, static_cast<int32_t>(IndexerJsResourceType::COLOR), nullptr);
416     }
417     return panda::JSValueRef::Undefined(vm);
418 }
419 
SetSelectedColor(ArkUIRuntimeCallInfo * runtimeCallInfo)420 ArkUINativeModuleValue AlphabetIndexerBridge::SetSelectedColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
421 {
422     EcmaVM* vm = runtimeCallInfo->GetVM();
423     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
424     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
425     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
426     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
427     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
428     Color color;
429     RefPtr<ResourceObject> resObj;
430     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
431     if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color, resObj, nodeInfo)) {
432         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetAlphabetIndexerSelectedColor(nativeNode);
433     } else {
434         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setAlphabetIndexerSelectedColor(
435             nativeNode, color.GetValue());
436     }
437     if (SystemProperties::ConfigChangePerform()) {
438         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(nativeNode,
439             static_cast<int32_t>(IndexerJsResourceType::SELECTED_COLOR),
440             reinterpret_cast<void*>(AceType::RawPtr(resObj)));
441     }
442     return panda::JSValueRef::Undefined(vm);
443 }
444 
ResetSelectedColor(ArkUIRuntimeCallInfo * runtimeCallInfo)445 ArkUINativeModuleValue AlphabetIndexerBridge::ResetSelectedColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
446 {
447     EcmaVM* vm = runtimeCallInfo->GetVM();
448     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
449     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
450     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
451     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
452     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetAlphabetIndexerSelectedColor(nativeNode);
453     if (SystemProperties::ConfigChangePerform()) {
454         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(
455             nativeNode, static_cast<int32_t>(IndexerJsResourceType::SELECTED_COLOR), nullptr);
456     }
457     return panda::JSValueRef::Undefined(vm);
458 }
459 
SetPopupBackground(ArkUIRuntimeCallInfo * runtimeCallInfo)460 ArkUINativeModuleValue AlphabetIndexerBridge::SetPopupBackground(ArkUIRuntimeCallInfo* runtimeCallInfo)
461 {
462     EcmaVM* vm = runtimeCallInfo->GetVM();
463     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
464     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
465     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
466     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
467     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
468     Color color;
469     RefPtr<ResourceObject> resObj;
470     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
471     if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color, resObj, nodeInfo)) {
472         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetPopupBackground(nativeNode);
473     } else {
474         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setPopupBackground(nativeNode, color.GetValue());
475     }
476     if (SystemProperties::ConfigChangePerform()) {
477         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(nativeNode,
478             static_cast<int32_t>(IndexerJsResourceType::POPUP_BACKGROUND),
479             reinterpret_cast<void*>(AceType::RawPtr(resObj)));
480     }
481     return panda::JSValueRef::Undefined(vm);
482 }
483 
ResetPopupBackground(ArkUIRuntimeCallInfo * runtimeCallInfo)484 ArkUINativeModuleValue AlphabetIndexerBridge::ResetPopupBackground(ArkUIRuntimeCallInfo* runtimeCallInfo)
485 {
486     EcmaVM* vm = runtimeCallInfo->GetVM();
487     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
488     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
489     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
490     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
491     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetPopupBackground(nativeNode);
492     if (SystemProperties::ConfigChangePerform()) {
493         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(
494             nativeNode, static_cast<int32_t>(IndexerJsResourceType::POPUP_BACKGROUND), nullptr);
495     }
496     return panda::JSValueRef::Undefined(vm);
497 }
498 
SetSelectedBackgroundColor(ArkUIRuntimeCallInfo * runtimeCallInfo)499 ArkUINativeModuleValue AlphabetIndexerBridge::SetSelectedBackgroundColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
500 {
501     EcmaVM* vm = runtimeCallInfo->GetVM();
502     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
503     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
504     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
505     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
506     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
507     Color color;
508     RefPtr<ResourceObject> resObj;
509     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
510     if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color, resObj, nodeInfo)) {
511         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetSelectedBackgroundColor(nativeNode);
512     } else {
513         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setSelectedBackgroundColor(
514             nativeNode, color.GetValue());
515     }
516     if (SystemProperties::ConfigChangePerform()) {
517         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(nativeNode,
518             static_cast<int32_t>(IndexerJsResourceType::SELECTED_BACKGROUND_COLOR),
519             reinterpret_cast<void*>(AceType::RawPtr(resObj)));
520     }
521     return panda::JSValueRef::Undefined(vm);
522 }
523 
ResetSelectedBackgroundColor(ArkUIRuntimeCallInfo * runtimeCallInfo)524 ArkUINativeModuleValue AlphabetIndexerBridge::ResetSelectedBackgroundColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
525 {
526     EcmaVM* vm = runtimeCallInfo->GetVM();
527     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
528     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
529     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
530     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
531     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetSelectedBackgroundColor(nativeNode);
532     if (SystemProperties::ConfigChangePerform()) {
533         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(
534             nativeNode, static_cast<int32_t>(IndexerJsResourceType::SELECTED_BACKGROUND_COLOR), nullptr);
535     }
536     return panda::JSValueRef::Undefined(vm);
537 }
538 
SetPopupUnselectedColor(ArkUIRuntimeCallInfo * runtimeCallInfo)539 ArkUINativeModuleValue AlphabetIndexerBridge::SetPopupUnselectedColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
540 {
541     EcmaVM* vm = runtimeCallInfo->GetVM();
542     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
543     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
544     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
545     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
546     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
547     Color color;
548     RefPtr<ResourceObject> resObj;
549     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
550     if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color, resObj, nodeInfo)) {
551         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetPopupUnselectedColor(nativeNode);
552     } else {
553         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setPopupUnselectedColor(nativeNode, color.GetValue());
554     }
555     if (SystemProperties::ConfigChangePerform()) {
556         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(nativeNode,
557             static_cast<int32_t>(IndexerJsResourceType::POPUP_UNSELECTED_COLOR),
558             reinterpret_cast<void*>(AceType::RawPtr(resObj)));
559     }
560     return panda::JSValueRef::Undefined(vm);
561 }
562 
ResetPopupUnselectedColor(ArkUIRuntimeCallInfo * runtimeCallInfo)563 ArkUINativeModuleValue AlphabetIndexerBridge::ResetPopupUnselectedColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
564 {
565     EcmaVM* vm = runtimeCallInfo->GetVM();
566     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
567     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
568     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
569     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
570     if (SystemProperties::ConfigChangePerform()) {
571         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(
572             nativeNode, static_cast<int32_t>(IndexerJsResourceType::POPUP_UNSELECTED_COLOR), nullptr);
573     }
574     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetPopupUnselectedColor(nativeNode);
575     return panda::JSValueRef::Undefined(vm);
576 }
577 
SetAlignStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)578 ArkUINativeModuleValue AlphabetIndexerBridge::SetAlignStyle(ArkUIRuntimeCallInfo* runtimeCallInfo)
579 {
580     EcmaVM* vm = runtimeCallInfo->GetVM();
581     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
582     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
583     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
584     Local<JSValueRef> thirdArg = runtimeCallInfo->GetCallArgRef(NUM_2);
585     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
586     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
587     if (!secondArg->IsNumber()) {
588         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetAlignStyle(nativeNode);
589     } else {
590         int32_t alignValue = secondArg->Int32Value(vm);
591         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setAlignStyle(nativeNode, alignValue);
592     }
593     CalcDimension popupHorizontalSpace;
594     RefPtr<ResourceObject> resObj;
595     if (!thirdArg->IsNull() && !thirdArg->IsUndefined() &&
596         ArkTSUtils::ParseJsDimensionVp(vm, thirdArg, popupHorizontalSpace, resObj)) {
597         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setPopupHorizontalSpace(
598             nativeNode, popupHorizontalSpace.Value(), static_cast<int>(popupHorizontalSpace.Unit()));
599     } else {
600         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetPopupHorizontalSpace(nativeNode);
601     }
602     if (SystemProperties::ConfigChangePerform()) {
603         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(nativeNode,
604             static_cast<int32_t>(IndexerJsResourceType::ALIGN_OFFSET),
605             reinterpret_cast<void*>(AceType::RawPtr(resObj)));
606     }
607     return panda::JSValueRef::Undefined(vm);
608 }
609 
ResetAlignStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)610 ArkUINativeModuleValue AlphabetIndexerBridge::ResetAlignStyle(ArkUIRuntimeCallInfo* runtimeCallInfo)
611 {
612     EcmaVM* vm = runtimeCallInfo->GetVM();
613     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
614     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
615     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
616     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
617     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetAlignStyle(nativeNode);
618     if (SystemProperties::ConfigChangePerform()) {
619         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(
620             nativeNode, static_cast<int32_t>(IndexerJsResourceType::ALIGN_OFFSET), nullptr);
621     }
622     return panda::JSValueRef::Undefined(vm);
623 }
624 
SetPopupSelectedColor(ArkUIRuntimeCallInfo * runtimeCallInfo)625 ArkUINativeModuleValue AlphabetIndexerBridge::SetPopupSelectedColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
626 {
627     EcmaVM* vm = runtimeCallInfo->GetVM();
628     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
629     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
630     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
631     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
632     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
633     Color color;
634     RefPtr<ResourceObject> resObj;
635     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
636     if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color, resObj, nodeInfo)) {
637         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetPopupSelectedColor(nativeNode);
638     } else {
639         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setPopupSelectedColor(nativeNode, color.GetValue());
640     }
641     if (SystemProperties::ConfigChangePerform()) {
642         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(nativeNode,
643             static_cast<int32_t>(IndexerJsResourceType::POPUP_SELECTED_COLOR),
644             reinterpret_cast<void*>(AceType::RawPtr(resObj)));
645     }
646     return panda::JSValueRef::Undefined(vm);
647 }
648 
ResetPopupSelectedColor(ArkUIRuntimeCallInfo * runtimeCallInfo)649 ArkUINativeModuleValue AlphabetIndexerBridge::ResetPopupSelectedColor(ArkUIRuntimeCallInfo* runtimeCallInfo)
650 {
651     EcmaVM* vm = runtimeCallInfo->GetVM();
652     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
653     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
654     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
655     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
656     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetPopupSelectedColor(nativeNode);
657     if (SystemProperties::ConfigChangePerform()) {
658         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(
659             nativeNode, static_cast<int32_t>(IndexerJsResourceType::POPUP_SELECTED_COLOR), nullptr);
660     }
661     return panda::JSValueRef::Undefined(vm);
662 }
663 
SetUsingPopup(ArkUIRuntimeCallInfo * runtimeCallInfo)664 ArkUINativeModuleValue AlphabetIndexerBridge::SetUsingPopup(ArkUIRuntimeCallInfo* runtimeCallInfo)
665 {
666     EcmaVM* vm = runtimeCallInfo->GetVM();
667     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
668     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(0);
669     Local<JSValueRef> usingPopupArg = runtimeCallInfo->GetCallArgRef(1);
670     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
671     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
672     if (usingPopupArg->IsNull() || usingPopupArg->IsUndefined()) {
673         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetUsingPopup(nativeNode);
674     } else {
675         bool usingPopup = usingPopupArg->ToBoolean(vm)->Value();
676         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setUsingPopup(nativeNode, usingPopup);
677     }
678     return panda::JSValueRef::Undefined(vm);
679 }
680 
ResetUsingPopup(ArkUIRuntimeCallInfo * runtimeCallInfo)681 ArkUINativeModuleValue AlphabetIndexerBridge::ResetUsingPopup(ArkUIRuntimeCallInfo* runtimeCallInfo)
682 {
683     EcmaVM* vm = runtimeCallInfo->GetVM();
684     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
685     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
686     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
687     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
688     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetUsingPopup(nativeNode);
689     return panda::JSValueRef::Undefined(vm);
690 }
691 
SetSelected(ArkUIRuntimeCallInfo * runtimeCallInfo)692 ArkUINativeModuleValue AlphabetIndexerBridge::SetSelected(ArkUIRuntimeCallInfo* runtimeCallInfo)
693 {
694     EcmaVM* vm = runtimeCallInfo->GetVM();
695     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
696     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(0);
697     Local<JSValueRef> selectedArg = runtimeCallInfo->GetCallArgRef(1);
698     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
699     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
700     int32_t selected = 0;
701     if (selectedArg->IsNull() || selectedArg->IsUndefined() || !ArkTSUtils::ParseJsInteger(vm, selectedArg, selected)) {
702         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetAlphabetIndexerSelected(nativeNode);
703     } else {
704         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setAlphabetIndexerSelected(nativeNode, selected);
705     }
706     return panda::JSValueRef::Undefined(vm);
707 }
708 
ResetSelected(ArkUIRuntimeCallInfo * runtimeCallInfo)709 ArkUINativeModuleValue AlphabetIndexerBridge::ResetSelected(ArkUIRuntimeCallInfo* runtimeCallInfo)
710 {
711     EcmaVM* vm = runtimeCallInfo->GetVM();
712     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
713     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
714     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
715     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
716     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetAlphabetIndexerSelected(nativeNode);
717     return panda::JSValueRef::Undefined(vm);
718 }
719 
SetItemSize(ArkUIRuntimeCallInfo * runtimeCallInfo)720 ArkUINativeModuleValue AlphabetIndexerBridge::SetItemSize(ArkUIRuntimeCallInfo* runtimeCallInfo)
721 {
722     EcmaVM* vm = runtimeCallInfo->GetVM();
723     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
724     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(0);
725     Local<JSValueRef> itemSizeArg = runtimeCallInfo->GetCallArgRef(1);
726     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
727     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
728     CalcDimension itemSize;
729 
730     if (itemSizeArg->IsNull() || itemSizeArg->IsUndefined()) {
731         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetItemSize(nativeNode);
732     }
733 
734     if (ArkTSUtils::ParseJsDimensionVp(vm, itemSizeArg, itemSize) && GreatNotEqual(itemSize.Value(), 0.0) &&
735         itemSize.Unit() != DimensionUnit::PERCENT) {
736         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setItemSize(
737             nativeNode, itemSize.Value(), static_cast<int>(itemSize.Unit()));
738     } else {
739         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetItemSize(nativeNode);
740     }
741     return panda::JSValueRef::Undefined(vm);
742 }
743 
ResetItemSize(ArkUIRuntimeCallInfo * runtimeCallInfo)744 ArkUINativeModuleValue AlphabetIndexerBridge::ResetItemSize(ArkUIRuntimeCallInfo* runtimeCallInfo)
745 {
746     EcmaVM* vm = runtimeCallInfo->GetVM();
747     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
748     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
749     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
750     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
751     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetItemSize(nativeNode);
752     return panda::JSValueRef::Undefined(vm);
753 }
754 
SetPopupPosition(ArkUIRuntimeCallInfo * runtimeCallInfo)755 ArkUINativeModuleValue AlphabetIndexerBridge::SetPopupPosition(ArkUIRuntimeCallInfo* runtimeCallInfo)
756 {
757     EcmaVM* vm = runtimeCallInfo->GetVM();
758     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
759     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
760     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
761     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
762     Local<JSValueRef> sizeX = runtimeCallInfo->GetCallArgRef(NUM_1);
763     Local<JSValueRef> sizeY = runtimeCallInfo->GetCallArgRef(NUM_2);
764     CalcDimension x;
765     CalcDimension y;
766     RefPtr<ResourceObject> resObjX;
767     RefPtr<ResourceObject> resObjY;
768     if (sizeX->IsNull() || sizeX->IsUndefined() || !ArkTSUtils::ParseJsDimensionVp(vm, sizeX, x, resObjX)) {
769         x = DEFAULT_POPUP_POSITION_X;
770     }
771     if (sizeY->IsNull() || sizeY->IsUndefined() || !ArkTSUtils::ParseJsDimensionVp(vm, sizeY, y, resObjY)) {
772         y = DEFAULT_POPUP_POSITION_Y;
773     }
774     if (SystemProperties::ConfigChangePerform()) {
775         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(nativeNode,
776             static_cast<int32_t>(IndexerJsResourceType::POPUP_POSITION_X),
777             reinterpret_cast<void*>(AceType::RawPtr(resObjX)));
778         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(nativeNode,
779             static_cast<int32_t>(IndexerJsResourceType::POPUP_POSITION_Y),
780             reinterpret_cast<void*>(AceType::RawPtr(resObjY)));
781     }
782     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setPopupPosition(
783         nativeNode, x.Value(), static_cast<int>(x.Unit()), y.Value(), static_cast<int>(y.Unit()));
784     return panda::JSValueRef::Undefined(vm);
785 }
786 
ResetPopupPosition(ArkUIRuntimeCallInfo * runtimeCallInfo)787 ArkUINativeModuleValue AlphabetIndexerBridge::ResetPopupPosition(ArkUIRuntimeCallInfo* runtimeCallInfo)
788 {
789     EcmaVM* vm = runtimeCallInfo->GetVM();
790     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
791     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
792     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
793     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
794     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetPopupPosition(nativeNode);
795     if (SystemProperties::ConfigChangePerform()) {
796         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(
797             nativeNode, static_cast<int32_t>(IndexerJsResourceType::POPUP_POSITION_X), nullptr);
798         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(
799             nativeNode, static_cast<int32_t>(IndexerJsResourceType::POPUP_POSITION_Y), nullptr);
800     }
801     return panda::JSValueRef::Undefined(vm);
802 }
803 
SetPopupItemBorderRadius(ArkUIRuntimeCallInfo * runtimeCallInfo)804 ArkUINativeModuleValue AlphabetIndexerBridge::SetPopupItemBorderRadius(ArkUIRuntimeCallInfo* runtimeCallInfo)
805 {
806     EcmaVM* vm = runtimeCallInfo->GetVM();
807     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
808     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(NUM_0);
809     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
810     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
811     Local<JSValueRef> radiusArg = runtimeCallInfo->GetCallArgRef(NUM_1);
812 
813     CalcDimension radius;
814     CalcDimension popupRadius;
815     if (radiusArg->IsNull() || radiusArg->IsUndefined() || !radiusArg->IsNumber()) {
816         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetPopupItemBorderRadius(nativeNode);
817     } else {
818         ArkTSUtils::ParseJsDimensionVp(vm, radiusArg, radius);
819         popupRadius.SetValue(radius.Value() + RADIUS_OFFSET);
820         popupRadius.SetUnit(DimensionUnit::VP);
821         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setPopupItemBorderRadius(nativeNode, radius.Value(),
822             static_cast<int>(radius.Unit()), popupRadius.Value(), static_cast<int>(popupRadius.Unit()));
823     }
824     return panda::JSValueRef::Undefined(vm);
825 }
826 
ResetPopupItemBorderRadius(ArkUIRuntimeCallInfo * runtimeCallInfo)827 ArkUINativeModuleValue AlphabetIndexerBridge::ResetPopupItemBorderRadius(ArkUIRuntimeCallInfo* runtimeCallInfo)
828 {
829     EcmaVM* vm = runtimeCallInfo->GetVM();
830     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
831     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(0);
832     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
833     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
834     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetPopupItemBorderRadius(nativeNode);
835     return panda::JSValueRef::Undefined(vm);
836 }
837 
SetItemBorderRadius(ArkUIRuntimeCallInfo * runtimeCallInfo)838 ArkUINativeModuleValue AlphabetIndexerBridge::SetItemBorderRadius(ArkUIRuntimeCallInfo* runtimeCallInfo)
839 {
840     EcmaVM* vm = runtimeCallInfo->GetVM();
841     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
842     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(0);
843     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
844     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
845     Local<JSValueRef> radiusArg = runtimeCallInfo->GetCallArgRef(NUM_1);
846     auto radius = CalcDimension(ZERO_RADIUS, DimensionUnit::VP);
847     auto indexerRadius = Dimension(ZERO_RADIUS, DimensionUnit::VP);
848     if (radiusArg->IsNull() || radiusArg->IsUndefined() || !radiusArg->IsNumber()) {
849         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetItemBorderRadius(nativeNode);
850     } else {
851         ArkTSUtils::ParseJsDimensionVp(vm, radiusArg, radius);
852         indexerRadius.SetValue(radius.Value() + RADIUS_OFFSET);
853         indexerRadius.SetUnit(DimensionUnit::VP);
854         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setItemBorderRadius(nativeNode, radius.Value(),
855             static_cast<int>(radius.Unit()), indexerRadius.Value(), static_cast<int>(indexerRadius.Unit()));
856     }
857     return panda::JSValueRef::Undefined(vm);
858 }
859 
ResetItemBorderRadius(ArkUIRuntimeCallInfo * runtimeCallInfo)860 ArkUINativeModuleValue AlphabetIndexerBridge::ResetItemBorderRadius(ArkUIRuntimeCallInfo* runtimeCallInfo)
861 {
862     EcmaVM* vm = runtimeCallInfo->GetVM();
863     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
864     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(0);
865     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
866     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
867     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetItemBorderRadius(nativeNode);
868     return panda::JSValueRef::Undefined(vm);
869 }
870 
SetPopupBackgroundBlurStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)871 ArkUINativeModuleValue AlphabetIndexerBridge::SetPopupBackgroundBlurStyle(ArkUIRuntimeCallInfo* runtimeCallInfo)
872 {
873     EcmaVM* vm = runtimeCallInfo->GetVM();
874     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
875     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(0);
876     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
877     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
878     Local<JSValueRef> blurStyleArg = runtimeCallInfo->GetCallArgRef(NUM_1);
879     int32_t blurStyle = blurStyleArg->Int32Value(vm);
880     if (!ArkTSUtils::ParseJsInteger(vm, blurStyleArg, blurStyle)) {
881         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetPopupBackgroundBlurStyle(nativeNode);
882     } else {
883         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setPopupBackgroundBlurStyle(nativeNode, blurStyle);
884     }
885     return panda::JSValueRef::Undefined(vm);
886 }
887 
ResetPopupBackgroundBlurStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)888 ArkUINativeModuleValue AlphabetIndexerBridge::ResetPopupBackgroundBlurStyle(ArkUIRuntimeCallInfo* runtimeCallInfo)
889 {
890     EcmaVM* vm = runtimeCallInfo->GetVM();
891     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
892     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(0);
893     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
894     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
895     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetPopupBackgroundBlurStyle(nativeNode);
896     return panda::JSValueRef::Undefined(vm);
897 }
SetPopupTitleBackground(ArkUIRuntimeCallInfo * runtimeCallInfo)898 ArkUINativeModuleValue AlphabetIndexerBridge::SetPopupTitleBackground(ArkUIRuntimeCallInfo* runtimeCallInfo)
899 {
900     EcmaVM* vm = runtimeCallInfo->GetVM();
901     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
902     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(0);
903     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
904     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
905     Local<JSValueRef> colorArg = runtimeCallInfo->GetCallArgRef(NUM_1);
906     Color color;
907     RefPtr<ResourceObject> resObj;
908     auto nodeInfo = ArkTSUtils::MakeNativeNodeInfo(nativeNode);
909     if (!ArkTSUtils::ParseJsColorAlpha(vm, colorArg, color, resObj, nodeInfo)) {
910         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetPopupTitleBackground(nativeNode);
911     } else {
912         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setPopupTitleBackground(nativeNode, color.GetValue());
913     }
914     if (SystemProperties::ConfigChangePerform()) {
915         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(nativeNode,
916             static_cast<int32_t>(IndexerJsResourceType::POPUP_TITLE_BACKGROUND),
917             reinterpret_cast<void*>(AceType::RawPtr(resObj)));
918     }
919     return panda::JSValueRef::Undefined(vm);
920 }
ResetPopupTitleBackground(ArkUIRuntimeCallInfo * runtimeCallInfo)921 ArkUINativeModuleValue AlphabetIndexerBridge::ResetPopupTitleBackground(ArkUIRuntimeCallInfo* runtimeCallInfo)
922 {
923     EcmaVM* vm = runtimeCallInfo->GetVM();
924     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
925     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(0);
926     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
927     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
928     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetPopupTitleBackground(nativeNode);
929     if (SystemProperties::ConfigChangePerform()) {
930         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->createWithResourceObj(
931             nativeNode, static_cast<int32_t>(IndexerJsResourceType::POPUP_TITLE_BACKGROUND), nullptr);
932     }
933     return panda::JSValueRef::Undefined(vm);
934 }
935 
SetAdaptiveWidth(ArkUIRuntimeCallInfo * runtimeCallInfo)936 ArkUINativeModuleValue AlphabetIndexerBridge::SetAdaptiveWidth(ArkUIRuntimeCallInfo* runtimeCallInfo)
937 {
938     EcmaVM* vm = runtimeCallInfo->GetVM();
939     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
940     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
941     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
942     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
943     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
944 
945     CalcDimension width;
946     ArkTSUtils::ParseJsDimensionVpNG(vm, secondArg, width);
947     if (width.Unit() == DimensionUnit::AUTO) {
948         CommonBridge::SetWidth(runtimeCallInfo);
949         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setAdaptiveWidth(nativeNode);
950         return panda::JSValueRef::Undefined(vm);
951     } else {
952         CommonBridge::SetWidth(runtimeCallInfo);
953         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetAdaptiveWidth(nativeNode);
954     }
955     CommonBridge::SetWidth(runtimeCallInfo);
956     return panda::JSValueRef::Undefined(vm);
957 }
958 
ResetAdaptiveWidth(ArkUIRuntimeCallInfo * runtimeCallInfo)959 ArkUINativeModuleValue AlphabetIndexerBridge::ResetAdaptiveWidth(ArkUIRuntimeCallInfo* runtimeCallInfo)
960 {
961     CommonBridge::ResetWidth(runtimeCallInfo);
962     EcmaVM* vm = runtimeCallInfo->GetVM();
963     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
964     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
965     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
966     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
967     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetAdaptiveWidth(nativeNode);
968     return panda::JSValueRef::Undefined(vm);
969 }
970 
SetAutoCollapse(ArkUIRuntimeCallInfo * runtimeCallInfo)971 ArkUINativeModuleValue AlphabetIndexerBridge::SetAutoCollapse(ArkUIRuntimeCallInfo* runtimeCallInfo)
972 {
973     EcmaVM* vm = runtimeCallInfo->GetVM();
974     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
975     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(0);
976     Local<JSValueRef> autoCollapseArg = runtimeCallInfo->GetCallArgRef(1);
977     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
978     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
979     bool autoCollapse = true;
980     if (autoCollapseArg->IsBoolean()) {
981         autoCollapse = autoCollapseArg->ToBoolean(vm)->Value();
982     }
983     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setAutoCollapse(nativeNode, autoCollapse);
984     return panda::JSValueRef::Undefined(vm);
985 }
986 
ResetAutoCollapse(ArkUIRuntimeCallInfo * runtimeCallInfo)987 ArkUINativeModuleValue AlphabetIndexerBridge::ResetAutoCollapse(ArkUIRuntimeCallInfo* runtimeCallInfo)
988 {
989     EcmaVM* vm = runtimeCallInfo->GetVM();
990     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
991     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
992     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
993     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
994     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetAutoCollapse(nativeNode);
995     return panda::JSValueRef::Undefined(vm);
996 }
997 
SetEnableHapticFeedback(ArkUIRuntimeCallInfo * runtimeCallInfo)998 ArkUINativeModuleValue AlphabetIndexerBridge::SetEnableHapticFeedback(ArkUIRuntimeCallInfo* runtimeCallInfo)
999 {
1000     EcmaVM* vm = runtimeCallInfo->GetVM();
1001     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1002     Local<JSValueRef> nodeArg = runtimeCallInfo->GetCallArgRef(0);
1003     Local<JSValueRef> hapticFeedbackArg = runtimeCallInfo->GetCallArgRef(1);
1004     CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
1005     auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value());
1006     bool isHapticEnable = true;
1007     if (hapticFeedbackArg->IsBoolean()) {
1008         isHapticEnable = hapticFeedbackArg->ToBoolean(vm)->Value();
1009     }
1010     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setEnableHapticFeedback(nativeNode, isHapticEnable);
1011     return panda::JSValueRef::Undefined(vm);
1012 }
1013 
ResetEnableHapticFeedback(ArkUIRuntimeCallInfo * runtimeCallInfo)1014 ArkUINativeModuleValue AlphabetIndexerBridge::ResetEnableHapticFeedback(ArkUIRuntimeCallInfo* runtimeCallInfo)
1015 {
1016     EcmaVM* vm = runtimeCallInfo->GetVM();
1017     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
1018     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
1019     CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm));
1020     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1021     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetEnableHapticFeedback(nativeNode);
1022     return panda::JSValueRef::Undefined(vm);
1023 }
1024 
SetOnSelected(ArkUIRuntimeCallInfo * runtimeCallInfo)1025 ArkUINativeModuleValue AlphabetIndexerBridge::SetOnSelected(ArkUIRuntimeCallInfo* runtimeCallInfo)
1026 {
1027     EcmaVM* vm = runtimeCallInfo->GetVM();
1028     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
1029     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
1030     Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(NUM_1);
1031     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1032     if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
1033         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetOnIndexerSelect(nativeNode);
1034         return panda::JSValueRef::Undefined(vm);
1035     }
1036     auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
1037     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
1038     panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
1039 
1040     std::function<void(const int32_t selected)> callback = [vm, frameNode, func = panda::CopyableGlobal(vm, func)](
1041                                                                const int32_t selected) {
1042         panda::LocalScope pandaScope(vm);
1043         panda::TryCatch trycatch(vm);
1044         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
1045         panda::Local<panda::JSValueRef> params[NUM_1] = { panda::NumberRef::New(vm, selected) };
1046         func->Call(vm, func.ToLocal(), params, NUM_1);
1047     };
1048     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setOnIndexerSelect(
1049         nativeNode, reinterpret_cast<void*>(&callback));
1050     return panda::JSValueRef::Undefined(vm);
1051 }
1052 
ResetOnSelected(ArkUIRuntimeCallInfo * runtimeCallInfo)1053 ArkUINativeModuleValue AlphabetIndexerBridge::ResetOnSelected(ArkUIRuntimeCallInfo* runtimeCallInfo)
1054 {
1055     EcmaVM* vm = runtimeCallInfo->GetVM();
1056     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
1057     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
1058     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1059     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetOnIndexerSelect(nativeNode);
1060     return panda::JSValueRef::Undefined(vm);
1061 }
1062 
SetOnSelect(ArkUIRuntimeCallInfo * runtimeCallInfo)1063 ArkUINativeModuleValue AlphabetIndexerBridge::SetOnSelect(ArkUIRuntimeCallInfo* runtimeCallInfo)
1064 {
1065     EcmaVM* vm = runtimeCallInfo->GetVM();
1066     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
1067     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
1068     Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(NUM_1);
1069     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1070     if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
1071         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetOnIndexerSelect(nativeNode);
1072         return panda::JSValueRef::Undefined(vm);
1073     }
1074     auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
1075     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
1076     panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
1077 
1078     std::function<void(const int32_t selected)> callback = [vm, frameNode, func = panda::CopyableGlobal(vm, func)](
1079                                                                const int32_t selected) {
1080         panda::LocalScope pandaScope(vm);
1081         panda::TryCatch trycatch(vm);
1082         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
1083         panda::Local<panda::JSValueRef> params[NUM_1] = { panda::NumberRef::New(vm, selected) };
1084         func->Call(vm, func.ToLocal(), params, NUM_1);
1085     };
1086     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setOnIndexerSelect(
1087         nativeNode, reinterpret_cast<void*>(&callback));
1088     return panda::JSValueRef::Undefined(vm);
1089 }
1090 
ResetOnSelect(ArkUIRuntimeCallInfo * runtimeCallInfo)1091 ArkUINativeModuleValue AlphabetIndexerBridge::ResetOnSelect(ArkUIRuntimeCallInfo* runtimeCallInfo)
1092 {
1093     EcmaVM* vm = runtimeCallInfo->GetVM();
1094     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
1095     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
1096     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1097     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetOnIndexerSelect(nativeNode);
1098     return panda::JSValueRef::Undefined(vm);
1099 }
1100 
SetOnRequestPopupData(ArkUIRuntimeCallInfo * runtimeCallInfo)1101 ArkUINativeModuleValue AlphabetIndexerBridge::SetOnRequestPopupData(ArkUIRuntimeCallInfo* runtimeCallInfo)
1102 {
1103     EcmaVM* vm = runtimeCallInfo->GetVM();
1104     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
1105     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
1106     Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(NUM_1);
1107     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1108     if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
1109         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetOnRequestPopupData(nativeNode);
1110         return panda::JSValueRef::Undefined(vm);
1111     }
1112     auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
1113     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
1114     panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
1115 
1116     std::function<std::vector<std::string>(int32_t)> callback =
1117         [vm, frameNode, func = panda::CopyableGlobal(vm, func)](const int32_t selected) -> std::vector<std::string> {
1118         std::vector<std::string> popupData = {};
1119         CHECK_NULL_RETURN(vm, popupData);
1120         panda::LocalScope pandaScope(vm);
1121         panda::TryCatch trycatch(vm);
1122         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
1123         panda::Local<panda::JSValueRef> params[NUM_1] = { panda::NumberRef::New(vm, selected) };
1124         auto result = func->Call(vm, func.ToLocal(), params, NUM_1);
1125         if (!result->IsArray(vm)) {
1126             return popupData;
1127         }
1128         auto array = panda::Local<panda::ArrayRef>(result);
1129         uint32_t length = array->Length(vm);
1130         for (uint32_t i = 0; i < length; ++i) {
1131             auto item = array->Get(vm, i);
1132             if (item->IsString(vm)) {
1133                 popupData.emplace_back(item->ToString(vm)->ToString(vm));
1134             }
1135         }
1136         return popupData;
1137     };
1138     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setOnRequestPopupData(
1139         nativeNode, reinterpret_cast<void*>(&callback));
1140     return panda::JSValueRef::Undefined(vm);
1141 }
1142 
ResetOnRequestPopupData(ArkUIRuntimeCallInfo * runtimeCallInfo)1143 ArkUINativeModuleValue AlphabetIndexerBridge::ResetOnRequestPopupData(ArkUIRuntimeCallInfo* runtimeCallInfo)
1144 {
1145     EcmaVM* vm = runtimeCallInfo->GetVM();
1146     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
1147     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
1148     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1149     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetOnRequestPopupData(nativeNode);
1150     return panda::JSValueRef::Undefined(vm);
1151 }
1152 
SetOnPopupSelect(ArkUIRuntimeCallInfo * runtimeCallInfo)1153 ArkUINativeModuleValue AlphabetIndexerBridge::SetOnPopupSelect(ArkUIRuntimeCallInfo* runtimeCallInfo)
1154 {
1155     EcmaVM* vm = runtimeCallInfo->GetVM();
1156     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
1157     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
1158     Local<JSValueRef> callbackArg = runtimeCallInfo->GetCallArgRef(NUM_1);
1159     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1160     if (callbackArg->IsUndefined() || callbackArg->IsNull() || !callbackArg->IsFunction(vm)) {
1161         GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetOnPopupSelected(nativeNode);
1162         return panda::JSValueRef::Undefined(vm);
1163     }
1164     auto frameNode = reinterpret_cast<FrameNode*>(nativeNode);
1165     CHECK_NULL_RETURN(frameNode, panda::JSValueRef::Undefined(vm));
1166     panda::Local<panda::FunctionRef> func = callbackArg->ToObject(vm);
1167 
1168     std::function<void(const int32_t selected)> callback = [vm, frameNode, func = panda::CopyableGlobal(vm, func)](
1169                                                                const int32_t selected) {
1170         panda::LocalScope pandaScope(vm);
1171         panda::TryCatch trycatch(vm);
1172         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
1173         panda::Local<panda::JSValueRef> params[NUM_1] = { panda::NumberRef::New(vm, selected) };
1174         func->Call(vm, func.ToLocal(), params, NUM_1);
1175     };
1176     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->setOnPopupSelected(
1177         nativeNode, reinterpret_cast<void*>(&callback));
1178     return panda::JSValueRef::Undefined(vm);
1179 }
1180 
ResetOnPopupSelect(ArkUIRuntimeCallInfo * runtimeCallInfo)1181 ArkUINativeModuleValue AlphabetIndexerBridge::ResetOnPopupSelect(ArkUIRuntimeCallInfo* runtimeCallInfo)
1182 {
1183     EcmaVM* vm = runtimeCallInfo->GetVM();
1184     CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
1185     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
1186     auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
1187     GetArkUINodeModifiers()->getAlphabetIndexerModifier()->resetOnPopupSelected(nativeNode);
1188     return panda::JSValueRef::Undefined(vm);
1189 }
1190 
1191 } // namespace OHOS::Ace::NG
1192