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 16 #include "bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_scrollbar_bridge.h" 17 18 #include "base/log/log.h" 19 #include "base/utils/string_utils.h" 20 #include "base/utils/utils.h" 21 #include "bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_scrollbar_bridge.h" 22 #include "bridge/declarative_frontend/engine/jsi/nativeModule/arkts_utils.h" 23 #include "bridge/declarative_frontend/jsview/scroll_bar/js_scroll_bar.h" 24 #include "core/components_ng/pattern/scroll_bar/scroll_bar_model_ng.h" 25 26 namespace OHOS::Ace::NG { SetScrollBarEnableNestedScroll(ArkUIRuntimeCallInfo * runtimeCallInfo)27ArkUINativeModuleValue ScrollBarBridge::SetScrollBarEnableNestedScroll(ArkUIRuntimeCallInfo* runtimeCallInfo) 28 { 29 EcmaVM* vm = runtimeCallInfo->GetVM(); 30 CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm)); 31 Local<JSValueRef> nativeNodeArg = runtimeCallInfo->GetCallArgRef(0); 32 Local<JSValueRef> enablePagingArg = runtimeCallInfo->GetCallArgRef(1); 33 auto nativeNode = nodePtr(nativeNodeArg->ToNativePointer(vm)->Value()); 34 if (enablePagingArg->IsBoolean()) { 35 bool enablePaging = enablePagingArg->ToBoolean(vm)->Value(); 36 GetArkUINodeModifiers()->getScrollBarModifier()->setScrollBarEnableNestedScroll(nativeNode, enablePaging); 37 } 38 return panda::JSValueRef::Undefined(vm); 39 } 40 ResetScrollBarEnableNestedScroll(ArkUIRuntimeCallInfo * runtimeCallInfo)41ArkUINativeModuleValue ScrollBarBridge::ResetScrollBarEnableNestedScroll(ArkUIRuntimeCallInfo* runtimeCallInfo) 42 { 43 EcmaVM* vm = runtimeCallInfo->GetVM(); 44 CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr)); 45 Local<JSValueRef> nativeNodeArg = runtimeCallInfo->GetCallArgRef(0); 46 auto nativeNode = nodePtr(nativeNodeArg->ToNativePointer(vm)->Value()); 47 GetArkUINodeModifiers()->getScrollBarModifier()->resetScrollBarEnableNestedScroll(nativeNode); 48 return panda::JSValueRef::Undefined(vm); 49 } 50 } // namespace OHOS::Ace::NG