1 /*
2 * Copyright (c) 2024 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_folder_stack_bridge.h"
16
17 namespace OHOS::Ace::NG {
18
SetEnableAnimation(ArkUIRuntimeCallInfo * runtimeCallInfo)19 ArkUINativeModuleValue FolderStackBridge::SetEnableAnimation(ArkUIRuntimeCallInfo* runtimeCallInfo)
20 {
21 EcmaVM* vm = runtimeCallInfo->GetVM();
22 CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
23 Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
24 Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
25 auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
26 bool isEnableAnimation = true;
27 if (secondArg->IsBoolean()) {
28 isEnableAnimation = secondArg->ToBoolean(vm)->Value();
29 }
30 GetArkUINodeModifiers()->getFolderStackModifier()->setEnableAnimation(nativeNode,
31 static_cast<int32_t>(isEnableAnimation));
32 return panda::JSValueRef::Undefined(vm);
33 }
34
ResetEnableAnimation(ArkUIRuntimeCallInfo * runtimeCallInfo)35 ArkUINativeModuleValue FolderStackBridge::ResetEnableAnimation(ArkUIRuntimeCallInfo* runtimeCallInfo)
36 {
37 EcmaVM* vm = runtimeCallInfo->GetVM();
38 CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
39 Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
40 auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
41 GetArkUINodeModifiers()->getFolderStackModifier()->resetEnableAnimation(nativeNode);
42 return panda::JSValueRef::Undefined(vm);
43 }
44
SetAutoHalfFold(ArkUIRuntimeCallInfo * runtimeCallInfo)45 ArkUINativeModuleValue FolderStackBridge::SetAutoHalfFold(ArkUIRuntimeCallInfo* runtimeCallInfo)
46 {
47 EcmaVM* vm = runtimeCallInfo->GetVM();
48 CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
49 Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
50 Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(1);
51 auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
52 bool isAutoHalfFold = true;
53 if (secondArg->IsBoolean()) {
54 isAutoHalfFold = secondArg->ToBoolean(vm)->Value();
55 }
56 GetArkUINodeModifiers()->getFolderStackModifier()->setAutoHalfFold(nativeNode,
57 static_cast<int32_t>(isAutoHalfFold));
58 return panda::JSValueRef::Undefined(vm);
59 }
60
ResetAutoHalfFold(ArkUIRuntimeCallInfo * runtimeCallInfo)61 ArkUINativeModuleValue FolderStackBridge::ResetAutoHalfFold(ArkUIRuntimeCallInfo* runtimeCallInfo)
62 {
63 EcmaVM* vm = runtimeCallInfo->GetVM();
64 CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
65 Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(0);
66 auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
67 GetArkUINodeModifiers()->getFolderStackModifier()->resetAutoHalfFold(nativeNode);
68 return panda::JSValueRef::Undefined(vm);
69 }
70 }
71