diff --git a/interface/filter/BUILD.gn b/BUILD.gn similarity index 38% rename from interface/filter/BUILD.gn rename to BUILD.gn index e06d1b77d10107f052a6349f956ae9cd0d1c760a..c681d2ab2f1976b97c67999d9ce3b90ed4dee95b 100644 --- a/interface/filter/BUILD.gn +++ b/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023-2023 Huawei Device Co., Ltd. +# Copyright (c) 2024 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -11,36 +11,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/ohos.gni") -import("//foundation/arkui/ace_engine/ace_config.gni") -import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") - -es2abc_gen_abc("gen_filter_abc") { - src_js = rebase_path("filter.js") - dst_file = rebase_path(target_out_dir + "/filter.abc") - in_puts = [ "filter.js" ] - out_puts = [ target_out_dir + "/filter.abc" ] - extra_args = [ "--module" ] -} - -gen_js_obj("filter_abc") { - input = get_label_info(":gen_filter_abc", "target_out_dir") + "/filter.abc" - output = target_out_dir + "/filter_abc.o" - dep = ":gen_filter_abc" -} - -ohos_shared_library("filter") { - sources = [ "filter.cpp" ] - - deps = [ ":filter_abc" ] - - external_deps = [ - "hilog:libhilog", - "napi:ace_napi", +group("advanced_ui_component") { + deps = [ + "atomicservicenavigation/interfaces:atomicservicenavigation", + "atomicservicetabs/interfaces:atomicservicetabs", + "atomicserviceweb/interfaces:atomicserviceweb", + "innerfullscreenlaunchcomponent/interfaces:innerfullscreenlaunchcomponent", + "interstitialdialogaction/interfaces:interstitialdialogaction", ] - - subsystem_name = "arkui" - part_name = "advanced_ui_component" - - relative_install_dir = "module/arkui/advanced" } diff --git a/README.md b/README.md index 6ea1082bc1fd50f942718c71f131f4239aa1b565..46fbe934c2c78e3caa16e25e362eb581b40f9ff6 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ advanced_ui is an ArkTS-based UI framework that offers efficient UI combinations **Figure 1** Relationship between advanced_ui and ArkUI ![](figures/advanced_ui_en.png "Relationship between advanced_ui and ArkUI") + **Figure 2** advanced_ui architecture ![](figures/advanced_ui_sub_en.png "advanced_ui architecture") @@ -16,20 +17,12 @@ The following figure shows the directory structure. ``` /arkui_advanced_ui_component -├── interface # APIs -│ ├── arkdialog # Components -│ └── composelistitem -│ └── ..... - -├── source # Framework source code -│ ├── arkdialog # Components -│ └── composelistitem -│ └── ..... +├── atomicservicetabs # Components +│ └── interface # APIs +│ └── source # framework sorce work +├── ..... + ``` ## When to Use With advanced_ui, you can develop your application UI must faster, leveraging its diverse array of UI component combinations with consistent design and style definitions. You can use and reuse any component anywhere as needed. - -## How to Use -> See the [doc folder](https://gitee.com/openharmony-sig/arkui_advanced_ui_component/tree/master/doc). - diff --git a/README_zh.md b/README_zh.md index d311683f8ba3bc320ac18804bd6eaf4fb9ade857..48e0ba0cb0522e7f546e60b44bb1f39c5c626d86 100644 --- a/README_zh.md +++ b/README_zh.md @@ -4,9 +4,12 @@ advanced_ui 是基于使用场景设计,为应用提供高效的UI组合,接口封闭、风格一致,开箱即用的组件接口;使用ArkTS语言开发,依赖系统的public API ## 软件架构 -**图 1** advanced_ui和ArkUI架构关系 +**图 1** advanced_ui和ArkUI架构关系 + ![](figures/advanced_ui.png "advanced_ui和ArkUI架构关系") -**图 2** advanced_ui架构设计 + +**图 2** advanced_ui架构设计 + ![](figures/advanced_ui_sub.png "advanced_ui架构设计") ## 目录 @@ -14,15 +17,11 @@ advanced_ui 是基于使用场景设计,为应用提供高效的UI组合,接 ``` /arkui_advanced_ui_component -├── interface # 接口目录 -│ ├── arkdialog # 各个组件目录 -│ └── composelistitem -│ └── ..... - -├── source # 框架源码 -│ ├── arkdialog # 各个组件目录 -│ └── composelistitem -│ └── ..... +├── atomicservicetabs # Components +│ └── interface # APIs +│ └── source # framework sorce work +├── ..... + ``` ## 使用场景 diff --git a/atomicservice_config.gni b/atomicservice_config.gni new file mode 100644 index 0000000000000000000000000000000000000000..77087d83bb3456db266cd14f5682ca33b0c7bf21 --- /dev/null +++ b/atomicservice_config.gni @@ -0,0 +1,95 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/config/clang/clang.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +enable_dump_drawcmd = false +is_ohos_standard_system = is_standard_system && !is_arkui_x +use_mingw_win = "${current_os}_${current_cpu}" == "mingw_x86_64" +use_mac = "${current_os}_${current_cpu}" == "mac_x64" || + "${current_os}_${current_cpu}" == "mac_arm64" +use_ios = "${current_os}_${current_cpu}" == "ios_x64" || + "${current_os}_${current_cpu}" == "ios_arm64" +use_linux = "${current_os}_${current_cpu}" == "linux_x64" + +# Config toolchain +windows_buildtool = "//build/toolchain/mingw:mingw_x86_64" +objcopy_default = "//prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/aarch64-linux-android/bin/objcopy" +objcopy_mingw = "//prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/bin/objcopy" +objcopy_x86_64 = "${default_clang_base_path}/bin/llvm-objcopy" +if ("${current_os}_${current_cpu}" == "mac_arm64") { + mac_buildtool = "//build/toolchain/mac:clang_arm64" +} else if ("${current_os}_${current_cpu}" == "mac_x64") { + mac_buildtool = "//build/toolchain/mac:clang_x64" +} + +objcopy_clang = "$clang_base_path/bin/llvm-objcopy" + +if (is_ohos_standard_system) { + objcopy_default = "//prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-objcopy" +} else if (is_arkui_x) { + if (host_os == "mac") { + objcopy_default = objcopy_clang + } +} + +use_hilog = is_mingw || is_mac || is_linux || is_ohos || is_ohos_standard_system + +# Config gen_obj +template("gen_obj") { + name = target_name + action("gen_obj_" + name) { + visibility = [ ":*" ] # Only targets in this file can depend on this. + + if (use_mingw_win) { + objcopy_tool = objcopy_mingw + script = "//foundation/arkui/ace_engine/build/tools/build_resource_to_bytecode.py" + } else if (use_mac || target_os == "ios") { + objcopy_tool = objcopy_clang + script = "//foundation/arkui/ace_engine/build/tools/build_resource_to_bytecode.py" + } else if (use_linux) { + objcopy_tool = objcopy_x86_64 + script = "//foundation/arkui/ace_engine/build/tools/build_resource_to_bytecode.py" + } else if (target_cpu == "x86_64") { + objcopy_tool = objcopy_x86_64 + script = "//foundation/arkui/ace_engine/build/tools/run_objcopy.py" + } else { + objcopy_tool = objcopy_default + script = "//foundation/arkui/ace_engine/build/tools/run_objcopy.py" + } + + args = [ + "--objcopy", + rebase_path(objcopy_tool), + "--input", + rebase_path(invoker.input), + "--output", + rebase_path(invoker.output), + "--arch", + current_cpu, + ] + + deps = [] + deps += invoker.snapshot_dep + + inputs = [ invoker.input ] + outputs = [ invoker.output ] + } + + source_set("gen_obj_src_" + name) { + sources = [ invoker.output ] + deps = [ ":gen_obj_" + name ] + } +} diff --git a/interface/selecttitlebar/BUILD.gn b/atomicservicenavigation/interfaces/BUILD.gn old mode 100755 new mode 100644 similarity index 35% rename from interface/selecttitlebar/BUILD.gn rename to atomicservicenavigation/interfaces/BUILD.gn index 2b37576e083394f1a4651d844a3faa27636e9637..614b698ed91745bd3f14d00a0a7f7d5110981dac --- a/interface/selecttitlebar/BUILD.gn +++ b/atomicservicenavigation/interfaces/BUILD.gn @@ -1,46 +1,57 @@ -# Copyright (c) 2023-2023 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") -import("//foundation/arkui/ace_engine/ace_config.gni") -import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") - -es2abc_gen_abc("gen_selecttitlebar_abc") { - src_js = rebase_path("selecttitlebar.js") - dst_file = rebase_path(target_out_dir + "/selecttitlebar.abc") - in_puts = [ "selecttitlebar.js" ] - out_puts = [ target_out_dir + "/selecttitlebar.abc" ] - extra_args = [ "--module" ] -} - -gen_js_obj("selecttitlebar_abc") { - input = get_label_info(":gen_selecttitlebar_abc", "target_out_dir") + "/selecttitlebar.abc" - output = target_out_dir + "/selecttitlebar_abc.o" - dep = ":gen_selecttitlebar_abc" -} - -ohos_shared_library("selecttitlebar") { - sources = [ "selecttitlebar.cpp" ] - - deps = [ ":selecttitlebar_abc" ] - - external_deps = [ - "hilog:libhilog", - "napi:ace_napi", - ] - - subsystem_name = "arkui" - part_name = "advanced_ui_component" - - relative_install_dir = "module/arkui/advanced" -} +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/config/components/ets_frontend/es2abc_config.gni") +import("//build/ohos.gni") +import("//foundation/arkui/advanced_ui_component/atomicservice_config.gni") + +es2abc_gen_abc("gen_atomicservicenavigation_abc") { + src_js = rebase_path("atomicservicenavigation.js") + dst_file = rebase_path(target_out_dir + "/atomicservicenavigation.abc") + in_puts = [ "atomicservicenavigation.js" ] + out_puts = [ target_out_dir + "/atomicservicenavigation.abc" ] + extra_args = [ "--module" ] +} + +gen_js_obj("atomicservicenavigation_abc") { + input = get_label_info(":gen_atomicservicenavigation_abc", "target_out_dir") + + "/atomicservicenavigation.abc" + output = target_out_dir + "/atomicservicenavigation_abc.o" + dep = ":gen_atomicservicenavigation_abc" +} + +gen_obj("atomicservicenavigation_abc_preview") { + input = get_label_info(":gen_atomicservicenavigation_abc", "target_out_dir") + + "/atomicservicenavigation.abc" + output = target_out_dir + "/atomicservicenavigation_abc.c" + snapshot_dep = [ ":gen_atomicservicenavigation_abc" ] +} + +ohos_shared_library("atomicservicenavigation") { + sources = [ "atomicservicenavigation.cpp" ] + + if (use_mingw_win || use_mac || use_linux) { + deps = [ ":gen_obj_src_atomicservicenavigation_abc_preview" ] + } else { + deps = [ ":atomicservicenavigation_abc" ] + } + + external_deps = [ + "hilog:libhilog", + "napi:ace_napi", + ] + + relative_install_dir = "module/atomicservice" + subsystem_name = "arkui" + part_name = "advanced_ui_component" +} diff --git a/interface/subheader/subheader.cpp b/atomicservicenavigation/interfaces/atomicservicenavigation.cpp similarity index 56% rename from interface/subheader/subheader.cpp rename to atomicservicenavigation/interfaces/atomicservicenavigation.cpp index 89d8b92098426e4f53cd9a8472ca1150e6a02528..8cdce4df8dc038b317e5968f58e0980467f7fbc3 100644 --- a/interface/subheader/subheader.cpp +++ b/atomicservicenavigation/interfaces/atomicservicenavigation.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. + * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,42 +13,39 @@ * limitations under the License. */ -#include "native_engine/native_engine.h" - -#include "napi/native_api.h" #include "napi/native_node_api.h" -extern const char _binary_subheader_abc_start[]; -extern const char _binary_subheader_abc_end[]; +extern const char _binary_atomicservicenavigation_abc_start[]; +extern const char _binary_atomicservicenavigation_abc_end[]; // Napi get abc code function extern "C" __attribute__((visibility("default"))) -void NAPI_arkui_advanced_SubHeader_GetABCCode(const char **buf, int *buflen) +void NAPI_atomicservice_AtomicServiceNavigation_GetABCCode(const char **buf, int *buflen) { if (buf != nullptr) { - *buf = _binary_subheader_abc_start; + *buf = _binary_atomicservicenavigation_abc_start; } if (buflen != nullptr) { - *buflen = _binary_subheader_abc_end - _binary_subheader_abc_start; + *buflen = _binary_atomicservicenavigation_abc_end - _binary_atomicservicenavigation_abc_start; } } /* * Module define */ -static napi_module subheaderModule = { +static napi_module AtomicServiceNavigationModule = { .nm_version = 1, .nm_flags = 0, .nm_filename = nullptr, - .nm_modname = "arkui.advanced.SubHeader", + .nm_modname = "atomicservice.AtomicServiceNavigation", .nm_priv = ((void*)0), .reserved = { 0 }, }; /* - * Module register function + * Module registerfunction */ -extern "C" __attribute__((constructor)) void subheaderRegisterModule(void) +extern "C" __attribute__((constructor)) void AtomicServiceNavigationRegisterModule(void) { - napi_module_register(&subheaderModule); + napi_module_register(&AtomicServiceNavigationModule); } \ No newline at end of file diff --git a/atomicservicenavigation/interfaces/atomicservicenavigation.js b/atomicservicenavigation/interfaces/atomicservicenavigation.js new file mode 100644 index 0000000000000000000000000000000000000000..8d98ae433107cce9e1334e1ad9ef2f204e2e1cbc --- /dev/null +++ b/atomicservicenavigation/interfaces/atomicservicenavigation.js @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +export class AtomicServiceNavigation extends ViewPU { + constructor(w, x, y, z = -1, a1 = undefined, b1) { + super(w, y, z, b1); + if (typeof a1 === "function") { + this.paramsGenerator_ = a1; + } + this.__navPathStack = new ObservedPropertyObjectPU(new NavPathStack(), this, "navPathStack"); + this.navigationContent = undefined; + this.__title = new SynchedPropertyObjectOneWayPU(x.title, this, "title"); + this.__titleOptions = new SynchedPropertyObjectOneWayPU(x.titleOptions, this, "titleOptions"); + this.__hideTitleBar = new SynchedPropertySimpleOneWayPU(x.hideTitleBar, this, "hideTitleBar"); + this.__navBarWidth = new SynchedPropertyObjectOneWayPU(x.navBarWidth, this, "navBarWidth"); + this.__mode = new SynchedPropertySimpleOneWayPU(x.mode, this, "mode"); + this.navDestinationBuilder = this.defaultNavDestinationBuilder; + this.__navBarWidthRange = new SynchedPropertyObjectOneWayPU(x.navBarWidthRange, this, "navBarWidthRange"); + this.__minContentWidth = new SynchedPropertyObjectOneWayPU(x.minContentWidth, this, "minContentWidth"); + this.stateChangeCallback = undefined; + this.modeChangeCallback = undefined; + this.setInitiallyProvidedValue(x); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(v) { + if (v.navPathStack !== undefined) { + this.navPathStack = v.navPathStack; + } + if (v.navigationContent !== undefined) { + this.navigationContent = v.navigationContent; + } + if (v.titleOptions === undefined) { + this.__titleOptions.set({ isBlurEnabled: true }); + } + if (v.navDestinationBuilder !== undefined) { + this.navDestinationBuilder = v.navDestinationBuilder; + } + if (v.stateChangeCallback !== undefined) { + this.stateChangeCallback = v.stateChangeCallback; + } + if (v.modeChangeCallback !== undefined) { + this.modeChangeCallback = v.modeChangeCallback; + } + } + updateStateVars(u) { + this.__title.reset(u.title); + this.__titleOptions.reset(u.titleOptions); + this.__hideTitleBar.reset(u.hideTitleBar); + this.__navBarWidth.reset(u.navBarWidth); + this.__mode.reset(u.mode); + this.__navBarWidthRange.reset(u.navBarWidthRange); + this.__minContentWidth.reset(u.minContentWidth); + } + purgeVariableDependenciesOnElmtId(t) { + this.__navPathStack.purgeDependencyOnElmtId(t); + this.__title.purgeDependencyOnElmtId(t); + this.__titleOptions.purgeDependencyOnElmtId(t); + this.__hideTitleBar.purgeDependencyOnElmtId(t); + this.__navBarWidth.purgeDependencyOnElmtId(t); + this.__mode.purgeDependencyOnElmtId(t); + this.__navBarWidthRange.purgeDependencyOnElmtId(t); + this.__minContentWidth.purgeDependencyOnElmtId(t); + } + aboutToBeDeleted() { + this.__navPathStack.aboutToBeDeleted(); + this.__title.aboutToBeDeleted(); + this.__titleOptions.aboutToBeDeleted(); + this.__hideTitleBar.aboutToBeDeleted(); + this.__navBarWidth.aboutToBeDeleted(); + this.__mode.aboutToBeDeleted(); + this.__navBarWidthRange.aboutToBeDeleted(); + this.__minContentWidth.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + get navPathStack() { + return this.__navPathStack.get(); + } + set navPathStack(s) { + this.__navPathStack.set(s); + } + get title() { + return this.__title.get(); + } + set title(r) { + this.__title.set(r); + } + get titleOptions() { + return this.__titleOptions.get(); + } + set titleOptions(q) { + this.__titleOptions.set(q); + } + get hideTitleBar() { + return this.__hideTitleBar.get(); + } + set hideTitleBar(p) { + this.__hideTitleBar.set(p); + } + get navBarWidth() { + return this.__navBarWidth.get(); + } + set navBarWidth(o) { + this.__navBarWidth.set(o); + } + get mode() { + return this.__mode.get(); + } + set mode(n) { + this.__mode.set(n); + } + get navBarWidthRange() { + return this.__navBarWidthRange.get(); + } + set navBarWidthRange(m) { + this.__navBarWidthRange.set(m); + } + get minContentWidth() { + return this.__minContentWidth.get(); + } + set minContentWidth(l) { + this.__minContentWidth.set(l); + } + defaultNavDestinationBuilder(i, j, k = null) { + } + initialRender() { + this.observeComponentCreation2((g, h) => { + Navigation.create(this.navPathStack); + Navigation.title(ObservedObject.GetRawObject(this.title), { + backgroundColor: this.titleOptions?.backgroundColor, + backgroundBlurStyle: this.titleOptions?.isBlurEnabled ? BlurStyle.COMPONENT_THICK : BlurStyle.NONE, + barStyle: this.titleOptions?.barStyle + }); + Navigation.titleMode(NavigationTitleMode.Mini); + Navigation.hideBackButton(true); + Navigation.hideTitleBar(this.hideTitleBar); + Navigation.navBarWidth(ObservedObject.GetRawObject(this.navBarWidth)); + Navigation.navBarPosition(NavBarPosition.Start); + Navigation.mode(this.mode); + Navigation.navDestination({ builder: this.navDestinationBuilder.bind(this) }); + Navigation.navBarWidthRange(ObservedObject.GetRawObject(this.navBarWidthRange)); + Navigation.minContentWidth(ObservedObject.GetRawObject(this.minContentWidth)); + Navigation.onNavBarStateChange(this.stateChangeCallback); + Navigation.onNavigationModeChange(this.modeChangeCallback); + }, Navigation); + this.observeComponentCreation2((c, d) => { + If.create(); + if (this.navigationContent) { + this.ifElseBranchUpdateFunction(0, () => { + this.navigationContent.bind(this)(this); + }); + } + else { + this.ifElseBranchUpdateFunction(1, () => { + }); + } + }, If); + If.pop(); + Navigation.pop(); + } + rerender() { + this.updateDirtyElements(); + } +} + +export default { AtomicServiceNavigation }; \ No newline at end of file diff --git a/atomicservicenavigation/source/atomicservicenavigation.ets b/atomicservicenavigation/source/atomicservicenavigation.ets new file mode 100644 index 0000000000000000000000000000000000000000..13596b8e06e580cb2add608c4c338ecc4203ee2c --- /dev/null +++ b/atomicservicenavigation/source/atomicservicenavigation.ets @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Callback } from '@ohos.base'; + +@Component +export struct AtomicServiceNavigation { + @State navPathStack?: NavPathStack = new NavPathStack(); + @BuilderParam navigationContent?: Callback; + @Prop title?: ResourceStr; + @Prop titleOptions?: TitleOptions = { isBlurEnabled: true }; + @Prop hideTitleBar?: boolean; + @Prop navBarWidth?: Length; + @Prop mode?: NavigationMode; + @BuilderParam navDestinationBuilder?: NavDestinationBuilder = this.defaultNavDestinationBuilder; + @Prop navBarWidthRange?: [Dimension, Dimension]; + @Prop minContentWidth?: Dimension; + stateChangeCallback?: Callback; + modeChangeCallback?: Callback; + + @Builder + defaultNavDestinationBuilder(name: string, param?: Object) { + } + + build() { + Navigation(this.navPathStack) { + if (this.navigationContent) { + this.navigationContent() + } + } + .title(this.title, { + backgroundColor: this.titleOptions?.backgroundColor, + backgroundBlurStyle: this.titleOptions?.isBlurEnabled ? BlurStyle.COMPONENT_THICK : BlurStyle.NONE, + barStyle: this.titleOptions?.barStyle + }) + .titleMode(NavigationTitleMode.Mini) + .hideBackButton(true) + .hideTitleBar(this.hideTitleBar) + .navBarWidth(this.navBarWidth) + .navBarPosition(NavBarPosition.Start) + .mode(this.mode) + .navDestination(this.navDestinationBuilder) + .navBarWidthRange(this.navBarWidthRange) + .minContentWidth(this.minContentWidth) + .onNavBarStateChange(this.stateChangeCallback) + .onNavigationModeChange(this.modeChangeCallback) + } +} + +export interface TitleOptions { + backgroundColor?: ResourceColor, + isBlurEnabled?: boolean, + barStyle?: BarStyle +} + +export type NavDestinationBuilder = (name: string, param?: Object) => void; \ No newline at end of file diff --git a/interface/editabletitlebar/BUILD.gn b/atomicservicetabs/interfaces/BUILD.gn old mode 100755 new mode 100644 similarity index 37% rename from interface/editabletitlebar/BUILD.gn rename to atomicservicetabs/interfaces/BUILD.gn index 2a7a013ccbced69ce734a0409efa14d0add267a8..6fbe8cb67f5146d22b3d8a88b3005199e30354aa --- a/interface/editabletitlebar/BUILD.gn +++ b/atomicservicetabs/interfaces/BUILD.gn @@ -1,46 +1,57 @@ -# Copyright (c) 2023-2023 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") -import("//foundation/arkui/ace_engine/ace_config.gni") -import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") - -es2abc_gen_abc("gen_editabletitlebar_abc") { - src_js = rebase_path("editabletitlebar.js") - dst_file = rebase_path(target_out_dir + "/editabletitlebar.abc") - in_puts = [ "editabletitlebar.js" ] - out_puts = [ target_out_dir + "/editabletitlebar.abc" ] - extra_args = [ "--module" ] -} - -gen_js_obj("editabletitlebar_abc") { - input = get_label_info(":gen_editabletitlebar_abc", "target_out_dir") + "/editabletitlebar.abc" - output = target_out_dir + "/editabletitlebar_abc.o" - dep = ":gen_editabletitlebar_abc" -} - -ohos_shared_library("editabletitlebar") { - sources = [ "editabletitlebar.cpp" ] - - deps = [ ":editabletitlebar_abc" ] - - external_deps = [ - "hilog:libhilog", - "napi:ace_napi", - ] - - subsystem_name = "arkui" - part_name = "advanced_ui_component" - - relative_install_dir = "module/arkui/advanced" -} +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/config/components/ets_frontend/es2abc_config.gni") +import("//build/ohos.gni") +import("//foundation/arkui/advanced_ui_component/atomicservice_config.gni") + +es2abc_gen_abc("gen_atomicservicetabs_abc") { + src_js = rebase_path("atomicservicetabs.js") + dst_file = rebase_path(target_out_dir + "/atomicservicetabs.abc") + in_puts = [ "atomicservicetabs.js" ] + out_puts = [ target_out_dir + "/atomicservicetabs.abc" ] + extra_args = [ "--module" ] +} + +gen_js_obj("atomicservicetabs_abc") { + input = get_label_info(":gen_atomicservicetabs_abc", "target_out_dir") + + "/atomicservicetabs.abc" + output = target_out_dir + "/atomicservicetabs_abc.o" + dep = ":gen_atomicservicetabs_abc" +} + +gen_obj("atomicservicetabs_abc_preview") { + input = get_label_info(":gen_atomicservicetabs_abc", "target_out_dir") + + "/atomicservicetabs.abc" + output = target_out_dir + "/atomicservicetabs_abc.c" + snapshot_dep = [ ":gen_atomicservicetabs_abc" ] +} + +ohos_shared_library("atomicservicetabs") { + sources = [ "atomicservicetabs.cpp" ] + + if (use_mingw_win || use_mac || use_linux) { + deps = [ ":gen_obj_src_atomicservicetabs_abc_preview" ] + } else { + deps = [ ":atomicservicetabs_abc" ] + } + + external_deps = [ + "hilog:libhilog", + "napi:ace_napi", + ] + + relative_install_dir = "module/atomicservice" + subsystem_name = "arkui" + part_name = "advanced_ui_component" +} diff --git a/interface/treeview/treeview.cpp b/atomicservicetabs/interfaces/atomicservicetabs.cpp similarity index 58% rename from interface/treeview/treeview.cpp rename to atomicservicetabs/interfaces/atomicservicetabs.cpp index 1c51ddbb753cdac224f666950943454296bbfbf0..456bea667923f8eba5c2ddeed62bf07291e57fb7 100644 --- a/interface/treeview/treeview.cpp +++ b/atomicservicetabs/interfaces/atomicservicetabs.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. + * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,43 +13,39 @@ * limitations under the License. */ -#include "native_engine/native_engine.h" - -#include "napi/native_api.h" #include "napi/native_node_api.h" -extern const char _binary_treeview_abc_start[]; -extern const char _binary_treeview_abc_end[]; +extern const char _binary_atomicservicetabs_abc_start[]; +extern const char _binary_atomicservicetabs_abc_end[]; // Napi get abc code function extern "C" __attribute__((visibility("default"))) -void NAPI_arkui_advanced_TreeView_GetABCCode(const char **buf, int *buflen) +void NAPI_atomicservice_AtomicServiceTabs_GetABCCode(const char **buf, int *buflen) { - if (buf != nullptr) { - *buf = _binary_treeview_abc_start; + *buf = _binary_atomicservicetabs_abc_start; } if (buflen != nullptr) { - *buflen = _binary_treeview_abc_end - _binary_treeview_abc_start; + *buflen = _binary_atomicservicetabs_abc_end - _binary_atomicservicetabs_abc_start; } } /* * Module define */ -static napi_module treeviewModule = { +static napi_module AtomicServiceTabsModule = { .nm_version = 1, .nm_flags = 0, .nm_filename = nullptr, - .nm_modname = "arkui.advanced.TreeView", + .nm_modname = "atomicservice.AtomicServiceTabs", .nm_priv = ((void*)0), .reserved = { 0 }, }; /* - * Module register function + * Module registerfunction */ -extern "C" __attribute__((constructor)) void treeviewRegisterModule(void) +extern "C" __attribute__((constructor)) void AtomicServiceTabsRegisterModule(void) { - napi_module_register(&treeviewModule); + napi_module_register(&AtomicServiceTabsModule); } \ No newline at end of file diff --git a/atomicservicetabs/interfaces/atomicservicetabs.js b/atomicservicetabs/interfaces/atomicservicetabs.js new file mode 100644 index 0000000000000000000000000000000000000000..172d3fb7b86d9214be8c864fea5b1b12a39fda10 --- /dev/null +++ b/atomicservicetabs/interfaces/atomicservicetabs.js @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +const DEFAULT_BAR_WIDTH = 96; +const DEFAULT_BAR_HEIGHT = 52; +export class AtomicServiceTabs extends ViewPU { + constructor(m1, n1, o1, p1 = -1, q1 = undefined, r1) { + super(m1, o1, p1, r1); + if (typeof q1 === "function") { + this.paramsGenerator_ = q1; + } + this.tabContents = undefined; + this.__tabBarOptionsArray = new SynchedPropertyObjectOneWayPU(n1.tabBarOptionsArray, this, "tabBarOptionsArray"); + this.__tabBarPosition = new SynchedPropertySimpleOneWayPU(n1.tabBarPosition, this, "tabBarPosition"); + this.__barBackgroundColor = new SynchedPropertyObjectOneWayPU(n1.barBackgroundColor, this, "barBackgroundColor"); + this.__index = new SynchedPropertyObjectOneWayPU(n1.index, this, "index"); + this.__barOverlap = new SynchedPropertySimpleOneWayPU(n1.barOverlap, this, "barOverlap"); + this.controller = new TabsController(); + this.onChange = undefined; + this.onTabBarClick = undefined; + this.onContentWillChange = undefined; + this.setInitiallyProvidedValue(n1); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(l1) { + if (l1.tabContents !== undefined) { + this.tabContents = l1.tabContents; + } + if (l1.tabBarPosition === undefined) { + this.__tabBarPosition.set(TabBarPosition.BOTTOM); + } + if (l1.barBackgroundColor === undefined) { + this.__barBackgroundColor.set(Color.Transparent); + } + if (l1.index === undefined) { + this.__index.set(0); + } + if (l1.barOverlap === undefined) { + this.__barOverlap.set(true); + } + if (l1.controller !== undefined) { + this.controller = l1.controller; + } + if (l1.onChange !== undefined) { + this.onChange = l1.onChange; + } + if (l1.onTabBarClick !== undefined) { + this.onTabBarClick = l1.onTabBarClick; + } + if (l1.onContentWillChange !== undefined) { + this.onContentWillChange = l1.onContentWillChange; + } + } + updateStateVars(k1) { + this.__tabBarOptionsArray.reset(k1.tabBarOptionsArray); + this.__tabBarPosition.reset(k1.tabBarPosition); + this.__barBackgroundColor.reset(k1.barBackgroundColor); + this.__index.reset(k1.index); + this.__barOverlap.reset(k1.barOverlap); + } + purgeVariableDependenciesOnElmtId(j1) { + this.__tabBarOptionsArray.purgeDependencyOnElmtId(j1); + this.__tabBarPosition.purgeDependencyOnElmtId(j1); + this.__barBackgroundColor.purgeDependencyOnElmtId(j1); + this.__index.purgeDependencyOnElmtId(j1); + this.__barOverlap.purgeDependencyOnElmtId(j1); + } + aboutToBeDeleted() { + this.__tabBarOptionsArray.aboutToBeDeleted(); + this.__tabBarPosition.aboutToBeDeleted(); + this.__barBackgroundColor.aboutToBeDeleted(); + this.__index.aboutToBeDeleted(); + this.__barOverlap.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + get tabBarOptionsArray() { + return this.__tabBarOptionsArray.get(); + } + set tabBarOptionsArray(i1) { + this.__tabBarOptionsArray.set(i1); + } + get tabBarPosition() { + return this.__tabBarPosition.get(); + } + set tabBarPosition(h1) { + this.__tabBarPosition.set(h1); + } + get barBackgroundColor() { + return this.__barBackgroundColor.get(); + } + set barBackgroundColor(g1) { + this.__barBackgroundColor.set(g1); + } + get index() { + return this.__index.get(); + } + set index(f1) { + this.__index.set(f1); + } + get barOverlap() { + return this.__barOverlap.get(); + } + set barOverlap(e1) { + this.__barOverlap.set(e1); + } + initialRender() { + this.observeComponentCreation2((c1, d1) => { + Tabs.create({ + barPosition: this.tabBarPosition === TabBarPosition.LEFT ? BarPosition.Start : BarPosition.End, + index: this.index, + controller: this.controller + }); + Tabs.barBackgroundColor(ObservedObject.GetRawObject(this.barBackgroundColor)); + Tabs.divider(null); + Tabs.vertical(this.tabBarPosition === TabBarPosition.LEFT ? true : false); + Tabs.scrollable(false); + Tabs.barOverlap(this.barOverlap); + Tabs.barBackgroundBlurStyle(BlurStyle.COMPONENT_THICK); + Tabs.onChange(this.onChange); + Tabs.onTabBarClick(this.onTabBarClick); + Tabs.onContentWillChange(this.onContentWillChange); + Tabs.width((!this.tabContents && this.tabBarPosition === TabBarPosition.LEFT) ? DEFAULT_BAR_WIDTH : '100%'); + Tabs.height((!this.tabContents && this.tabBarPosition === TabBarPosition.BOTTOM) ? DEFAULT_BAR_HEIGHT : '100%'); + }, Tabs); + this.observeComponentCreation2((h, i) => { + ForEach.create(); + const j = (l, m) => { + const n = l; + this.observeComponentCreation2((p, q) => { + If.create(); + if (n) { + this.ifElseBranchUpdateFunction(0, () => { + this.observeComponentCreation2((u, v) => { + TabContent.create(() => { + this.observeComponentCreation2((y, z) => { + If.create(); + if (this.tabContents && this.tabContents[m]) { + this.ifElseBranchUpdateFunction(0, () => { + this.tabContents[m]?.bind(this)?.(this); + }); + } + else { + this.ifElseBranchUpdateFunction(1, () => { + }); + } + }, If); + If.pop(); + }); + TabContent.tabBar(BottomTabBarStyle.of(n.icon, n.text) + .labelStyle({ unselectedColor: n.unselectedColor, selectedColor: n.selectedColor }) + .iconStyle({ unselectedColor: n.unselectedColor, selectedColor: n.selectedColor })); + TabContent.width((!this.tabContents && this.tabBarPosition === TabBarPosition.LEFT) ? DEFAULT_BAR_WIDTH : '100%'); + TabContent.height((!this.tabContents && this.tabBarPosition === TabBarPosition.BOTTOM) ? DEFAULT_BAR_HEIGHT : '100%'); + }, TabContent); + TabContent.pop(); + }); + } + else { + this.ifElseBranchUpdateFunction(1, () => { + }); + } + }, If); + If.pop(); + }; + this.forEachUpdateFunction(h, this.tabBarOptionsArray, j, undefined, true, false); + }, ForEach); + ForEach.pop(); + Tabs.pop(); + } + rerender() { + this.updateDirtyElements(); + } +} +export class TabBarOptions { + constructor(b, c, d, e) { + this.icon = b; + this.text = c; + this.unselectedColor = d; + this.selectedColor = e; + } +} + +export var TabBarPosition; +(function (a) { + a[a["LEFT"] = 0] = "LEFT"; + a[a["BOTTOM"] = 1] = "BOTTOM"; +})(TabBarPosition || (TabBarPosition = {})); + +export default { AtomicServiceTabs, TabBarOptions, TabBarPosition}; \ No newline at end of file diff --git a/atomicservicetabs/source/atomicservicetabs.ets b/atomicservicetabs/source/atomicservicetabs.ets new file mode 100644 index 0000000000000000000000000000000000000000..8598e2808fdbc5208f07751495804b29c05e7bed --- /dev/null +++ b/atomicservicetabs/source/atomicservicetabs.ets @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const DEFAULT_BAR_WIDTH: number = 96; +const DEFAULT_BAR_HEIGHT: number = 52; + +@Component +export struct AtomicServiceTabs { + @BuilderParam tabContents?: [TabContentBuilder?, + TabContentBuilder?, + TabContentBuilder?, + TabContentBuilder?, + TabContentBuilder?]; + @Prop tabBarOptionsArray: [TabBarOptions, TabBarOptions, TabBarOptions?, TabBarOptions?, TabBarOptions?]; + @Prop tabBarPosition?: TabBarPosition = TabBarPosition.BOTTOM; + @Prop barBackgroundColor?: ResourceColor = Color.Transparent; + @Prop index?: number | undefined = 0; + @Prop barOverlap?: boolean = true; + controller?: TabsController = new TabsController(); + onChange?: Callback; + onTabBarClick?: Callback; + onContentWillChange?: OnContentWillChangeCallback; + + build() { + Tabs({ + barPosition: this.tabBarPosition === TabBarPosition.LEFT ? BarPosition.Start : BarPosition.End, + index: this.index, + controller: this.controller + }) { + ForEach(this.tabBarOptionsArray, (item: TabBarOptions, index: number) => { + if (item) { + TabContent() { + if (this.tabContents && this.tabContents[index]) { + this.tabContents[index]?.() + } + } + .tabBar(BottomTabBarStyle.of(item.icon, item.text) + .labelStyle({ unselectedColor: item.unselectedColor, selectedColor: item.selectedColor }) + .iconStyle({ unselectedColor: item.unselectedColor, selectedColor: item.selectedColor })) + .width((!this.tabContents && this.tabBarPosition === TabBarPosition.LEFT) ? DEFAULT_BAR_WIDTH : '100%') + .height((!this.tabContents && this.tabBarPosition === TabBarPosition.BOTTOM) ? DEFAULT_BAR_HEIGHT : '100%') + } + }) + } + .barBackgroundColor(this.barBackgroundColor) + .divider(null) + .vertical(this.tabBarPosition === TabBarPosition.LEFT ? true : false) + .scrollable(false) + .barOverlap(this.barOverlap) + .barBackgroundBlurStyle(BlurStyle.COMPONENT_THICK) + .onChange(this.onChange) + .onTabBarClick(this.onTabBarClick) + .onContentWillChange(this.onContentWillChange) + .width((!this.tabContents && this.tabBarPosition === TabBarPosition.LEFT) ? DEFAULT_BAR_WIDTH : '100%') + .height((!this.tabContents && this.tabBarPosition === TabBarPosition.BOTTOM) ? DEFAULT_BAR_HEIGHT : '100%') + } +} + +export class TabBarOptions { + public icon: ResourceStr | TabBarSymbol; + public text: ResourceStr; + public unselectedColor?: ResourceColor; + public selectedColor?: ResourceColor; + + constructor(icon: ResourceStr | TabBarSymbol, text: ResourceStr, + unselectedColor?: ResourceColor, selectedColor?: ResourceColor) { + this.icon = icon; + this.text = text; + this.unselectedColor = unselectedColor; + this.selectedColor = selectedColor; + } +} + +export enum TabBarPosition { + LEFT = 0, + BOTTOM = 1 +} + +export type TabContentBuilder = () => void; +export type OnContentWillChangeCallback = (currentIndex: number, comingIndex: number) => boolean; \ No newline at end of file diff --git a/interface/progressbutton/BUILD.gn b/atomicserviceweb/interfaces/BUILD.gn similarity index 36% rename from interface/progressbutton/BUILD.gn rename to atomicserviceweb/interfaces/BUILD.gn index 411fb32008f30c1d76bee56136e05ca98c1f628c..92718c9f43f0ec9e1f5b44c23428b39675273baa 100644 --- a/interface/progressbutton/BUILD.gn +++ b/atomicserviceweb/interfaces/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023-2023 Huawei Device Co., Ltd. +# Copyright (c) 2024 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -11,36 +11,52 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build/config/components/ets_frontend/es2abc_config.gni") import("//build/ohos.gni") -import("//foundation/arkui/ace_engine/ace_config.gni") -import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") - -es2abc_gen_abc("gen_progressbutton_abc") { - src_js = rebase_path("progressbutton.js") - dst_file = rebase_path(target_out_dir + "/progressbutton.abc") - in_puts = [ "progressbutton.js" ] - out_puts = [ target_out_dir + "/progressbutton.abc" ] +import("//foundation/arkui/advanced_ui_component/atomicservice_config.gni") + +es2abc_gen_abc("gen_atomicserviceweb_abc") { + src_js = rebase_path("atomicserviceweb.js") + dst_file = rebase_path(target_out_dir + "/atomicserviceweb.abc") + in_puts = [ "atomicserviceweb.js" ] + out_puts = [ target_out_dir + "/atomicserviceweb.abc" ] extra_args = [ "--module" ] } -gen_js_obj("progressbutton_abc") { - input = get_label_info(":gen_progressbutton_abc", "target_out_dir") + "/progressbutton.abc" - output = target_out_dir + "/progressbutton_abc.o" - dep = ":gen_progressbutton_abc" +gen_js_obj("atomicserviceweb_abc") { + input = get_label_info(":gen_atomicserviceweb_abc", "target_out_dir") + + "/atomicserviceweb.abc" + output = target_out_dir + "/atomicserviceweb_abc.o" + dep = ":gen_atomicserviceweb_abc" +} + +gen_obj("atomicserviceweb_abc_preview") { + input = get_label_info(":gen_atomicserviceweb_abc", "target_out_dir") + + "/atomicserviceweb.abc" + output = target_out_dir + "/atomicserviceweb_abc.c" + snapshot_dep = [ ":gen_atomicserviceweb_abc" ] } -ohos_shared_library("progressbutton") { - sources = [ "progressbutton.cpp" ] +ohos_shared_library("atomicserviceweb") { + include_dirs = [ "include" ] - deps = [ ":progressbutton_abc" ] + sources = [ + "api_policy_adapter.cpp", + "atomicserviceweb.cpp", + ] + + if (use_mingw_win || use_mac || use_linux) { + deps = [ ":gen_obj_src_atomicserviceweb_abc_preview" ] + } else { + deps = [ ":atomicserviceweb_abc" ] + } external_deps = [ "hilog:libhilog", "napi:ace_napi", ] + relative_install_dir = "module/atomicservice" subsystem_name = "arkui" part_name = "advanced_ui_component" - - relative_install_dir = "module/arkui/advanced" } diff --git a/source/Swiperefresher/SwipeRefresher.ets b/atomicserviceweb/interfaces/api_policy_adapter.cpp similarity index 42% rename from source/Swiperefresher/SwipeRefresher.ets rename to atomicserviceweb/interfaces/api_policy_adapter.cpp index 141a8cf802bb8b203d2d57228072aa12466731e1..05c6ea74e67f7d422e1d500219486d51e1b3aa41 100644 --- a/source/Swiperefresher/SwipeRefresher.ets +++ b/atomicserviceweb/interfaces/api_policy_adapter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. + * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,35 +13,35 @@ * limitations under the License. */ -const LOADINGPROGRESS_SIZE = 24 -const DEFAULT_MARGIN = 16 -const ITEM_SPACE = 4 +#include "api_policy_adapter.h" -@Component -export struct SwipeRefresher { - @Prop - content: string = null +ApiPolicyAdapter::ApiPolicyAdapter() +{ +#ifndef __WIN32 + handle = dlopen("/system/lib64/platformsdk/libapipolicy_client.z.so", RTLD_NOW); + if (!handle) { + return; + } + func = reinterpret_cast(dlsym(handle, "CheckUrl")); +#endif +} - @Prop - isLoading: boolean = false; +ApiPolicyAdapter::~ApiPolicyAdapter() +{ +#ifndef __WIN32 + if (handle) { + dlclose(handle); + handle = nullptr; + } +#endif +} - build() { - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - if (this.isLoading) { - LoadingProgress() - .height(LOADINGPROGRESS_SIZE) - .width(LOADINGPROGRESS_SIZE) - .margin({ - right: ITEM_SPACE - }) - } - Text(this.content) - .fontColor($r('sys.color.ohos_id_color_text_secondary')) - .fontSize($r('sys.float.ohos_id_text_size_body2')) +int32_t ApiPolicyAdapter::CheckUrl(const std::string& bundleName, const std::string& domainType, const std::string& url) +{ + int32_t res = 0; + if (func == nullptr) { + return res; } - .margin({ - top: DEFAULT_MARGIN, - bottom: DEFAULT_MARGIN - }) - } -} \ No newline at end of file + res = func(bundleName, domainType, url); + return res; +} diff --git a/interface/splitlayout/splitlayout.cpp b/atomicserviceweb/interfaces/api_policy_adapter.h similarity index 38% rename from interface/splitlayout/splitlayout.cpp rename to atomicserviceweb/interfaces/api_policy_adapter.h index 154b774aaa2bfb0f8df858a25494ffaebef367de..03f009ef5e783b05dd1ab46414ba4e50421b65e0 100644 --- a/interface/splitlayout/splitlayout.cpp +++ b/atomicserviceweb/interfaces/api_policy_adapter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. + * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,36 +13,27 @@ * limitations under the License. */ -#include "native_engine/native_engine.h" +#ifndef API_POLICY_ADAPTER_H +#define API_POLICY_ADAPTER_H -#include "napi/native_api.h" -#include "napi/native_node_api.h" +#include "string" +#ifndef __WIN32 +#include +#endif -extern const char _binary_splitlayout_abc_start[]; -extern const char _binary_splitlayout_abc_end[]; +class ApiPolicyAdapter { +public: + ApiPolicyAdapter(); + ~ApiPolicyAdapter(); -// Napi get abc code function -extern "C" __attribute__((visibility("default"))) -void NAPI_splitlayout_GetABCCode(const char **buf, int *buflen) -{ - if (buf != nullptr) { - *buf = _binary_splitlayout_abc_start; - } - if (buflen != nullptr) { - *buflen = _binary_splitlayout_abc_end - _binary_splitlayout_abc_start; - } -} + int32_t CheckUrl(const std::string& bundleName, const std::string& domainType, const std::string& url); -static napi_module splitlayoutModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_modname = "splitlayout", - .nm_priv = ((void*)0), - .reserved = { 0 }, + using CheckUrlFunc = int32_t (*)(const std::string&, const std::string&, const std::string&); + void SetCheckUrlFunc(CheckUrlFunc& func); + +private: + void *handle = nullptr; + CheckUrlFunc func = nullptr; }; -extern "C" __attribute__((constructor)) void splitlayoutRegisterModule(void) -{ - napi_module_register(&splitlayoutModule); -} \ No newline at end of file +#endif diff --git a/atomicserviceweb/interfaces/atomicserviceweb.cpp b/atomicserviceweb/interfaces/atomicserviceweb.cpp new file mode 100644 index 0000000000000000000000000000000000000000..03a3ba825ca1cb2a6fe73d4c9a4906133349ea7e --- /dev/null +++ b/atomicserviceweb/interfaces/atomicserviceweb.cpp @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "napi/native_node_api.h" +#include "api_policy_adapter.h" + +using namespace std; + +extern const char _binary_atomicserviceweb_abc_start[]; +extern const char _binary_atomicserviceweb_abc_end[]; + +namespace HMS::AtomicServiceWeb { + static napi_value CheckUrl(napi_env env, napi_callback_info info) + { + const int indexTwo = 2; + size_t requireArgc = 3; + size_t argc = 3; + napi_value args[3] = { nullptr }; + NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, nullptr, nullptr)); + + NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments"); + + napi_valuetype bundleNameType; + NAPI_CALL(env, napi_typeof(env, args[0], &bundleNameType)); + + napi_valuetype domainTypeType; + NAPI_CALL(env, napi_typeof(env, args[1], &domainTypeType)); + + napi_valuetype urlType; + NAPI_CALL(env, napi_typeof(env, args[indexTwo], &urlType)); + + NAPI_ASSERT(env, bundleNameType == napi_string && domainTypeType == napi_string && urlType == napi_string, + "Wrong argument type. String expected."); + + size_t maxValueLen = 1024; + char bundleNameValue[maxValueLen]; + size_t bundleNameLength = 0; + napi_get_value_string_utf8(env, args[0], bundleNameValue, maxValueLen, &bundleNameLength); + std::string bundleName = bundleNameValue; + + char domainTypeValue[maxValueLen]; + size_t domainTypeLength = 0; + napi_get_value_string_utf8(env, args[1], domainTypeValue, maxValueLen, &domainTypeLength); + std::string domainType = domainTypeValue; + + char urlValue[maxValueLen]; + size_t urlLength = 0; + napi_get_value_string_utf8(env, args[indexTwo], urlValue, maxValueLen, &urlLength); + std::string url = urlValue; + + std::shared_ptr apiPolicyAdapter = std::make_shared(); + int32_t res = apiPolicyAdapter->CheckUrl(bundleName, domainType, url); + + napi_value result; + NAPI_CALL(env, napi_create_double(env, res, &result)); + return result; + } + + static napi_value Init(napi_env env, napi_value exports) + { + napi_property_descriptor desc[] = { + DECLARE_NAPI_FUNCTION("checkUrl", CheckUrl), + }; + NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc)); + return exports; + } + + // Napi get abc code function + extern "C" __attribute__((visibility("default"))) + void NAPI_atomicservice_AtomicServiceWeb_GetABCCode(const char **buf, int *buflen) + { + if (buf != nullptr) { + *buf = _binary_atomicserviceweb_abc_start; + } + if (buflen != nullptr) { + *buflen = _binary_atomicserviceweb_abc_end - _binary_atomicserviceweb_abc_start; + } + } + + /* + * Module define + */ + static napi_module AtomicServiceWebModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "atomicservice.AtomicServiceWeb", + .nm_priv = ((void*)0), + .reserved = { 0 }, + }; + + /* + * Module registerfunction + */ + extern "C" __attribute__((constructor)) void AtomicServiceWebRegisterModule(void) + { + napi_module_register(&AtomicServiceWebModule); + } +} diff --git a/atomicserviceweb/interfaces/atomicserviceweb.js b/atomicserviceweb/interfaces/atomicserviceweb.js new file mode 100644 index 0000000000000000000000000000000000000000..232beecc9ee5de5ee00da75f9a8e8c0b451e9c20 --- /dev/null +++ b/atomicserviceweb/interfaces/atomicserviceweb.js @@ -0,0 +1,1328 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var __decorate = (this && this.__decorate) || function (a12, b12, c12, d12) { + var e12 = arguments.length, + f12 = e12 < 3 ? b12 : d12 === null ? d12 = Object.getOwnPropertyDescriptor(b12, c12) : d12, g12; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") { + f12 = Reflect.decorate(a12, b12, c12, d12); + } else { + for (var h12 = a12.length - 1; h12 >= 0; h12--) { + if (g12 = a12[h12]) { + f12 = (e12 < 3 ? g12(f12) : e12 > 3 ? g12(b12, c12, f12) : g12(b12, c12)) || f12; + } + } + } + return e12 > 3 && f12 && Object.defineProperty(b12, c12, f12), f12; +}; + +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { + }); +} +const web_webview = requireNapi('web.webview'); +const router = requireNapi('router'); +const deviceInfo = requireNapi('deviceInfo'); +const geoLocationManager = requireNapi('geoLocationManager'); +const bundleManager = requireNapi('bundle.bundleManager'); +const abilityAccessCtrl = requireNapi('abilityAccessCtrl'); +const connection = requireNapi('net.connection'); +const request = requireNapi('request'); +const fs = requireNapi('file.fs'); +const util = requireNapi('util'); +const photoAccessHelper = requireNapi('file.photoAccessHelper'); +const filePreview = globalThis.requireNapi('filemanagement.filepreview', false, '', 'hms'); +const fileUri = requireNapi('file.fileuri'); +const picker = requireNapi('multimedia.cameraPicker'); +const filePicker = requireNapi('file.picker'); +const atomicServiceWebNapi = requireInternal('atomicservice.AtomicServiceWeb'); + +class AsError { + constructor(m11, n11) { + this.code = m11; + this.message = n11; + } +} + +class JsApiConfig { + constructor(i11, j11, k11, l11) { + this.apiName = i11; + this.minVersion = j11; + this.maxVersion = k11; + this.requiredFieldNames = l11; + } +} + +const LOG_ENABLE = true; +const LOG_PREFIX = '[AtomicServiceWebLog]'; +const UPLOAD_IMAGE_CACHE_DIR = '/cache/'; +const JAVA_SCRIPT_PROXY_OBJECT_NAME = 'atomicServiceProxy'; +const JAVA_SCRIPT_PROXY_API_NAME_LIST = ['invokeJsApi']; +const ATOMIC_SERVICE_JS_API_MAP = new Map(); +const registerJsApi = (u11, v11, w11, x11, y11) => { + ATOMIC_SERVICE_JS_API_MAP.set(u11, new JsApiConfig(v11, w11, x11, y11)); +}; +const MAX_VERSION = '99.99.99'; +const ATOMIC_SERVICE_JS_SDK_CURRENT_VERSION = '1.0.0'; +const PERMISSION_APPROXIMATELY_LOCATION = 'ohos.permission.APPROXIMATELY_LOCATION'; +const SYSTEM_INTERNAL_ERROR = new AsError(500, 'System internal error.'); +const JS_API_INVALID_INVOKE_ERROR = new AsError(200001, 'Invalid invoke.'); +const PARAM_REQUIRED_ERROR_CODE = 200002; +const PARAM_NUMBER_POSITIVE_ERROR_CODE = 200003; +const ROUTER_PARAM_MODE_INVALID_ERROR = new AsError(200004, 'Param mode is invalid.'); +const BACK_URL_NOT_EXIST_OR_OPENED_ERROR = new AsError(200005, 'Url is not exist or opened, can not be back.'); +const NAV_PATH_STACK_NOT_EXIST_ERROR_CODE = 200006; +const POP_PATH_NAME_NOT_EXIST_ERROR = new AsError(200007, 'Name is not exist or opened, can not be pop.'); +const POP_PATH_PARAM_INDEX_INVALID_ERROR = new AsError(200008, 'Param index is invalid.'); +const POP_PATH_INDEX_OUT_OF_RANGE_ERROR = new AsError(200009, 'The Index is out of range.'); +const UPLOAD_IMAGE_FILES_REQUIRED_ERROR = new AsError(200010, 'Param files is required.'); +const UPLOAD_IMAGE_FILE_NOT_EXIST_ERROR_CODE = 200011; +const UPLOAD_IMAGE_FILES_URI_REQUIRED_ERROR = new AsError(200012, 'Param uri of files is required.'); +const UPLOAD_FILE_ERROR = new AsError(200013, 'Upload file error.'); +const IMAGE_CAN_NOT_PREVIEW_ERROR = new AsError(200014, 'The filePath can not preview.'); +const NETWORK_NO_ACTIVE_ERROR = new AsError(200015, 'The network is not active.'); +const PERMISSION_LOCATION_USER_REFUSED_ERROR = 200016; + +registerJsApi('router.pushUrl', 'pushUrl', '1.0.0', MAX_VERSION, ['url']); +registerJsApi('router.replaceUrl', 'replaceUrl', '1.0.0', MAX_VERSION, ['url']); +registerJsApi('router.back', 'backUrl', '1.0.0', MAX_VERSION, []); +registerJsApi('router.clear', 'clearUrl', '1.0.0', MAX_VERSION, []); +registerJsApi('navPathStack.pushPath', 'pushPath', '1.0.0', MAX_VERSION, ['name']); +registerJsApi('navPathStack.replacePath', 'replacePath', '1.0.0', MAX_VERSION, ['name']); +registerJsApi('navPathStack.pop', 'popPath', '1.0.0', MAX_VERSION, []); +registerJsApi('navPathStack.clear', 'clearPath', '1.0.0', MAX_VERSION, []); +registerJsApi('asWeb.postMessage', 'postMessage', '1.0.0', MAX_VERSION, ['data']); +registerJsApi('asWeb.getEnv', 'getEnv', '1.0.0', MAX_VERSION, []); +registerJsApi('asWeb.checkJsApi', 'checkJsApi', '1.0.0', MAX_VERSION, ['jsApiList']); +registerJsApi('cameraPicker.pick', 'pickCamera', '1.0.0', MAX_VERSION, ['mediaTypes', 'cameraPosition']); +registerJsApi('photoViewPicker.select', 'selectPhoto', '1.0.0', MAX_VERSION, []); +registerJsApi('filePreview.openPreview', 'openPreview', '1.0.0', MAX_VERSION, ['uri']); +registerJsApi('request.uploadFile', 'uploadFile', '1.0.0', MAX_VERSION, ['url', 'files']); +registerJsApi('request.downloadFile', 'downloadFile', '1.0.0', MAX_VERSION, ['url']); +registerJsApi('connection.getNetworkType', 'getNetworkType', '1.0.0', MAX_VERSION, []); +registerJsApi('location.getLocation', 'getLocation', '1.0.0', MAX_VERSION, []); + +export class AtomicServiceWeb extends ViewPU { + constructor(s10, t10, u10, v10 = -1, w10 = undefined, x10) { + super(s10, u10, v10, x10); + if (typeof w10 === "function") { + this.paramsGenerator_ = w10; + } + this.src = undefined; + this.navPathStack = undefined; + this.__mixedMode = new SynchedPropertySimpleOneWayPU(t10.mixedMode, this, "mixedMode"); + this.__darkMode = new SynchedPropertySimpleOneWayPU(t10.darkMode, this, "darkMode"); + this.__forceDarkAccess = new SynchedPropertySimpleOneWayPU(t10.forceDarkAccess, this, "forceDarkAccess"); + this.__controller = new SynchedPropertyNesedObjectPU(t10.controller, this, "controller"); + this.onMessage = () => { + }; + this.onErrorReceive = () => { + }; + this.onHttpErrorReceive = () => { + }; + this.onPageBegin = () => { + }; + this.onPageEnd = () => { + }; + this.onProgressChange = () => { + }; + this.onControllerAttached = undefined; + this.onLoadIntercept = undefined; + this.context = this.getUIContext().getHostContext(); + this.webViewController = new web_webview.WebviewController(); + this.schemeHandler = new web_webview.WebSchemeHandler(); + this.atomicService = undefined; + this.atomicServiceProxy = undefined; + this.setInitiallyProvidedValue(t10); + this.finalizeConstruction(); + } + + setInitiallyProvidedValue(r10) { + if (r10.src !== undefined) { + this.src = r10.src; + } + if (r10.navPathStack !== undefined) { + this.navPathStack = r10.navPathStack; + } + this.__controller.set(r10.controller); + if (r10.onMessage !== undefined) { + this.onMessage = r10.onMessage; + } + if (r10.onErrorReceive !== undefined) { + this.onErrorReceive = r10.onErrorReceive; + } + if (r10.onHttpErrorReceive !== undefined) { + this.onHttpErrorReceive = r10.onHttpErrorReceive; + } + if (r10.onPageBegin !== undefined) { + this.onPageBegin = r10.onPageBegin; + } + if (r10.onPageEnd !== undefined) { + this.onPageEnd = r10.onPageEnd; + } + if (r10.onProgressChange !== undefined) { + this.onProgressChange = r10.onProgressChange; + } + if (r10.onControllerAttached !== undefined) { + this.onControllerAttached = r10.onControllerAttached; + } + if (r10.onLoadIntercept !== undefined) { + this.onLoadIntercept = r10.onLoadIntercept; + } + if (r10.context !== undefined) { + this.context = r10.context; + } + if (r10.webViewController !== undefined) { + this.webViewController = r10.webViewController; + } + if (r10.schemeHandler !== undefined) { + this.schemeHandler = r10.schemeHandler; + } + if (r10.atomicService !== undefined) { + this.atomicService = r10.atomicService; + } + if (r10.atomicServiceProxy !== undefined) { + this.atomicServiceProxy = r10.atomicServiceProxy; + } + } + + updateStateVars(q10) { + this.__mixedMode.reset(q10.mixedMode); + this.__darkMode.reset(q10.darkMode); + this.__forceDarkAccess.reset(q10.forceDarkAccess); + this.__controller.set(q10.controller); + } + + purgeVariableDependenciesOnElmtId(p10) { + this.__mixedMode.purgeDependencyOnElmtId(p10); + this.__darkMode.purgeDependencyOnElmtId(p10); + this.__forceDarkAccess.purgeDependencyOnElmtId(p10); + this.__controller.purgeDependencyOnElmtId(p10); + } + + aboutToBeDeleted() { + this.__mixedMode.aboutToBeDeleted(); + this.__darkMode.aboutToBeDeleted(); + this.__forceDarkAccess.aboutToBeDeleted(); + this.__controller.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + + get mixedMode() { + return this.__mixedMode.get(); + } + + set mixedMode(t11) { + this.__mixedMode.set(t11); + } + + get darkMode() { + return this.__darkMode.get(); + } + + set darkMode(s11) { + this.__darkMode.set(s11); + } + + get forceDarkAccess() { + return this.__forceDarkAccess.get(); + } + + set forceDarkAccess(r11) { + this.__forceDarkAccess.set(r11); + } + + get controller() { + return this.__controller.get(); + } + + aboutToAppear() { + if (!this.atomicService) { + this.atomicService = new AtomicServiceApi(this.context, this.navPathStack, this.onMessage); + this.atomicServiceProxy = new AtomicServiceProxy(this.atomicService); + } + try { + let h2 = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION); + if (h2?.appInfo?.appProvisionType === 'debug') { + console.log(`AtomicServiceWeb setWebDebuggingAccess`); + web_webview.WebviewController.setWebDebuggingAccess(true); + } + } catch (d2) { + console.error(`AtomicServiceWeb set Web Debug Mode failed, code is ${d2.code}, message is ${d2.message}`); + } + } + + aboutToDisappear() { + this.atomicService?.notifyMessage(); + } + + initialRender() { + this.observeComponentCreation2((g10, h10) => { + Web.create({ src: this.src, controller: this.webViewController }); + Web.zoomAccess(false); + Web.allowWindowOpenMethod(false); + Web.domStorageAccess(true); + Web.layoutMode(WebLayoutMode.NONE); + Web.mixedMode(this.mixedMode); + Web.darkMode(this.darkMode); + Web.forceDarkAccess(this.forceDarkAccess); + Web.onErrorReceive((q11) => this.onCommonCallBack('onErrorReceive', q11, this.onErrorReceive)); + Web.onHttpErrorReceive((p11) => this.onCommonCallBack('onHttpErrorReceive', p11, this.onHttpErrorReceive)); + Web.onPageBegin((l10) => this.onCommonCallBack('onPageBegin', l10, this.onPageBegin)); + Web.onPageEnd((b11) => this.onCommonCallBack('onPageEnd', b11, this.onPageEnd)); + Web.onProgressChange((a11) => this.onCommonCallBack('onProgressChange', a11, this.onProgressChange)); + Web.onControllerAttached(() => { + this.registerJavaScriptProxy(); + this.schemeHandler.onRequestStart((z10) => { + return !this.checkUrl(z10.getRequestUrl()); + }); + this.webViewController.setWebSchemeHandler('https', this.schemeHandler); + this.initAtomicServiceWebController(); + if (this.onControllerAttached) { + try { + this.onControllerAttached(); + } catch (y10) { + console.error(`AtomicServiceWeb onControllerAttached failed, code is ${y10.code}, message is ${y10.message}`); + } + } + }); + Web.onOverrideUrlLoading((i10) => { + return !this.checkUrl(i10.getRequestUrl()); + }); + Web.onLoadIntercept(m7 => { + let n7 = !this.checkUrl(m7.data.getRequestUrl()); + if (!n7 && this.onLoadIntercept) { + try { + return this.onLoadIntercept(m7); + } catch (u7) { + console.error(`AtomicServiceWeb onLoadIntercept failed, code is ${u7.code}, message is ${u7.message}`); + return true; + } + } + return n7; + }); + }, Web); + } + + onCommonCallBack(q5, e6, j6) { + try { + j6 && j6(e6); + } catch (k7) { + console.error(`AtomicServiceWeb ${q5} failed, code is ${k7.code}, message is ${k7.message}`); + } + } + + registerJavaScriptProxy() { + try { + this.webViewController.registerJavaScriptProxy(this.atomicServiceProxy, JAVA_SCRIPT_PROXY_OBJECT_NAME, + JAVA_SCRIPT_PROXY_API_NAME_LIST); + } catch (d10) { + let e10 = d10; + console.error(`AtomicServiceWeb registerJavaScriptProxy failed, code is ${e10.code}, message is ${e10.message}`); + } + } + + initAtomicServiceWebController() { + if (!this.controller) { + return; + } + this.controller.setWebviewController(this.webViewController); + } + + cutUrl(b10) { + if (b10) { + let c10 = b10.indexOf('?'); + if (c10 > -1) { + return b10.substring(0, c10); + } + } + return b10; + } + + checkUrl(q1) { + if (!q1) { + return false; + } + if (q1.startsWith('resource://rawfile')) { + return true; + } + try { + let w1 = this.context.abilityInfo.bundleName; + let t1 = 'webView'; + q1 = this.cutUrl(q1); + let res = atomicServiceWebNapi.checkUrl(w1, t1, q1); + return res === 0; + } catch (j2) { + let n2 = j2; + console.error(`AtomicServiceWeb checkUrl failed, code is ${n2.code}, message is ${n2.message}`); + return false; + } + } + + rerender() { + this.updateDirtyElements(); + } +} +let AtomicServiceWebController = class AtomicServiceWebController { + setWebviewController(l5) { + this.webViewController = l5; + } + + checkWebviewController() { + if (!this.webViewController) { + const d5 = { + name: '', + message: 'Init error. The AtomicServiceWebController must be associated with a AtomicServiceWeb component.', + code: 17100001, + }; + throw d5; + } + } + + getUserAgent() { + this.checkWebviewController(); + return this.webViewController?.getUserAgent(); + } + + getCustomUserAgent() { + this.checkWebviewController(); + return this.webViewController?.getCustomUserAgent(); + } + + setCustomUserAgent(z4) { + this.checkWebviewController(); + this.webViewController?.setCustomUserAgent(z4); + } + + accessForward() { + this.checkWebviewController(); + return this.webViewController?.accessForward(); + } + + accessBackward() { + this.checkWebviewController(); + return this.webViewController?.accessBackward(); + } + + accessStep(d4) { + this.checkWebviewController(); + return this.webViewController?.accessStep(d4); + } + + forward() { + this.checkWebviewController(); + this.webViewController?.forward(); + } + + backward() { + this.checkWebviewController(); + this.webViewController?.backward(); + } + + refresh() { + this.checkWebviewController(); + this.webViewController?.refresh(); + } + + loadUrl(t3, y3) { + this.checkWebviewController(); + if (y3) { + this.webViewController?.loadUrl(t3, y3); + } else { + this.webViewController?.loadUrl(t3); + } + } +}; +AtomicServiceWebController = __decorate([ + Observed +], AtomicServiceWebController); + +export { AtomicServiceWebController }; + +class AtomicServiceProxy { + constructor(z9) { + this.atomicService = z9; + } + + invokeJsApi(u9, v9) { + try { + v9 = v9 || {}; + if (!u9 || !ATOMIC_SERVICE_JS_API_MAP.has(u9)) { + this.atomicService.errorWithCodeAndMsg(JS_API_INVALID_INVOKE_ERROR, v9); + return; + } + let x9 = ATOMIC_SERVICE_JS_API_MAP.get(u9); + if (!this.atomicService.checkRequiredFieldInOptions(x9, v9)) { + return; + } + let y9 = this.atomicService; + y9[x9?.apiName](v9); + } catch (w9) { + this.atomicService.error(w9, v9); + } + } +} + +class AtomicService { + constructor(q9, r9, s9) { + this.messageDataList = []; + this.onMessage = () => { + }; + this.context = q9; + this.navPathStack = r9; + this.onMessage = s9 ? s9 : this.onMessage; + } + + success(o9, p9) { + try { + p9?.callback && p9?.callback(undefined, o9); + } catch (f3) { + this.consoleError(`callback error, code is ${f3.code}, message is ${f3.message}`); + } + } + + error(m9, n9) { + try { + n9?.callback && n9?.callback(new AsError(m9.code ? m9.code : SYSTEM_INTERNAL_ERROR.code, + m9.message ? m9.message : SYSTEM_INTERNAL_ERROR.message)); + } catch (a3) { + this.consoleError(`callback error, code is ${a3.code}, message is ${a3.message}`); + } + } + + errorWithCodeAndMsg(k9, l9) { + try { + l9?.callback && l9?.callback(k9); + } catch (u2) { + this.consoleError(`callback error, code is ${u2.code}, message is ${u2.message}`); + } + } + + consoleLog(j9) { + if (LOG_ENABLE) { + console.log(`${LOG_PREFIX} ${j9}`); + } + } + + consoleError(i9) { + if (LOG_ENABLE) { + console.error(`${LOG_PREFIX} ${i9}`); + } + } + + logOptions(g9, h9) { + this.consoleLog(`${g9} options=${JSON.stringify(h9)}`); + } + + checkParamRequired(d9, e9, f9) { + if (e9 === undefined || e9 === null || e9 === '') { + this.errorWithCodeAndMsg(new AsError(PARAM_REQUIRED_ERROR_CODE, `Param ${d9} is required.`), f9); + return false; + } + return true; + } + + checkNumberParamPositive(a9, b9, c9) { + if (b9 <= 0) { + this.errorWithCodeAndMsg(new AsError(PARAM_NUMBER_POSITIVE_ERROR_CODE, + `Param ${a9} must be a positive number.`), c9); + return false; + } + return true; + } + + checkRequiredFieldInOptions(v8, w8) { + if (!v8) { + return false; + } + if (!v8.requiredFieldNames) { + return true; + } + let x8 = w8; + for (let y8 = 0; y8 < v8.requiredFieldNames.length; y8++) { + let z8 = v8.requiredFieldNames[y8]; + if (!this.checkParamRequired(z8, x8[z8], w8)) { + return false; + } + } + return true; + } + + checkRouterMode(t8, u8) { + if (!t8 || t8 === 'Single' || t8 === 'Standard') { + return true; + } + this.errorWithCodeAndMsg(ROUTER_PARAM_MODE_INVALID_ERROR, u8); + return false; + } + + parseRouterMode(s8) { + return s8 === 'Single' ? router.RouterMode.Single : router.RouterMode.Standard; + } + + getRouterIndexByDelta(o8) { + let p8 = Number.parseInt(router.getLength()); + for (let q8 = p8; q8 > 0; q8--) { + let r8 = router.getStateByIndex(q8); + if (r8?.name && o8-- == 0) { + return q8; + } + } + return 1; + } + + checkBackUrlExists(i8, j8) { + let k8 = Number.parseInt(router.getLength()); + for (let l8 = k8; l8 > 0; l8--) { + let m8 = router.getStateByIndex(l8); + if (m8?.name) { + let n8 = m8?.path + m8?.name; + if (n8 === i8) { + return true; + } + } + } + this.errorWithCodeAndMsg(BACK_URL_NOT_EXIST_OR_OPENED_ERROR, j8); + return false; + } + + checkNavPathStack(g8, h8) { + if (!this.navPathStack) { + this.errorWithCodeAndMsg(new AsError(NAV_PATH_STACK_NOT_EXIST_ERROR_CODE, + `Current page is not NavDestination, not support ${g8}().`), h8); + return false; + } + return true; + } + + getNavPathIndexByDelta(e8) { + let f8 = this.navPathStack?.getAllPathName(); + if (!f8 || f8.length == 0) { + return -1; + } + return f8.length > e8 ? (f8.length - e8 - 1) : -1; + } + + onPopHandler(c8, d8) { + if (!c8?.info || !d8) { + return; + } + d8(new OnPopEvent(c8.info.name, c8.info.param, c8.result)); + } + + getCurrentNavPathInfo() { + let a8 = this.navPathStack?.getAllPathName(); + let b8 = (a8 && a8.length > 0) ? + new NavPathInfo(a8[a8.length - 1], a8.length - 1) : new NavPathInfo(undefined, -1); + if (b8.index >= 0) { + b8.param = this.navPathStack?.getParamByIndex(b8.index); + } + return b8; + } + + notifyMessage() { + if (this.messageDataList.length <= 0) { + return; + } + try { + this.onMessage(new OnMessageEvent(this.messageDataList)); + } catch (q2) { + this.consoleError(`onMessage failed, code is ${q2.code}, message is ${q2.message}`); + } + this.messageDataList = []; + } + + isJsApiEnable(z7) { + if (!z7) { + return false; + } + if (this.compareVersion(z7.minVersion, ATOMIC_SERVICE_JS_SDK_CURRENT_VERSION) && + this.compareVersion(ATOMIC_SERVICE_JS_SDK_CURRENT_VERSION, z7.maxVersion)) { + return true; + } + return false; + } + + compareVersion(p7, q7) { + if (!p7 || !q7) { + return false; + } + let r7 = p7.split('.').map(y7 => Number.parseInt(y7)); + let s7 = q7.split('.').map(x7 => Number.parseInt(x7)); + const t7 = Math.max(r7.length, s7.length); + for (let w7 = 0; w7 < t7; w7++) { + if (r7[w7] < s7[w7]) { + return true; + } else if (r7[w7] > s7[w7]) { + return false; + } + } + if (r7.length < s7.length) { + return true; + } + if (r7.length > s7.length) { + return false; + } + return true; + } + + getUri(o7) { + if (!o7 || o7.startsWith('file://')) { + return o7; + } + return fileUri.getUriFromPath(o7); + } + + async checkUploadFile(e7) { + if (!e7.files || e7.files.length <= 0) { + this.errorWithCodeAndMsg(UPLOAD_IMAGE_FILES_REQUIRED_ERROR, e7); + return new CheckUploadFileResult(false); + } + let f7 = new Map(); + for (let g7 = 0; g7 < e7.files?.length; g7++) { + let h7 = e7.files[g7]; + if (!h7.uri) { + this.errorWithCodeAndMsg(UPLOAD_IMAGE_FILES_URI_REQUIRED_ERROR, e7); + return new CheckUploadFileResult(false); + } + if (!h7.uri.startsWith('file://') && !fs.accessSync(h7.uri, fs.AccessModeType.EXIST)) { + this.errorWithCodeAndMsg(new AsError(UPLOAD_IMAGE_FILE_NOT_EXIST_ERROR_CODE, + `File uri ${h7.uri} is not exist.`), e7); + return new CheckUploadFileResult(false); + } + let i7 = h7.uri; + let j7 = h7.uri; + if (j7.indexOf(UPLOAD_IMAGE_CACHE_DIR) < 0) { + let l7 = j7.startsWith('file://') ? j7 : fileUri.getUriFromPath(h7.uri); + j7 = this.context.cacheDir + '/' + j7.substring(j7.lastIndexOf('/') + 1); + try { + await fs.copy(l7, fileUri.getUriFromPath(j7)); + } catch (x1) { + this.errorWithCodeAndMsg(UPLOAD_FILE_ERROR, e7); + return new CheckUploadFileResult(false); + } + } + h7.uri = 'internal://' + j7.substring(j7.indexOf(UPLOAD_IMAGE_CACHE_DIR) + 1); + f7.set(j7, i7); + } + return new CheckUploadFileResult(true, f7); + } + + convertToRequestData(a7) { + let b7 = []; + if (a7) { + a7.forEach(d7 => { + if (!d7.name || !d7.value) { + return; + } + b7.push({ name: d7.name, value: d7.value }); + }); + } + return b7; + } + + convertToFile(w6) { + let x6 = []; + if (w6) { + w6.forEach(z6 => { + x6.push({ + filename: z6.filename, + name: z6.name, + uri: z6.uri, + type: z6.type + }); + }); + } + return x6; + } + + handleUploadFileResult(p6, q6, r6) { + let s6 = []; + if (p6) { + p6.forEach(u6 => { + let v6 = u6.path ? q6.get(u6.path) : u6.path; + s6.push(new UploadFileTaskState(v6 ? v6 : u6.path, u6.responseCode, u6.message)); + }); + } + this.success(new UploadFileResult(s6), r6); + } + + parseFileNameFromUrl(m6) { + if (!m6) { + return ''; + } + let n6 = m6.split('?')[0]; + if (n6.indexOf('/') < 0) { + return ''; + } + let o6 = n6.lastIndexOf('/'); + if (o6 == (n6.length - 1)) { + return ''; + } + return n6.substring(o6 + 1); + } + + checkAccessToken(v5) { + let w5 = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION); + let x5 = w5.appInfo.accessTokenId; + let y5 = abilityAccessCtrl.createAtManager(); + return y5.checkAccessToken(x5, v5); + } + + checkPermissions(j5, k5) { + this.checkAccessToken(j5).then(o5 => { + if (o5 == abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) { + k5(undefined); + } else { + let p5 = abilityAccessCtrl.createAtManager(); + p5.requestPermissionsFromUser(this.context, [j5]).then(t5 => { + for (let u5 = 0; u5 < t5.authResults.length; u5++) { + if (t5.authResults[u5] != 0) { + const error = { + name: '', + message: `RequestPermissionsFromUser error. authResult: ${t5.authResults[u5]}.`, + code: PERMISSION_LOCATION_USER_REFUSED_ERROR + }; + k5(error); + return; + } + } + k5(undefined); + }).catch((s5) => { + k5(s5); + }); + } + }).catch((n5) => { + k5(n5); + }); + } +} + +class AtomicServiceApi extends AtomicService { + constructor(g5, h5, i5) { + super(g5, h5, i5); + } + + pushUrl(c5) { + if (!this.checkRouterMode(c5.mode, c5)) { + return; + } + router.pushUrl({ url: c5.url, params: c5.params }, this.parseRouterMode(c5.mode)).then(() => { + this.success(new PushUrlResult(), c5); + }).catch((f5) => { + this.error(f5, c5); + }); + } + + replaceUrl(y4) { + if (!this.checkRouterMode(y4.mode, y4)) { + return; + } + router.replaceUrl({ url: y4.url, params: y4.params }, this.parseRouterMode(y4.mode)).then(() => { + this.success(new ReplaceUrlResult(), y4); + }).catch((b5) => { + this.error(b5, y4); + }); + } + + backUrl(x4) { + if (x4.url) { + if (!this.checkBackUrlExists(x4.url, x4)) { + return; + } + router.back({ url: x4.url, params: x4.params }); + this.success(new BackUrlResult(), x4); + } else if (x4.index || x4.index === 0) { + if (!this.checkNumberParamPositive('index', x4.index, x4)) { + return; + } + router.back(x4.index, x4.params); + this.success(new BackUrlResult(), x4); + } else if (x4.delta || x4.delta === 0) { + if (!this.checkNumberParamPositive('delta', x4.delta, x4)) { + return; + } + router.back(this.getRouterIndexByDelta(x4.delta), x4.params); + this.success(new BackUrlResult(), x4); + } else { + router.back(); + this.success(new BackUrlResult(), x4); + } + } + + clearUrl(w4) { + router.clear(); + this.success(new ClearUrlResult(), w4); + } + + pushPath(u4) { + if (!this.checkNavPathStack('navPathStack.pushPath', u4)) { + return; + } + this.navPathStack?.pushPath({ + name: u4.name, + param: u4.param, + onPop: v4 => this.onPopHandler(v4, u4.onPop) + }, u4.animated); + this.success(new PushPathResult(), u4); + } + + replacePath(s4) { + if (!this.checkNavPathStack('navPathStack.replacePath', s4)) { + return; + } + this.navPathStack?.replacePath({ + name: s4.name, + param: s4.param, + onPop: t4 => this.onPopHandler(t4, s4.onPop) + }, s4.animated); + this.success(new ReplacePathResult(), s4); + } + + popPath(p4) { + if (!this.checkNavPathStack('navPathStack.pop', p4)) { + return; + } + if (p4.name) { + let r4 = this.navPathStack?.popToName(p4.name, p4.result, p4.animated); + if (r4 === undefined || r4 === -1) { + this.errorWithCodeAndMsg(POP_PATH_NAME_NOT_EXIST_ERROR, p4); + return; + } + } else if (p4.index || p4.index === 0) { + if (p4.index < -1) { + this.errorWithCodeAndMsg(POP_PATH_PARAM_INDEX_INVALID_ERROR, p4); + return; + } + if (p4.index > this.getCurrentNavPathInfo().index) { + this.errorWithCodeAndMsg(POP_PATH_INDEX_OUT_OF_RANGE_ERROR, p4); + return; + } + this.navPathStack?.popToIndex(p4.index, p4.result, p4.animated); + } else if (p4.delta || p4.delta === 0) { + if (!this.checkNumberParamPositive('delta', p4.delta, p4)) { + return; + } + this.navPathStack?.popToIndex(this.getNavPathIndexByDelta(p4.delta), p4.result, p4.animated); + } else { + this.navPathStack?.pop(p4.result, p4.animated); + } + let q4 = this.getCurrentNavPathInfo(); + this.success(new PopPathResult(q4.name, q4.index, q4.param), p4); + } + + clearPath(o4) { + if (!this.checkNavPathStack('navPathStack.clear', o4)) { + return; + } + this.navPathStack?.clear(o4.animated); + this.success(new ClearPathResult(), o4); + } + + postMessage(n4) { + n4.data && this.messageDataList.push(n4.data); + this.success(new PostMessageResult(), n4); + } + + getEnv(l4) { + let m4 = new GetEnvResult(); + m4.deviceType = deviceInfo.deviceType; + m4.brand = deviceInfo.brand; + m4.productModel = deviceInfo.productModel; + m4.osFullName = deviceInfo.osFullName; + this.success(m4, l4); + } + + checkJsApi(h4) { + let i4 = new Map(); + h4.jsApiList?.forEach(k4 => { + i4[k4] = this.isJsApiEnable(ATOMIC_SERVICE_JS_API_MAP.get(k4)); + }); + this.success(new CheckJsApiResult(i4), h4); + } + + pickCamera(c4) { + picker.pick(this.context, c4.mediaTypes, { + cameraPosition: c4.cameraPosition, + saveUri: c4.saveUri, + videoDuration: c4.videoDuration + }).then((g4) => { + this.success(new PickCameraResult(g4.resultCode, g4.resultUri, g4.mediaType), c4); + }).catch((f4) => { + this.error(f4, c4); + }); + } + + selectPhoto(w3) { + let x3 = new photoAccessHelper.PhotoViewPicker(); + x3.select({ + MIMEType: w3.mimeType, + maxSelectNumber: w3.maxSelectNumber, + isPhotoTakingSupported: w3.isPhotoTakingSupported, + isEditSupported: w3.isEditSupported, + isSearchSupported: w3.isSearchSupported, + recommendationOptions: { + recommendationType: w3.recommendationType + }, + preselectedUris: w3.preselectedUris + }).then((b4) => { + this.success(new SelectPhotoResult(b4.photoUris, b4.isOriginalPhoto), w3); + }).catch((a4) => { + this.error(a4, w3); + }); + } + + openPreview(n3) { + let o3 = this.getUri(n3.uri); + filePreview.openPreview(this.context, { + uri: o3, + mimeType: n3.mimeType, + title: n3.title + }).then(() => { + this.success(new OpenPreviewResult(), n3); + }).catch((v3) => { + this.error(v3, n3); + }); + } + + uploadFile(z2) { + this.checkUploadFile(z2).then(d3 => { + if (!d3.checkResult) { + return; + } + let e3 = { + url: z2.url, + header: z2.header, + method: z2.method, + files: this.convertToFile(z2.files), + data: this.convertToRequestData(z2.data) + }; + request.uploadFile(this.context, e3).then((i3) => { + i3.on('complete', (m3) => { + this.handleUploadFileResult(m3, d3.uriMap, z2); + }); + i3.on('fail', (l3) => { + this.handleUploadFileResult(l3, d3.uriMap, z2); + }); + }).catch((h3) => { + this.error(h3, z2); + }); + }).catch((c3) => { + this.error(c3, z2); + }); + } + + downloadFile(m2) { + let o2 = `${util.generateRandomUUID().replaceAll('-', '')}`; + let p2 = `${this.context.cacheDir}/${o2}`; + request.downloadFile(this.context, { + url: m2.url, + header: m2.header ? m2.header : new Object(), + filePath: p2, + enableMetered: m2.enableMetered, + enableRoaming: m2.enableRoaming, + networkType: m2.networkType, + background: false + }).then((t2) => { + t2.on('complete', () => { + this.success(new DownloadFileResult(p2), m2); + }); + t2.on('fail', w2 => { + this.errorWithCodeAndMsg(new AsError(w2, 'File download fail.'), m2); + }); + }).catch((s2) => { + this.error(s2, m2); + }); + } + + getNetworkType(c2) { + connection.getDefaultNet().then(g2 => { + if (!g2 || g2.netId === 0) { + this.errorWithCodeAndMsg(NETWORK_NO_ACTIVE_ERROR, c2); + return; + } + connection.getNetCapabilities(g2).then(k2 => { + let l2 = new GetNetworkTypeResult(k2.bearerTypes, k2.networkCap, k2.linkUpBandwidthKbps, + k2.linkDownBandwidthKbps); + this.success(l2, c2); + }).catch((j2) => { + this.error(j2, c2); + }); + }).catch((f2) => { + this.error(f2, c2); + }); + } + + getLocation(u1) { + this.checkPermissions(PERMISSION_APPROXIMATELY_LOCATION, w1 => { + if (w1) { + this.error(w1, u1); + return; + } + geoLocationManager.getCurrentLocation({ + priority: u1.priority, + scenario: u1.scenario, + maxAccuracy: u1.maxAccuracy, + timeoutMs: u1.timeoutMs + }).then(a2 => { + let b2 = + new GetLocationResult(a2.latitude, a2.longitude, a2.altitude, a2.accuracy, a2.speed, a2.timeStamp, + a2.direction, a2.timeSinceBoot, a2.additions, a2.additionSize); + this.success(b2, u1); + }).catch((z1) => { + this.error(z1, u1); + }); + }); + } +} + +class NavPathInfo { + constructor(s1, t1) { + this.name = s1; + this.index = t1; + } +} + +class CheckUploadFileResult { + constructor(q1, r1) { + this.checkResult = q1; + this.uriMap = r1; + } +} + +class BaseOptions { +} + +class PushUrlOptions extends BaseOptions { +} + +class PushUrlResult { +} + +class ReplaceUrlOptions extends BaseOptions { +} + +class ReplaceUrlResult { +} + +class BackUrlOptions extends BaseOptions { +} + +class BackUrlResult { +} + +class ClearUrlOptions extends BaseOptions { +} + +class ClearUrlResult { +} + +class OnPopEvent { + constructor(n1, o1, p1) { + this.name = n1; + this.param = o1; + this.result = p1; + } +} + +class PushPathOptions extends BaseOptions { +} + +class PushPathResult { +} + +class ReplacePathOptions extends BaseOptions { +} + +class ReplacePathResult { +} + +class PopPathOptions extends BaseOptions { +} + +class PopPathResult { + constructor(k1, l1, m1) { + this.name = k1; + this.index = l1; + this.param = m1; + } +} + +class ClearPathOptions extends BaseOptions { +} + +class ClearPathResult { +} + +class PostMessageOptions extends BaseOptions { +} + +class PostMessageResult { +} + +export class OnMessageEvent { + constructor(j1) { + this.data = j1; + } +} + +export class OnErrorReceiveEvent { + constructor(h1, i1) { + this.request = h1; + this.error = i1; + } +} + +export class OnHttpErrorReceiveEvent { + constructor(f1, g1) { + this.request = f1; + this.response = g1; + } +} + +export class OnPageBeginEvent { + constructor(e1) { + this.url = e1; + } +} + +export class OnPageEndEvent { + constructor(d1) { + this.url = d1; + } +} + +export class WebHeader { + constructor(j3, p3) { + this.headerKey = j3; + this.headerValue = p3; + } +} + +class GetEnvOptions extends BaseOptions { +} + +class GetEnvResult { +} + +class CheckJsApiOptions extends BaseOptions { +} + +class CheckJsApiResult { + constructor(c1) { + this.checkResult = c1; + } +} + +class PickCameraOptions extends BaseOptions { +} + +class PickCameraResult { + constructor(z, a1, b1) { + this.resultCode = z; + this.resultUri = a1; + this.mediaType = b1; + } +} + +class SelectPhotoOptions extends BaseOptions { +} + +class SelectPhotoResult { + constructor(x, y) { + this.photoUris = x; + this.isOriginalPhoto = y; + } +} + +class OpenPreviewOptions extends BaseOptions { +} + +class OpenPreviewResult { +} + +class UploadFileOptions extends BaseOptions { +} + +class UploadFile { + constructor(t, u, v, w) { + this.filename = t; + this.name = u; + this.uri = v; + this.type = w; + } +} + +class UploadRequestData { +} + +class UploadFileResult { + constructor(s) { + this.taskStates = s; + } +} + +class UploadFileTaskState { + constructor(p, q, r) { + this.path = p; + this.responseCode = q; + this.message = r; + } +} + +class DownloadFileOptions extends BaseOptions { +} + +class DownloadFileResult { + constructor(o) { + this.uri = o; + } +} + +class GetNetworkTypeOptions extends BaseOptions { +} + +class GetNetworkTypeResult { + constructor(k, l, m, n) { + this.bearerTypes = k; + this.networkCap = l; + this.linkUpBandwidthKbps = m; + this.linkDownBandwidthKbps = n; + } +} + +class GetLocationOptions extends BaseOptions { +} + +class GetLocationResult { + constructor(a, b, c, d, e, f, g, h, i, j) { + this.latitude = a; + this.longitude = b; + this.altitude = c; + this.accuracy = d; + this.speed = e; + this.timeStamp = f; + this.direction = g; + this.timeSinceBoot = h; + this.additions = i; + this.additionSize = j; + } +} + +export default { + AtomicServiceWeb, + AtomicServiceWebController +} diff --git a/atomicserviceweb/source/atomicserviceweb.ets b/atomicserviceweb/source/atomicserviceweb.ets new file mode 100644 index 0000000000000000000000000000000000000000..67faf488adb39044a80dd09729e7b26f997ab500 --- /dev/null +++ b/atomicserviceweb/source/atomicserviceweb.ets @@ -0,0 +1,1340 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import web_webview from '@ohos.web.webview'; +import router from '@ohos.router'; +import deviceInfo from '@ohos.deviceInfo'; +import common from '@ohos.app.ability.common'; +import geoLocationManager from '@ohos.geoLocationManager'; +import bundleManager from '@ohos.bundle.bundleManager'; +import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; +import connection from '@ohos.net.connection'; +import request from '@ohos.request'; +import fs from '@ohos.file.fs'; +import util from '@ohos.util'; +import photoAccessHelper from '@ohos.file.photoAccessHelper'; +import { filePreview } from '@kit.PreviewKit'; +import fileUri from '@ohos.file.fileuri'; +import picker from '@ohos.multimedia.cameraPicker'; +import filePicker from '@ohos.file.picker'; +import { BusinessError } from '@ohos.base'; + +class AsError { + public code: number; + public message: string; + + constructor(code: number, message: string) { + this.code = code; + this.message = message; + } +} + +class JsApiConfig { + public apiName: string; + public minVersion: string; + public maxVersion: string; + public requiredFieldNames?: string[]; + + constructor(apiName: string, minVersion: string, maxVersion: string, requiredFieldNames?: string[]) { + this.apiName = apiName; + this.minVersion = minVersion; + this.maxVersion = maxVersion; + this.requiredFieldNames = requiredFieldNames; + } +} + +const LOG_ENABLE: boolean = true; +const LOG_PREFIX: string = '[AtomicServiceWebLog]'; +const UPLOAD_IMAGE_CACHE_DIR: string = '/cache/'; +const JAVA_SCRIPT_PROXY_OBJECT_NAME: string = 'atomicServiceProxy'; +const JAVA_SCRIPT_PROXY_API_NAME_LIST: string[] = ['invokeJsApi']; +const ATOMIC_SERVICE_JS_API_MAP = new Map(); +const registerJsApi = (apiNameAlias: string, apiName: string, minVersion: string, maxVersion: string, + requiredFieldNames: string[]): void => { + ATOMIC_SERVICE_JS_API_MAP.set(apiNameAlias, new JsApiConfig(apiName, minVersion, maxVersion, requiredFieldNames)); +}; +const MAX_VERSION = '99.99.99'; +const ATOMIC_SERVICE_JS_SDK_CURRENT_VERSION = '1.0.0'; +const PERMISSION_APPROXIMATELY_LOCATION: Permissions = 'ohos.permission.APPROXIMATELY_LOCATION'; + +const SYSTEM_INTERNAL_ERROR: AsError = new AsError(500, 'System internal error.'); +const JS_API_INVALID_INVOKE_ERROR: AsError = new AsError(200001, 'Invalid invoke.'); +const PARAM_REQUIRED_ERROR_CODE: number = 200002; +const PARAM_NUMBER_POSITIVE_ERROR_CODE: number = 200003; +const ROUTER_PARAM_MODE_INVALID_ERROR: AsError = new AsError(200004, 'Param mode is invalid.'); +const BACK_URL_NOT_EXIST_OR_OPENED_ERROR: AsError = new AsError(200005, 'Url is not exist or opened, can not be back.'); +const NAV_PATH_STACK_NOT_EXIST_ERROR_CODE: number = 200006; +const POP_PATH_NAME_NOT_EXIST_ERROR: AsError = new AsError(200007, 'Name is not exist or opened, can not be pop.'); +const POP_PATH_PARAM_INDEX_INVALID_ERROR: AsError = new AsError(200008, 'Param index is invalid.'); +const POP_PATH_INDEX_OUT_OF_RANGE_ERROR: AsError = new AsError(200009, 'The Index is out of range.'); +const UPLOAD_IMAGE_FILES_REQUIRED_ERROR: AsError = new AsError(200010, 'Param files is required.'); +const UPLOAD_IMAGE_FILE_NOT_EXIST_ERROR_CODE: number = 200011; +const UPLOAD_IMAGE_FILES_URI_REQUIRED_ERROR: AsError = new AsError(200012, 'Param uri of files is required.'); +const UPLOAD_FILE_ERROR: AsError = new AsError(200013, 'Upload file error.'); +const IMAGE_CAN_NOT_PREVIEW_ERROR: AsError = new AsError(200014, 'The filePath can not preview.'); +const NETWORK_NO_ACTIVE_ERROR: AsError = new AsError(200015, 'The network is not active.'); +const PERMISSION_LOCATION_USER_REFUSED_ERROR: number = 200016; + +registerJsApi('router.pushUrl', 'pushUrl', '1.0.0', MAX_VERSION, ['url']); +registerJsApi('router.replaceUrl', 'replaceUrl', '1.0.0', MAX_VERSION, ['url']); +registerJsApi('router.back', 'backUrl', '1.0.0', MAX_VERSION, []); +registerJsApi('router.clear', 'clearUrl', '1.0.0', MAX_VERSION, []); +registerJsApi('navPathStack.pushPath', 'pushPath', '1.0.0', MAX_VERSION, ['name']); +registerJsApi('navPathStack.replacePath', 'replacePath', '1.0.0', MAX_VERSION, ['name']); +registerJsApi('navPathStack.pop', 'popPath', '1.0.0', MAX_VERSION, []); +registerJsApi('navPathStack.clear', 'clearPath', '1.0.0', MAX_VERSION, []); +registerJsApi('asWeb.postMessage', 'postMessage', '1.0.0', MAX_VERSION, ['data']); +registerJsApi('asWeb.getEnv', 'getEnv', '1.0.0', MAX_VERSION, []); +registerJsApi('asWeb.checkJsApi', 'checkJsApi', '1.0.0', MAX_VERSION, ['jsApiList']); +registerJsApi('cameraPicker.pick', 'pickCamera', '1.0.0', MAX_VERSION, ['mediaTypes', 'cameraPosition']); +registerJsApi('photoViewPicker.select', 'selectPhoto', '1.0.0', MAX_VERSION, []); +registerJsApi('filePreview.openPreview', 'openPreview', '1.0.0', MAX_VERSION, ['uri']); +registerJsApi('request.uploadFile', 'uploadFile', '1.0.0', MAX_VERSION, ['url', 'files']); +registerJsApi('request.downloadFile', 'downloadFile', '1.0.0', MAX_VERSION, ['url']); +registerJsApi('connection.getNetworkType', 'getNetworkType', '1.0.0', MAX_VERSION, []); +registerJsApi('location.getLocation', 'getLocation', '1.0.0', MAX_VERSION, []); + +@Component +export struct AtomicServiceWeb { + public src: ResourceStr | undefined = undefined; + public navPathStack?: NavPathStack; + @Prop mixedMode?: MixedMode; + @Prop darkMode?: WebDarkMode; + @Prop forceDarkAccess?: boolean; + @ObjectLink controller: AtomicServiceWebController; + public onMessage?: Callback = () => { + }; + public onErrorReceive?: Callback = () => { + }; + public onHttpErrorReceive?: Callback = () => { + }; + public onPageBegin?: Callback = () => { + }; + public onPageEnd?: Callback = () => { + }; + public onProgressChange?: Callback = () => { + }; + public onControllerAttached?: VoidCallback; + public onLoadIntercept?: Callback; + private context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext; + private webViewController: web_webview.WebviewController = new web_webview.WebviewController(); + private schemeHandler: web_webview.WebSchemeHandler = new web_webview.WebSchemeHandler(); + private atomicService?: AtomicService; + private atomicServiceProxy?: AtomicServiceProxy; + + aboutToAppear(): void { + if (!this.atomicService) { + this.atomicService = new AtomicServiceApi(this.context, this.navPathStack, this.onMessage); + this.atomicServiceProxy = new AtomicServiceProxy(this.atomicService); + } + + try { + let bundleInfo: bundleManager.BundleInfo = bundleManager.getBundleInfoForSelfSync( + bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION); + if (bundleInfo?.appInfo?.appProvisionType === 'debug') { + console.log(`AtomicServiceWeb setWebDebuggingAccess`); + web_webview.WebviewController.setWebDebuggingAccess(true); + } + } catch (err) { + console.error(`AtomicServiceWeb set Web Debug Mode failed, code is ${err.code}, message is ${err.message}`); + } + } + + aboutToDisappear(): void { + this.atomicService?.notifyMessage(); + } + + build() { + Web({ src: this.src, controller: this.webViewController }) + .zoomAccess(false) + .allowWindowOpenMethod(false) + .domStorageAccess(true) + .layoutMode(WebLayoutMode.NONE) + .mixedMode(this.mixedMode) + .darkMode(this.darkMode) + .forceDarkAccess(this.forceDarkAccess) + .onErrorReceive((event: OnErrorReceiveEvent) => this.onCommonCallBack('onErrorReceive', event, + this.onErrorReceive)) + .onHttpErrorReceive((event: OnHttpErrorReceiveEvent) => this.onCommonCallBack('onHttpErrorReceive', event, + this.onHttpErrorReceive)) + .onPageBegin((event: OnPageBeginEvent) => this.onCommonCallBack('onPageBegin', event, this.onPageBegin)) + .onPageEnd((event: OnPageEndEvent) => this.onCommonCallBack('onPageEnd', event, this.onPageEnd)) + .onProgressChange((event: OnProgressChangeEvent) => this.onCommonCallBack('onProgressChange', event, + this.onProgressChange)) + .onControllerAttached(() => { + this.registerJavaScriptProxy(); + this.schemeHandler.onRequestStart((request: web_webview.WebSchemeHandlerRequest) => { + return !this.checkUrl(request.getRequestUrl()); + }); + this.webViewController.setWebSchemeHandler('https', this.schemeHandler); + this.initAtomicServiceWebController(); + if (this.onControllerAttached) { + try { + this.onControllerAttached(); + } catch (error) { + console.error(`AtomicServiceWeb onControllerAttached failed, code is ${error.code}, message is ${error.message}`); + } + } + }) + .onOverrideUrlLoading((webResourceRequest: WebResourceRequest) => { + return !this.checkUrl(webResourceRequest.getRequestUrl()); + }) + .onLoadIntercept(event => { + let checkResult = !this.checkUrl(event.data.getRequestUrl()); + if (!checkResult && this.onLoadIntercept) { + try { + return this.onLoadIntercept(event); + } catch (error) { + console.error(`AtomicServiceWeb onLoadIntercept failed, code is ${error.code}, message is ${error.message}`); + return true; + } + } + return checkResult + }) + } + + onCommonCallBack(method: string, event: T, callback?: (event: T) => void): void { + try { + callback && callback(event); + } catch (error) { + console.error(`AtomicServiceWeb ${method} failed, code is ${error.code}, message is ${error.message}`); + } + } + + registerJavaScriptProxy(): void { + try { + this.webViewController.registerJavaScriptProxy(this.atomicServiceProxy, JAVA_SCRIPT_PROXY_OBJECT_NAME, + JAVA_SCRIPT_PROXY_API_NAME_LIST); + } catch (error) { + let e: BusinessError = error as BusinessError; + console.error(`AtomicServiceWeb registerJavaScriptProxy failed, code is ${e.code}, message is ${e.message}`); + } + } + + initAtomicServiceWebController(): void { + if (!this.controller) { + return; + } + this.controller.setWebviewController(this.webViewController); + } + + cutUrl(url: string): string { + if (url) { + let index: number = url.indexOf('?'); + if (index > -1) { + return url.substring(0, index); + } + } + return url; + } + + checkUrl(url: string): boolean { + if (!url) { + return false; + } + if (url.startsWith('resource://rawfile')) { + return true; + } + url = this.cutUrl(url); + return true; + } +} + +@Observed +export class AtomicServiceWebController { + private webViewController?: web_webview.WebviewController; + + setWebviewController(webViewController: web_webview.WebviewController): void { + this.webViewController = webViewController; + } + + checkWebviewController(): void { + if (!this.webViewController) { + const error: BusinessError = { + name: '', + message: 'Init error. The AtomicServiceWebController must be associated with a AtomicServiceWeb component.', + code: 17100001, + } + throw error as Error; + } + } + + getUserAgent(): string | undefined { + this.checkWebviewController(); + return this.webViewController?.getUserAgent(); + } + + getCustomUserAgent(): string | undefined { + this.checkWebviewController(); + return this.webViewController?.getCustomUserAgent(); + } + + setCustomUserAgent(userAgent: string): void { + this.checkWebviewController(); + this.webViewController?.setCustomUserAgent(userAgent); + } + + accessForward(): boolean | undefined { + this.checkWebviewController(); + return this.webViewController?.accessForward(); + } + + accessBackward(): boolean | undefined { + this.checkWebviewController(); + return this.webViewController?.accessBackward(); + } + + accessStep(step: number): boolean | undefined { + this.checkWebviewController(); + return this.webViewController?.accessStep(step); + } + + forward(): void { + this.checkWebviewController(); + this.webViewController?.forward(); + } + + backward(): void { + this.checkWebviewController(); + this.webViewController?.backward(); + } + + refresh(): void { + this.checkWebviewController(); + this.webViewController?.refresh(); + } + + loadUrl(url: string | Resource, headers?: Array): void { + this.checkWebviewController(); + if (headers) { + this.webViewController?.loadUrl(url, headers); + } else { + this.webViewController?.loadUrl(url); + } + } +} + +class AtomicServiceProxy { + private atomicService: AtomicService; + + constructor(atomicService: AtomicService) { + this.atomicService = atomicService; + } + + invokeJsApi(apiNameAlias: string, options: BaseOptions): void { + try { + options = options || {}; + if (!apiNameAlias || !ATOMIC_SERVICE_JS_API_MAP.has(apiNameAlias)) { + this.atomicService.errorWithCodeAndMsg(JS_API_INVALID_INVOKE_ERROR, options); + return; + } + let jsApiConfig: JsApiConfig | undefined = ATOMIC_SERVICE_JS_API_MAP.get(apiNameAlias); + if (!this.atomicService.checkRequiredFieldInOptions(jsApiConfig, options)) { + return; + } + let atomicService: object = this.atomicService; + atomicService[jsApiConfig?.apiName as string](options); + } catch (err) { + this.atomicService.error(err, options); + } + } +} + +class AtomicService { + protected context: common.UIAbilityContext; + protected navPathStack?: NavPathStack; + protected messageDataList: object[] = []; + protected onMessage: (event: OnMessageEvent) => void = () => { + }; + + constructor(context: common.UIAbilityContext, navPathStack?: NavPathStack, + onMessage?: (event: OnMessageEvent) => void) { + this.context = context; + this.navPathStack = navPathStack; + this.onMessage = onMessage ? onMessage : this.onMessage; + } + + success(res: T, options: BaseOptions): void { + try { + options?.callback && options?.callback(undefined, res); + } catch (err) { + this.consoleError(`callback error, code is ${err.code}, message is ${err.message}`); + } + } + + error(err: BusinessError, options: BaseOptions,): void { + try { + options?.callback && options?.callback(new AsError(err.code ? err.code : SYSTEM_INTERNAL_ERROR.code, + err.message ? err.message : SYSTEM_INTERNAL_ERROR.message)); + } catch (err) { + this.consoleError(`callback error, code is ${err.code}, message is ${err.message}`); + } + } + + errorWithCodeAndMsg(error: AsError, options: BaseOptions): void { + try { + options?.callback && options?.callback(error); + } catch (err) { + this.consoleError(`callback error, code is ${err.code}, message is ${err.message}`); + } + } + + consoleLog(msg: string): void { + if (LOG_ENABLE) { + console.log(`${LOG_PREFIX} ${msg}`); + } + } + + consoleError(msg: string): void { + if (LOG_ENABLE) { + console.error(`${LOG_PREFIX} ${msg}`); + } + } + + logOptions(name: string, options: BaseOptions): void { + this.consoleLog(`${name} options=${JSON.stringify(options)}`); + } + + checkParamRequired(paramKey: string, paramValue: V, options: BaseOptions): boolean { + if (paramValue === undefined || paramValue === null || paramValue === '') { + this.errorWithCodeAndMsg(new AsError(PARAM_REQUIRED_ERROR_CODE, `Param ${paramKey} is required.`), options); + return false; + } + return true; + } + + checkNumberParamPositive(paramKey: string, paramValue: number, options: BaseOptions): boolean { + if (paramValue <= 0) { + this.errorWithCodeAndMsg(new AsError(PARAM_NUMBER_POSITIVE_ERROR_CODE, + `Param ${paramKey} must be a positive number.`), options); + return false; + } + return true; + } + + checkRequiredFieldInOptions(jsApiConfig: JsApiConfig | undefined, options: BaseOptions): boolean { + if (!jsApiConfig) { + return false; + } + if (!jsApiConfig.requiredFieldNames) { + return true; + } + let obj: object = options; + for (let i = 0; i < jsApiConfig.requiredFieldNames.length; i++) { + let fieldName: string = jsApiConfig.requiredFieldNames[i]; + if (!this.checkParamRequired(fieldName, obj[fieldName], options)) { + return false; + } + } + return true; + } + + checkRouterMode(mode: string | undefined, options: BaseOptions): boolean { + if (!mode || mode === 'Single' || mode === 'Standard') { + return true; + } + this.errorWithCodeAndMsg(ROUTER_PARAM_MODE_INVALID_ERROR, options); + return false; + } + + parseRouterMode(routerMode?: string): router.RouterMode { + return routerMode === 'Single' ? router.RouterMode.Single : router.RouterMode.Standard; + } + + getRouterIndexByDelta(delta: number): number { + let length: number = Number.parseInt(router.getLength()); + for (let i = length; i > 0; i--) { + let state = router.getStateByIndex(i); + if (state?.name && delta-- == 0) { + return i; + } + } + return 1; + } + + checkBackUrlExists(url: string, options: BaseOptions): boolean { + let length: number = Number.parseInt(router.getLength()); + for (let i = length; i > 0; i--) { + let state = router.getStateByIndex(i); + if (state?.name) { + let stateUrl: string = state?.path + state?.name; + if (stateUrl === url) { + return true; + } + } + } + this.errorWithCodeAndMsg(BACK_URL_NOT_EXIST_OR_OPENED_ERROR, options); + return false; + } + + checkNavPathStack(apiName: string, options: BaseOptions): boolean { + if (!this.navPathStack) { + this.errorWithCodeAndMsg(new AsError(NAV_PATH_STACK_NOT_EXIST_ERROR_CODE, + `Current page is not NavDestination, not support ${apiName}().`), options); + return false; + } + return true; + } + + getNavPathIndexByDelta(delta: number): number { + let pathStack: string[] | undefined = this.navPathStack?.getAllPathName(); + if (!pathStack || pathStack.length == 0) { + return -1; + } + return pathStack.length > delta ? (pathStack.length - delta - 1) : -1; + } + + onPopHandler(popInfo: PopInfo, onPop?: (event: OnPopEvent) => void): void { + if (!popInfo?.info || !onPop) { + return; + } + onPop(new OnPopEvent(popInfo.info.name, popInfo.info.param as object, popInfo.result)); + } + + getCurrentNavPathInfo(): NavPathInfo { + let navPathStack: Array | undefined = this.navPathStack?.getAllPathName(); + let navPathInfo: NavPathInfo = (navPathStack && navPathStack.length > 0) ? + new NavPathInfo(navPathStack[navPathStack.length - 1], navPathStack.length - 1) : new NavPathInfo(undefined, -1); + if (navPathInfo.index >= 0) { + navPathInfo.param = this.navPathStack?.getParamByIndex(navPathInfo.index) as object; + } + return navPathInfo; + } + + notifyMessage(): void { + if (this.messageDataList.length <= 0) { + return; + } + try { + this.onMessage(new OnMessageEvent(this.messageDataList)); + } catch (err) { + this.consoleError(`onMessage failed, code is ${err.code}, message is ${err.message}`); + } + this.messageDataList = []; + } + + isJsApiEnable(jsApiConfig?: JsApiConfig): boolean { + if (!jsApiConfig) { + return false; + } + if (this.compareVersion(jsApiConfig.minVersion, ATOMIC_SERVICE_JS_SDK_CURRENT_VERSION) && + this.compareVersion(ATOMIC_SERVICE_JS_SDK_CURRENT_VERSION, jsApiConfig.maxVersion)) { + return true; + } + return false; + } + + compareVersion(lowVersion: string, highVersion: string): boolean { + if (!lowVersion || !highVersion) { + return false; + } + let v1 = lowVersion.split('.').map(m => Number.parseInt(m)); + let v2 = highVersion.split('.').map(m => Number.parseInt(m)); + const maxLength = Math.max(v1.length, v2.length); + for (let i = 0; i < maxLength; i++) { + if (v1[i] < v2[i]) { + return true; + } else if (v1[i] > v2[i]) { + return false; + } + } + if (v1.length < v2.length) { + return true; + } + if (v1.length > v2.length) { + return false; + } + return true; + } + + getUri(uriOrFilePath: string): string { + if (!uriOrFilePath || uriOrFilePath.startsWith('file://')) { + return uriOrFilePath; + } + return fileUri.getUriFromPath(uriOrFilePath); + } + + async checkUploadFile(options: UploadFileOptions): Promise { + if (!options.files || options.files.length <= 0) { + this.errorWithCodeAndMsg(UPLOAD_IMAGE_FILES_REQUIRED_ERROR, options); + return new CheckUploadFileResult(false); + } + let uriMap: Map = new Map(); + for (let i = 0; i < options.files?.length; i++) { + let file: UploadFile = options.files[i]; + if (!file.uri) { + this.errorWithCodeAndMsg(UPLOAD_IMAGE_FILES_URI_REQUIRED_ERROR, options); + return new CheckUploadFileResult(false); + } + if (!file.uri.startsWith('file://') && !fs.accessSync(file.uri, fs.AccessModeType.EXIST)) { + this.errorWithCodeAndMsg(new AsError(UPLOAD_IMAGE_FILE_NOT_EXIST_ERROR_CODE, + `File uri ${file.uri} is not exist.`), options); + return new CheckUploadFileResult(false); + } + let originUri: string = file.uri; + let uploadUri: string = file.uri; + if (uploadUri.indexOf(UPLOAD_IMAGE_CACHE_DIR) < 0) { + let srcUri: string = uploadUri.startsWith('file://') ? uploadUri : fileUri.getUriFromPath(file.uri); + uploadUri = this.context.cacheDir + '/' + uploadUri.substring(uploadUri.lastIndexOf('/') + 1); + try { + await fs.copy(srcUri, fileUri.getUriFromPath(uploadUri)) + } catch (err) { + this.errorWithCodeAndMsg(UPLOAD_FILE_ERROR, options); + return new CheckUploadFileResult(false); + } + } + file.uri = 'internal://' + uploadUri.substring(uploadUri.indexOf(UPLOAD_IMAGE_CACHE_DIR) + 1); + uriMap.set(uploadUri, originUri); + } + return new CheckUploadFileResult(true, uriMap); + } + + convertToRequestData(data?: UploadRequestData[]): request.RequestData[] { + let requestData: request.RequestData[] = []; + if (data) { + data.forEach(item => { + if (!item.name || !item.value) { + return; + } + requestData.push({ name: item.name, value: item.value }); + }); + } + return requestData; + } + + convertToFile(files?: UploadFile[]): request.File[] { + let requestFiles: request.File[] = []; + if (files) { + files.forEach(item => { + requestFiles.push({ + filename: item.filename, + name: item.name, + uri: item.uri, + type: item.type + }); + }); + } + return requestFiles; + } + + handleUploadFileResult(taskStateArray: Array, uriMap: Map, + options: UploadFileOptions): void { + let taskStates: UploadFileTaskState[] = []; + if (taskStateArray) { + taskStateArray.forEach(taskState => { + let path: (string | undefined) = taskState.path ? uriMap.get(taskState.path) : taskState.path; + taskStates.push(new UploadFileTaskState(path ? path : taskState.path, taskState.responseCode, + taskState.message)); + }); + } + this.success(new UploadFileResult(taskStates), options); + } + + parseFileNameFromUrl(url?: string): string { + if (!url) { + return ''; + } + let http: string = url.split('?')[0]; + if (http.indexOf('/') < 0) { + return ''; + } + let index: number = http.lastIndexOf('/'); + if (index == (http.length - 1)) { + return ''; + } + return http.substring(index + 1); + } + + checkAccessToken(permissionName: Permissions): Promise { + let bundleInfo: bundleManager.BundleInfo = bundleManager.getBundleInfoForSelfSync( + bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION); + let tokenId: number = bundleInfo.appInfo.accessTokenId; + let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); + return atManager.checkAccessToken(tokenId, permissionName); + } + + checkPermissions(permissionName: Permissions, grantCallback: (err?: BusinessError) => void): void { + this.checkAccessToken(permissionName).then(grantStatus => { + if (grantStatus == abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) { + grantCallback(undefined); + } else { + let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); + atManager.requestPermissionsFromUser(this.context, [permissionName]).then(permissionRequestResult => { + for (let i = 0; i < permissionRequestResult.authResults.length; i++) { + if (permissionRequestResult.authResults[i] != 0) { + const error: BusinessError = { + name: '', + message: `RequestPermissionsFromUser error. authResult: ${permissionRequestResult.authResults[i]}.`, + code: PERMISSION_LOCATION_USER_REFUSED_ERROR + }; + grantCallback(error); + return; + } + } + grantCallback(undefined); + }).catch((err: BusinessError) => { + grantCallback(err); + }); + } + }).catch((err: BusinessError) => { + grantCallback(err); + }); + } +} + +class AtomicServiceApi extends AtomicService { + constructor(context: common.UIAbilityContext, navPathStack?: NavPathStack, + onMessage?: (event: OnMessageEvent) => void) { + super(context, navPathStack, onMessage); + } + + pushUrl(options: PushUrlOptions): void { + if (!this.checkRouterMode(options.mode, options)) { + return; + } + router.pushUrl({ url: options.url, params: options.params }, this.parseRouterMode(options.mode)).then(() => { + this.success(new PushUrlResult(), options); + }).catch((err: BusinessError) => { + this.error(err, options); + }); + } + + replaceUrl(options: ReplaceUrlOptions): void { + if (!this.checkRouterMode(options.mode, options)) { + return; + } + router.replaceUrl({ url: options.url, params: options.params }, this.parseRouterMode(options.mode)).then(() => { + this.success(new ReplaceUrlResult(), options); + }).catch((err: BusinessError) => { + this.error(err, options); + }); + } + + backUrl(options: BackUrlOptions): void { + if (options.url) { + if (!this.checkBackUrlExists(options.url, options)) { + return; + } + router.back({ url: options.url, params: options.params }); + this.success(new BackUrlResult(), options); + } else if (options.index || options.index === 0) { + if (!this.checkNumberParamPositive('index', options.index, options)) { + return; + } + router.back(options.index, options.params); + this.success(new BackUrlResult(), options); + } else if (options.delta || options.delta === 0) { + if (!this.checkNumberParamPositive('delta', options.delta, options)) { + return; + } + router.back(this.getRouterIndexByDelta(options.delta), options.params); + this.success(new BackUrlResult(), options); + } else { + router.back(); + this.success(new BackUrlResult(), options); + } + } + + clearUrl(options: ClearUrlOptions): void { + router.clear(); + this.success(new ClearUrlResult(), options); + } + + pushPath(options: PushPathOptions): void { + if (!this.checkNavPathStack('navPathStack.pushPath', options)) { + return; + } + this.navPathStack?.pushPath({ + name: options.name, + param: options.param, + onPop: popInfo => this.onPopHandler(popInfo, options.onPop) + }, options.animated); + this.success(new PushPathResult(), options); + } + + replacePath(options: ReplacePathOptions): void { + if (!this.checkNavPathStack('navPathStack.replacePath', options)) { + return; + } + this.navPathStack?.replacePath({ + name: options.name, + param: options.param, + onPop: popInfo => this.onPopHandler(popInfo, options.onPop) + }, options.animated); + this.success(new ReplacePathResult(), options); + } + + popPath(options: PopPathOptions): void { + if (!this.checkNavPathStack('navPathStack.pop', options)) { + return; + } + if (options.name) { + let index: number | undefined = this.navPathStack?.popToName(options.name, options.result, options.animated); + if (index === undefined || index === -1) { + this.errorWithCodeAndMsg(POP_PATH_NAME_NOT_EXIST_ERROR, options); + return; + } + } else if (options.index || options.index === 0) { + if (options.index < -1) { + this.errorWithCodeAndMsg(POP_PATH_PARAM_INDEX_INVALID_ERROR, options); + return; + } + if (options.index > this.getCurrentNavPathInfo().index) { + this.errorWithCodeAndMsg(POP_PATH_INDEX_OUT_OF_RANGE_ERROR, options); + return; + } + this.navPathStack?.popToIndex(options.index, options.result, options.animated); + } else if (options.delta || options.delta === 0) { + if (!this.checkNumberParamPositive('delta', options.delta, options)) { + return; + } + this.navPathStack?.popToIndex(this.getNavPathIndexByDelta(options.delta), options.result, options.animated); + } else { + this.navPathStack?.pop(options.result, options.animated); + } + let navPathInfo: NavPathInfo = this.getCurrentNavPathInfo(); + this.success(new PopPathResult(navPathInfo.name, navPathInfo.index, navPathInfo.param), options); + } + + clearPath(options: ClearPathOptions): void { + if (!this.checkNavPathStack('navPathStack.clear', options)) { + return; + } + this.navPathStack?.clear(options.animated); + this.success(new ClearPathResult(), options); + } + + postMessage(options: PostMessageOptions): void { + options.data && this.messageDataList.push(options.data); + this.success(new PostMessageResult(), options); + } + + getEnv(options: GetEnvOptions): void { + let res: GetEnvResult = new GetEnvResult(); + res.deviceType = deviceInfo.deviceType; + res.brand = deviceInfo.brand; + res.productModel = deviceInfo.productModel; + res.osFullName = deviceInfo.osFullName; + this.success(res, options); + } + + checkJsApi(options: CheckJsApiOptions): void { + let res: Map = new Map(); + options.jsApiList?.forEach(jsApi => { + res[jsApi] = this.isJsApiEnable(ATOMIC_SERVICE_JS_API_MAP.get(jsApi)); + }); + this.success(new CheckJsApiResult(res), options); + } + + pickCamera(options: PickCameraOptions): void { + picker.pick(this.context, options.mediaTypes as Array, { + cameraPosition: options.cameraPosition, + saveUri: options.saveUri, + videoDuration: options.videoDuration + }).then((pickerResult: picker.PickerResult) => { + this.success(new PickCameraResult(pickerResult.resultCode, pickerResult.resultUri, pickerResult.mediaType), + options); + }).catch((err: BusinessError) => { + this.error(err, options); + }); + } + + selectPhoto(options: SelectPhotoOptions): void { + let photoViewPicker = new photoAccessHelper.PhotoViewPicker(); + photoViewPicker.select({ + MIMEType: options.mimeType as photoAccessHelper.PhotoViewMIMETypes, + maxSelectNumber: options.maxSelectNumber, + isPhotoTakingSupported: options.isPhotoTakingSupported, + isEditSupported: options.isEditSupported, + isSearchSupported: options.isSearchSupported, + recommendationOptions: { + recommendationType: options.recommendationType + }, + preselectedUris: options.preselectedUris + }).then((selectResult: photoAccessHelper.PhotoSelectResult) => { + this.success(new SelectPhotoResult(selectResult.photoUris, selectResult.isOriginalPhoto), options); + }).catch((err: BusinessError) => { + this.error(err, options); + }); + } + + openPreview(options: OpenPreviewOptions): void { + let uri: string = this.getUri(options.uri as string); + filePreview.openPreview(this.context, { + uri: uri, + mimeType: options.mimeType as string, + title: options.title + }).then(() => { + this.success(new OpenPreviewResult(), options); + }).catch((err: BusinessError) => { + this.error(err, options); + }); + } + + uploadFile(options: UploadFileOptions): void { + this.checkUploadFile(options).then(res => { + if (!res.checkResult) { + return; + } + let uploadConfig: request.UploadConfig = { + url: options.url as string, + header: options.header as object, + method: options.method as string, + files: this.convertToFile(options.files), + data: this.convertToRequestData(options.data) + }; + request.uploadFile(this.context, uploadConfig).then((uploadTask: request.UploadTask) => { + uploadTask.on('complete', (taskStateArray: Array) => { + this.handleUploadFileResult(taskStateArray, res.uriMap as Map, options); + }); + uploadTask.on('fail', (taskStateArray: Array) => { + this.handleUploadFileResult(taskStateArray, res.uriMap as Map, options); + }); + }).catch((err: BusinessError) => { + this.error(err, options); + }); + }).catch((err: BusinessError) => { + this.error(err, options); + }); + } + + downloadFile(options: DownloadFileOptions): void { + let cacheFileName: string = `${util.generateRandomUUID().replaceAll('-', '')}`; + let filePath: string = `${this.context.cacheDir}/${cacheFileName}`; + request.downloadFile(this.context, { + url: options.url, + header: options.header ? options.header : new Object(), + filePath: filePath, + enableMetered: options.enableMetered, + enableRoaming: options.enableRoaming, + networkType: options.networkType, + background: false + }).then((downloadTask: request.DownloadTask) => { + downloadTask.on('complete', () => { + this.success(new DownloadFileResult(filePath), options); + }); + downloadTask.on('fail', errCode => { + this.errorWithCodeAndMsg(new AsError(errCode, 'File download fail.'), options); + }); + }).catch((err: BusinessError) => { + this.error(err, options); + }); + } + + getNetworkType(options: GetNetworkTypeOptions): void { + connection.getDefaultNet().then(netHandle => { + if (!netHandle || netHandle.netId === 0) { + this.errorWithCodeAndMsg(NETWORK_NO_ACTIVE_ERROR, options); + return; + } + connection.getNetCapabilities(netHandle).then(netCapabilities => { + let res: GetNetworkTypeResult = new GetNetworkTypeResult(netCapabilities.bearerTypes, + netCapabilities.networkCap, netCapabilities.linkUpBandwidthKbps, netCapabilities.linkDownBandwidthKbps); + this.success(res, options); + }).catch((err: BusinessError) => { + this.error(err, options); + }); + }).catch((err: BusinessError) => { + this.error(err, options); + }); + } + + getLocation(options: GetLocationOptions): void { + this.checkPermissions(PERMISSION_APPROXIMATELY_LOCATION, err => { + if (err) { + this.error(err, options); + return; + } + geoLocationManager.getCurrentLocation({ + priority: options.priority, + scenario: options.scenario, + maxAccuracy: options.maxAccuracy, + timeoutMs: options.timeoutMs + }).then(location => { + let res: GetLocationResult = new GetLocationResult(location.latitude, location.longitude, location.altitude, + location.accuracy, location.speed, location.timeStamp, location.direction, location.timeSinceBoot, + location.additions, location.additionSize); + this.success(res, options); + }).catch((err: BusinessError) => { + this.error(err, options); + }); + }); + } +} + +class NavPathInfo { + public name: string | undefined; + public index: number; + public param?: object; + + constructor(name: string | undefined, index: number) { + this.name = name; + this.index = index; + } +} + +class CheckUploadFileResult { + public checkResult: boolean; + public uriMap?: Map; + + constructor(checkResult: boolean, uriMap?: Map) { + this.checkResult = checkResult; + this.uriMap = uriMap; + } +} + +class BaseOptions { + public callback?: (err: AsError | undefined, res?: T) => void; +} + +class PushUrlOptions extends BaseOptions { + public url?: string; + public params?: object; + public mode?: string; +} + +class PushUrlResult { +} + +class ReplaceUrlOptions extends BaseOptions { + public url?: string; + public params?: object; + public mode?: string; +} + +class ReplaceUrlResult { +} + +class BackUrlOptions extends BaseOptions { + public url?: string; + public index?: number; + public delta?: number; + public params?: object; +} + +class BackUrlResult { +} + +class ClearUrlOptions extends BaseOptions { +} + +class ClearUrlResult { +} + +class OnPopEvent { + public name?: string; + public param?: object; + public result?: object; + + constructor(name?: string, param?: object, result?: object) { + this.name = name; + this.param = param; + this.result = result; + } +} + +class PushPathOptions extends BaseOptions { + public name?: string; + public param?: object; + public animated?: boolean; + public onPop?: (event: OnPopEvent) => void; +} + +class PushPathResult { +} + +class ReplacePathOptions extends BaseOptions { + public name?: string; + public param?: object; + public animated?: boolean; + public onPop?: (event: OnPopEvent) => void; +} + +class ReplacePathResult { +} + +class PopPathOptions extends BaseOptions { + public name?: string; + public index?: number; + public delta?: number; + public result?: object; + public animated?: boolean; +} + +class PopPathResult { + public name: string | undefined; + public index: number; + public param?: object; + + constructor(name: string | undefined, index: number, param?: object) { + this.name = name; + this.index = index; + this.param = param; + } +} + +class ClearPathOptions extends BaseOptions { + public animated?: boolean; +} + +class ClearPathResult { +} + +class PostMessageOptions extends BaseOptions { + public data?: object; +} + +class PostMessageResult { +} + +export class OnMessageEvent { + public data: object[]; + + constructor(data: object[]) { + this.data = data; + } +} + +export class OnErrorReceiveEvent { + public request: WebResourceRequest; + public error: WebResourceError; + + constructor(request: WebResourceRequest, error: WebResourceError) { + this.request = request; + this.error = error; + } +} + +export class OnHttpErrorReceiveEvent { + public request: WebResourceRequest; + public response: WebResourceResponse; + + constructor(request: WebResourceRequest, response: WebResourceResponse) { + this.request = request; + this.response = response; + } +} + +export class OnPageBeginEvent { + public url: string; + + constructor(url: string) { + this.url = url; + } +} + +export class OnPageEndEvent { + public url: string; + + constructor(url: string) { + this.url = url; + } +} + +export class WebHeader { + public headerKey: string; + public headerValue: string; + + constructor(headerKey: string, headerValue: string) { + this.headerKey = headerKey; + this.headerValue = headerValue; + } +} + +class GetEnvOptions extends BaseOptions { +} + +class GetEnvResult { + public deviceType?: string; + public brand?: string; + public productModel?: string; + public osFullName?: string; +} + +class CheckJsApiOptions extends BaseOptions { + public jsApiList?: string[]; +} + +class CheckJsApiResult { + public checkResult?: Map; + + constructor(checkResult?: Map) { + this.checkResult = checkResult; + } +} + +class PickCameraOptions extends BaseOptions { + public mediaTypes?: string[]; + public cameraPosition?: number; + public saveUri?: string; + public videoDuration?: number; +} + +class PickCameraResult { + public resultCode?: number; + public resultUri?: string; + public mediaType?: string; + + constructor(resultCode?: number, resultUri?: string, mediaType?: string) { + this.resultCode = resultCode; + this.resultUri = resultUri; + this.mediaType = mediaType; + } +} + +class SelectPhotoOptions extends BaseOptions { + public mimeType?: string; + public maxSelectNumber?: number; + public isPhotoTakingSupported?: boolean; + public isEditSupported?: boolean; + public isSearchSupported?: boolean; + public recommendationType?: number; + public preselectedUris?: string[]; +} + +class SelectPhotoResult { + public photoUris?: string[]; + public isOriginalPhoto?: boolean; + + constructor(photoUris?: string[], isOriginalPhoto?: boolean) { + this.photoUris = photoUris; + this.isOriginalPhoto = isOriginalPhoto; + } +} + +class OpenPreviewOptions extends BaseOptions { + public title?: string; + public uri?: string; + public mimeType?: string; +} + +class OpenPreviewResult { +} + +class UploadFileOptions extends BaseOptions { + public url?: string; + public header?: object; + public method?: string; + public files?: UploadFile[]; + public data?: UploadRequestData[]; +} + +class UploadFile { + public filename: string; + public name: string; + public uri: string; + public type: string; + + constructor(filename: string, name: string, uri: string, type: string) { + this.filename = filename; + this.name = name; + this.uri = uri; + this.type = type; + } +} + +class UploadRequestData { + public name?: string; + public value?: string; +} + +class UploadFileResult { + public taskStates?: UploadFileTaskState[]; + + constructor(taskStates?: UploadFileTaskState[]) { + this.taskStates = taskStates; + } +} + +class UploadFileTaskState { + public path?: string; + public responseCode?: number; + public message?: string; + + constructor(path?: string, responseCode?: number, message?: string) { + this.path = path; + this.responseCode = responseCode; + this.message = message; + } +} + +class DownloadFileOptions extends BaseOptions { + public url?: string; + public header?: object; + public fileName?: string; + public enableMetered?: boolean; + public enableRoaming?: boolean; + public networkType?: number; +} + +class DownloadFileResult { + public uri?: string; + + constructor(uri?: string) { + this.uri = uri; + } +} + +class GetNetworkTypeOptions extends BaseOptions { +} + +class GetNetworkTypeResult { + public bearerTypes: number[]; + public networkCap?: number[]; + public linkUpBandwidthKbps?: number; + public linkDownBandwidthKbps?: number; + + constructor(bearerTypes: number[], networkCap?: number[], linkUpBandwidthKbps?: number, + linkDownBandwidthKbps?: number) { + this.bearerTypes = bearerTypes; + this.networkCap = networkCap; + this.linkUpBandwidthKbps = linkUpBandwidthKbps; + this.linkDownBandwidthKbps = linkDownBandwidthKbps; + } +} + +class GetLocationOptions extends BaseOptions { + public priority?: number; + public scenario?: number; + public maxAccuracy?: number; + public timeoutMs?: number; +} + +class GetLocationResult { + public latitude: number; + public longitude: number; + public altitude: number; + public accuracy: number; + public speed: number; + public timeStamp: number; + public direction: number; + public timeSinceBoot: number; + public additions?: string[] | undefined; + public additionSize?: number; + + constructor(latitude: number, longitude: number, altitude: number, accuracy: number, speed: number, + timeStamp: number, direction: number, timeSinceBoot: number, additions?: string[], additionSize?: number) { + this.latitude = latitude; + this.longitude = longitude; + this.altitude = altitude; + this.accuracy = accuracy; + this.speed = speed; + this.timeStamp = timeStamp; + this.direction = direction; + this.timeSinceBoot = timeSinceBoot; + this.additions = additions; + this.additionSize = additionSize; + } +} diff --git a/bundle.json b/bundle.json index c1bf0a65183f23b6581726766a2580a34336cf0e..ca80fc0637ffa0f48a4c7f0c945dba0714254b9a 100644 --- a/bundle.json +++ b/bundle.json @@ -25,19 +25,11 @@ }, "build": { "sub_component": [ - "//foundation/arkui/advanced_ui_component/interface/filter:filter", - "//foundation/arkui/advanced_ui_component/interface/composetitlebar:composetitlebar", - "//foundation/arkui/advanced_ui_component/interface/editabletitlebar:editabletitlebar", - "//foundation/arkui/advanced_ui_component/interface/selecttitlebar:selecttitlebar", - "//foundation/arkui/advanced_ui_component/interface/tabtitlebar:tabtitlebar", - "//foundation/arkui/advanced_ui_component/interface/splitlayout:splitlayout", - "//foundation/arkui/advanced_ui_component/interface/subheader:subheader", - "//foundation/arkui/advanced_ui_component/interface/treeview:treeview", - "//foundation/arkui/advanced_ui_component/interface/composelistitem:composelistitem", - "//foundation/arkui/advanced_ui_component/interface/swiperefresher:swiperefresher", - "//foundation/arkui/advanced_ui_component/interface/arkdialog:arkdialog", - "//foundation/arkui/advanced_ui_component/interface/toolbar:toolbar", - "//foundation/arkui/advanced_ui_component/interface/progressbutton:progressbutton" + "//foundation/arkui/advanced_ui_component/atomicservicenavigation/interfaces:atomicservicenavigation", + "//foundation/arkui/advanced_ui_component/atomicservicetabs/interfaces:atomicservicetabs", + "//foundation/arkui/advanced_ui_component/atomicserviceweb/interfaces:atomicserviceweb", + "//foundation/arkui/advanced_ui_component/innerfullscreenlaunchcomponent/interfaces:innerfullscreenlaunchcomponent", + "//foundation/arkui/advanced_ui_component/interstitialdialogaction/interfaces:interstitialdialogaction" ], "inner_kits": [], "test": [] diff --git a/doc/Readme-CN.md b/doc/Readme-CN.md deleted file mode 100644 index 0728c2b58e848ff16f1686d95e155be7c1589978..0000000000000000000000000000000000000000 --- a/doc/Readme-CN.md +++ /dev/null @@ -1,15 +0,0 @@ -# 组件目录 - -- [Dialog](ts-composite-components-arkdialog.md) -- [SplitLayout](ts-composite-components-splitlayout.md) -- [ToolBar](ts-composite-components-toolbar.md) -- [ProgressButton](ts-composite-components-progressbutton.md) -- [SubHeader](ts-composite-components-subheader.md) -- [Filter](ts-composite-components-filter.md) -- [TreeView](ts-composite-components-treeview.md) -- [ComposeListItem](ts-composite-components-composelistitem.md) -- [EditableTitleBar](ts-composite-components-editabletitlebar.md) -- [ComposeTitleBar](ts-composite-components-composetitlebar.md) -- [SelectTitleBar](ts-composite-components-selecttitlebar.md) -- [TabTitleBar](ts-composite-components-tabtitlebar.md) -- [SwipeRefresher](ts-composite-components-swiperefresher.md) diff --git a/doc/figures/20230728-101201.png b/doc/figures/20230728-101201.png deleted file mode 100644 index 614c1695ed63cc22075243b2ab5ba876323e598c..0000000000000000000000000000000000000000 Binary files a/doc/figures/20230728-101201.png and /dev/null differ diff --git a/doc/figures/20230728-101236.png b/doc/figures/20230728-101236.png deleted file mode 100644 index e57a28b2105e0d5bbf81e258b98d02ded2ab4231..0000000000000000000000000000000000000000 Binary files a/doc/figures/20230728-101236.png and /dev/null differ diff --git a/doc/figures/20230728-101306.png b/doc/figures/20230728-101306.png deleted file mode 100644 index 0070b5776bac9214fa050fc03e31731dbadfc475..0000000000000000000000000000000000000000 Binary files a/doc/figures/20230728-101306.png and /dev/null differ diff --git a/doc/figures/20230728-101355.png b/doc/figures/20230728-101355.png deleted file mode 100644 index 8d840d101314b8f7f3b832958f6db519a18dc16e..0000000000000000000000000000000000000000 Binary files a/doc/figures/20230728-101355.png and /dev/null differ diff --git a/doc/figures/20230728-111325.png b/doc/figures/20230728-111325.png deleted file mode 100644 index 53aefe6ed573aeaaad2c8940a63dbdaa02c66550..0000000000000000000000000000000000000000 Binary files a/doc/figures/20230728-111325.png and /dev/null differ diff --git a/doc/figures/Snipaste_2023-07-24_11-35-40.png b/doc/figures/Snipaste_2023-07-24_11-35-40.png deleted file mode 100644 index 742fccf1fdd00a1ab5677089e0ddf2aec95aae6b..0000000000000000000000000000000000000000 Binary files a/doc/figures/Snipaste_2023-07-24_11-35-40.png and /dev/null differ diff --git a/doc/figures/zh-cn_image_0000001616913438.png b/doc/figures/zh-cn_image_0000001616913438.png deleted file mode 100644 index f36a02570f611f1cabb87d2e0d6d0550ea3fe13f..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_0000001616913438.png and /dev/null differ diff --git a/doc/figures/zh-cn_image_0000001616916278.png b/doc/figures/zh-cn_image_0000001616916278.png deleted file mode 100644 index c4b0a4336e59dfc6b445bde282f6aec7582fe066..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_0000001616916278.png and /dev/null differ diff --git a/doc/figures/zh-cn_image_0000001616957408.png b/doc/figures/zh-cn_image_0000001616957408.png deleted file mode 100644 index 2a0835b3c57e24de75bc5e73209a1787d5768307..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_0000001616957408.png and /dev/null differ diff --git a/doc/figures/zh-cn_image_0000001616959836.png b/doc/figures/zh-cn_image_0000001616959836.png deleted file mode 100644 index 8bf1753dbcc2bbe6118ce494c8657797d04e551c..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_0000001616959836.png and /dev/null differ diff --git a/doc/figures/zh-cn_image_0000001617073302.png b/doc/figures/zh-cn_image_0000001617073302.png deleted file mode 100644 index 5aa7060cdce371038d088f923f94b726d5b45f95..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_0000001617073302.png and /dev/null differ diff --git a/doc/figures/zh-cn_image_0000001617116972.png b/doc/figures/zh-cn_image_0000001617116972.png deleted file mode 100644 index 1b0d3aa9f0b5147f63eb932bed2a334ccaef4d8d..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_0000001617116972.png and /dev/null differ diff --git a/doc/figures/zh-cn_image_0000001617233250.png b/doc/figures/zh-cn_image_0000001617233250.png deleted file mode 100644 index b4ea8f87bf29aecca9cdb2ff3d01a56a5cef4fbd..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_0000001617233250.png and /dev/null differ diff --git a/doc/figures/zh-cn_image_0000001617393174.png b/doc/figures/zh-cn_image_0000001617393174.png deleted file mode 100644 index 739a1cb4ff6ecdb4d2a4e67c77871dd25daadfc6..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_0000001617393174.png and /dev/null differ diff --git a/doc/figures/zh-cn_image_0000001617439304.png b/doc/figures/zh-cn_image_0000001617439304.png deleted file mode 100644 index 59694cec007ed68fac17b2dba24abb9e85eefb7b..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_0000001617439304.png and /dev/null differ diff --git a/doc/figures/zh-cn_image_0000001658655445.png b/doc/figures/zh-cn_image_0000001658655445.png deleted file mode 100644 index 4c01b6d9ec9f718768815ef282dfe995509bd351..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_0000001658655445.png and /dev/null differ diff --git a/doc/figures/zh-cn_image_0000001664546481.png b/doc/figures/zh-cn_image_0000001664546481.png deleted file mode 100644 index 6e383ed2c18d97d420bd8a057910e9a747db5d85..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_0000001664546481.png and /dev/null differ diff --git a/doc/figures/zh-cn_image_0000001664713029.png b/doc/figures/zh-cn_image_0000001664713029.png deleted file mode 100644 index 99ff75f82273c9fef99f3c7c3d3b639c911f990b..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_0000001664713029.png and /dev/null differ diff --git a/doc/figures/zh-cn_image_0000001664822257.png b/doc/figures/zh-cn_image_0000001664822257.png deleted file mode 100644 index 6d4a01abf90a068b00a088e29d9ad9861022b627..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_0000001664822257.png and /dev/null differ diff --git a/doc/figures/zh-cn_image_0000001665393297.png b/doc/figures/zh-cn_image_0000001665393297.png deleted file mode 100644 index fe44722c34b468d217b0b38e034c2f05f51679d1..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_0000001665393297.png and /dev/null differ diff --git a/doc/figures/zh-cn_image_0000001665513149.png b/doc/figures/zh-cn_image_0000001665513149.png deleted file mode 100644 index 00230be6617822ae5fa1bf3218be7f4f4888c3cf..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_0000001665513149.png and /dev/null differ diff --git a/doc/figures/zh-cn_image_0000001665553957.png b/doc/figures/zh-cn_image_0000001665553957.png deleted file mode 100644 index 23685e015de39f78aff0ff747ec4908a75f21e35..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_0000001665553957.png and /dev/null differ diff --git a/doc/figures/zh-cn_image_0000001665793709.png b/doc/figures/zh-cn_image_0000001665793709.png deleted file mode 100644 index 6511f95354d114df16f4c4871ff78e508adbb203..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_0000001665793709.png and /dev/null differ diff --git a/doc/figures/zh-cn_image_0000001665809293.png b/doc/figures/zh-cn_image_0000001665809293.png deleted file mode 100644 index a5a22f5c7fc5d7876afe038e70dd45e8f05fa48a..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_0000001665809293.png and /dev/null differ diff --git a/doc/figures/zh-cn_image_2023072902.png b/doc/figures/zh-cn_image_2023072902.png deleted file mode 100644 index 2ddd83b5d3f695c7db10f4ff8503af570f19b12c..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_2023072902.png and /dev/null differ diff --git a/doc/figures/zh-cn_image_2023072903.PNG b/doc/figures/zh-cn_image_2023072903.PNG deleted file mode 100644 index 6e64323ff465d6207f278ec39e89cbd7c55ad51e..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_2023072903.PNG and /dev/null differ diff --git a/doc/figures/zh-cn_image_2023072904.PNG b/doc/figures/zh-cn_image_2023072904.PNG deleted file mode 100644 index 49d6c2a5ca2f802f942589677d47e76493509932..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_2023072904.PNG and /dev/null differ diff --git a/doc/figures/zh-cn_image_2023072905.PNG b/doc/figures/zh-cn_image_2023072905.PNG deleted file mode 100644 index 31ea0da1431401157e90e18cd2419bc7524e84ab..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_2023072905.PNG and /dev/null differ diff --git a/doc/figures/zh-cn_image_2023072906.PNG b/doc/figures/zh-cn_image_2023072906.PNG deleted file mode 100644 index 1c937421c10ebcc6c58f5769b9cda94e9789f8a1..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_2023072906.PNG and /dev/null differ diff --git a/doc/figures/zh-cn_image_202307291.png b/doc/figures/zh-cn_image_202307291.png deleted file mode 100644 index 9b1e6b767f37c3f3c816dbe4a8aeca1468b065e2..0000000000000000000000000000000000000000 Binary files a/doc/figures/zh-cn_image_202307291.png and /dev/null differ diff --git a/doc/public_sys-resources/icon-caution.gif b/doc/public_sys-resources/icon-caution.gif deleted file mode 100644 index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000 Binary files a/doc/public_sys-resources/icon-caution.gif and /dev/null differ diff --git a/doc/public_sys-resources/icon-danger.gif b/doc/public_sys-resources/icon-danger.gif deleted file mode 100644 index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000 Binary files a/doc/public_sys-resources/icon-danger.gif and /dev/null differ diff --git a/doc/public_sys-resources/icon-note.gif b/doc/public_sys-resources/icon-note.gif deleted file mode 100644 index 6314297e45c1de184204098efd4814d6dc8b1cda..0000000000000000000000000000000000000000 Binary files a/doc/public_sys-resources/icon-note.gif and /dev/null differ diff --git a/doc/public_sys-resources/icon-notice.gif b/doc/public_sys-resources/icon-notice.gif deleted file mode 100644 index 86024f61b691400bea99e5b1f506d9d9aef36e27..0000000000000000000000000000000000000000 Binary files a/doc/public_sys-resources/icon-notice.gif and /dev/null differ diff --git a/doc/public_sys-resources/icon-tip.gif b/doc/public_sys-resources/icon-tip.gif deleted file mode 100644 index 93aa72053b510e456b149f36a0972703ea9999b7..0000000000000000000000000000000000000000 Binary files a/doc/public_sys-resources/icon-tip.gif and /dev/null differ diff --git a/doc/public_sys-resources/icon-warning.gif b/doc/public_sys-resources/icon-warning.gif deleted file mode 100644 index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000 Binary files a/doc/public_sys-resources/icon-warning.gif and /dev/null differ diff --git a/doc/ts-composite-components-arkdialog.md b/doc/ts-composite-components-arkdialog.md deleted file mode 100644 index 791271f25ca7ab1c19864ac2c68998ffa5d76670..0000000000000000000000000000000000000000 --- a/doc/ts-composite-components-arkdialog.md +++ /dev/null @@ -1,414 +0,0 @@ -# Dialog - - -弹出框是一种模态窗口,通常用于在保持当前的上下文环境时,临时展示用户需关注的信息或待处理的操作,用户在模态弹出框内完成上述交互任务。模态弹出框需要用户进行交互才能够退出模态模式。 - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 该组件从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 导入模块 - -``` -import { TipsDialog, SelectDialog, ConfirmDialog, AlertDialog, LoadingDialog } from '@ohos.arkui.advanced.Dialog' -``` - - -## 子组件 - -无 - - -## TipsDialog - - -TipsDialog({controller: CustomDialogController, imageRes: Resource, imageSize: SizeOptions, title: ResourceStr, content?: ResourceStr, checkTips?: ResourceStr, ischecked?: boolean, primaryButton?: ButtonOptions, secondaryButton?: ButtonOptions}) - - -提示弹出框,即为带图形确认框,必要时可通过图形化方式展现确认框。 - - -**装饰器类型:**\@CustomDialog - - -**系统能力:** SystemCapability.ArkUI.ArkUI.Full - - -**参数:** - - -| 参数名 | 参数类型 | 必填 | 装饰器类型 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| controller | [CustomDialogController](https://docs.openharmony.cn/pages/v3.2/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md/) | 是 | - | 提示弹出框控制器。 | -| imageRes | [Resource](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resource) | 是 | - | 展示的图片。 | -| imageSize | [SizeOptions](https://docs.openharmony.cn/pages/v4.0/en/application-dev/reference/arkui-ts/ts-types.md/#sizeoptions) | 是 | - | 自定义图片尺寸。 | -| title | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 是 | - | 提示弹出框标题。 | -| content | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 否 | - | 提示弹出框内容。 | -| checkTips | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 否 | - | checkbox的提示内容。 | -| isChecked | boolean | 否 | \@Prop | value为true时,表示checkbox已选中,value为false时,表示未选中。
默认值:false。 | -| primaryButton | [ButtonOptions](#buttonoptions) | 否 | - | 提示框左侧按钮。 | -| secondaryButton | [ButtonOptions](#buttonoptions) | 否 | - | 提示框右侧按钮。 | - - -## SelectDialog - -SelectDialog({controller: CustomDialogController, title: ResourceStr, content?: ResourceStr, selectedIndex?: number, confirm?: ButtonOptions, radioContent?: Array<SheetInfo>}) - -选择类弹出框,弹框中以列表或网格的形式提供可选的的内容。 - -**装饰器类型:**\@CustomDialog - -**系统能力:** SystemCapability.ArkUI.ArkUI.Full - -**参数:** - -| 参数名 | 参数类型 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -| controller | CustomDialogController | 是 | 选择弹出框控制器。 | -| title | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 是 | 选择弹出框标题。 | -| content | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 否 | 选择弹出框内容。 | -| selectedIndex | number | 否 | 选择弹出框的选中项。 | -| confirm | boolean | 否 | 确认按钮。 | -| radioContent | Array<[SheetInfo](https://docs.openharmony.cn/pages/v3.2/en/application-dev/reference/arkui-ts/ts-methods-action-sheet.md/)> | 否 | 选择弹出框的子项内容列表,每个选择项支持设置图片、文本和选中的回调事件。 | - - -## ConfirmDialog - -ConfirmDialog({controller: CustomDialogController, title: ResourceStr, content?: ResourceStr, checkTips?: ResourceStr, ischecked?: boolean, primaryButton?: ButtonOptions, secondaryButton?: ButtonOptions}) - -信息确认类弹出框,操作未正确执行(如网络错误、电池电量过低),或未正确操作时(如指纹录入),反馈的错误或提示信息。 - -**装饰器类型:**\@CustomDialog - -**系统能力:** SystemCapability.ArkUI.ArkUI.Full - -**参数:** - -| 参数名 | 参数类型 | 必选 | 装饰器类型 | 参数描述 | -| -------- | -------- | -------- | -------- | -------- | -| controller | CustomDialogController | 是 | - | 确认弹出框控制器。 | -| title | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 是 | - | 确认弹出框标题。 | -| content | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 否 | - | 确认弹出框内容。 | -| checkTips | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 否 | - | checkbox的提示内容。 | -| isChecked | boolean | 否 | \@Prop | value为true时,表示checkbox已选中,value为false时,表示未选中。
默认值:false。 | -| primaryButton | [ButtonOptions](#buttonoptions) | 否 | - | 确认框左侧按钮。 | -| secondaryButton | [ButtonOptions](#buttonoptions) | 否 | - | 确认框右侧按钮。 | - - -## AlertDialog - -AlertDialog({controller: CustomDialogController, content?: ResourceStr, primaryButton?: ButtonOptions, secondaryButton?: ButtonOptions}) - -操作确认类弹出框,触发一个将产生严重后果的不可逆操作时,如删除、重置、取消编辑、停止等。 - -**装饰器类型:**\@CustomDialog - -**系统能力:** SystemCapability.ArkUI.ArkUI.Full - -**参数:** - -| 参数名 | 参数类型 | 必选 | 参数描述 | -| -------- | -------- | -------- | -------- | -| controller | CustomDialogController | 是 | 确认弹出框控制器。 | -| content | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 是 | 确认弹出框内容。 | -| primaryButton | [ButtonOptions](#buttonoptions) | 否 | 确认框左侧按钮。 | -| secondaryButton | [ButtonOptions](#buttonoptions) | 否 | 确认框右侧按钮。 | - - -## LoadingDialog - -LoadingDialog({controller: CustomDialogController, content?: ResourceStr}) - -**参数:** - -| 参数名 | 参数类型 | 必选 | 参数描述 | -| -------- | -------- | -------- | -------- | -| controller | CustomDialogController | 是 | 加载弹出框控制器。 | -| content | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 是 | 加载弹出框内容。 | - - -## ButtonOptions - -**系统能力:** SystemCapability.ArkUI.ArkUI.Full - -| 名称 | 类型 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -| value | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 是 | 按钮的内容。 | -| action | () => void | 否 | 按钮的点击事件。 | -| background | [ResourceColor](https://docs.openharmony.cn/pages/v3.2/en/application-dev/reference/arkui-ts/ts-types.md/#resourcecolor) | 否 | 按钮的背景。 | -| fontColor | [ResourceColor](https://docs.openharmony.cn/pages/v3.2/en/application-dev/reference/arkui-ts/ts-types.md/#resourcecolor) | 否 | 按钮的字体颜色。 | - - -## 示例 - - -### 示例1 - -``` -import { TipsDialog } from '@ohos.arkui.advanced.Dialog' -@Entry -@Component -struct Index { - radioIndex = 0; - isChecked = false; - dialogControllerImage: CustomDialogController = new CustomDialogController({ - builder: TipsDialog({ - imageRes: $r('app.media.icon'), - title: '文本标题', - content: '文本文本文本文本文本文本文本文本文本', - isChecked: this.isChecked, - checkTips: '不再提示', - primaryButton: { - value: '取消', - action: () => { - console.info('Callback when the CheckBox is clicked') - }, - }, - secondaryButton: { - value: '确定', - action: () => { - console.info('Callback when the second button is clicked') - } - }, - }), - autoCancel: true, - customStyle: true, - alignment: DialogAlignment.Bottom - }) - - build() { - Row() { - Stack() { - Column(){ - Button("上图下文弹出框") - .width(96) - .height(40) - .onClick(() => { - this.dialogControllerImage.open() - }) - }.margin({bottom: 300}) - }.align(Alignment.Bottom) - .width('100%').height('100%') - } - .backgroundImageSize({ width: '100%', height: '100%' }) - .height('100%') - } -} -``` - -![20230728-111325](figures/20230728-111325.png) - - -### 示例2 - -``` -import { SelectDialog } from '@ohos.arkui.advanced.Dialog' -@Entry -@Component -struct Index { - radioIndex = 0; - isChecked = false; -dialogControllerList: CustomDialogController = new CustomDialogController({ - builder: SelectDialog({ - title: '文本标题', - selectedIndex: this.radioIndex, - confirm: { - value: '取消', - action: () => null, - }, - radioContent: [ - { - title: '文本文本文本文本文本', - action: () => { - this.radioIndex = 0 - } - }, - { - title: '文本文本文本文本', - action: () => { - this.radioIndex = 1 - } - }, - { - title: '文本文本文本文本', - action: () => { - this.radioIndex = 2 - } - }, - ] - }), - customStyle: true, - alignment: DialogAlignment.Bottom, - autoCancel: false -}) - - build() { - Row() { - Stack() { - Column(){ - Button("纯列表弹出框") - .width(96) - .height(40) - .onClick(() => { - this.dialogControllerList.open() - }) - }.margin({bottom: 300}) - }.align(Alignment.Bottom) - .width('100%').height('100%') - } - .backgroundImageSize({ width: '100%', height: '100%' }) - .height('100%') - } -} -``` - -![20230728-101201](figures/20230728-101201.png) - - -### 示例3 - -``` -import { ConfirmDialog } from '@ohos.arkui.advanced.Dialog' -@Entry -@Component -struct Index { - radioIndex = 0; - isChecked = false; -dialogControllerCheckBox: CustomDialogController = new CustomDialogController({ - builder: CheckBoxDialog({ - title: '文本标题', - content: '文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本', - isChecked: this.isChecked, - checkTips: '禁止后不再提示', - primaryButton: { - value: '禁止', - action: () => null, - }, - secondaryButton: { - value: '允许', - action: () => { - this.isChecked = false - console.info('Callback when the second button is clicked') - } - }, - }), - autoCancel: true, - customStyle: true, - alignment: DialogAlignment.Bottom -}) - - build() { - Row() { - Stack() { - Column(){ - Button("文本+勾选弹出框") - .width(96) - .height(40) - .onClick(() => { - this.dialogControllerCheckBox.open() - }) - }.margin({bottom: 300}) - }.align(Alignment.Bottom) - .width('100%').height('100%') - } - .backgroundImageSize({ width: '100%', height: '100%' }) - .height('100%') - } -} -``` - -![20230728-101236](figures/20230728-101236.png) - - -### 示例4 - -``` -import { AlertDialog } from '@ohos.arkui.advanced.Dialog' -@Entry -@Component -struct Index { - radioIndex = 0; - isChecked = false; -dialogControllerConfirm: CustomDialogController = new CustomDialogController({ - builder: AlertDialog({ - content: '文本文本文本文本文本', - primaryButton: { - value: '取消', - action: () => null, - }, - secondaryButton: { - value: '确认', - fontColor: $r('sys.color.ohos_id_color_warning'), - action: () => { - console.info('Callback when the second button is clicked') - } - }, - }), - autoCancel: true, - customStyle: true, - alignment: DialogAlignment.Bottom -}) - - build() { - Row() { - Stack() { - Column(){ - Button("纯文本弹出框") - .width(96) - .height(40) - .onClick(() => { - this.dialogControllerConfirm.open() - }) - }.margin({bottom: 300}) - }.align(Alignment.Bottom) - .width('100%').height('100%') - } - .backgroundImageSize({ width: '100%', height: '100%' }) - .height('100%') - } -} -``` - -![20230728-101355](figures/20230728-101355.png) - - -### 示例5 - -``` -import { LoadingDialog } from '@ohos.arkui.advanced.Dialog' -@Entry -@Component -struct Index { - radioIndex = 0; - isChecked = false; -dialogControllerProgress: CustomDialogController = new CustomDialogController({ - builder: ProgressDialog({ - content: '文本文本文本文本文本...', - }), - autoCancel: true, - customStyle: true, - alignment: DialogAlignment.Bottom -}) - - build() { - Row() { - Stack() { - Column(){ - Button("进度条弹出框") - .width(96) - .height(40) - .onClick(() => { - this.dialogControllerProgress.open() - }) - }.margin({bottom: 300}) - }.align(Alignment.Bottom) - .width('100%').height('100%') - } - .backgroundImageSize({ width: '100%', height: '100%' }) - .height('100%') - } -} -``` - -![20230728-101306](figures/20230728-101306.png) diff --git a/doc/ts-composite-components-composelistitem.md b/doc/ts-composite-components-composelistitem.md deleted file mode 100644 index 17aa3d6e74cfec2a45a491762f37c50bf7496934..0000000000000000000000000000000000000000 --- a/doc/ts-composite-components-composelistitem.md +++ /dev/null @@ -1,240 +0,0 @@ -# ComposeListItem - - -列表包含一系列相同宽度的列表项。适合连续、多行呈现同类数据,例如图片和文本。 - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 该组件从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 导入模块 - -``` -import { ComposeListItem } from "@ohos.arkui.advanced.ComposeListItem" -``` - - -## 子组件 - -无 - - -## 接口 - -ComposeListItem({contentItem?: ContentItem, operateItem?: OperateItem}) - -**装饰器类型:**\@Component - -**系统能力:** SystemCapability.ArkUI.ArkUI.Full - - -**参数:** - - -| 参数名 | 参数类型 | 必填 | 装饰器类型 | 参数描述 | -| -------- | -------- | -------- | -------- | -------- | -| contentItem | [ContentItem](#contentitem) | 否 | \@Prop | 定义左侧以及中间元素。 | -| operateItem | [OperateItem](#operateitem) | 否 | \@Prop | 定义右侧元素。 | - - -## ContentItem - -| 名称 | 值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -| iconStyle | [IconType](#icontype枚举说明) | 否 | 左侧元素-图标样式。 | -| icon | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 否 | 左侧元素-图标。 | -| primaryText | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 否 | 中间元素-标题内容。 | -| secondaryText | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 否 | 中间元素-副标题内容。 | -| description | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 否 | 中间元素-描述内容。 | - - -## IconType枚举说明 - -| 名称 | 描述 | -| -------- | -------- | -| BADGE | 左侧图标为badge类型,图标大小为8\*8dp。 | -| NORMAL_ICON | 左侧图标为小图标类型,图标大小为16\*16dp。 | -| SYSTEM_ICON | 左侧图标为系统图标类型,图标大小为24\*24dp。 | -| HEAD_SCULPTURE | 左侧图标为头像类型,图标大小为40\*40dp。 | -| APP_ICON | 左侧图标为应用图标类型,图标大小为64\*64dp。 | -| PREVIEW | 左侧图标为预览图类型,图标大小为96\*96dp。 | -| LONGITUDINAL | 左侧图标为横向特殊比例(宽比高大),保持最长边为96dp。 | -| VERTICAL | 左侧图标为竖向特殊比例(高比宽大),保持最长边为96dp。 | - - -## OperateItem - -| 名称 | 值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -| arrow | [OperateIcon](#operateicon) | 否 | 右侧元素-箭头,大小为12\*24dp。 | -| icon | [OperateIcon](#operateicon) | 否 | 右侧元素-第一个图标,大小为24\*24dp。 | -| subIcon | [OperateIcon](#operateicon) | 否 | 右侧元素-第二个图标,大小为24\*24dp。 | -| button | [OperateButton](#operatebutton) | 否 | 右侧元素-按钮。 | -| switch | [OperateCheck](https://gitee.com/openharmony-sig/arkui_advanced_ui_component/blob/master/doc/ts-composite-components-composelistitem.md#switchcheckboxradio-operatecheck) | 否 | 右侧元素-开关。 | -| checkbox | [OperateCheck](https://gitee.com/openharmony-sig/arkui_advanced_ui_component/blob/master/doc/ts-composite-components-composelistitem.md#switchcheckboxradio-operatecheck) | 否 | 右侧元素-多选框,大小为24\*24dp。 | -| radio | [OperateCheck](https://gitee.com/openharmony-sig/arkui_advanced_ui_component/blob/master/doc/ts-composite-components-composelistitem.md#switchcheckboxradio-operatecheck) | 否 | 右侧元素-单选,大小为24\*24dp。 | -| image | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 否 | 右侧元素-图片,大小为48\*48dp。 | -| text | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 否 | 右侧元素-文字。 | - - -## OperateIcon - -| 名称 | 值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -| value | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 是 | 右侧元素-图标/箭头。 | -| action | ()=>void | 否 | 右侧元素-图标/箭头点击事件。 | - - -## OperateButton - -| 名称 | 值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -| text | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 否 | 右侧元素-按钮文字。 | - - -## Switch/CheckBox/Radio-OperateCheck - -| 名称 | 值 | 必填 | 描述 | -| -------- | -------- | -------- | -------- | -| isCheck | boolean | 否 | 右侧元素-右侧Switch/CheckBox/Radio选中状态。 | -| onChange | (value: boolean)=>void | 否 | 右侧元素-右侧Switch/CheckBox/Radio选中状态改变时触发回调。 | - - -## 示例1-纯文本 - -```ts -import { ComposeListItem } from '@ohos.arkui.advanced.ComposeListItem'; -import { ContentItem } from '@ohos.arkui.advanced.ComposeListItem'; - -@Entry -@Component -struct ComposeListItemExample { - build() { - Column() { - List() { - ListItem(){ - ComposeListItem({ - contentItem: ({ - primaryText: '单行列表' - }) - }) - } - } - } - } -} -``` - - -![示例1-纯文本](figures/zh-cn_image_2023072903.PNG) - - -## 示例2-左侧元素+文本 - -```ts -import { ComposeListItem } from '@ohos.arkui.advanced.ComposeListItem'; -import { IconType } from '@ohos.arkui.advanced.ComposeListItem'; -import { ContentItem } from '@ohos.arkui.advanced.ComposeListItem'; - -@Entry -@Component -struct ComposeListItemExample { - build() { - Column() { - List() { - ListItem(){ - ComposeListItem({ - contentItem: ({ - iconStyle: IconType.NORMAL_ICON, - icon: $r('sys.media.ohos_app_icon'), - primaryText: '双行列表', - secondaryText: '辅助文字' - }) - }) - } - } - } - } -} -``` - - -![示例2-左侧元素+文本](figures/zh-cn_image_2023072904.PNG) - - -## 示例3-右侧元素 - -```ts -import { ComposeListItem } from '@ohos.arkui.advanced.ComposeListItem'; -import { OperateItem } from '@ohos.arkui.advanced.ComposeListItem'; -import promptAction from '@ohos.promptAction' - -@Entry -@Component -struct ComposeListItemExample { - build() { - Column() { - List() { - ListItem() { - ComposeListItem({ - operateItem: ({ - icon: { - value: $r('sys.media.ohos_app_icon'), - action: () => { - promptAction.showToast({ message: 'icon' }) - } - }, - text: '右侧文本' - }) - }) - } - } - } - } -} -``` - - -![示例3-右侧元素](figures/zh-cn_image_2023072905.PNG) - - -## 示例4-左右元素+文本 - -```ts -import { ComposeListItem } from '@ohos.arkui.advanced.ComposeListItem'; -import { IconType } from '@ohos.arkui.advanced.ComposeListItem'; -import { ContentItem } from '@ohos.arkui.advanced.ComposeListItem'; -import { OperateItem } from '@ohos.arkui.advanced.ComposeListItem'; -import promptAction from '@ohos.promptAction' - -@Entry -@Component -struct ComposeListItemExample { - build() { - Column() { - List() { - ListItem() { - ComposeListItem({ - contentItem: ({ - iconStyle: IconType.NORMAL_ICON, - icon: $r('sys.media.ohos_app_icon'), - primaryText: '双行列表', - secondaryText: '辅助文字' - }), - operateItem: ({ - icon: { - value: $r('sys.media.ohos_app_icon'), - action: () => { - promptAction.showToast({ message: 'icon' }) - } }, - text: '右侧文本' - }) - }) - } - } - } - } -``` - -![示例4-左右元素+文本](figures/zh-cn_image_2023072906.PNG) diff --git a/doc/ts-composite-components-composetitlebar.md b/doc/ts-composite-components-composetitlebar.md deleted file mode 100644 index fd6143ff4910cec69021d3d10584d97f932dcdaa..0000000000000000000000000000000000000000 --- a/doc/ts-composite-components-composetitlebar.md +++ /dev/null @@ -1,177 +0,0 @@ -# ComposeTitleBar - - -普通型标题栏的一种,支持设置标题、头像(可选)、副标题(可选);可用于一级页面、二级及其以上界面(配置返回键)。 - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 该组件从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 导入模块 - -``` -import { ComposeTitleBar } from "@ohos.arkui.advanced.ComposeTitleBar" -``` - - -## 子组件 - -无 - - -## 接口 - -ComposeTitleBar({item?: ComposeTitleBarMenuItem, title: ResourceStr, subtitle?: ResourceStr, menuItems?: Array<ComposeTitleBarMenuItem>}) - -**装饰器类型:**\@Component - -**系统能力:** SystemCapability.ArkUI.ArkUI.Full - -**参数:** - -| 参数名 | 参数类型 | 必选 | 参数描述 | -| -------- | -------- | -------- | -------- | -| item | [ERROR:Invalid link:zh-cn_topic_0000001617072014.xml#xref1948916525328,link:zh-cn_topic_0000001609264184.xml#section478410410453](zh-cn_topic_0000001609264184.xml#section478410410453) | 否 | 用于左侧头像的单个菜单项目 | -| title | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 是 | 标题 | -| subtitle | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 否 | 副标题 | -| menuItems | Array<[ERROR:Invalid link:zh-cn_topic_0000001617072014.xml#xref33563123310,link:zh-cn_topic_0000001609264184.xml#section478410410453](zh-cn_topic_0000001609264184.xml#section478410410453)> | 否 | 右侧菜单项目列表 | - - -### ComposeTitleBarMenuItem - -| 名称 | 值 | 是否必填 | 描述 | -| -------- | -------- | -------- | -------- | -| value | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 是 | 图标资源 | -| isEnabled | boolean | 是 | 是否启用,默认启用 | -| action | () => void | 否 | 触发时的动作闭包 | - - -## 示例 1 - 单行文本 - -``` -import { ComposeTitleBar } from "@ohos.arkui.advanced.ComposeTitleBar" - -@Entry -@Component -struct Index { - build() { - Row() { - Column() { - ComposeTitleBar({ - title: "啦啦啦啦啦啦啦啦啦啦啦啦啦啦" - }) - }.width('100%') - }.height('100%') - } -} -``` - -![zh-cn_image_0000001616913438](figures/zh-cn_image_0000001616913438.png) - - -## 示例 2 - 双行文本 - -``` -import { ComposeTitleBar } from "@ohos.arkui.advanced.ComposeTitleBar" - -@Entry -@Component -struct Index { - build() { - Row() { - Column() { - ComposeTitleBar({ - title: "啦啦啦啦啦啦啦啦啦啦啦啦啦啦", - subtitle: "啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦" - }) - }.width('100%') - }.height('100%') - } -} -``` - -![zh-cn_image_0000001665513149](figures/zh-cn_image_0000001665513149.png) - - -## 示例 3 - 双行文本带菜单 - -``` -import { ComposeTitleBar } from "@ohos.arkui.advanced.ComposeTitleBar" -import Prompt from '@system.prompt' - -@Entry -@Component -struct Index { - menuItems: { value: Resource, isEnabled: boolean, action: () => void }[] = - [ { isEnabled: true, value: $r('app.media.ic_public_save'), - action: () => prompt.showToast({ message: "show toast index 1" }) - }, - { isEnabled: true, value: $r('app.media.ic_public_reduce'), - action: () => prompt.showToast({ message: "show toast index 2" }) - }, - { isEnabled: true, value: $r('app.media.ic_public_edit'), - action: () => prompt.showToast({ message: "show toast index 3" }) - }, - { isEnabled: true, value: $r('app.media.ic_public_reduce'), - action: () => prompt.showToast({ message: "show toast index 4" }) - } ] - build() { - Row() { - Column() { - Divider().height(2).color(0xCCCCCC) - ComposeTitleBar({ - title: "啦啦啦啦啦啦啦啦啦啦啦啦啦啦", - subtitle: "啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦", - menuItems: this.menuItems.slice(0, 1), - }) - Divider().height(2).color(0xCCCCCC) - ComposeTitleBar({ - title: "啦啦啦啦啦啦啦啦啦啦啦啦啦啦", - subtitle: "啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦", - menuItems: this.menuItems.slice(0, 2), - }) - Divider().height(2).color(0xCCCCCC) - ComposeTitleBar({ - title: "啦啦啦啦啦啦啦啦啦啦啦啦啦啦", - subtitle: "啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦", - menuItems: this.menuItems, - }) - Divider().height(2).color(0xCCCCCC) - }.width('100%') - }.height('100%') - } -} -``` - -![zh-cn_image_0000001617233250](figures/zh-cn_image_0000001617233250.png) - - -## 示例 4 - 头像+双行文本带菜单 - -``` -import { ComposeTitleBar } from "@ohos.arkui.advanced.ComposeTitleBar" -import Prompt from '@system.prompt' - -@Entry -@Component -struct Index { - build() { - Row() { - Column() { - ComposeTitleBar({ - menuItems: [ { isEnabled: true, value: $r('app.media.ic_public_save'), - action: () => Prompt.showToast({ message: "show toast index 1" }) - } ], - title: "啦啦啦啦啦啦啦啦啦啦啦啦啦啦", - subtitle: "啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦", - item: { isEnabled: true, value: $r('app.media.app_icon'), - action: () => Prompt.showToast({message:"show toast index portrait"}) - } }) - }.width('100%') - }.height('100%') - } -} -``` - -![zh-cn_image_0000001617393174](figures/zh-cn_image_0000001617393174.png) diff --git a/doc/ts-composite-components-editabletitlebar.md b/doc/ts-composite-components-editabletitlebar.md deleted file mode 100644 index f82a255b96f38bdeacbbd87a798e1b91f2eeb845..0000000000000000000000000000000000000000 --- a/doc/ts-composite-components-editabletitlebar.md +++ /dev/null @@ -1,130 +0,0 @@ -# EditableTitleBar - - -编辑型标题栏,适用于多选界面或者内容的编辑界面,一般采取左叉右勾的形式。 - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 该组件从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 导入模块 - -``` -import { EditableTitleBar } from "@ohos.arkui.advanced.EditableTitleBar" -``` - - -## 子组件 - -无 - - -## 接口 - -EditableTitleBar({leftIconType: EditableLeftIconType, title: ResourceStr, menuItems?: Array<EditableTitleBarMenuItem>, onSave?: () => void, onCancel?: () =>void}) - -**装饰器类型:**\@Component - -**系统能力:** SystemCapability.ArkUI.ArkUI.Full - -**参数:** - -| 参数名 | 参数类型 | 必选 | 参数描述 | -| -------- | -------- | -------- | -------- | -| leftIconStyle | [ERROR:Invalid link:zh-cn_topic_0000001665632009.xml#xref19441410133613,link:zh-cn_topic_0000001658583341.xml#section1340683083317](zh-cn_topic_0000001658583341.xml#section1340683083317) | 是 | 左侧按钮类型 | -| title | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 是 | 标题 | -| menuItems | Array<[ERROR:Invalid link:zh-cn_topic_0000001665632009.xml#xref81499144365,link:zh-cn_topic_0000001658583341.xml#section1287821819325](zh-cn_topic_0000001658583341.xml#section1287821819325)> | 否 | 右侧菜单项目列表 | -| onSave | () => void | 否 | 保存时的动作闭包 | -| onCancel | () => void | 否 | 当左侧按钮类型为 Left,触发取消时的动作闭包 | - - -### EditableLeftIconType - -| 名称 | 描述 | -| -------- | -------- | -| Back | 返回按钮 | -| Cancel | 取消按钮 | - - -### EditableTitleBarMenuItem - -| 名称 | 值 | 是否必填 | 描述 | -| -------- | -------- | -------- | -------- | -| value | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 是 | 图标资源 | -| isEnabled | boolean | 是 | 是否启用,默认启用 | -| action | () => void | 否 | 触发时的动作闭包 | - - -## 示例 1 - -``` -import { EditableLeftIconType } from "@ohos.arkui.advanced.EditableTitleBar" -import { EditableTitleBar } from "@ohos.arkui.advanced.EditableTitleBar" -import Prompt from '@system.prompt' - -@Entry -@Component -struct Index { - build() { - Row() { - Column() { - EditableTitleBar({ - leftIconStyle: EditableLeftIconType.Cancel, - title: "编辑页面", - menuItems: [], - onCancel: () => { - Prompt.showToast({ message: "on cancel" }) - }, - onSave: () => { - Prompt.showToast({ message: "on save" }) - } - }) - }.width('100%') - }.height('100%') - } -} -``` - - -![zh-cn_image_0000001617073302](figures/zh-cn_image_0000001617073302.png) - - -## 示例 2 - -``` -import { EditableLeftIconType } from "@ohos.arkui.advanced.EditableTitleBar" -import { EditableTitleBar } from "@ohos.arkui.advanced.EditableTitleBar" -import Prompt from '@system.prompt' - -@Entry -@Component -struct Index { - build() { - Row() { - Column() { - EditableTitleBar({ - leftIconStyle: EditableLeftIconType.Back, - title: "编辑页面", - menuItems: [ - { value: $r('app.media.ic_public_reduce'), - isEnabled: false, - action: () => { - Prompt.showToast({ message: "show toast index 2" }) - } - } - ], - onCancel: () => { - Prompt.showToast({ message: "on cancel" }) - }, - onSave: () => { - Prompt.showToast({ message: "on save" }) - } - }) - }.width('100%') - }.height('100%') - } -} -``` - -![zh-cn_image_0000001665393297](figures/zh-cn_image_0000001665393297.png) diff --git a/doc/ts-composite-components-filter.md b/doc/ts-composite-components-filter.md deleted file mode 100644 index f6118c8b7bfde5f548bf63b34e59bc0296434ae7..0000000000000000000000000000000000000000 --- a/doc/ts-composite-components-filter.md +++ /dev/null @@ -1,119 +0,0 @@ -# Filter - - -多条件筛选,帮助用户在大量信息中找到所需内容,应结合具体场景选择合适筛选方式。多条件筛选控件由筛选器与悬浮条构成,悬浮条可下拉展示悬浮筛选器。筛选器样式可分为多行可折叠类型与多行列表类型,并可以在筛选器最后一行附加快捷筛选器。 - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 该组件从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 导入模块 - -``` -import { Filter } from '@ohos.arkui.advanced.Filter' -``` - - -## 子组件 - -无 - - -## Filter - -Filter({ multiFilters: Array<FilterParams>, additionFilters: FilterParams, filterType: FilterType, onFilterChanged: (Array<FilterResult>) => void }) - -**装饰器类型:**\@Component - -**系统能力:** SystemCapability.ArkUI.ArkUI.Full - -**参数:** - - -| 参数名 | 参数类型 | 必选 | 装饰器类型 | 参数描述 | -| -------- | -------- | -------- | -------- | -------- | -| multiFilters | Array<[FilterParams](#filterparams)> | 是 | \@Prop | 多条件筛选列表。 | -| additionFilters | [FilterParams](#filterparams) | 否 | \@Prop | 附加快捷筛选项。 | -| filterType | [FilterType](#filtertype) | 否 | \@Prop | 筛选器的样式类型。 | -| onFilterChanged | (Array<[FilterResult](#filterresult)>) => void | 是 | \@Prop | 用户点击后的回调事件。回调函数的参数为选中的筛选项结果列表。 | -| container | ()=>void | 否 | \@BuilderParam | 筛选结果展示区域自定义内容,通过尾随闭包形式传入。 | - - -## FilterParams - -| 名称 | 值 | 是否必选 | 描述 | -| -------- | -------- | -------- | -------- | -| name | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 是 | 筛选项维度名称。 | -| options | Array<[ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr)> | 是 | 筛选项维度可选项列表。 | - - -## FilterType - -| 参数名 | 描述 | -| -------- | -------- | -| MULTI_LINE_FILTER | 多行可折叠类型筛选器。 | -| LIST_FILTER | 多行列表类型筛选器。 | - - -## FilterResult - -| 名称 | 值 | 是否必选 | 描述 | -| -------- | -------- | -------- | -------- | -| name | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 是 | 筛选项维度名称。 | -| index | number | 是 | 该维度筛选项选中项目的索引值。
默认值:-1 | -| value | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 是 | 该维度筛选项选中项目的值。
默认值:"" | - - -## 示例 - -多行可折叠Filter:内容区可完全自定义。 - -``` -import { Filter, FilterParams, FilterResult, FilterType } from '@ohos.arkui.advanced.Filter' - -@Entry -@Component -struct Index { - private filterParam: Array = [{name: '月份', options: ['全部','1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月']}, - {name: '年份', options: ['全部','2023','2022','2021','2020','2019','2018','2017','2016','2015','2014','2013','2012','2011','2010','2009','2008']}, - {name: '节气', options: ['全部','立春','雨水','惊蛰','春分','清明','谷雨','立夏','小满','芒种','夏至','小暑','大暑','立秋','处暑','白露','秋分','寒露','霜降','立冬','小雪','大雪','冬至','小寒','大寒']}] - private additionParam: FilterParams = { name: '您还可以搜', options: ['运营栏目1','运营栏目2','运营栏目3','运营栏目4','运营栏目5','运营栏目6']} - private arr: number[] = [1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10]; - build() { - Column() { - Filter({ - multiFilters: this.filterParam, - additionFilters: this.additionParam, - filterType: FilterType.MULTI_LINE_FILTER, - onFilterChanged: (select: Array) => { - console.log('rec filter change') - for (let filter of select) { - console.log('name:' + filter.name + ',index:' + filter.index + ',value:' + filter.value) - } - } - }){ - List({ initialIndex: 0 }) { - ForEach(this.arr, (item, index: number) => { - ListItem() { - Text(item.toString()) - .width("100%") - .height(100) - .fontSize(16) - .textAlign(TextAlign.Center) - .borderRadius(10) - .backgroundColor(Color.White) - .margin({ top:10, bottom: 10 }) - } - }) - }.backgroundColor(Color.Gray) - .padding({ left: 20, right: 20 }) - } - } - .height('100%') - .width('100%') - } -} -``` - -![zh-cn_image_0000001665809293](figures/zh-cn_image_0000001665809293.png) diff --git a/doc/ts-composite-components-progressbutton.md b/doc/ts-composite-components-progressbutton.md deleted file mode 100644 index 171c800e3a0a3774c98a4988498dfe88c68cc9da..0000000000000000000000000000000000000000 --- a/doc/ts-composite-components-progressbutton.md +++ /dev/null @@ -1,152 +0,0 @@ -# ProgressButton - - -文本下载按钮,可显示具体下载进度。 - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 该组件从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 导入模块 - -``` -import { ProgressButton } from '@ohos.arkui.advanced.ProgressButton' -``` - - -## ProgressButton - -ProgressButton({progress: number, content: string, progressButtonWidth?: Length, clickCallback: () => void, enable: boolean}) - -**装饰器类型:**\@Component - -**系统能力:** SystemCapability.ArkUI.ArkUI.Full - -**参数:** - -| 参数名 | 参数类型 | 必填 | 装饰器类型 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| progress | number | 是 | \@Prop | 下载按钮的当前进度值。 | -| content | string | 是 | | 下载按钮的文本。 | -| progressButtonWidth | Length | 否 | - | 下载按钮的宽度。 | -| clickCallback | void | 是 | | 下载按钮的点击回调。 | -| enable | boolean | 是 | | 下载按钮是否可以点击,
默认为true。 | - - -## 示例 - -``` -import { ProgressButton } from '@ohos.arkui.advanced.ProgressButton' -@Entry -@Component -struct Index { - @State halfProgress: number = 50 - @State smallProgress: number = 8 - @State bigProgress: number = 51 - @State textState1: string = '下载' - @State textState2: string = '下载' - @State textState3: string = '下载' - @State isRunning1: boolean = false - @State isRunning2: boolean = false - @State isRunning3: boolean = false - @State enableState1: boolean = true - @State enableState2: boolean = true - @State enableState3: boolean = true - build() { - Column({space: 20}) { - Text('6、下载按钮:') - ProgressButton({ - progress: this.halfProgress, - progressButtonWidth: "60", - content: this.textState1, - enable: this.enableState1, - clickCallback: () => { - if (this.textState1 && !this.isRunning1 && this.halfProgress < 100) { - this.textState1 = '继续' - } - this.isRunning1 = !this.isRunning1 - let timer = setInterval(() => { - if (this.isRunning1) { - if (this.halfProgress === 100) { - } else { - this.halfProgress++ - if (this.halfProgress === 100) { - // this.halfProgress = 0 - this.textState1 = '已完成' - this.enableState1 = false - } - console.info('x progress++ = ' + this.halfProgress) - } - } else { - console.info('x isRunning = ' + false) - clearInterval(timer) - } - }, 100) - } - }) - ProgressButton({ - progress: this.smallProgress, - progressButtonWidth: "100", - content: this.textState2, - enable: this.enableState2, - clickCallback: () => { - if (this.textState2 && !this.isRunning2 && this.smallProgress < 100) { - this.textState2 = '继续' - } - this.isRunning2 = !this.isRunning2 - let timer = setInterval(() => { - if (this.isRunning2) { - if (this.smallProgress === 100) { - - } else { - this.smallProgress++ - if (this.smallProgress === 100) { - this.textState2 = '已完成' - this.enableState2 = false - } - console.info('x progress++ = ' + this.smallProgress) - } - } else { - console.info('x isRunning = ' + false) - clearInterval(timer) - } - }, 100) - } - }) - ProgressButton({ - progress: this.bigProgress, - progressButtonWidth: '300', - content: this.textState3, - enable: this.enableState3, - clickCallback: () => { - this.isRunning3 = !this.isRunning3 - if (!this.isRunning3 && this.textState3 && this.bigProgress < 100) { - this.textState3 = '继续' - } - - let timer = setInterval(() => { - if (this.isRunning3) { - if (this.bigProgress === 100) { - } else { - this.bigProgress++ - if (this.bigProgress === 100) { - this.textState3 = '已完成' - this.enableState3 = false - } - console.info('x progress++ = ' + this.bigProgress) - } - } else { - console.info('x isRunning = ' + false) - clearInterval(timer) - } - }, 100) - } - }) - }.alignItems(HorizontalAlign.Center).width('100%') - } -} -``` - - -![zh-cn_image_0000001664713029](figures/zh-cn_image_0000001664713029.png) diff --git a/doc/ts-composite-components-selecttitlebar.md b/doc/ts-composite-components-selecttitlebar.md deleted file mode 100644 index 84af7429bd7d7adab9623ed2a3a160100f005a07..0000000000000000000000000000000000000000 --- a/doc/ts-composite-components-selecttitlebar.md +++ /dev/null @@ -1,186 +0,0 @@ -# SelectTitleBar - - -普通型标题栏的一种,含有一个 Select 控件,可用于页面之间的切换;可用于一级页面、二级及其以上界面(配置返回键)。 - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 该组件从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 导入模块 - -``` -import { SelectTitleBar } from "@ohos.arkui.advanced.SelectTitleBar" -``` - - -## 子组件 - -无 - - -## 接口 - -SelectTitleBar({selected: number, options: Array<SelectOption>, menuItems?: Array<SelectTitleBarMenuItem>, subtitle?: ResourceStr, badgeValue?: number, hidesBackButton?: boolean, onSelected?: (index: number) => void}) - -**装饰器类型:**\@Component - -**系统能力:** SystemCapability.ArkUI.ArkUI.Full - -**参数:** - -| 参数名 | 参数类型 | 必选 | 装饰器类型 | 参数描述 | -| -------- | -------- | -------- | -------- | -------- | -| selected | number | 是 | \@Prop | 当前选中项目的索引 | -| options | Array<SelectOption> | 是 | - | 下拉菜单中的项目 | -| menuItems | Array Prompt.showToast({ message: 'page index ' + index }), - hidesBackButton: true - }) - }.width('100%') - }.height('100%') - } -} -``` - -![zh-cn_image_0000001665793709](figures/zh-cn_image_0000001665793709.png) - - -## 示例 2 - 二级页面下拉菜单 - -``` -import { SelectTitleBar } from "@ohos.arkui.advanced.SelectTitleBar" -import Prompt from '@system.prompt' - -@Entry -@Component -struct Index { - build() { - Row() { - Column() { - Divider().height(2).color(0xCCCCCC) - SelectTitleBar({ - options: [ - { value: '所有照片' }, - { value: '本地(设备)' }, - { value: '本地本地本地本地本地(储存卡)' } - ], - selected: 0, - onSelected: (index) => Prompt.showToast({ message: 'page index ' + index }), - hidesBackButton: false - }) - Divider().height(2).color(0xCCCCCC) - SelectTitleBar({ - options: [ - { value: '所有照片' }, - { value: '本地(设备)' }, - { value: '本地本地本地本地本地(储存卡)' } - ], - selected: 1, - onSelected: (index) => Prompt.showToast({ message: 'page index ' + index }), - subtitle: "example@openharmony.cn" - }) - Divider().height(2).color(0xCCCCCC) - SelectTitleBar({ - options: [ - { value: '所有照片' }, - { value: '本地(设备)' }, - { value: '本地本地本地本地本地(储存卡)' } - ], - selected: 1, - onSelected: (index) => Prompt.showToast({ message: 'page index ' + index }), - subtitle: "example@openharmony.cn", - menuItems: [ { isEnabled: true, value: $r('app.media.ic_public_save'), - action: () => Prompt.showToast({ message: "show toast index 1" }) - } ] - }) - Divider().height(2).color(0xCCCCCC) - }.width('100%') - }.height('100%') - } -} -``` - -![zh-cn_image_0000001617439304](figures/zh-cn_image_0000001617439304.png) - - -## 示例 3 - 新事件标记 - -``` -import { SelectTitleBar } from "@ohos.arkui.advanced.SelectTitleBar" -import Prompt from '@system.prompt' - -@Entry -@Component -struct Index { - menuItems: { value: Resource, isEnabled: boolean, action: () => void }[] = - [ { isEnabled: true, value: $r('app.media.ic_public_save'), - action: () => prompt.showToast({ message: "show toast index 1" }) - }, - { isEnabled: true, value: $r('app.media.ic_public_reduce'), - action: () => prompt.showToast({ message: "show toast index 2" }) - }, - { isEnabled: true, value: $r('app.media.ic_public_edit'), - action: () => prompt.showToast({ message: "show toast index 3" }) - }, - { isEnabled: true, value: $r('app.media.ic_public_reduce'), - action: () => prompt.showToast({ message: "show toast index 4" }) - } ] - build() { - Row() { - Column() { - SelectTitleBar({ - options: [ - { value: '所有照片' }, - { value: '本地(设备)' }, - { value: '本地本地本地本地本地(储存卡)' } - ], - selected: 0, - onSelected: (index) => Prompt.showToast({ message: 'page index ' + index }), - subtitle: "example@openharmony.cn", - menuItems: this.menuItems, - badgeValue: 99, - hidesBackButton: true - }) - }.width('100%') - }.height('100%') - } -} -``` - -![zh-cn_image_0000001616959836](figures/zh-cn_image_0000001616959836.png) diff --git a/doc/ts-composite-components-splitlayout.md b/doc/ts-composite-components-splitlayout.md deleted file mode 100644 index 4206e22a5f5f26b13bf2855863b960a1f11950f0..0000000000000000000000000000000000000000 --- a/doc/ts-composite-components-splitlayout.md +++ /dev/null @@ -1,88 +0,0 @@ -# SplitLayout - - -上下结构布局介绍了常用的页面布局样式。主要分为上下文本和上下图文两种类型。 - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 该组件从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 导入模块 - -``` -import { SplitLayout } from '@ohos.arkui.advanced.SplitLayout' -``` - - -## 子组件 - -无 - - -## 接口 - -SplitLayout({mainImage: Resource, primaryText: string, secondaryText?: string, tertiaryText?: string}) - -**装饰器类型:**\@Component - -**系统能力:** SystemCapability.ArkUI.ArkUI.Full - -**参数:** - -| 参数名 | 参数类型 | 必选 | 参数描述 | -| -------- | -------- | -------- | -------- | -| mainImage | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 是 | 传入图片。 | -| primaryText | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 是 | 标题内容。 | -| secondaryText | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 否 | 副标题内容。 | -| tertiaryText | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 否 | 辅助文本。 | -| container | () => void | 否 | 容器内组件。 | - - -## 示例 - -``` -import { SplitLayout } from '@ohos.arkui.advanced.SplitLayout' -@Entry -@Component -struct Index { - @State demoImage: Resource = $r("app.media.music") - @State primaryText: string = "主标题" - @State secondaryText: string = "副标题" - - build() { - Column() { - SplitLayout({ - mainImage: this.demoImage, - primaryText: '新歌推荐', - secondaryText: '私人订制新歌精选站,为你推荐专属优质新歌;', - tertiaryText: "每日更新", - }) { - Text('示例:空白区域容器内可添加组件') - .margin({top:36}) - } - } - .justifyContent(FlexAlign.SpaceBetween) - .height('100%') - .width('100%') - } -} -``` - - -小于600Vp布局: - - -![zh-cn_image_0000001665553957](figures/zh-cn_image_0000001665553957.png) - - -大于600Vp小于840Vp布局: - - -![zh-cn_image_0000001616957408](figures/zh-cn_image_0000001616957408.png) - - -大于840Vp布局: - - -![zh-cn_image_0000001617116972](figures/zh-cn_image_0000001617116972.png) diff --git a/doc/ts-composite-components-subheader.md b/doc/ts-composite-components-subheader.md deleted file mode 100644 index d7b226bac27327b9dee1d538fffa055b78f5145e..0000000000000000000000000000000000000000 --- a/doc/ts-composite-components-subheader.md +++ /dev/null @@ -1,168 +0,0 @@ -# SubHeader - - -子标题,用于列表项顶部,将该组列表划分为一个区块,子标题名称用来概括该区块内容;也可以用于内容项顶部,子标题名称用来概括该区块内容。 - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 该组件从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 导入模块 - -```ts -import { SubHeader } from '@ohos.arkui.advanced.SubHeader' -``` - - -## 子组件 - -无 - - -## 接口 - -SubHeader({primaryTitle?: ResourceStr, secondaryTitle?: ResourceStr, icon?: ResourceStr, select?: SelectOptions, operationType?: OperationType, operationItem?: Array<OperationOption>}) - -**装饰器类型:**\@Component - -**系统能力:** SystemCapability.ArkUI.ArkUI.Full - - -**参数:** - - -| 参数名 | 参数类型 | 必填 | 装饰器类型 | 参数描述 | -| -------- | -------- | -------- | -------- | -------- | -| primaryTitle | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 否 | \@Prop | 标题内容。 | -| secondaryTitle | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 否 | \@Prop | 副标题内容。 | -| icon | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 否 | \@Prop | 图标设置项。 | -| select | SelectOptions | 否 | - | select内容以及事件。 | -| operationType | OperationType | 否 | \@Prop | 操作区(右侧)元素样式。
默认值:OperationType.BUTTON | -| operationItem | Array<OperationOption> | 否 | - | 操作区(右侧)的设置项。 | - - -## OperationType枚举说明 - -| 名称 | 描述 | -| -------- | -------- | -| TEXT_ARROW | 文本按钮(带右箭头)。 | -| BUTTON | 文本按钮(不带右箭头)。 | -| ICON_GROUP | 图标按钮(最多支持配置三张图标)。 | -| LOADING | 加载动画。 | - - -## SelectOptions - -| 名称 | 值 | 是否必填 | 描述 | -| -------- | -------- | -------- | -------- | -| options | Array<[SelectOption](https://docs.openharmony.cn/pages/v3.1/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md/)> | 是 | 下拉选项内容。 | -| selected | number | 否 | 设置下拉菜单初始选项的索引。
第一项的索引为0。
当不设置selected属性时,
默认选择值为-1,菜单项不选中。 | -| value | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 否 | 设置下拉按钮本身的文本内容。 | -| onSelect | callback: (index: number, value?: string) => void | 否 | 下拉菜单选中某一项的回调。
- index:选中项的索引。
- value:选中项的值。 | - - -## OperationOption - -| 名称 | 值 | 是否必填 | 描述 | -| -------- | -------- | -------- | -------- | -| value | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 是 | 文本内容。 | -| action | ()=>void | 否 | 事件。 | - - -## 示例 - -```ts -import promptAction from '@ohos.promptAction' -import { OperationType, SubHeader } from '@ohos.arkui.advanced.SubHeader' - -@Entry -@Component -struct SubHeaderExample { - build() { - Column() { - SubHeader({ - icon: $r('app.media.ic_public_community_messages'), - primaryTitle: '子标题', - operationType: OperationType.BUTTON, - operationItem: [{ value: '操作', - action: () => { - promptAction.showToast({ message: 'demo' }) - } - }] - }) - } - } -} -``` - -![子标题3](figures/zh-cn_image_202307291.png) - -```ts -import promptAction from '@ohos.promptAction' -import { OperationType, SubHeader } from '@ohos.arkui.advanced.SubHeader' - -@Entry -@Component -struct SubHeaderExample { - build() { - Column() { - SubHeader({ - primaryTitle: '标题', - secondaryTitle: '副文本副文本副文本副文本', - operationType: OperationType.TEXT_ARROW, - operationItem: [{ value: '更多', - action: () => { - promptAction.showToast({ message: 'demo' }) - } - }] - }) - } - } -} -``` - -![zh-cn_image_0000001664546481](figures/zh-cn_image_0000001664546481.png) - -```ts -import promptAction from '@ohos.promptAction' -import { OperationType, SubHeader } from '@ohos.arkui.advanced.SubHeader' - -@Entry -@Component -struct SubHeaderExample { - build() { - Column() { - SubHeader({ - select: { - options: [{ value: 'aaa' }, { value: 'bbb' }, { value: 'ccc' }], - value: 'selectdemo', - selected: 2, - onSelect: (index: number, value?: string) => { - promptAction.showToast({ message: 'demo' }) - } - }, - operationType: OperationType.ICON_GROUP, - operationItem: [{ - value: $r('app.media.ic_public_community_messages'), - action: () => { - promptAction.showToast({ message: 'demo' }) - } - }, { - value: $r('app.media.ic_public_community_messages'), - action: () => { - promptAction.showToast({ message: 'demo' }) - } - }, { - value: $r('app.media.ic_public_community_messages'), - action: () => { - promptAction.showToast({ message: 'demo' }) - } - } - }) - } - } -} -``` - -![子标题5](figures/zh-cn_image_2023072902.png) diff --git a/doc/ts-composite-components-swiperefresher.md b/doc/ts-composite-components-swiperefresher.md deleted file mode 100644 index a8c161665f8be14362af2d5f944d67425880327f..0000000000000000000000000000000000000000 --- a/doc/ts-composite-components-swiperefresher.md +++ /dev/null @@ -1,63 +0,0 @@ -# SwipeRefresher - - -内容加载指获取内容并加载出来。 - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 该组件及其子组件从 API Version 10 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 导入模块 - -``` -import { SwipeRefresher } from '@ohos.arkui.advacned.SwipeRefresher' -``` - - -## 子组件 - -无 - - -## 接口 - -SwipeRefresher ({content: string, isLoading: boolean}) - -**装饰器类型:**\@Component - -**系统能力:** SystemCapability.ArkUI.ArkUI.Full - -**参数:** - -| 参数值 | 参数类型 | 必填 | 装饰器类型 | 参数描述 | -| -------- | -------- | -------- | -------- | -------- | -| content | string | 否 | \@Prop | 内容加载时显示的文本。 | -| isLoading | boolean | 是 | \@Prop | 当前是否正在加载。 | - - -## 示例 - -``` -import { SwipeRefresher } from '@ohos.arkui.advacned.SwipeRefresher'; - -@Entry -@Component -struct Index { - build() { - Column() { - SwipeRefresher({ - content: '正在加载中', - isLoading: true }) - - SwipeRefresher({ - isLoading: true }) - SwipeRefresher({ - content: '正在加载中', - isLoading: false }) - } - } -} -``` - -![Snipaste_2023-07-24_11-35-40](figures/Snipaste_2023-07-24_11-35-40.png) diff --git a/doc/ts-composite-components-tabtitlebar.md b/doc/ts-composite-components-tabtitlebar.md deleted file mode 100644 index e07951535d3fcc22821866f10a81a8c92330a006..0000000000000000000000000000000000000000 --- a/doc/ts-composite-components-tabtitlebar.md +++ /dev/null @@ -1,126 +0,0 @@ -# TabTitleBar - - -页签型标题栏,用于页面之间的切换;仅一级页面适用。 - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 该组件从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 导入模块 - -``` -import { TabTitleBar } from "@ohos.arkui.advanced.TabTitleBar" -``` - - -## 子组件 - -无 - - -## 接口 - -TabTitleBar({tabItems: Array<TabTitleBarTabItem>, menuItems?: Array<TabTitleBarMenuItem>, swiperContent: () => void}) - -**装饰器类型:**\@Component - -**系统能力:** SystemCapability.ArkUI.ArkUI.Full - -**参数:** - -| 参数名 | 参数类型 | 必选 | 装饰器类型 | 参数描述 | -| -------- | -------- | -------- | -------- | -------- | -| tabItems | Array<[TabTitleBarTabItem](https://gitee.com/openharmony-sig/arkui_advanced_ui_component/blob/master/doc/ts-composite-components-tabtitlebar.md/#tabtitlebartabitem)> | 是 | - | 左侧页签项目列表,定义标题栏左侧的页签项目。 | -| menuItems | Array<[TabTitleBarMenuItem](https://gitee.com/openharmony-sig/arkui_advanced_ui_component/blob/master/doc/ts-composite-components-tabtitlebar.md/#tabtitlebarmenuitem)> | 否 | - | 右侧菜单项目列表,定义标题栏右侧的菜单项目 | -| swiperContent | () => void | 否 | \@BuilderParam | 页签列表关联的页面内容构造器 | - - -### TabTitleBarMenuItem - -| 名称 | 值 | 是否必填 | 描述 | -| -------- | -------- | -------- | -------- | -| value | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 是 | 图标资源 | -| isEnabled | boolean | 是 | 是否启用 | -| action | () => void | 否 | 触发时的动作闭包 | - - -### TabTitleBarTabItem - -| 名称 | 值 | 是否必填 | 描述 | -| -------- | -------- | -------- | -------- | -| title | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 是 | 文字页签 | -| icon | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 否 | 图片页签资源 | - - -## 示例 - -``` -import { TabTitleBar } from "@ohos.arkui.advanced.TabTitleBar" -import Prompt from '@system.prompt' - -@Entry -@Component -struct Index { - @Builder componentBuilder() { - Text("#1ABC9C\nTURQUOISE") - .fontWeight(FontWeight.Bold) - .fontSize(14) - .width("100%") - .textAlign(TextAlign.Center) - .fontColor("#CCFFFFFF") - .backgroundColor("#1ABC9C") - Text("#16A085\nGREEN SEA") - .fontWeight(FontWeight.Bold) - .fontSize(14) - .width("100%") - .textAlign(TextAlign.Center) - .fontColor("#CCFFFFFF") - .backgroundColor("#16A085") - Text("#2ECC71\nEMERALD") - .fontWeight(FontWeight.Bold) - .fontSize(14) - .width("100%") - .textAlign(TextAlign.Center) - .fontColor("#CCFFFFFF") - .backgroundColor("#2ECC71") - Text("#27AE60\nNEPHRITIS") - .fontWeight(FontWeight.Bold) - .fontSize(14) - .width("100%") - .textAlign(TextAlign.Center) - .fontColor("#CCFFFFFF") - .backgroundColor("#27AE60") - } - private readonly tabItems: { title: ResourceStr, icon?: ResourceStr }[] = - [ { title: "页签1" }, - { title: "页签2" }, - { title: "页签3" }, - { title: "Happy", - icon: $r('app.media.emoji_happy') } ] - private readonly menuItems: { value: Resource, isEnabled: boolean, action: () => void }[] = - [ { isEnabled: true, value: $r('app.media.ic_public_reduce'), - action: () => Prompt.showToast({ message: "on item click! index 0" }) - }, - { isEnabled: true, value: $r('app.media.ic_public_edit'), - action: () => Prompt.showToast({ message: "on item click! index 1" }) - }, - { isEnabled: true, value: $r('app.media.ic_public_save'), - action: () => Prompt.showToast({ message: "on item click! index 2" }) - } ] - build() { - Row() { - Column() { - TabTitleBar({ - swiperContent: this.componentBuilder, - tabItems: this.tabItems, - menuItems: this.menuItems, - }) - }.width('100%') - }.height('100%') - } -} -``` - -![zh-cn_image_0000001616916278](figures/zh-cn_image_0000001616916278.png) diff --git a/doc/ts-composite-components-toolbar.md b/doc/ts-composite-components-toolbar.md deleted file mode 100644 index f460ee9a7158fab78dfe15584c3062149809340a..0000000000000000000000000000000000000000 --- a/doc/ts-composite-components-toolbar.md +++ /dev/null @@ -1,135 +0,0 @@ -# ToolBar - - -工具栏用于展示针对当前界面内容的操作选项,在界面底部显示。底部最多显示5个入口,超过则收纳入“更多”子项中,在最右侧显示。 - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 该组件从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 导入模块 - -``` -import { ToolBar, ToolBarOptions } from '@ohos.arkui.advanced.ToolBar' -``` - - -## 子组件 - -无 - - -## 接口 - -Toolbar({toolBarList: ToolBarOptions, activateIndex?: number, controller: TabsController}) - -**装饰器类型:**\@Component - -**系统能力:** SystemCapability.ArkUI.ArkUI.Full - -**参数:** - -| 参数名 | 参数类型 | 必选 | 参数描述 | -| -------- | -------- | -------- | -------- | -| toolBarList | [ToolBarOptions](#toolbaroptions) | 是 | 工具栏列表。 | -| activateIndex | number | 否 | 激活态的子项。
默认值为-1。 | -| controller | [TabsController](https://docs.openharmony.cn/pages/v3.1/zh-cn/application-dev/reference/arkui-ts/ts-container-tabs.md/#Tabscontroller) | 是 | 筛选器的样式类型。 | - - -## ToolBarOptions - -继承自Array<ToolBarOption> - -**ToolBarOption:** - -| 名称 | 值 | 是否必填 | 描述 | -| -------- | -------- | -------- | -------- | -| content | [ResourceStr](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resourcestr) | 是 | 工具栏子项的文本。 | -| action | void | 否 | 工具栏子项点击事件。 | -| icon | [Resource](https://docs.openharmony.cn/pages/v4.0/zh-cn/application-dev/reference/arkui-ts/ts-types.md/#resource) | 否 | 工具栏子项的图标。 | -| state | [ItemState](#itemstate) | 否 | 工具栏子项的状态,默认为ENABLE。 | - - -## ItemState - -| 名称 | 描述 | -| -------- | -------- | -| ENABLE | 工具栏子项为正常可点击状态。 | -| DISABLE | 工具栏子项为不可点击状态。 | -| ACTIVATE | 工具栏子项为激活状态,可点击。 | - - -## 示例 - -``` -import { ToolBar, ToolBarOptions } from '@ohos.arkui.advanced.ToolBar' -@Entry -@Component -struct Index { - @State toolbarList: ToolBarOptions = new ToolBarOptions() - aboutToAppear() { - this.toolbarList.push({ text: '剪贴我是超超超超超超超超超长样式', - icon: $r('sys.media.ohos_ic_public_share'), - action: () => { - }, - }) - this.toolbarList.push({ text: '拷贝', - icon: $r('sys.media.ohos_ic_public_copy'), - action: () => { - }, - state:2 - }) - this.toolbarList.push({ text: '粘贴', - icon: $r('sys.media.ohos_ic_public_paste'), - action: () => { - }, - state:3 - }) - this.toolbarList.push({ text: '全选', - icon: $r('sys.media.ohos_ic_public_select_all'), - action: () => { - }, - }) - this.toolbarList.push({ text: '分享', - icon: $r('sys.media.ohos_ic_public_share'), - action: () => { - }, - }) - this.toolbarList.push({ text: '分享', - icon: $r('sys.media.ohos_ic_public_share'), - action: () => { - }, - }) - } - build() { - Row() { - Stack() { - Column(){ - Button("修改减少item") - .width(96) - .height(40) - .onClick(() => { - this.toolbarList.pop() - }) - Button("修改增加item") - .width(96) - .height(40) - .onClick(() => { - this.toolbarList.push(this.toolbarList[1]) - }) - }.margin({bottom: 300}) - Column() { - ToolBar({ - currentIndex: 2, - hwToolBarList: this.toolbarList, - }) - } - }.align(Alignment.Bottom) - .width('100%').height('100%') - } - } -} -``` - -![zh-cn_image_0000001658655445](figures/zh-cn_image_0000001658655445.png) diff --git a/doc/ts-composite-components-treeview.md b/doc/ts-composite-components-treeview.md deleted file mode 100644 index 0a8ddaef87bf167dfd54bb370ce75583d0d16e0d..0000000000000000000000000000000000000000 --- a/doc/ts-composite-components-treeview.md +++ /dev/null @@ -1,379 +0,0 @@ -# TreeView - - -树视图作为一种分层显示的列表,适合显示嵌套结构。拥有父列表项和子列表项,可展开或折叠。子列表项支持选中一项或多项。 - - -用于效率型应用,如备忘录、电子邮件、图库中的侧边导航栏中。 - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 该组件从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - -## 导入模块 - -``` -import { TreeView } from "@ohos.arkui.advanced.TreeView" -``` - - -## 子组件 - -无 - - -## 接口 - -TreeView({ treeController: TreeController }) - -**装饰器类型:**\@Component - -**系统能力:** SystemCapability.ArkUI.ArkUI.Full - - -**参数:** - - -| 参数名 | 参数类型 | 必填 | 参数描述 | -| -------- | -------- | -------- | -------- | -| treeController | [TreeController](#treecontroller) | 是 | 树视图节点信息。 | - - -## TreeController - -树视图组件的控制器,可以将此对象绑定至树视图组件,然后通过它控制树的节点信息,同一个控制器不可以控制多个树视图组件。 - - -### 导入对象 - -``` -treeController: TreeController = new TreeController() -``` - - -### addNode - - -addNode(nodeParam?: NodeParam): void - - -点击某个节点后,调用该方法可以触发新增孩子节点 - - -**参数:** - - -| 参数名 | 参数类型 | 必填 | 参数描述 | -| -------- | -------- | -------- | -------- | -| nodeParam | [NodeParam](#nodeparam) | 否 | 节点信息。 | - - -### removeNode - -removeNode(): void - -点击某个节点后,调用该方法可以触发删除该节点 - - -### modifyNode - - -modifyNode(): void - - -点击某个节点后,调用该方法可以触发修改该节点 - - -### buildDone - -buildDone(): void - -建立树视图。节点增加完毕后,必须调用该方法,触发树信息的保存 - - -### refreshNode - -refreshNode(parentId: number, parentSubTitle: ResourceStr, currentSubtitle: ResourceStr): void - -**参数:** - -| 参数名 | 参数类型 | 必填 | 参数描述 | -| -------- | -------- | -------- | -------- | -| parentId | number | 是 | 父节点Id。 | -| parentSubTitle | ResourceStr | 是 | 父节点副文本 | -| currentSubtitle | ResourceStr | 是 | 当前节点副文本 | - - -## NodeParam - -| 名称 | 值 | 是否必填 | 描述 | -| -------- | -------- | -------- | -------- | -| parentNodeId | number | 否 | 父亲节点 | -| currentNodeId | number | 否 | 当前孩子节点 | -| isFolder | boolean | 否 | 是否是目录 | -| icon | ResourceStr | 否 | 图标 | -| selectedIcon | ResourceStr | 否 | 选中图标 | -| editIcon | ResourceStr | 否 | 编辑图标 | -| primaryTitle | ResourceStr | 否 | 主标题 | -| secondaryTitle | ResourceStr | 否 | 副标题 | -| container | () => void | 否 | 绑定在节点上的子组件,子组件由[@Builder](https://docs.openharmony.cn/pages/v3.1/en/application-dev/ui/ts-component-based-builder.md/)修饰 | - - -## TreeListenerManager对象说明 - -树视图组件的监听器,可以将此对象绑定至树视图组件,然后通过它监听树的节点的变化,同一个监听器不可以控制多个树视图组件。 - - -### 导入对象 - -``` -import { TreeListenerManager } from '@ohos.arkui.advanced.TreeView' -``` - - -### getInstance - -getInstance(): TreeListenerManager - -获取监听管理器单例对象 - - -### getTreeListener() - -getTreeListener(): TreeListener - -获取监听器 - - -## TreeListener对象说明 - -树视图组件的监听器,可以将此对象绑定至树视图组件,然后通过它监听树的节点的变化,同一个监听器不可以控制多个树视图组件。 - - -### 导入对象 - -``` -treeListener: TreeListener = TreeListenerManager.getInstance().getTreeListener() -``` - - -### on - -on(type: TreeListenType, callback: (callbackParam: CallbackParam) => void): void; - -注册监听 - -**参数:** - -| 参数名 | 参数类型 | 必填 | 参数描述 | -| -------- | -------- | -------- | -------- | -| type | [TreeListenType](#treelistentype) | 是 | 监听类型 | -| nodeParam | [NodeParam](#nodeparam) | 是 | 节点信息。 | - - -### once - -once(type: TreeListenType, callback: (callbackParam: CallbackParam) => void): void; - -注册一次监听 - -**参数:** - -| 参数名 | 参数类型 | 必填 | 参数描述 | -| -------- | -------- | -------- | -------- | -| type | [TreeListenType](#treelistentype) | 是 | 监听类型 | -| nodeParam | [NodeParam](#nodeparam) | 是 | 节点信息。 | - - -### off - - -off(type: TreeListenType, callback?: (callbackParam: CallbackParam) => void): void; - - -取消监听 - - -**参数:** - - -| 参数名 | 参数类型 | 必填 | 参数描述 | -| -------- | -------- | -------- | -------- | -| type | [TreeListenType](#treelistentype) | 是 | 监听类型 | -| nodeParam | [NodeParam](#nodeparam) | 是 | 节点信息。 | - - -## TreeListenType - -| 名称 | 描述 | -| -------- | -------- | -| NODE_CLICK | 监听节点点击事件 | -| NODE_ADD | 监听节点增加事件 | -| NODE_DELETE | 监听节点删除事件 | -| NODE_MODIFY | 监听节点修改事件 | -| NODE_MOVE | 监听节点移动事件 | - - -## CallbackParam - -| 名称 | 值 | 是否必填 | 描述 | -| -------- | -------- | -------- | -------- | -| currentNodeId | number | 是 | 当前孩子节点 | -| parentNodeId | number | 否 | 父亲节点表 | -| childIndex: number | number | 否 | 孩子索引 | - - -## 示例 - -``` -import { TreeController, TreeListener, TreeListenerManager, TreeListenType, NodeParam, TreeView, CallbackParam } from '@ohos.arkui.advanced.TreeView' - -@Entry -@Component -struct TreeViewDemo { - private listTreeNode: TreeController = new TreeController(); - private appEventBus: TreeListener = TreeListenerManager.getInstance().getTreeListener(); - @State clickNodeId: number = 0; - @State numbers: string[] = ['one', 'two', 'three', 'four', 'five', 'six']; - - aboutToDisappear(): void { - this.appEventBus.off(TreeListenType.NODE_CLICK, null); - this.appEventBus.off(TreeListenType.NODE_ADD, null); - this.appEventBus.off(TreeListenType.NODE_DELETE, null); - } - - @Builder menuBuilder0() { - Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - Text('删除').fontSize(16).width(100).height(30).textAlign(TextAlign.Center) - .onClick((event: ClickEvent) => { - this.listTreeNode.removeNode(); - }) - }.width(100).border({width: 1, color: 0x80808a, radius: '16dp'}) - } - - @Builder menuBuilder1() { - Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - Text('新增').fontSize(16).width(100).height(30).textAlign(TextAlign.Center) - .onClick((event: ClickEvent) => { - this.listTreeNode.addNode(); - }) - Divider() - Text('删除').fontSize(16).width(100).height(30).textAlign(TextAlign.Center) - .onClick((event: ClickEvent) => { - this.listTreeNode.removeNode(); - }) - Divider() - Text('重命名').fontSize(16).width(100).height(30).textAlign(TextAlign.Center) - .onClick((event: ClickEvent) => { - this.listTreeNode.modifyNode(); - }) - }.width(100).border({width: 1, color: 0x80808a, radius: '16dp'}) - } - - aboutToAppear(): void { - this.appEventBus.on(TreeListenType.NODE_MOVE, (callbackParam: CallbackParam) => { - }) - this.appEventBus.on(TreeListenType.NODE_CLICK, (callbackParam: CallbackParam) => { - }) - - let normalResource: Resource = $r('app.media.ic_public_collect_normal'); - let selectedResource: Resource = $r('app.media.ic_public_collect_selected'); - let editResource: Resource = $r('app.media.ic_public_collect_edit'); - let nodeParam: NodeParam = { parentNodeId:-1, currentNodeId: 1, isFolder: true, icon: normalResource, selectedIcon: selectedResource, - editIcon: editResource, primaryTitle: "目录1验证悬浮框自适应效果是否OK", - menu: this.menuBuilder1.bind(this), secondaryTitle: "6" }; - this.listTreeNode - .addNode(nodeParam) - .addNode({parentNodeId:1, currentNodeId: 2, isFolder: false, primaryTitle: "项目1_1" }) - .addNode({ parentNodeId:-1, currentNodeId: 7, isFolder: true, primaryTitle: "目录2", menu: this.menuBuilder1.bind(this) }) - .addNode({ parentNodeId:-1, currentNodeId: 23, isFolder: true, icon: normalResource, selectedIcon: selectedResource, - editIcon: editResource, primaryTitle: "目录3", menu: this.menuBuilder1.bind(this) }) - .addNode({ parentNodeId:-1, currentNodeId: 24, isFolder: false, primaryTitle: "项目4", menu: this.menuBuilder1.bind(this) }) - .addNode({ parentNodeId:-1, currentNodeId: 31, isFolder: true, icon: normalResource, selectedIcon: selectedResource, - editIcon: editResource, primaryTitle: "目录5", menu: this.menuBuilder1.bind(this), secondaryTitle: "0" }) - .addNode({ parentNodeId:-1, currentNodeId: 32, isFolder: true, icon: normalResource, selectedIcon: selectedResource, - editIcon: editResource, primaryTitle: "目录6", menu: this.menuBuilder1.bind(this), secondaryTitle: "0" }) - .addNode({ parentNodeId:32, currentNodeId: 35, isFolder: true, icon: normalResource, selectedIcon: selectedResource, - editIcon: editResource, primaryTitle: "目录6-1", menu: this.menuBuilder1.bind(this), secondaryTitle: "0" }) - .addNode({ parentNodeId:-1, currentNodeId: 33, isFolder: true, icon: normalResource, selectedIcon: selectedResource, - editIcon: editResource, primaryTitle: "目录7", menu: this.menuBuilder1.bind(this), secondaryTitle: "0" }) - .addNode({ parentNodeId:33, currentNodeId: 34, isFolder: false, primaryTitle: "项目8" }) - .addNode({ parentNodeId:-1, currentNodeId: 36, isFolder: false, primaryTitle: "项目9" }) - .buildDone(); - } - - @Builder subfieldPopup(item: any) { - Column() { - Text(item) - .width('50%').height(60).fontSize(16).borderRadius(10) - .textAlign(TextAlign.Center).backgroundColor(Color.Yellow) - } - } - - build() { - SideBarContainer(SideBarContainerType.Embed) - { - TreeView({ treeController: this.listTreeNode }) - Row() { - Divider().vertical(true).strokeWidth(2).color(0x000000).lineCap(LineCapStyle.Round) - Column() { - Row() { - Text('ClickNodeId=' + this.clickNodeId).fontSize('16fp') - Button('Add', { type: ButtonType.Normal, stateEffect: true }) - .borderRadius(8).backgroundColor(0x317aff).width(90) - .onClick((event: ClickEvent) => { - this.listTreeNode.addNode(); - }) - Button('Modify', { type: ButtonType.Normal, stateEffect: true }) - .borderRadius(8).backgroundColor(0x317aff).width(90) - .onClick((event: ClickEvent) => { - this.listTreeNode.modifyNode(); - }) - Button('Remove', { type: ButtonType.Normal, stateEffect: true }) - .borderRadius(8).backgroundColor(0x317aff).width(120) - .onClick((event: ClickEvent) => { - this.listTreeNode.removeNode(); - }) - } - - /* drag item. */ - List({ space: 10, initialIndex: 0 }) { - ForEach(this.numbers, (item) => { - ListItem() { - Text('' + item) - .width('100%').height(38).fontSize(16).borderRadius(10) - .textAlign(TextAlign.Center).backgroundColor(0xAFEEEE) - } - .onSelect((isSelected: boolean) => { - console.log('listItem selected') - }) - .onDragStart(() => { - this.listTreeNode.refreshNode(1,'选择节点','目标节点') - return this.subfieldPopup(item) - }) - }, item => item) - } - .editMode(true) - .multiSelectable(true) - .onDrop((event: DragEvent, extraParams: string) => { - console.log('outer onDrop') - }) - - }.height('100%').width('70%').alignItems(HorizontalAlign.Start) - } - } - .focusable(true) - .sideBarWidth(240) - .minSideBarWidth(0) - .maxSideBarWidth(900) - .showControlButton(false) - .showSideBar(true) - .onChange((value: boolean) => { - console.info('status:' + value); - }) - } -} -``` - -![zh-cn_image_0000001664822257](figures/zh-cn_image_0000001664822257.png) diff --git a/interface/composelistitem/BUILD.gn b/innerfullscreenlaunchcomponent/interfaces/BUILD.gn similarity index 35% rename from interface/composelistitem/BUILD.gn rename to innerfullscreenlaunchcomponent/interfaces/BUILD.gn index a70c722e51152b2e9f62f457f8b747e974d2fa0d..e48444a93d28896b3d26de6a63536d643bbcf644 100644 --- a/interface/composelistitem/BUILD.gn +++ b/innerfullscreenlaunchcomponent/interfaces/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023-2023 Huawei Device Co., Ltd. +# Copyright (c) 2024 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -11,36 +11,49 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build/config/components/ets_frontend/es2abc_config.gni") import("//build/ohos.gni") -import("//foundation/arkui/ace_engine/ace_config.gni") -import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") - -es2abc_gen_abc("gen_composelistitem_abc") { - src_js = rebase_path("composelistitem.js") - dst_file = rebase_path(target_out_dir + "/composelistitem.abc") - in_puts = [ "composelistitem.js" ] - out_puts = [ target_out_dir + "/composelistitem.abc" ] +import("//foundation/arkui/advanced_ui_component/atomicservice_config.gni") + +es2abc_gen_abc("gen_innerfullscreenlaunchcomponent_abc") { + src_js = rebase_path("innerfullscreenlaunchcomponent.js") + dst_file = rebase_path(target_out_dir + "/innerfullscreenlaunchcomponent.abc") + in_puts = [ "innerfullscreenlaunchcomponent.js" ] + out_puts = [ target_out_dir + "/innerfullscreenlaunchcomponent.abc" ] extra_args = [ "--module" ] } -gen_js_obj("composelistitem_abc") { - input = get_label_info(":gen_composelistitem_abc", "target_out_dir") + "/composelistitem.abc" - output = target_out_dir + "/composelistitem_abc.o" - dep = ":gen_composelistitem_abc" +gen_js_obj("innerfullscreenlaunchcomponent_abc") { + input = + get_label_info(":gen_innerfullscreenlaunchcomponent_abc", + "target_out_dir") + "/innerfullscreenlaunchcomponent.abc" + output = target_out_dir + "/innerfullscreenlaunchcomponent_abc.o" + dep = ":gen_innerfullscreenlaunchcomponent_abc" +} + +gen_obj("innerfullscreenlaunchcomponent_abc_preview") { + input = + get_label_info(":gen_innerfullscreenlaunchcomponent_abc", + "target_out_dir") + "/innerfullscreenlaunchcomponent.abc" + output = target_out_dir + "/innerfullscreenlaunchcomponent_abc.c" + snapshot_dep = [ ":gen_innerfullscreenlaunchcomponent_abc" ] } -ohos_shared_library("composelistitem") { - sources = [ "composelistitem.cpp" ] +ohos_shared_library("innerfullscreenlaunchcomponent") { + sources = [ "innerfullscreenlaunchcomponent.cpp" ] - deps = [ ":composelistitem_abc" ] + if (use_mingw_win || use_mac || use_linux) { + deps = [ ":gen_obj_src_innerfullscreenlaunchcomponent_abc_preview" ] + } else { + deps = [ ":innerfullscreenlaunchcomponent_abc" ] + } external_deps = [ "hilog:libhilog", "napi:ace_napi", ] + relative_install_dir = "module/arkui/advanced" subsystem_name = "arkui" part_name = "advanced_ui_component" - - relative_install_dir = "module/arkui/advanced" } diff --git a/interface/filter/filter.cpp b/innerfullscreenlaunchcomponent/interfaces/innerfullscreenlaunchcomponent.cpp similarity index 50% rename from interface/filter/filter.cpp rename to innerfullscreenlaunchcomponent/interfaces/innerfullscreenlaunchcomponent.cpp index c3321f470bc3f2ef7bad055bf8583eb279a3725f..07cab766dc78c2adbde9b5c42713d3e2a5085dde 100644 --- a/interface/filter/filter.cpp +++ b/innerfullscreenlaunchcomponent/interfaces/innerfullscreenlaunchcomponent.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. + * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,41 +13,40 @@ * limitations under the License. */ -#include "native_engine/native_engine.h" - -#include "napi/native_api.h" #include "napi/native_node_api.h" -extern const char _binary_filter_abc_start[]; -extern const char _binary_filter_abc_end[]; +extern const char _binary_innerfullscreenlaunchcomponent_abc_start[]; +extern const char _binary_innerfullscreenlaunchcomponent_abc_end[]; // Napi get abc code function -extern "C" __attribute__((visibility("default"))) -void NAPI_arkui_advanced_Filter_GetABCCode(const char **buf, int *buflen) +extern "C" __attribute__((visibility("default"))) void NAPI_arkui_advanced_InnerFullScreenLaunchComponent_GetABCCode( + const char** buf, int* buflen) { if (buf != nullptr) { - *buf = _binary_filter_abc_start; + *buf = _binary_innerfullscreenlaunchcomponent_abc_start; } if (buflen != nullptr) { - *buflen = _binary_filter_abc_end - _binary_filter_abc_start; + *buflen = _binary_innerfullscreenlaunchcomponent_abc_end - + _binary_innerfullscreenlaunchcomponent_abc_start; } } /* * Module define */ -static napi_module filterModule = { +static napi_module InnerFullScreenLaunchComponentModule = { .nm_version = 1, .nm_flags = 0, .nm_filename = nullptr, - .nm_modname = "arkui.advanced.Filter", + .nm_modname = "arkui.advanced.InnerFullScreenLaunchComponent", .nm_priv = ((void*)0), .reserved = { 0 }, }; + /* - * Module register function + * Module registerfunction */ -extern "C" __attribute__((constructor)) void filterRegisterModule(void) +extern "C" __attribute__((constructor)) void InnerFullScreenLaunchComponentRegisterModule(void) { - napi_module_register(&filterModule); -} + napi_module_register(&InnerFullScreenLaunchComponentModule); +} \ No newline at end of file diff --git a/innerfullscreenlaunchcomponent/interfaces/innerfullscreenlaunchcomponent.js b/innerfullscreenlaunchcomponent/interfaces/innerfullscreenlaunchcomponent.js new file mode 100644 index 0000000000000000000000000000000000000000..30dd75d83187259e77f73e1d50961821eaa9783b --- /dev/null +++ b/innerfullscreenlaunchcomponent/interfaces/innerfullscreenlaunchcomponent.js @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +const hilog = requireNapi('hilog'); +const abilityManager = requireNapi('app.ability.abilityManager'); +const commonEventManager = requireNapi('commonEventManager'); +export class LaunchController { + constructor() { + this.launchAtomicService = (n1, o1) => { }; + } +} + +const EMBEDDED_FULL_MODE = 1; +export class InnerFullScreenLaunchComponent extends ViewPU { + constructor(d1, e1, f1, g1 = -1, h1 = undefined, i1) { + super(d1, f1, g1, i1); + if (typeof h1 === "function") { + this.paramsGenerator_ = h1; + } + this.content = this.doNothingBuilder; + this.context = getContext(this); + this.controller = new LaunchController(); + this.appId = ''; + this.options = undefined; + this.__isShow = new ObservedPropertySimplePU(false, this, "isShow"); + this.subscriber = null; + this.launchAtomicService = (k1, l1) => { + hilog.info(0x3900, 'InnerFullScreenLaunchComponent', 'launchAtomicService, appId: %{public}s.', k1); + this.appId = k1; + this.options = l1; + this.checkAbility(); + }; + this.setInitiallyProvidedValue(e1); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(c1) { + if (c1.content !== undefined) { + this.content = c1.content; + } + if (c1.context !== undefined) { + this.context = c1.context; + } + if (c1.controller !== undefined) { + this.controller = c1.controller; + } + if (c1.appId !== undefined) { + this.appId = c1.appId; + } + if (c1.options !== undefined) { + this.options = c1.options; + } + if (c1.isShow !== undefined) { + this.isShow = c1.isShow; + } + if (c1.subscriber !== undefined) { + this.subscriber = c1.subscriber; + } + if (c1.launchAtomicService !== undefined) { + this.launchAtomicService = c1.launchAtomicService; + } + } + updateStateVars(b1) { + } + purgeVariableDependenciesOnElmtId(a1) { + this.__isShow.purgeDependencyOnElmtId(a1); + } + aboutToBeDeleted() { + this.__isShow.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + get isShow() { + return this.__isShow.get(); + } + set isShow(z) { + this.__isShow.set(z); + } + aboutToAppear() { + let s = { + events: [commonEventManager.Support.COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT], + }; + commonEventManager.createSubscriber(s, (u, v) => { + if (u) { + hilog.error(0x3900, 'InnerFullScreenLaunchComponent', 'Failed to create subscriber, err: %{public}s.', u.message); + return; + } + if (v == null || v == undefined) { + hilog.error(0x3900, 'InnerFullScreenLaunchComponent', 'Failed to create subscriber, data is null.'); + return; + } + this.subscriber = v; + commonEventManager.subscribe(this.subscriber, (x, y) => { + if (x) { + hilog.error(0x3900, 'InnerFullScreenLaunchComponent', 'Failed to subscribe common event, err: %{public}s.', x.message); + return; + } + hilog.info(0x3900, 'InnerFullScreenLaunchComponent', 'Received account logout event.'); + this.isShow = false; + }); + }); + this.controller.launchAtomicService = this.launchAtomicService; + } + aboutToDisappear() { + if (this.subscriber !== null) { + commonEventManager.unsubscribe(this.subscriber, (r) => { + if (r) { + hilog.error(0x3900, 'InnerFullScreenLaunchComponent', 'UnsubscribeCallBack, err: %{public}s.', r.message); + } + else { + hilog.info(0x3900, 'InnerFullScreenLaunchComponent', 'Unsubscribe.'); + this.subscriber = null; + } + }); + } + } + doNothingBuilder(p = null) { + } + resetOptions() { + if (this.options?.parameters) { + this.options.parameters['ohos.extra.param.key.showMode'] = EMBEDDED_FULL_MODE; + this.options.parameters['ability.want.params.IsNotifyOccupiedAreaChange'] = true; + hilog.info(0x3900, 'InnerFullScreenLaunchComponent', 'replaced options is %{public}s !', JSON.stringify(this.options)); + } + else { + this.options = { + parameters: { + 'ohos.extra.param.key.showMode': EMBEDDED_FULL_MODE, + 'ability.want.params.IsNotifyOccupiedAreaChange': true, + } + }; + } + } + async checkAbility() { + this.resetOptions(); + try { + const o = await abilityManager.isEmbeddedOpenAllowed(this.context, this.appId); + if (o) { + this.isShow = true; + hilog.info(0x3900, 'InnerFullScreenLaunchComponent', ' EmbeddedOpen is Allowed!'); + } + else { + hilog.info(0x3900, 'InnerFullScreenLaunchComponent', ' EmbeddedOpen is not Allowed!'); + this.popUp(); + } + } + catch (n) { + hilog.error(0x3900, 'InnerFullScreenLaunchComponent', 'isEmbeddedOpenAllowed called error!%{public}s', n.message); + } + } + async popUp() { + this.isShow = false; + try { + const m = await this.context.openAtomicService(this.appId, this.options); + hilog.info(0x3900, 'InnerFullScreenLaunchComponent', '%{public}s open service success!', m.want); + } + catch (l) { + hilog.error(0x3900, 'InnerFullScreenLaunchComponent', '%{public}s open service error!', l.message); + } + } + initialRender() { + this.observeComponentCreation2((i, j) => { + Row.create(); + Row.justifyContent(FlexAlign.Center); + Row.bindContentCover({ value: this.isShow, changeEvent: k => { this.isShow = k; } }, { builder: () => { + this.uiExtensionBuilder.call(this); + } }, { modalTransition: ModalTransition.DEFAULT }); + }, Row); + this.content.bind(this)(this); + Row.pop(); + } + uiExtensionBuilder(a = null) { + this.observeComponentCreation2((c, d) => { + UIExtensionComponent.create({ + bundleName: `com.atomicservice.${this.appId}`, + flags: this.options?.flags, + parameters: this.options?.parameters + }); + UIExtensionComponent.backgroundColor({ 'id': -1, 'type': 10001, params: ['sys.color.ohos_id_color_titlebar_bg'], 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); + UIExtensionComponent.defaultFocus(true); + UIExtensionComponent.height('100%'); + UIExtensionComponent.width('100%'); + UIExtensionComponent.onRelease(() => { + hilog.error(0x3900, 'InnerFullScreenLaunchComponent', 'onRelease'); + this.isShow = false; + }); + UIExtensionComponent.onError(g => { + this.isShow = false; + hilog.error(0x3900, 'InnerFullScreenLaunchComponent', 'call up UIExtension error!%{public}s', g.message); + this.getUIContext().showAlertDialog({ + message: g.message + }); + }); + }, UIExtensionComponent); + } + rerender() { + this.updateDirtyElements(); + } +} + + +export default { InnerFullScreenLaunchComponent, LaunchController}; \ No newline at end of file diff --git a/innerfullscreenlaunchcomponent/source/innerfullscreenlaunchcomponent.ets b/innerfullscreenlaunchcomponent/source/innerfullscreenlaunchcomponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..a54aacb3cf60d1226ee67c33804da8ac705fafa0 --- /dev/null +++ b/innerfullscreenlaunchcomponent/source/innerfullscreenlaunchcomponent.ets @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import hilog from '@ohos.hilog'; +import abilityManager from '@ohos.app.ability.abilityManager'; +import common from '@ohos.app.ability.common'; +import { Callback } from '@ohos.base'; +import AtomicServiceOptions from '@ohos.app.ability.AtomicServiceOptions'; +import commonEventManager from '@ohos.commonEventManager'; +import Base from '@ohos.base'; + +export class LaunchController { + public launchAtomicService = (appId: string, options?: AtomicServiceOptions) => {}; +} + +const EMBEDDED_FULL_MODE: number = 1; + +@Component +export struct InnerFullScreenLaunchComponent { + @BuilderParam content: Callback = this.doNothingBuilder; + private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + controller: LaunchController = new LaunchController(); + private appId: string = ''; + private options?: AtomicServiceOptions; + @State private isShow: boolean = false; + private subscriber: commonEventManager.CommonEventSubscriber | null = null; + private launchAtomicService = (appId: string, options?: AtomicServiceOptions) => { + hilog.info(0x3900, 'InnerFullScreenLaunchComponent', + 'launchAtomicService, appId: %{public}s.', appId); + this.appId = appId; + this.options = options; + this.checkAbility(); + } + + aboutToAppear() { + let subscribeInfo: commonEventManager.CommonEventSubscribeInfo = { + events: [commonEventManager.Support.COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT], + }; + + commonEventManager.createSubscriber(subscribeInfo, + (err:Base.BusinessError, data: commonEventManager.CommonEventSubscriber) => { + if (err) { + hilog.error(0x3900, 'InnerFullScreenLaunchComponent', + 'Failed to create subscriber, err: %{public}s.', err.message); + return; + } + + if (data == null || data == undefined) { + hilog.error(0x3900, 'InnerFullScreenLaunchComponent', 'Failed to create subscriber, data is null.'); + return; + } + + this.subscriber = data; + commonEventManager.subscribe(this.subscriber, + (err: Base.BusinessError, data: commonEventManager.CommonEventData) => { + if (err) { + hilog.error(0x3900, 'InnerFullScreenLaunchComponent', + 'Failed to subscribe common event, err: %{public}s.', err.message); + return; + } + + hilog.info(0x3900, 'InnerFullScreenLaunchComponent', 'Received account logout event.'); + this.isShow = false; + }) + }) + this.controller.launchAtomicService = this.launchAtomicService; + } + + aboutToDisappear() { + if (this.subscriber !== null) { + commonEventManager.unsubscribe(this.subscriber, (err) => { + if (err) { + hilog.error(0x3900, 'InnerFullScreenLaunchComponent', + 'UnsubscribeCallBack, err: %{public}s.', err.message); + } else { + hilog.info(0x3900, 'InnerFullScreenLaunchComponent', 'Unsubscribe.'); + this.subscriber = null; + } + }) + } + } + + @Builder + doNothingBuilder() { + }; + + resetOptions() { + if (this.options?.parameters) { + this.options.parameters['ohos.extra.param.key.showMode'] = EMBEDDED_FULL_MODE; + this.options.parameters['ability.want.params.IsNotifyOccupiedAreaChange'] = true; + hilog.info(0x3900, 'InnerFullScreenLaunchComponent', 'replaced options is %{public}s !', JSON.stringify(this.options)); + } else { + this.options = { + parameters: { + 'ohos.extra.param.key.showMode': EMBEDDED_FULL_MODE, + 'ability.want.params.IsNotifyOccupiedAreaChange': true, + } + }; + } + } + + async checkAbility() { + this.resetOptions(); + try { + const res: boolean = await abilityManager.isEmbeddedOpenAllowed(this.context, this.appId); + if (res) { + this.isShow = true; + hilog.info(0x3900, 'InnerFullScreenLaunchComponent', ' EmbeddedOpen is Allowed!'); + } else { + hilog.info(0x3900, 'InnerFullScreenLaunchComponent', ' EmbeddedOpen is not Allowed!'); + this.popUp(); + } + } catch (e) { + hilog.error(0x3900, 'InnerFullScreenLaunchComponent', 'isEmbeddedOpenAllowed called error!%{public}s', e.message); + } + } + + async popUp() { + this.isShow = false; + try { + const ability = await this.context.openAtomicService(this.appId, this.options); + hilog.info(0x3900, 'InnerFullScreenLaunchComponent', '%{public}s open service success!', ability.want); + } catch (e) { + hilog.error(0x3900, 'InnerFullScreenLaunchComponent', '%{public}s open service error!', e.message); + } + } + + build() { + Row() { + this.content(); + } + .justifyContent(FlexAlign.Center) + .bindContentCover($$this.isShow, this.uiExtensionBuilder()) + } + + @Builder + uiExtensionBuilder() { + UIExtensionComponent({ + bundleName: `com.atomicservice.${this.appId}`, + flags: this.options?.flags, + parameters: this.options?.parameters + }) + .backgroundColor($r('sys.color.ohos_id_color_titlebar_bg')) + .defaultFocus(true) + .height('100%') + .width('100%') + .onRelease( + () => { + hilog.error(0x3900, 'InnerFullScreenLaunchComponent', 'onRelease'); + this.isShow = false; + } + ).onError( + err => { + this.isShow = false; + hilog.error(0x3900, 'InnerFullScreenLaunchComponent', 'call up UIExtension error! %{public}s', err.message); + this.getUIContext().showAlertDialog({ + message: err.message + }); + } + ) + } +} \ No newline at end of file diff --git a/interface/arkdialog/BUILD.gn b/interface/arkdialog/BUILD.gn deleted file mode 100644 index 6c5b90f388364789e312a0ca2013a98c1843ddf3..0000000000000000000000000000000000000000 --- a/interface/arkdialog/BUILD.gn +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (c) 2023-2023 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") -import("//foundation/arkui/ace_engine/ace_config.gni") -import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") - -es2abc_gen_abc("gen_arkdialog_abc") { - src_js = rebase_path("arkdialog.js") - dst_file = rebase_path(target_out_dir + "/arkdialog.abc") - in_puts = [ "arkdialog.js" ] - out_puts = [ target_out_dir + "/arkdialog.abc" ] - extra_args = [ "--module" ] -} - -gen_js_obj("arkdialog_abc") { - input = get_label_info(":gen_arkdialog_abc", "target_out_dir") + "/arkdialog.abc" - output = target_out_dir + "/arkdialog_abc.o" - dep = ":gen_arkdialog_abc" -} - -ohos_shared_library("arkdialog") { - sources = [ "arkdialog.cpp" ] - - deps = [ ":arkdialog_abc" ] - - external_deps = [ - "hilog:libhilog", - "napi:ace_napi", - ] - - subsystem_name = "arkui" - part_name = "advanced_ui_component" - - relative_install_dir = "module/arkui/advanced" -} diff --git a/interface/arkdialog/arkdialog.js b/interface/arkdialog/arkdialog.js deleted file mode 100644 index 36e355fa0f24fb54df281315e6eb33fe3a93d3b1..0000000000000000000000000000000000000000 --- a/interface/arkdialog/arkdialog.js +++ /dev/null @@ -1,1604 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const CHECKBOX_CONTAINER_HEIGHT = 48; -const CONTENT_MAX_LINES = 2; -const DIVIDER_CONTAINER_WIDTH = 16; -const DIVIDER_HEIGHT = 24; -const DIVIDER_WIDTH = 2; -const LOADING_PROGRESS_WIDTH = 40; -const LOADING_PROGRESS_HEIGHT = 48; -const ITEM_TEXT_SIZE = 14; - -export class TipsDialog extends ViewPU { - constructor(e, o, t, r = -1) { - super(e, t, r); - this.controller = void 0; - this.imageRes = void 0; - this.imageSize = { width: '100%', height: 180 }; - this.title = ''; - this.content = ''; - this.checkTips = ''; - this.__isChecked = new ObservedPropertySimplePU(!1, this, 'isChecked'); - this.primaryButton = { value: '' }; - this.secondaryButton = { value: '' }; - this.setInitiallyProvidedValue(o); - } - - setInitiallyProvidedValue(e) { - void 0 !== e.controller && (this.controller = e.controller); - void 0 !== e.imageRes && (this.imageRes = e.imageRes); - void 0 !== e.imageSize && (this.imageSize = e.imageSize); - void 0 !== e.title && (this.title = e.title); - void 0 !== e.content && (this.content = e.content); - void 0 !== e.checkTips && (this.checkTips = e.checkTips); - void 0 !== e.isChecked && (this.isChecked = e.isChecked); - void 0 !== e.primaryButton && (this.primaryButton = e.primaryButton); - void 0 !== e.secondaryButton && (this.secondaryButton = e.secondaryButton); - } - - updateStateVars(e) { - } - - purgeVariableDependenciesOnElmtId(e) { - this.__isChecked.purgeDependencyOnElmtId(e); - } - - aboutToBeDeleted() { - this.__isChecked.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal(); - } - - setController(e) { - this.controller = e; - } - - get isChecked() { - return this.__isChecked.get(); - } - - set isChecked(e) { - this.__isChecked.set(e); - } - - initialRender() { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.backgroundBlurStyle(BlurStyle.Thick); - Column.borderRadius({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_corner_radius_dialog'], - bundleName: '', - moduleName: '' - }); - Column.margin({ - left: { - id: -1, - type: 10002, - params: ['sys.float.ohos_id_dialog_margin_start'], - bundleName: '', - moduleName: '' - }, - right: { - id: -1, - type: 10002, - params: ['sys.float.ohos_id_dialog_margin_end'], - bundleName: '', - moduleName: '' - }, - bottom: { - id: -1, - type: 10002, - params: ['sys.float.ohos_id_dialog_margin_bottom'], - bundleName: '', - moduleName: '' - } - }); - Column.backgroundColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_dialog_bg'], - bundleName: '', - moduleName: '' - }); - o || Column.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.width('100%'); - Row.padding({ left: 24, right: 24 }); - Row.margin({ top: 24 }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.layoutWeight(1); - Column.clip(!0); - o || Column.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(this.imageRes); - Image.size(this.imageSize); - Image.objectFit(ImageFit.Fill); - o || Image.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Column.pop(); - Row.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.padding({ left: 24, right: 24 }); - Row.margin({ top: 16 }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.title); - Text.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_headline8'], - bundleName: '', - moduleName: '' - }); - Text.fontWeight(FontWeight.Medium); - Text.fontColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary'], - bundleName: '', - moduleName: '' - }); - Text.textAlign(TextAlign.Center); - o || Text.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Text.pop(); - Row.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.content ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.padding({ left: 24, right: 24, top: 8, bottom: 8 }); - Row.width('100%'); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.content); - Text.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_body2'], - bundleName: '', - moduleName: '' - }); - Text.fontWeight(FontWeight.Medium); - Text.fontColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary'], - bundleName: '', - moduleName: '' - }); - Text.textAlign(TextAlign.Center); - Text.minFontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_body3'], - bundleName: '', - moduleName: '' - }); - o || Text.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Text.pop(); - Row.pop(); - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - If.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.height(CHECKBOX_CONTAINER_HEIGHT); - Row.width('100%'); - Row.padding({ left: 24, right: 24, top: 8, bottom: 8 }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Checkbox.create({ name: 'checkbox', group: 'checkboxGroup' }); - Checkbox.select(this.isChecked); - Checkbox.onChange((e => { - this.isChecked = e; - })); - Checkbox.margin({ left: 0, right: 8 }); - o || Checkbox.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Checkbox.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.checkTips); - Text.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_body2'], - bundleName: '', - moduleName: '' - }); - Text.fontWeight(FontWeight.Medium); - Text.fontColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary'], - bundleName: '', - moduleName: '' - }); - Text.maxLines(CONTENT_MAX_LINES); - Text.layoutWeight(1); - Text.focusOnTouch(!0); - Text.onClick((() => { - this.isChecked = !this.isChecked; - })); - o || Text.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Text.pop(); - Row.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.width('100%'); - Row.padding({ left: 16, right: 16, top: 16, bottom: 16 }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.primaryButton.value ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Button.createWithLabel(this.primaryButton.value); - Button.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_button1'], - bundleName: '', - moduleName: '' - }); - Button.fontWeight(FontWeight.Medium); - Button.layoutWeight(1); - Button.backgroundColor(this.primaryButton.background ? this.primaryButton.background : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_background_transparent'], - bundleName: '', - moduleName: '' - }); - Button.fontColor(this.primaryButton.fontColor ? this.primaryButton.fontColor : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary_activated'], - bundleName: '', - moduleName: '' - }); - Button.onClick((() => { - this.primaryButton.action && this.primaryButton.action(); - this.controller.close(); - })); - o || Button.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Button.pop(); - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - If.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.secondaryButton.value && this.primaryButton.value ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.width(DIVIDER_CONTAINER_WIDTH); - Column.alignItems(HorizontalAlign.Center); - o || Column.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.secondaryButton.background ? If.branchId(1) : this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Divider.create(); - Divider.width(DIVIDER_WIDTH); - Divider.height(DIVIDER_HEIGHT); - Divider.color({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_list_separator'], - bundleName: '', - moduleName: '' - }); - Divider.vertical(!0); - o || Divider.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - })); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - If.pop(); - Column.pop(); - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - If.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.secondaryButton.value ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Button.createWithLabel(this.secondaryButton.value); - Button.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_button1'], - bundleName: '', - moduleName: '' - }); - Button.fontWeight(FontWeight.Medium); - Button.layoutWeight(1); - Button.backgroundColor(this.secondaryButton.background ? this.secondaryButton.background : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_background_transparent'], - bundleName: '', - moduleName: '' - }); - Button.fontColor(this.secondaryButton.fontColor ? this.secondaryButton.fontColor : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary_activated'], - bundleName: '', - moduleName: '' - }); - Button.onClick((() => { - this.secondaryButton.action && this.secondaryButton.action(); - this.controller.close(); - })); - o || Button.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Button.pop(); - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - If.pop(); - Row.pop(); - Column.pop(); - } - - rerender() { - this.updateDirtyElements(); - } -} - -export class SelectDialog extends ViewPU { - constructor(e, o, t, r = -1) { - super(e, t, r); - this.controller = void 0; - this.title = ''; - this.content = ''; - this.selectedIndex = -1; - this.confirm = { value: '' }; - this.radioContent = []; - this.setInitiallyProvidedValue(o); - } - - setInitiallyProvidedValue(e) { - void 0 !== e.controller && (this.controller = e.controller); - void 0 !== e.title && (this.title = e.title); - void 0 !== e.content && (this.content = e.content); - void 0 !== e.selectedIndex && (this.selectedIndex = e.selectedIndex); - void 0 !== e.confirm && (this.confirm = e.confirm); - void 0 !== e.radioContent && (this.radioContent = e.radioContent); - } - - updateStateVars(e) { - } - - purgeVariableDependenciesOnElmtId(e) { - } - - aboutToBeDeleted() { - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal(); - } - - setController(e) { - this.controller = e; - } - - initialRender() { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.backgroundBlurStyle(BlurStyle.Thick); - Column.borderRadius({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_corner_radius_dialog'], - bundleName: '', - moduleName: '' - }); - Column.margin({ - left: { - id: -1, - type: 10002, - params: ['sys.float.ohos_id_dialog_margin_start'], - bundleName: '', - moduleName: '' - }, - right: { - id: -1, - type: 10002, - params: ['sys.float.ohos_id_dialog_margin_end'], - bundleName: '', - moduleName: '' - }, - bottom: { - id: -1, - type: 10002, - params: ['sys.float.ohos_id_dialog_margin_bottom'], - bundleName: '', - moduleName: '' - } - }); - Column.backgroundColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_dialog_bg'], - bundleName: '', - moduleName: '' - }); - o || Column.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.padding({ left: 24, right: 24, top: 24 }); - Row.constraintSize({ minHeight: 56 }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.title); - Text.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_dialog_tittle'], - bundleName: '', - moduleName: '' - }); - Text.fontWeight(FontWeight.Medium); - Text.maxLines(CONTENT_MAX_LINES); - Text.minFontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_sub_title1'], - bundleName: '', - moduleName: '' - }); - Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - Text.fontColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary'], - bundleName: '', - moduleName: '' - }); - Text.textAlign(TextAlign.Start); - Text.width('100%'); - o || Text.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Text.pop(); - Row.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.content ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.padding({ left: 24, right: 24, top: 8, bottom: 8 }); - Row.width('100%'); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.content); - Text.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_body2'], - bundleName: '', - moduleName: '' - }); - Text.fontWeight(FontWeight.Medium); - Text.fontColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary'], - bundleName: '', - moduleName: '' - }); - Text.maxLines(CONTENT_MAX_LINES); - Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - Text.minFontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_body3'], - bundleName: '', - moduleName: '' - }); - o || Text.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Text.pop(); - Row.pop(); - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - If.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - List.create({ space: 1 }); - List.width('100%'); - List.padding({ left: 24, right: 24, top: 8, bottom: 8 }); - List.clip(!1); - o || List.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - ForEach.create(); - this.forEachUpdateFunction(e, this.radioContent, ((e, o) => { - const t = e; - { - const e = !0; - const r = (o, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - ListItem.create(i, e); - t || ListItem.pop(); - ViewStackProcessor.StopGetAccessRecording(); - }; - const s = () => { - this.observeComponentCreation(r); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - o || Column.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.constraintSize({ minHeight: 48 }); - Row.clip(!1); - Row.onClick((() => { - t.action && t.action(); - this.controller.close(); - })); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(t.title); - Text.fontSize(ITEM_TEXT_SIZE); - Text.fontWeight(FontWeight.Regular); - Text.maxLines(CONTENT_MAX_LINES); - Text.fontColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary'], - bundleName: '', - moduleName: '' - }); - Text.layoutWeight(1); - o || Text.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Text.pop(); - this.observeComponentCreation(((e, r) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Radio.create({ value: 'item.title', group: 'radioGroup' }); - Radio.checked(this.selectedIndex === o); - Radio.onChange((() => { - t.action && t.action(); - this.controller.close(); - })); - Radio.onClick((() => { - t.action && t.action(); - this.controller.close(); - })); - r || Radio.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Row.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - o < this.radioContent.length - 1 ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Divider.create(); - Divider.color({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_list_separator'], - bundleName: '', - moduleName: '' - }); - o || Divider.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - If.pop(); - Column.pop(); - ListItem.pop(); - }; - const i = (e, s) => { - r(e, s); - this.updateFuncByElmtId.set(e, r); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - o || Column.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.constraintSize({ minHeight: 48 }); - Row.clip(!1); - Row.onClick((() => { - t.action && t.action(); - this.controller.close(); - })); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(t.title); - Text.fontSize(ITEM_TEXT_SIZE); - Text.fontWeight(FontWeight.Regular); - Text.maxLines(CONTENT_MAX_LINES); - Text.fontColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary'], - bundleName: '', - moduleName: '' - }); - Text.layoutWeight(1); - o || Text.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Text.pop(); - this.observeComponentCreation(((e, r) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Radio.create({ value: 'item.title', group: 'radioGroup' }); - Radio.checked(this.selectedIndex === o); - Radio.onChange((() => { - t.action && t.action(); - this.controller.close(); - })); - Radio.onClick((() => { - t.action && t.action(); - this.controller.close(); - })); - r || Radio.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Row.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - o < this.radioContent.length - 1 ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Divider.create(); - Divider.color({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_list_separator'], - bundleName: '', - moduleName: '' - }); - o || Divider.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - If.pop(); - Column.pop(); - ListItem.pop(); - }; - e ? (() => { - this.observeComponentCreation(r); - ListItem.pop(); - })() : s(); - } - }), void 0, !0, !1); - o || ForEach.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - ForEach.pop(); - List.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.width('100%'); - Row.padding({ left: 16, right: 16, top: 16, bottom: 16 }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.confirm.value ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Button.createWithLabel(this.confirm.value); - Button.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_button1'], - bundleName: '', - moduleName: '' - }); - Button.fontWeight(FontWeight.Medium); - Button.layoutWeight(1); - Button.backgroundColor(this.confirm.background ? this.confirm.background : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_background_transparent'], - bundleName: '', - moduleName: '' - }); - Button.fontColor(this.confirm.fontColor ? this.confirm.fontColor : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary_activated'], - bundleName: '', - moduleName: '' - }); - Button.onClick((() => { - this.confirm.action && this.confirm.action(); - this.controller.close(); - })); - o || Button.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Button.pop(); - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - If.pop(); - Row.pop(); - Column.pop(); - } - - rerender() { - this.updateDirtyElements(); - } -} - -export class ConfirmDialog extends ViewPU { - constructor(e, o, t, r = -1) { - super(e, t, r); - this.controller = void 0; - this.title = ''; - this.content = ''; - this.checkTips = ''; - this.__isChecked = new ObservedPropertySimplePU(!1, this, 'isChecked'); - this.primaryButton = { value: '' }; - this.secondaryButton = { value: '' }; - this.setInitiallyProvidedValue(o); - } - - setInitiallyProvidedValue(e) { - void 0 !== e.controller && (this.controller = e.controller); - void 0 !== e.title && (this.title = e.title); - void 0 !== e.content && (this.content = e.content); - void 0 !== e.checkTips && (this.checkTips = e.checkTips); - void 0 !== e.isChecked && (this.isChecked = e.isChecked); - void 0 !== e.primaryButton && (this.primaryButton = e.primaryButton); - void 0 !== e.secondaryButton && (this.secondaryButton = e.secondaryButton); - } - - updateStateVars(e) { - } - - purgeVariableDependenciesOnElmtId(e) { - this.__isChecked.purgeDependencyOnElmtId(e); - } - - aboutToBeDeleted() { - this.__isChecked.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal(); - } - - setController(e) { - this.controller = e; - } - - get isChecked() { - return this.__isChecked.get(); - } - - set isChecked(e) { - this.__isChecked.set(e); - } - - initialRender() { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.backgroundBlurStyle(BlurStyle.Thick); - Column.borderRadius({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_corner_radius_dialog'], - bundleName: '', - moduleName: '' - }); - Column.margin({ - left: { - id: -1, - type: 10002, - params: ['sys.float.ohos_id_dialog_margin_start'], - bundleName: '', - moduleName: '' - }, - right: { - id: -1, - type: 10002, - params: ['sys.float.ohos_id_dialog_margin_end'], - bundleName: '', - moduleName: '' - }, - bottom: { - id: -1, - type: 10002, - params: ['sys.float.ohos_id_dialog_margin_bottom'], - bundleName: '', - moduleName: '' - } - }); - Column.backgroundColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_dialog_bg'], - bundleName: '', - moduleName: '' - }); - o || Column.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.padding({ left: 24, right: 24, top: 24 }); - Row.constraintSize({ minHeight: 56 }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.title); - Text.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_dialog_tittle'], - bundleName: '', - moduleName: '' - }); - Text.fontWeight(FontWeight.Medium); - Text.maxLines(CONTENT_MAX_LINES); - Text.minFontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_sub_title1'], - bundleName: '', - moduleName: '' - }); - Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - Text.fontColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary'], - bundleName: '', - moduleName: '' - }); - Text.textAlign(TextAlign.Start); - Text.width('100%'); - o || Text.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Text.pop(); - Row.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.content ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.padding({ left: 24, right: 24, top: 8, bottom: 8 }); - Row.width('100%'); - Row.constraintSize({ minHeight: 36 }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.content); - Text.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_body1'], - bundleName: '', - moduleName: '' - }); - Text.fontWeight(FontWeight.Medium); - Text.fontColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary'], - bundleName: '', - moduleName: '' - }); - Text.maxLines(CONTENT_MAX_LINES); - Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - Text.minFontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_body3'], - bundleName: '', - moduleName: '' - }); - o || Text.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Text.pop(); - Row.pop(); - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - If.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.height(CHECKBOX_CONTAINER_HEIGHT); - Row.width('100%'); - Row.padding({ left: 24, right: 24, top: 8, bottom: 8 }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Checkbox.create({ name: 'checkbox', group: 'checkboxGroup' }); - Checkbox.select(this.isChecked); - Checkbox.onChange((e => { - this.isChecked = e; - })); - Checkbox.margin({ left: 0, right: 8 }); - o || Checkbox.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Checkbox.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.checkTips); - Text.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_body2'], - bundleName: '', - moduleName: '' - }); - Text.fontWeight(FontWeight.Medium); - Text.fontColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary'], - bundleName: '', - moduleName: '' - }); - Text.maxLines(CONTENT_MAX_LINES); - Text.layoutWeight(1); - Text.focusOnTouch(!0); - Text.onClick((() => { - this.isChecked = !this.isChecked; - })); - o || Text.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Text.pop(); - Row.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.width('100%'); - Row.padding({ left: 16, right: 16, top: 16, bottom: 16 }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.primaryButton.value ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Button.createWithLabel(this.primaryButton.value); - Button.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_button1'], - bundleName: '', - moduleName: '' - }); - Button.fontWeight(FontWeight.Medium); - Button.layoutWeight(1); - Button.backgroundColor(this.primaryButton.background ? this.primaryButton.background : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_background_transparent'], - bundleName: '', - moduleName: '' - }); - Button.fontColor(this.primaryButton.fontColor ? this.primaryButton.fontColor : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary_activated'], - bundleName: '', - moduleName: '' - }); - Button.onClick((() => { - this.primaryButton.action && this.primaryButton.action(); - this.controller.close(); - })); - o || Button.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Button.pop(); - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - If.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.secondaryButton.value && this.primaryButton.value ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.width(DIVIDER_CONTAINER_WIDTH); - Column.alignItems(HorizontalAlign.Center); - o || Column.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.secondaryButton.background ? If.branchId(1) : this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Divider.create(); - Divider.width(DIVIDER_WIDTH); - Divider.height(DIVIDER_HEIGHT); - Divider.color({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_list_separator'], - bundleName: '', - moduleName: '' - }); - Divider.vertical(!0); - o || Divider.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - })); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - If.pop(); - Column.pop(); - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - If.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.secondaryButton.value ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Button.createWithLabel(this.secondaryButton.value); - Button.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_button1'], - bundleName: '', - moduleName: '' - }); - Button.fontWeight(FontWeight.Medium); - Button.layoutWeight(1); - Button.backgroundColor(this.secondaryButton.background ? this.secondaryButton.background : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_background_transparent'], - bundleName: '', - moduleName: '' - }); - Button.fontColor(this.secondaryButton.fontColor ? this.secondaryButton.fontColor : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary_activated'], - bundleName: '', - moduleName: '' - }); - Button.onClick((() => { - this.secondaryButton.action && this.secondaryButton.action(); - this.controller.close(); - })); - o || Button.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Button.pop(); - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - If.pop(); - Row.pop(); - Column.pop(); - } - - rerender() { - this.updateDirtyElements(); - } -} - -export class AlertDialog extends ViewPU { - constructor(e, o, t, r = -1) { - super(e, t, r); - this.controller = void 0; - this.content = ''; - this.primaryButton = { value: '' }; - this.secondaryButton = { value: '' }; - this.setInitiallyProvidedValue(o); - } - - setInitiallyProvidedValue(e) { - void 0 !== e.controller && (this.controller = e.controller); - void 0 !== e.content && (this.content = e.content); - void 0 !== e.primaryButton && (this.primaryButton = e.primaryButton); - void 0 !== e.secondaryButton && (this.secondaryButton = e.secondaryButton); - } - - updateStateVars(e) { - } - - purgeVariableDependenciesOnElmtId(e) { - } - - aboutToBeDeleted() { - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal(); - } - - setController(e) { - this.controller = e; - } - - initialRender() { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.backgroundBlurStyle(BlurStyle.Thick); - Column.borderRadius({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_corner_radius_dialog'], - bundleName: '', - moduleName: '' - }); - Column.margin({ - left: { - id: -1, - type: 10002, - params: ['sys.float.ohos_id_dialog_margin_start'], - bundleName: '', - moduleName: '' - }, - right: { - id: -1, - type: 10002, - params: ['sys.float.ohos_id_dialog_margin_end'], - bundleName: '', - moduleName: '' - }, - bottom: { - id: -1, - type: 10002, - params: ['sys.float.ohos_id_dialog_margin_bottom'], - bundleName: '', - moduleName: '' - } - }); - Column.backgroundColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_dialog_bg'], - bundleName: '', - moduleName: '' - }); - o || Column.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.padding({ left: 24, right: 24, top: 24 }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.content); - Text.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_body1'], - bundleName: '', - moduleName: '' - }); - Text.fontWeight(FontWeight.Medium); - Text.fontColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary'], - bundleName: '', - moduleName: '' - }); - o || Text.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Text.pop(); - Row.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.width('100%'); - Row.padding({ left: 16, right: 16, top: 16, bottom: 16 }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.primaryButton.value ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Button.createWithLabel(this.primaryButton.value); - Button.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_button1'], - bundleName: '', - moduleName: '' - }); - Button.fontWeight(FontWeight.Medium); - Button.layoutWeight(1); - Button.backgroundColor(this.primaryButton.background ? this.primaryButton.background : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_background_transparent'], - bundleName: '', - moduleName: '' - }); - Button.fontColor(this.primaryButton.fontColor ? this.primaryButton.fontColor : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary_activated'], - bundleName: '', - moduleName: '' - }); - Button.onClick((() => { - this.primaryButton.action && this.primaryButton.action(); - this.controller.close(); - })); - o || Button.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Button.pop(); - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - If.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.secondaryButton.value && this.primaryButton.value ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.width(DIVIDER_CONTAINER_WIDTH); - Column.alignItems(HorizontalAlign.Center); - o || Column.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.secondaryButton.background ? If.branchId(1) : this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Divider.create(); - Divider.width(DIVIDER_WIDTH); - Divider.height(DIVIDER_HEIGHT); - Divider.color({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_list_separator'], - bundleName: '', - moduleName: '' - }); - Divider.vertical(!0); - o || Divider.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - })); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - If.pop(); - Column.pop(); - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - If.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.secondaryButton.value ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Button.createWithLabel(this.secondaryButton.value); - Button.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_button1'], - bundleName: '', - moduleName: '' - }); - Button.fontWeight(FontWeight.Medium); - Button.layoutWeight(1); - Button.backgroundColor(this.secondaryButton.background ? this.secondaryButton.background : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_background_transparent'], - bundleName: '', - moduleName: '' - }); - Button.fontColor(this.secondaryButton.fontColor ? this.secondaryButton.fontColor : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary_activated'], - bundleName: '', - moduleName: '' - }); - Button.onClick((() => { - this.secondaryButton.action && this.secondaryButton.action(); - this.controller.close(); - })); - o || Button.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Button.pop(); - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - If.pop(); - Row.pop(); - Column.pop(); - } - - rerender() { - this.updateDirtyElements(); - } -} - -export class LoadingDialog extends ViewPU { - constructor(e, o, t, r = -1) { - super(e, t, r); - this.controller = void 0; - this.content = ''; - this.setInitiallyProvidedValue(o); - } - - setInitiallyProvidedValue(e) { - void 0 !== e.controller && (this.controller = e.controller); - void 0 !== e.content && (this.content = e.content); - } - - updateStateVars(e) { - } - - purgeVariableDependenciesOnElmtId(e) { - } - - aboutToBeDeleted() { - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal(); - } - - setController(e) { - this.controller = e; - } - - initialRender() { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.backgroundBlurStyle(BlurStyle.Thick); - Column.borderRadius({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_corner_radius_dialog'], - bundleName: '', - moduleName: '' - }); - Column.margin({ - left: { - id: -1, - type: 10002, - params: ['sys.float.ohos_id_dialog_margin_start'], - bundleName: '', - moduleName: '' - }, - right: { - id: -1, - type: 10002, - params: ['sys.float.ohos_id_dialog_margin_end'], - bundleName: '', - moduleName: '' - }, - bottom: { - id: -1, - type: 10002, - params: ['sys.float.ohos_id_dialog_margin_bottom'], - bundleName: '', - moduleName: '' - } - }); - Column.backgroundColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_dialog_bg'], - bundleName: '', - moduleName: '' - }); - o || Column.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.margin({ left: 24, right: 24, top: 24, bottom: 24 }); - Row.constraintSize({ minHeight: 48 }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.content); - Text.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_body1'], - bundleName: '', - moduleName: '' - }); - Text.fontWeight(FontWeight.Medium); - Text.fontColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary'], - bundleName: '', - moduleName: '' - }); - Text.layoutWeight(1); - o || Text.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Text.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - LoadingProgress.create(); - LoadingProgress.width(LOADING_PROGRESS_WIDTH); - LoadingProgress.height(LOADING_PROGRESS_HEIGHT); - LoadingProgress.margin({ left: 16 }); - o || LoadingProgress.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Row.pop(); - Column.pop(); - } - - rerender() { - this.updateDirtyElements(); - } -} -export default { TipsDialog, ConfirmDialog, SelectDialog, AlertDialog, LoadingDialog }; \ No newline at end of file diff --git a/interface/composelistitem/composelistitem.cpp b/interface/composelistitem/composelistitem.cpp deleted file mode 100644 index bf795fc4f35db86bdec86f3d4843bf8950547217..0000000000000000000000000000000000000000 --- a/interface/composelistitem/composelistitem.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "native_engine/native_engine.h" - -#include "napi/native_api.h" -#include "napi/native_node_api.h" - -extern const char _binary_composelistitem_abc_start[]; -extern const char _binary_composelistitem_abc_end[]; - -// Napi get abc code function -extern "C" __attribute__((visibility("default"))) -void NAPI_arkui_advanced_ComposeListItem_GetABCCode(const char **buf, int *buflen) - { - if (buf != nullptr) { - *buf = _binary_composelistitem_abc_start; - } - if (buflen != nullptr) { - *buflen = _binary_composelistitem_abc_end - _binary_composelistitem_abc_start; - } - } - - -static napi_module composelistitemModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_modname = "arkui.advanced.ComposeListItem", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; - -extern "C" __attribute__((constructor)) void composelistitemRegisterModule(void) -{ - napi_module_register(&composelistitemModule); -} \ No newline at end of file diff --git a/interface/composelistitem/composelistitem.js b/interface/composelistitem/composelistitem.js deleted file mode 100644 index 09de65f085cf0b1eb0453b9be9f99e5e7b6069c6..0000000000000000000000000000000000000000 --- a/interface/composelistitem/composelistitem.js +++ /dev/null @@ -1,799 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export var IconType; -!function(e){ - e[e.BADGE=1] = "BADGE"; - e[e.NORMAL_ICON=2] = "NORMAL_ICON"; - e[e.SYSTEM_ICON=3] = "SYSTEM_ICON"; - e[e.HEAD_SCULPTURE=4] = "HEAD_SCULPTURE"; - e[e.APP_ICON=5] = "APP_ICON"; - e[e.PREVIEW=6] = "PREVIEW"; - e[e.LONGITUDINAL=7] = "LONGITUDINAL"; - e[e.VERTICAL=8] = "VERTICAL" -}(IconType || (IconType = {})); -var ItemHeight; -!function(e){ - e[e.FIRST_HEIGHT=48] = "FIRST_HEIGHT"; - e[e.SECOND_HEIGHT=56] = "SECOND_HEIGHT"; - e[e.THIRD_HEIGHT=64] = "THIRD_HEIGHT"; - e[e.FOURTH_HEIGHT=72] = "FOURTH_HEIGHT"; - e[e.FIFTH_HEIGHT=96] = "FIFTH_HEIGHT" -}(ItemHeight || (ItemHeight = {})); -const LISTITEMCARD_BORDER_HIDDEN = 0; -const TEXT_MAX_LINE = 1; -const LISTITEMCARD_BORDER_SHOWN = 2; -const TEXT_COLUMN_SPACE = 2; -const TEXT_SAFE_MARGIN = 8; -const BADGE_SIZE = 8; -const SMALL_ICON_SIZE = 16; -const SYSTEM_ICON_SIZE = 24; -const SAFE_LIST_PADDING = 32; -const HEADSCULPTURE_SIZE = 40; -const BUTTON_SIZE = 28; -const APP_ICON_SIZE = 64; -const PREVIEW_SIZE = 96; -const LONGITUDINAL_SIZE = 96; -const VERTICAL_SIZE = 96; -const NORMAL_ITEM_ROW_SPACE = 16; -const SPECIAL_ITEM_ROW_SPACE = 0; -const SPECIAL_ICON_SIZE = 0; -const DEFAULT_ROW_SPACE = 0; -const SPECICAL_ROW_SPACE = 4; -const OPERATEITEM_ICONLIKE_SIZE = 24; -const OPERATEITEM_ARROW_WIDTH = 12; -const OPERATEITEM_ICON_CLICKABLE_SIZE = 48; -const OPERATEITEM_IMAGE_SIZE = 48; -const HOVERING_COLOR = "#0d000000"; -const TOUCH_DOWN_COLOR = "#1a000000"; -const ACTIVED_COLOR = "#1a0a59f7"; - -class ContentItemStruct extends ViewPU { - constructor(e, t, o, i = -1) { - super(e, o, i); - this.iconStyle = null; - this.icon = null; - this.title = null; - this.subtitle = null; - this.description = null; - this.iconSizeMap = new Map([[IconType.BADGE, 8], [IconType.NORMAL_ICON, 16], [IconType.SYSTEM_ICON, 24], [IconType.HEAD_SCULPTURE, 40], [IconType.APP_ICON, 64], [IconType.PREVIEW, 96], [IconType.LONGITUDINAL, 96], [IconType.VERTICAL, 96]]); - this.itemHeight = ItemHeight.FIRST_HEIGHT; - this.itemRowSpace = 16; - this.setInitiallyProvidedValue(t) - } - - setInitiallyProvidedValue(e) { - void 0 !== e.iconStyle && (this.iconStyle = e.iconStyle); - void 0 !== e.icon && (this.icon = e.icon); - void 0 !== e.title && (this.title = e.title); - void 0 !== e.subtitle && (this.subtitle = e.subtitle); - void 0 !== e.description && (this.description = e.description); - void 0 !== e.iconSizeMap && (this.iconSizeMap = e.iconSizeMap); - void 0 !== e.itemHeight && (this.itemHeight = e.itemHeight); - void 0 !== e.itemRowSpace && (this.itemRowSpace = e.itemRowSpace) - } - - updateStateVars(e) { - } - - purgeVariableDependenciesOnElmtId(e) { - } - - aboutToBeDeleted() { - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - - aboutToAppear() { - null == this.subtitle && null == this.description ? null == this.icon ? this.itemHeight = ItemHeight.FIRST_HEIGHT : this.itemHeight = this.iconStyle <= IconType.HEAD_SCULPTURE ? ItemHeight.SECOND_HEIGHT : ItemHeight.THIRD_HEIGHT : null == this.description ? null == this.icon || null != this.icon && this.iconStyle <= IconType.SYSTEM_ICON ? this.itemHeight = ItemHeight.THIRD_HEIGHT : this.itemHeight = ItemHeight.FOURTH_HEIGHT : this.itemHeight = ItemHeight.FIFTH_HEIGHT; - null == this.icon && null == this.iconStyle && (this.itemRowSpace = 0); - this.iconSizeMap.get(this.iconStyle) >= this.itemHeight && (this.itemHeight = this.iconSizeMap.get(this.iconStyle) + 32) - } - - createIcon(e = null) { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - null != this.icon && null != this.iconStyle ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.iconStyle <= IconType.PREVIEW ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(this.icon); - Image.objectFit(ImageFit.Contain); - Image.width(this.iconSizeMap.get(this.iconStyle)); - Image.height(this.iconSizeMap.get(this.iconStyle)); - Image.borderRadius({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_default_m"], - bundleName: "", - moduleName: "" - }); - Image.focusable(!0); - t || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })) - })) : this.ifElseBranchUpdateFunction(1, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(this.icon); - Image.objectFit(ImageFit.Contain); - Image.constraintSize({ - minWidth: 0, - maxWidth: this.iconSizeMap.get(this.iconStyle), - minHeight: 0, - maxHeight: this.iconSizeMap.get(this.iconStyle) - }); - Image.borderRadius({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_default_m"], - bundleName: "", - moduleName: "" - }); - Image.focusable(!0); - t || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })) - })); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop() - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop() - } - - createText(e = null) { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create({ space: 2 }); - Column.margin({ top: 8, bottom: 8 }); - Column.alignItems(HorizontalAlign.Start); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.title); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body1"], - bundleName: "", - moduleName: "" - }); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary"], - bundleName: "", - moduleName: "" - }); - Text.maxLines(1); - Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - Text.focusable(!0); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - null != this.subtitle ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.subtitle); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body2"], - bundleName: "", - moduleName: "" - }); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_secondary"], - bundleName: "", - moduleName: "" - }); - Text.maxLines(1); - Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - Text.focusable(!0); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop() - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - null != this.description ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.description); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body2"], - bundleName: "", - moduleName: "" - }); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_secondary"], - bundleName: "", - moduleName: "" - }); - Text.maxLines(1); - Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - Text.focusable(!0); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop() - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - Column.pop() - } - - initialRender() { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create({ space: this.itemRowSpace }); - Row.height(this.itemHeight); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.createIcon.bind(this)(); - this.createText.bind(this)(); - Row.pop() - } - - rerender() { - this.updateDirtyElements() - } -} - -class OperateItemStruct extends ViewPU { - constructor(e, t, o, i = -1) { - super(e, o, i); - this.arrow = null; - this.icon = null; - this.subIcon = null; - this.button = null; - this.switch = null; - this.checkBox = null; - this.radio = null; - this.image = null; - this.text = null; - this.__switchState = new ObservedPropertySimplePU(!1, this, "switchState"); - this.__radioState = new ObservedPropertySimplePU(!1, this, "radioState"); - this.__checkBoxState = new ObservedPropertySimplePU(!1, this, "checkBoxState"); - this.rowSpace = 0; - this.setInitiallyProvidedValue(t) - } - - setInitiallyProvidedValue(e) { - void 0 !== e.arrow && (this.arrow = e.arrow); - void 0 !== e.icon && (this.icon = e.icon); - void 0 !== e.subIcon && (this.subIcon = e.subIcon); - void 0 !== e.button && (this.button = e.button); - void 0 !== e.switch && (this.switch = e.switch); - void 0 !== e.checkBox && (this.checkBox = e.checkBox); - void 0 !== e.radio && (this.radio = e.radio); - void 0 !== e.image && (this.image = e.image); - void 0 !== e.text && (this.text = e.text); - void 0 !== e.switchState && (this.switchState = e.switchState); - void 0 !== e.radioState && (this.radioState = e.radioState); - void 0 !== e.checkBoxState && (this.checkBoxState = e.checkBoxState); - void 0 !== e.rowSpace && (this.rowSpace = e.rowSpace) - } - - updateStateVars(e) { - } - - purgeVariableDependenciesOnElmtId(e) { - this.__switchState.purgeDependencyOnElmtId(e); - this.__radioState.purgeDependencyOnElmtId(e); - this.__checkBoxState.purgeDependencyOnElmtId(e) - } - - aboutToBeDeleted() { - this.__switchState.aboutToBeDeleted(); - this.__radioState.aboutToBeDeleted(); - this.__checkBoxState.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - - get switchState() { - return this.__switchState.get() - } - - set switchState(e) { - this.__switchState.set(e) - } - - get radioState() { - return this.__radioState.get() - } - - set radioState(e) { - this.__radioState.set(e) - } - - get checkBoxState() { - return this.__checkBoxState.get() - } - - set checkBoxState(e) { - this.__checkBoxState.set(e) - } - - aboutToAppear() { - null != this.switch && (this.switchState = this.switch.isCheck); - null != this.radio && (this.radioState = this.radio.isCheck); - null != this.checkBox && (this.checkBoxState = this.checkBox.isCheck); - (null == this.button && null == this.image && null != this.icon && null != this.text || null == this.button && null == this.image && null == this.icon && null != this.arrow && null != this.text) && (this.rowSpace = 4) - } - - createButton(e, t = null) { - this.observeComponentCreation(((t, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(t); - Button.createWithLabel(e); - Button.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_button3"], - bundleName: "", - moduleName: "" - }); - Button.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary_activated_transparent"], - bundleName: "", - moduleName: "" - }); - Button.height(28); - Button.backgroundColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_button_normal"], - bundleName: "", - moduleName: "" - }); - Button.labelStyle({ maxLines: 1 }); - o || Button.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Button.pop() - } - - createIcon(e, t = null) { - this.observeComponentCreation(((t, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(t); - Row.create(); - Row.height(48); - Row.width(48); - Row.justifyContent(FlexAlign.Center); - Row.onClick(e.action); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((t, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(t); - Image.create(e.value); - Image.height(24); - Image.width(24); - Image.focusable(!0); - Image.fillColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_primary"], - bundleName: "", - moduleName: "" - }); - o || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop() - } - - createImage(e, t = null) { - this.observeComponentCreation(((t, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(t); - Image.create(e); - Image.height(48); - Image.width(48); - o || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })) - } - - createText(e, t = null) { - this.observeComponentCreation(((t, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(t); - Text.create(e); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body2"], - bundleName: "", - moduleName: "" - }); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_secondary"], - bundleName: "", - moduleName: "" - }); - Text.focusable(!0); - o || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop() - } - - createArrow(e, t = null) { - this.observeComponentCreation(((t, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(t); - Image.create(e.value); - Image.height(24); - Image.width(12); - Image.focusable(!0); - Image.fillColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_fourth"], - bundleName: "", - moduleName: "" - }); - Image.onClick(e.action); - o || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })) - } - - createRadio(e, t = null) { - this.observeComponentCreation(((t, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(t); - Radio.create({ value: null, group: null }); - Radio.checked(this.radioState); - Radio.onChange(e.onChange); - Radio.height(24); - Radio.width(24); - o || Radio.pop(); - ViewStackProcessor.StopGetAccessRecording() - })) - } - - createCheckBox(e, t = null) { - this.observeComponentCreation(((t, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(t); - Checkbox.create(); - Checkbox.select(this.checkBoxState); - Checkbox.onChange(e.onChange); - Checkbox.height(24); - Checkbox.height(24); - o || Checkbox.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Checkbox.pop() - } - - createSwitch(e, t = null) { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.height(48); - Row.width(48); - Row.justifyContent(FlexAlign.Center); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((t, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(t); - Toggle.create({ type: ToggleType.Switch, isOn: this.switchState }); - Toggle.onChange(e.onChange); - Toggle.onClick((() => { - this.switchState = !this.switchState - })); - o || Toggle.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Toggle.pop(); - Row.pop() - } - - initialRender() { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create({ space: this.rowSpace }); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - null != this.button ? this.ifElseBranchUpdateFunction(0, (() => { - this.createButton.bind(this)(this.button.text) - })) : null != this.image ? this.ifElseBranchUpdateFunction(1, (() => { - this.createImage.bind(this)(this.image) - })) : null != this.icon && null != this.text ? this.ifElseBranchUpdateFunction(2, (() => { - this.createText.bind(this)(this.text); - this.createIcon.bind(this)(this.icon) - })) : null != this.arrow && null == this.text ? this.ifElseBranchUpdateFunction(3, (() => { - this.createArrow.bind(this)(this.arrow) - })) : null != this.arrow && null != this.text ? this.ifElseBranchUpdateFunction(4, (() => { - this.createText.bind(this)(this.text); - this.createArrow.bind(this)(this.arrow) - })) : null != this.text ? this.ifElseBranchUpdateFunction(5, (() => { - this.createText.bind(this)(this.text) - })) : null != this.radio ? this.ifElseBranchUpdateFunction(6, (() => { - this.createRadio.bind(this)(this.radio) - })) : null != this.checkBox ? this.ifElseBranchUpdateFunction(7, (() => { - this.createCheckBox.bind(this)(this.checkBox) - })) : null != this.switch ? this.ifElseBranchUpdateFunction(8, (() => { - this.createSwitch.bind(this)(this.switch) - })) : null != this.icon && this.ifElseBranchUpdateFunction(9, (() => { - this.createIcon.bind(this)(this.icon); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - null != this.subIcon ? this.ifElseBranchUpdateFunction(0, (() => { - this.createIcon.bind(this)(this.subIcon) - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop() - })); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - Row.pop() - } - - rerender() { - this.updateDirtyElements() - } -} - -export class ComposeListItem extends ViewPU { - constructor(e, t, o, i = -1) { - super(e, o, i); - this.__contentItem = new SynchedPropertyObjectOneWayPU(t.contentItem, this, "contentItem"); - this.__operateItem = new SynchedPropertyObjectOneWayPU(t.operateItem, this, "operateItem"); - this.__frontColor = new ObservedPropertySimplePU(Color.Transparent.toString(), this, "frontColor"); - this.__borderSize = new ObservedPropertySimplePU(0, this, "borderSize"); - this.isActive = !1; - this.setInitiallyProvidedValue(t) - } - - setInitiallyProvidedValue(e) { - void 0 !== e.contentItem ? this.__contentItem.set(e.contentItem) : this.__contentItem.set(null); - void 0 !== e.operateItem ? this.__operateItem.set(e.operateItem) : this.__operateItem.set(null); - void 0 !== e.frontColor && (this.frontColor = e.frontColor); - void 0 !== e.borderSize && (this.borderSize = e.borderSize); - void 0 !== e.isActive && (this.isActive = e.isActive) - } - - updateStateVars(e) { - this.__contentItem.reset(e.contentItem); - this.__operateItem.reset(e.operateItem) - } - - purgeVariableDependenciesOnElmtId(e) { - this.__contentItem.purgeDependencyOnElmtId(e); - this.__operateItem.purgeDependencyOnElmtId(e); - this.__frontColor.purgeDependencyOnElmtId(e); - this.__borderSize.purgeDependencyOnElmtId(e) - } - - aboutToBeDeleted() { - this.__contentItem.aboutToBeDeleted(); - this.__operateItem.aboutToBeDeleted(); - this.__frontColor.aboutToBeDeleted(); - this.__borderSize.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - - get contentItem() { - return this.__contentItem.get() - } - - set contentItem(e) { - this.__contentItem.set(e) - } - - get operateItem() { - return this.__operateItem.get() - } - - set operateItem(e) { - this.__operateItem.set(e) - } - - get frontColor() { - return this.__frontColor.get() - } - - set frontColor(e) { - this.__frontColor.set(e) - } - - get borderSize() { - return this.__borderSize.get() - } - - set borderSize(e) { - this.__borderSize.set(e) - } - - initialRender() { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.padding({ - left: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_default_padding_start"], - bundleName: "", - moduleName: "" - }, - right: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_default_padding_end"], - bundleName: "", - moduleName: "" - } - }); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Flex.create({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }); - Flex.focusable(!0); - Flex.border({ - width: this.borderSize, - color: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_focused_outline"], - bundleName: "", - moduleName: "" - } - }); - Flex.borderRadius({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_default_m"], - bundleName: "", - moduleName: "" - }); - Flex.backgroundColor(this.frontColor); - Flex.onFocus((() => { - this.borderSize = 2 - })); - Flex.onBlur((() => { - this.borderSize = 0 - })); - Flex.onHover((e => { - this.frontColor = e ? "#0d000000" : this.isActive ? "#1a0a59f7" : Color.Transparent.toString() - })); - Flex.onTouch((e => { - e.type == TouchType.Down && (this.frontColor = "#1a000000"); - e.type == TouchType.Up && (this.frontColor = this.isActive ? "#1a0a59f7" : Color.Transparent.toString()) - })); - Flex.onClick((() => { - this.isActive = !this.isActive; - this.frontColor = this.isActive ? "#1a0a59f7" : Color.Transparent.toString() - })); - t || Flex.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - null == this.contentItem ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - t ? ViewPU.create(new ContentItemStruct(this, { - title: null - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })) - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - null != this.contentItem ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - t ? ViewPU.create(new ContentItemStruct(this, { - icon: "string" == typeof this.contentItem.icon ? null : this.contentItem.icon, - iconStyle: this.contentItem.iconStyle, - title: "string" == typeof this.contentItem.primaryText ? this.contentItem.primaryText : null, - subtitle: "string" == typeof this.contentItem.secondaryText ? this.contentItem.secondaryText : null, - description: "string" == typeof this.contentItem.description ? this.contentItem.description : null - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })) - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - null != this.operateItem ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - t ? ViewPU.create(new OperateItemStruct(this, { - icon: this.operateItem.icon, - subIcon: this.operateItem.subIcon, - button: this.operateItem.button, - switch: this.operateItem.switch, - checkBox: this.operateItem.checkbox, - radio: this.operateItem.radio, - image: "string" == typeof this.operateItem.image ? null : this.operateItem.image, - text: "string" == typeof this.operateItem.text ? this.operateItem.text : null, - arrow: "string" == typeof this.operateItem.arrow ? null : this.operateItem.arrow - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })) - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - Flex.pop(); - Column.pop() - } - - rerender() { - this.updateDirtyElements() - } -} - -export default { IconType, ComposeListItem }; \ No newline at end of file diff --git a/interface/composetitlebar/composetitlebar.cpp b/interface/composetitlebar/composetitlebar.cpp deleted file mode 100644 index efe49d9c2904567fa22dcff676359bf7622a4fe9..0000000000000000000000000000000000000000 --- a/interface/composetitlebar/composetitlebar.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "native_engine/native_engine.h" - -#include "napi/native_api.h" -#include "napi/native_node_api.h" - -extern const char _binary_composetitlebar_abc_start[]; -extern const char _binary_composetitlebar_abc_end[]; - -// Napi get abc code function -extern "C" __attribute__((visibility("default"))) -void NAPI_arkui_advanced_ComposeTitleBar_GetABCCode(const char **buf, int *buflen) - { - if (buf != nullptr) { - *buf = _binary_composetitlebar_abc_start; - } - if (buflen != nullptr) { - *buflen = _binary_composetitlebar_abc_end - _binary_composetitlebar_abc_start; - } - } - - -static napi_module composetitlebarModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_modname = "arkui.advanced.ComposeTitleBar", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; - -extern "C" __attribute__((constructor)) void composetitlebarRegisterModule(void) -{ - napi_module_register(&composetitlebarModule); -} \ No newline at end of file diff --git a/interface/composetitlebar/composetitlebar.js b/interface/composetitlebar/composetitlebar.js deleted file mode 100644 index cff24b96f4cfc290d0b8c51d6782090624528db3..0000000000000000000000000000000000000000 --- a/interface/composetitlebar/composetitlebar.js +++ /dev/null @@ -1,714 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var __decorate = this && this.__decorate || function(e, t, o, i) { - var s, r = arguments.length, - n = r < 3 ? t : null === i ? i = Object.getOwnPropertyDescriptor(t, o) : i; - if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(e, t, o, i); - else - for (var c = e.length - 1; c >= 0; c--)(s = e[c]) && (n = (r < 3 ? s(n) : r > 3 ? s(t, o, n) : s(t, o)) || n); - return r > 3 && n && Object.defineProperty(t, o, n), n -}; -const KeyCode = requireNapi('multimodalInput.keyCode').KeyCode; -const PUBLIC_MORE = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAABS3GwHAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAEZ0FNQQAAsY58+1GTAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOxAAADsQBlSsOGwAABEZJREFUeNrt3D1rFFEUBuAxhmAhFlYpUohYiYWFRcAmKAhWK2pjo1iKf8BCMIKFf8BarCyMhVj4VZhGSKEg2FqJyCKWIhYWnstMINgYsh+cmfs88BICydxw7jmzu2HvNg0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADBN+3r6dx+LXIqsRpa7FF8j48hm5Fn3Peo9mAEYRdYjJ3f582Vj7nZfUe/eDsCRyMPI2h5/fyNyI/JDT6v3Tvt7sBllE15ETkxwjeORi5G3ke/6W737MgBnI68jh6ZwrcORq5HnhkC9+zAA5YXXy8jBKV5zKXIu8jjyS7+rd+YBeNVtyrSVO9PRyBM9r94LSTfjWuTUDK9/eYIXeENUbb0zDsBi5PYc1rmj79U74wCszuih+F/ljrSi/+uud8YBGA10rayqrnfGAVgb6FpZVV3vjAOwPNC1sqq63hkHYGWga2VVdb0XKt/8Rf1fd70zDsB4jmt5u3Tl9a59AMb6v+56ZxyArYGulVXV9c44ABtzXOup/q+73hkH4N2cHio/Rj7r/7rrnXEAfkfuz2Gddb2v3ln/DfpgxneLzaY9xE3l9c46AH8iVyI/Z3Dt8nB/Xc+rd5H5QMy3yJemPVs6zY0edc9HUe/0Z4I/dQ/N5Vjd0oTXKp9QcKFpD2qj3r0YgO1NeRM507TH6/bifeR85IMeV++d+vTBWOV9JDcjt5rdv6uw3M3uRR7pa/Xu+wBsOxA53bTnTP/3UX1b3fNQ1BsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKqyr6d/97HIpchqZLlL8TUyjmxGnnXfo96DGYBRZD1ycpc/XzbmbvcV9e7tAByJPIys7fH3NyI3Ij/0tHrvtL8Hm1E24UXkxATXOB65GHkb+a6/1bsvA3A28jpyaArXOhy5GnluCNS7DwNQXni9jByc4jWXIucijyO/9Lt6Zx6AV92mTFu5Mx2NPNHz6r2QdDOuRU7N8PqXJ3iBN0TV1jvjACxGbs9hnTv6Xr0zDsDqjB6K/1XuSCv6v+56ZxyA0UDXyqrqemccgLWBrpVV1fXOOADLA10rq6rrnXEAVga6VlZV13uh8s1f1P911zvjAIznuJa3S1de79oHYKz/6653xgHYGuhaWVVd74wDsDHHtZ7q/7rrnXEA3s3pofJj5LP+r7veGQfgd+T+HNZZ1/vqnfXfoA9mfLfYbNpD3FRe76wD8CdyJfJzBtcuD/fX9bx6F5kPxHyLfGnas6XT3OhR93wU9U5/JvhT99BcjtUtTXit8gkFF5r2oDbq3YsB2N6UN5EzTXu8bi/eR85HPuhx9d6pTx+MVd5HcjNyq9n9uwrL3exe5JG+Vu++D8C2A5HTTXvO9H8f1bfVPQ9FvQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgCn7C9HjBtwWfXpKAAAAAElFTkSuQmCC"; -const PUBLIC_BACK = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAABS3GwHAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAEZ0FNQQAAsY58+1GTAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAA8VJREFUeNrt3LFLlHEYwPFXz0GiIZpEoikkwsFRIiK3gqCigxIC/4Kmhv6OoChouaGoqKCgCKducGh0cDAIamhwiCaHCIeelztpUszee/vl8/nAM3Vd8nufr+fddVYVAAAAAAAAAAAAAAAAAAAAAABQijFH0KhrMd2Y2ZitmNWYRzHLjkYAB9lUzMOYizv8eS/mZsymoypLxxE0svzvY07vcpu5mOmY145LAAdx+U/u4bZzwx+JPjq2cow7glaWf1vXsQkg6/JvPwoggJTLjwDSL/8nRyiAzN/5nzpGAWRd/n7MM0cpgIzLvx6z6CjL453gdpZ/IWbDcQrA8iMAy48ALD8CsPwIwPIjAMuPACw/ArD8CMDyIwDLjwAsPwKw/AjA8iMAy48ALD8CsPwIwPIjAMuPACw/ArD85A3A8pM2AMtP2gAsP2kDsPykDcDykzYAy0/aACw/aQOw/KQNwPKTNgDLT9oALD9pA7D8pA3A8pM2AMtP2gAsP2kDsPykDcDykzYAy0/aACw/aQOw/KQNwPKTNgDLT9oALD9pA7D8pA3A8pM2AMtP2gAsP2kDsPykDcDykzYAy0/aACw/aQOw/KQNwPLz3xlv6H4mYp5YfrI+AizF9BwnI/AlZi3mbsxy03feaeh+HsQcc60YgSMxMzE3YmZj3sX8LOlHoPoLnHedaEE35n5pzwF856dN9SPBpZICmHRNaNnlkgL46nrQsvmSAqhftlx1TWjR4ZICqPVcE1q0XloA96rBa7XQhl5pAWzFXKm8i8vo9WMeN3VnnQa/sO8xL2POxEy7Toxo+RdjNpu6w1F9HuBqNXi99lw1eKMM9utHzIeYV8MftbccCQAAAAAAsBdt/XLc+sPy9W+MmPqL+1iJuVA1+C4gdFr6d77FvK0GH2nb739lPR5zNuZ51eBnQhFAJQIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIE8M8jmBlGgABSRnAqZiXms+MUQNYIDnkUKMu4I/gj6zELMRv7/PsnHKEAMkcw6fgEkDmCNUcngMwRvHFsngRnfWJcL/9tRyaAgxrB+ZijO9ymH7MUs+m4yjLmCBozEXMr5nr1+9We1ZgXMXccDwAAAAAAAAAAAAAAAAAAAAAAwO5+AfVgtqHKRnawAAAAAElFTkSuQmCC"; -export class ComposeTitleBar extends ViewPU { - constructor(e, t, o, i = -1) { - super(e, o, i); - this.item = void 0; - this.title = void 0; - this.subtitle = void 0; - this.menuItems = void 0; - this.__titleMaxWidth = new ObservedPropertySimplePU(0, this, "titleMaxWidth"); - this.__isItemOnFocus = new ObservedPropertySimplePU(!1, this, "isItemOnFocus"); - this.setInitiallyProvidedValue(t) - } - setInitiallyProvidedValue(e) { - void 0 !== e.item && (this.item = e.item); - void 0 !== e.title && (this.title = e.title); - void 0 !== e.subtitle && (this.subtitle = e.subtitle); - void 0 !== e.menuItems && (this.menuItems = e.menuItems); - void 0 !== e.titleMaxWidth && (this.titleMaxWidth = e.titleMaxWidth); - void 0 !== e.isItemOnFocus && (this.isItemOnFocus = e.isItemOnFocus) - } - updateStateVars(e) {} - purgeVariableDependenciesOnElmtId(e) { - this.__titleMaxWidth.purgeDependencyOnElmtId(e); - this.__isItemOnFocus.purgeDependencyOnElmtId(e) - } - aboutToBeDeleted() { - this.__titleMaxWidth.aboutToBeDeleted(); - this.__isItemOnFocus.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - get titleMaxWidth() { - return this.__titleMaxWidth.get() - } - set titleMaxWidth(e) { - this.__titleMaxWidth.set(e) - } - get isItemOnFocus() { - return this.__isItemOnFocus.get() - } - set isItemOnFocus(e) { - this.__isItemOnFocus.set(e) - } - initialRender() { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Flex.create({ - justifyContent: FlexAlign.SpaceBetween, - alignItems: ItemAlign.Stretch - }); - Flex.width("100%"); - Flex.height(ComposeTitleBar.totalHeight); - Flex.backgroundColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - }); - Flex.onAreaChange(((e, t) => { - let o = Number(t.width); - if (void 0 !== this.menuItems) { - let e = this.menuItems.length; - e >= CollapsibleMenuSection.maxCountOfVisibleItems ? o -= ImageMenuItem.imageHotZoneWidth * CollapsibleMenuSection.maxCountOfVisibleItems : e > 0 && (o -= ImageMenuItem.imageHotZoneWidth * e) - } - this.titleMaxWidth = o; - this.titleMaxWidth -= ComposeTitleBar.leftPadding; - this.titleMaxWidth -= ImageMenuItem.imageHotZoneWidth; - void 0 !== this.item && (this.titleMaxWidth -= ComposeTitleBar.portraitImageLeftPadding + ComposeTitleBar.portraitImageSize + ComposeTitleBar.portraitImageRightPadding); - this.titleMaxWidth -= ComposeTitleBar.rightPadding - })); - t || Flex.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.margin({ - left: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_default_padding_start"], - bundleName: "", - moduleName: "" - } - }); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Navigator.create(); - t || Navigator.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - t ? ViewPU.create(new ImageMenuItem(this, { - item: { - value: PUBLIC_BACK, - isEnabled: !0 - } - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })); - Navigator.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - void 0 !== this.item ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(this.item.value); - Image.width(ComposeTitleBar.portraitImageSize); - Image.height(ComposeTitleBar.portraitImageSize); - Image.margin({ - left: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_paragraph_margin_xs"], - bundleName: "", - moduleName: "" - }, - right: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_paragraph_margin_m"], - bundleName: "", - moduleName: "" - } - }); - Image.focusable(this.item.isEnabled); - Image.borderRadius(ImageMenuItem.buttonBorderRadius); - Image.onFocus((() => this.isItemOnFocus = !0)); - Image.onBlur((() => this.isItemOnFocus = !1)); - Image.border(this.isItemOnFocus ? { - width: ImageMenuItem.focusBorderWidth, - color: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_emphasize"], - bundleName: "", - moduleName: "" - }, - style: BorderStyle.Solid - } : { - width: 0 - }); - Image.onClick((() => this.item.isEnabled && this.item.action && this.item.action())); - t || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })) - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.justifyContent(FlexAlign.Start); - Column.alignItems(HorizontalAlign.Start); - Column.constraintSize({ - maxWidth: this.titleMaxWidth - }); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - void 0 !== this.title ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.justifyContent(FlexAlign.Start); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.title); - Text.fontWeight(FontWeight.Medium); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_headline8"], - bundleName: "", - moduleName: "" - }); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_text"], - bundleName: "", - moduleName: "" - }); - Text.maxLines(void 0 !== this.subtitle ? 1 : 2); - Text.textOverflow({ - overflow: TextOverflow.Ellipsis - }); - Text.constraintSize({ - maxWidth: this.titleMaxWidth - }); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - Row.pop() - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - void 0 !== this.subtitle ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.justifyContent(FlexAlign.Start); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.subtitle); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_over_line"], - bundleName: "", - moduleName: "" - }); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_subtitle_text"], - bundleName: "", - moduleName: "" - }); - Text.maxLines(1); - Text.textOverflow({ - overflow: TextOverflow.Ellipsis - }); - Text.constraintSize({ - maxWidth: this.titleMaxWidth - }); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - Row.pop() - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - Column.pop(); - Row.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - void 0 !== this.menuItems && this.menuItems.length > 0 ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - t ? ViewPU.create(new CollapsibleMenuSection(this, { - menuItems: this.menuItems - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })) - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - Flex.pop() - } - rerender() { - this.updateDirtyElements() - } -} -ComposeTitleBar.totalHeight = 56; -ComposeTitleBar.leftPadding = 12; -ComposeTitleBar.rightPadding = 12; -ComposeTitleBar.portraitImageSize = 40; -ComposeTitleBar.portraitImageLeftPadding = 4; -ComposeTitleBar.portraitImageRightPadding = 16; -class CollapsibleMenuSection extends ViewPU { - constructor(e, t, o, i = -1) { - super(e, o, i); - this.menuItems = void 0; - this.__isPopupShown = new ObservedPropertySimplePU(!1, this, "isPopupShown"); - this.__isMoreIconOnFocus = new ObservedPropertySimplePU(!1, this, "isMoreIconOnFocus"); - this.__isMoreIconOnHover = new ObservedPropertySimplePU(!1, this, "isMoreIconOnHover"); - this.__isMoreIconOnClick = new ObservedPropertySimplePU(!1, this, "isMoreIconOnClick"); - this.setInitiallyProvidedValue(t) - } - setInitiallyProvidedValue(e) { - void 0 !== e.menuItems && (this.menuItems = e.menuItems); - void 0 !== e.isPopupShown && (this.isPopupShown = e.isPopupShown); - void 0 !== e.isMoreIconOnFocus && (this.isMoreIconOnFocus = e.isMoreIconOnFocus); - void 0 !== e.isMoreIconOnHover && (this.isMoreIconOnHover = e.isMoreIconOnHover); - void 0 !== e.isMoreIconOnClick && (this.isMoreIconOnClick = e.isMoreIconOnClick) - } - updateStateVars(e) {} - purgeVariableDependenciesOnElmtId(e) { - this.__isPopupShown.purgeDependencyOnElmtId(e); - this.__isMoreIconOnFocus.purgeDependencyOnElmtId(e); - this.__isMoreIconOnHover.purgeDependencyOnElmtId(e); - this.__isMoreIconOnClick.purgeDependencyOnElmtId(e) - } - aboutToBeDeleted() { - this.__isPopupShown.aboutToBeDeleted(); - this.__isMoreIconOnFocus.aboutToBeDeleted(); - this.__isMoreIconOnHover.aboutToBeDeleted(); - this.__isMoreIconOnClick.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - get isPopupShown() { - return this.__isPopupShown.get() - } - set isPopupShown(e) { - this.__isPopupShown.set(e) - } - get isMoreIconOnFocus() { - return this.__isMoreIconOnFocus.get() - } - set isMoreIconOnFocus(e) { - this.__isMoreIconOnFocus.set(e) - } - get isMoreIconOnHover() { - return this.__isMoreIconOnHover.get() - } - set isMoreIconOnHover(e) { - this.__isMoreIconOnHover.set(e) - } - get isMoreIconOnClick() { - return this.__isMoreIconOnClick.get() - } - set isMoreIconOnClick(e) { - this.__isMoreIconOnClick.set(e) - } - getMoreIconFgColor() { - return this.isMoreIconOnClick ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_icon_pressed"], - bundleName: "", - moduleName: "" - } : { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_icon"], - bundleName: "", - moduleName: "" - } - } - getMoreIconBgColor() { - return this.isMoreIconOnClick ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_click_effect"], - bundleName: "", - moduleName: "" - } : this.isMoreIconOnHover ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - } : Color.Transparent - } - initialRender() { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.height("100%"); - Column.margin({ - right: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_default_padding_end"], - bundleName: "", - moduleName: "" - } - }); - Column.justifyContent(FlexAlign.Center); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.menuItems.length <= CollapsibleMenuSection.maxCountOfVisibleItems ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - ForEach.create(); - this.forEachUpdateFunction(e, this.menuItems, (e => { - const t = e; - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - o ? ViewPU.create(new ImageMenuItem(this, { - item: t - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })) - })); - t || ForEach.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - ForEach.pop() - })) : this.ifElseBranchUpdateFunction(1, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - ForEach.create(); - this.forEachUpdateFunction(e, this.menuItems.slice(0, CollapsibleMenuSection.maxCountOfVisibleItems - 1), (e => { - const t = e; - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - o ? ViewPU.create(new ImageMenuItem(this, { - item: t - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })) - })); - t || ForEach.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - ForEach.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.width(ImageMenuItem.imageHotZoneWidth); - Row.height(ImageMenuItem.imageHotZoneWidth); - Row.borderRadius(ImageMenuItem.buttonBorderRadius); - Row.foregroundColor(this.getMoreIconFgColor()); - Row.backgroundColor(this.getMoreIconBgColor()); - Row.justifyContent(FlexAlign.Center); - Row.border(this.isMoreIconOnFocus ? { - width: ImageMenuItem.focusBorderWidth, - color: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_emphasize"], - bundleName: "", - moduleName: "" - }, - style: BorderStyle.Solid - } : { - width: 0 - }); - Row.onFocus((() => this.isMoreIconOnFocus = !0)); - Row.onBlur((() => this.isMoreIconOnFocus = !1)); - Row.onHover((e => this.isMoreIconOnHover = e)); - Row.onKeyEvent((e => { - if (e.keyCode === KeyCode.KEYCODE_ENTER || e.keyCode === KeyCode.KEYCODE_SPACE) { - e.type === KeyType.Down && (this.isMoreIconOnClick = !0); - e.type === KeyType.Up && (this.isMoreIconOnClick = !1) - } - })); - Row.onTouch((e => { - e.type === TouchType.Down && (this.isMoreIconOnClick = !0); - e.type === TouchType.Up && (this.isMoreIconOnClick = !1) - })); - Row.onClick((() => this.isPopupShown = !0)); - Row.bindPopup(this.isPopupShown, { - builder: { - builder: this.popupBuilder.bind(this) - }, - placement: Placement.Bottom, - popupColor: Color.White, - enableArrow: !1, - onStateChange: e => this.isPopupShown = e.isVisible - }); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(PUBLIC_MORE); - Image.width(ImageMenuItem.imageSize); - Image.height(ImageMenuItem.imageSize); - Image.focusable(!0); - t || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop() - })); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - Row.pop(); - Column.pop() - } - popupBuilder(e = null) { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.width(ImageMenuItem.imageHotZoneWidth + CollapsibleMenuSection.focusPadding * CollapsibleMenuSection.marginsNum); - Column.margin({ - top: CollapsibleMenuSection.focusPadding, - bottom: CollapsibleMenuSection.focusPadding - }); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - ForEach.create(); - this.forEachUpdateFunction(e, this.menuItems.slice(CollapsibleMenuSection.maxCountOfVisibleItems - 1, this.menuItems.length), ((e, t) => { - const o = e; - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - t ? ViewPU.create(new ImageMenuItem(this, { - item: o - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })) - }), void 0, !0, !1); - t || ForEach.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - ForEach.pop(); - Column.pop() - } - rerender() { - this.updateDirtyElements() - } -} -CollapsibleMenuSection.maxCountOfVisibleItems = 3; -CollapsibleMenuSection.focusPadding = 4; -CollapsibleMenuSection.marginsNum = 2; -__decorate([], CollapsibleMenuSection.prototype, "popupBuilder", null); -class ImageMenuItem extends ViewPU { - constructor(e, t, o, i = -1) { - super(e, o, i); - this.item = void 0; - this.__isOnFocus = new ObservedPropertySimplePU(!1, this, "isOnFocus"); - this.__isOnHover = new ObservedPropertySimplePU(!1, this, "isOnHover"); - this.__isOnClick = new ObservedPropertySimplePU(!1, this, "isOnClick"); - this.setInitiallyProvidedValue(t) - } - setInitiallyProvidedValue(e) { - void 0 !== e.item && (this.item = e.item); - void 0 !== e.isOnFocus && (this.isOnFocus = e.isOnFocus); - void 0 !== e.isOnHover && (this.isOnHover = e.isOnHover); - void 0 !== e.isOnClick && (this.isOnClick = e.isOnClick) - } - updateStateVars(e) {} - purgeVariableDependenciesOnElmtId(e) { - this.__isOnFocus.purgeDependencyOnElmtId(e); - this.__isOnHover.purgeDependencyOnElmtId(e); - this.__isOnClick.purgeDependencyOnElmtId(e) - } - aboutToBeDeleted() { - this.__isOnFocus.aboutToBeDeleted(); - this.__isOnHover.aboutToBeDeleted(); - this.__isOnClick.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - get isOnFocus() { - return this.__isOnFocus.get() - } - set isOnFocus(e) { - this.__isOnFocus.set(e) - } - get isOnHover() { - return this.__isOnHover.get() - } - set isOnHover(e) { - this.__isOnHover.set(e) - } - get isOnClick() { - return this.__isOnClick.get() - } - set isOnClick(e) { - this.__isOnClick.set(e) - } - getFgColor() { - return this.isOnClick ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_icon_pressed"], - bundleName: "", - moduleName: "" - } : { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_icon"], - bundleName: "", - moduleName: "" - } - } - getBgColor() { - return this.isOnClick ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_click_effect"], - bundleName: "", - moduleName: "" - } : this.isOnHover ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - } : Color.Transparent - } - initialRender() { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.width(ImageMenuItem.imageHotZoneWidth); - Row.height(ImageMenuItem.imageHotZoneWidth); - Row.borderRadius(ImageMenuItem.buttonBorderRadius); - Row.foregroundColor(this.getFgColor()); - Row.backgroundColor(this.getBgColor()); - Row.justifyContent(FlexAlign.Center); - Row.opacity(this.item.isEnabled ? 1 : ImageMenuItem.disabledImageOpacity); - Row.border(this.isOnFocus ? { - width: ImageMenuItem.focusBorderWidth, - color: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_emphasize"], - bundleName: "", - moduleName: "" - }, - style: BorderStyle.Solid - } : { - width: 0 - }); - Row.onFocus((() => { - this.item.isEnabled && (this.isOnFocus = !0) - })); - Row.onBlur((() => this.isOnFocus = !1)); - Row.onHover((e => { - this.item.isEnabled && (this.isOnHover = e) - })); - Row.onKeyEvent((e => { - if (this.item.isEnabled && (e.keyCode === KeyCode.KEYCODE_ENTER || e.keyCode === KeyCode.KEYCODE_SPACE)) { - e.type === KeyType.Down && (this.isOnClick = !0); - e.type === KeyType.Up && (this.isOnClick = !1) - } - })); - Row.onTouch((e => { - if (this.item.isEnabled) { - e.type === TouchType.Down && (this.isOnClick = !0); - e.type === TouchType.Up && (this.isOnClick = !1) - } - })); - Row.onClick((() => this.item.isEnabled && this.item.action && this.item.action())); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(this.item.value); - Image.width(ImageMenuItem.imageSize); - Image.height(ImageMenuItem.imageSize); - Image.focusable(this.item.isEnabled); - t || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop() - } - rerender() { - this.updateDirtyElements() - } -} -ImageMenuItem.imageSize = 24; -ImageMenuItem.imageHotZoneWidth = 48; -ImageMenuItem.buttonBorderRadius = 8; -ImageMenuItem.focusBorderWidth = 2; -ImageMenuItem.disabledImageOpacity = .4; -export default { - ComposeTitleBar: ComposeTitleBar -}; \ No newline at end of file diff --git a/interface/editabletitlebar/editabletitlebar.cpp b/interface/editabletitlebar/editabletitlebar.cpp deleted file mode 100644 index 2630a0d0c757bc1a66ded4ec3dd7e64f113fbf16..0000000000000000000000000000000000000000 --- a/interface/editabletitlebar/editabletitlebar.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "native_engine/native_engine.h" - -#include "napi/native_api.h" -#include "napi/native_node_api.h" - -extern const char _binary_editabletitlebar_abc_start[]; -extern const char _binary_editabletitlebar_abc_end[]; - -// Napi get abc code function -extern "C" __attribute__((visibility("default"))) -void NAPI_arkui_advanced_EditableTitleBar_GetABCCode(const char **buf, int *buflen) - { - if (buf != nullptr) { - *buf = _binary_editabletitlebar_abc_start; - } - if (buflen != nullptr) { - *buflen = _binary_editabletitlebar_abc_end - _binary_editabletitlebar_abc_start; - } - } - - -static napi_module editabletitlebarModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_modname = "arkui.advanced.EditableTitleBar", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; - -extern "C" __attribute__((constructor)) void editabletitlebarRegisterModule(void) -{ - napi_module_register(&editabletitlebarModule); -} \ No newline at end of file diff --git a/interface/editabletitlebar/editabletitlebar.js b/interface/editabletitlebar/editabletitlebar.js deleted file mode 100644 index d3e9b683b148fd1814140242e79fce36bb7748b7..0000000000000000000000000000000000000000 --- a/interface/editabletitlebar/editabletitlebar.js +++ /dev/null @@ -1,435 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const KeyCode = requireNapi('multimodalInput.keyCode').KeyCode; -export var EditableLeftIconType; -! function(e) { - e[e.Back = 0] = "Back"; - e[e.Cancel = 1] = "Cancel" -}(EditableLeftIconType || (EditableLeftIconType = {})); -const PUBLIC_CANCEL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAABS3GwHAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAEZ0FNQQAAsY58+1GTAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOxAAADsQBlSsOGwAABKpJREFUeNrt3bFrlHccx/Ff4o2dgkOQ4JzR4SYJgksnbYcGOrTQsUPtpE4d/RNcFBeFlg7NUlTSTrXQQgsKGV0KHTs4ODiJSL8PdxaUGJK7pPc893m94TvleZLnnt/7fcc9z5FrDQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAnDQrPTuej2u2a87VvKp5XLNT87OlGiSf1lx6Zz2/q3kkgLdZr7k5lX8/7tZ8XfOCU4OgW887U/n341bN9T6s56menLAfaj464OfdM8iF6XYv+dV7+X+pOX/ANuOatZqHAmjti5prh9jurAgGI//mIbbtIvi15u9FHvBqD07a50fYdqtmt+YDrg1a/jd8tuiD7kMA4yNuL4LlkH+WtV/KAEYz7COC4cs/69ovXQB7M+4ngmHLP8/aL1UAD+bYVwTDlX/etT8W+nAV6M82uQS6PuP+rg4NV/5vBNDa6za5HLY9xzO5CIYl/9OaT5obYf/xrE1uioggQ/6LNf/04QGd6tHJFQH5owMQAfnjAxAB+eMDEAH54wMQAfnjAxAB+eMDEAH54wMQAfnjAxAB+eMDEAH54wMQAfnjAxAB+eMDEAH54wMQAfnjAxAB+eMDEAH54wMQAfnjAxAB+eMDEAH54wMQAfnjAxAB+eMDSI6A/AKIjYD8AoiNgPwCiI2A/AKIjYD8AoiNgPwCiI2A/AKIjYD8AoiNgPwCiI2A/AKIjYD8AoiNgPwCiI2A/AKIjYD8AoiNgPwCiI2A/AKIjYD8AoiNgPwCiI2A/AKIjYD8AoiNgPwCiI1gjfyLY8UpmJnNqbjrc/yO32pOk98rQPIrwWnyCyA5AvILQATkF4AIyC8AEZBfACIgvwBEQH4BiID8J8qqU3BiPJ8O+XuMO8Eng8/2CID85BcA+ckvAPKT35tg8h+n/KP2/3/2SADojfzf1+yKYH7cBxim/N39hWX8RnsBkP9Q8r9BBAKIlV8EAoiXXwQCiJdfBAKIl18EAoiXXwQz4D5A/+Tv2KjZmuPvdfu6T+AVYJDyd3Qfo17Gb7QXAPkPzTMRCCBVfhEIIF5+EQggXn4RCCBefhEIIF5+EQggXn4RCCBefhEIIF5+EQggXn4RCCBefhEIIF5+EQggXn4RCCBefhEIIF5+EQggXn4RCCBefhEIwD+qFUFuAOQXQWwA5BdBbADkF0FsAOQXQWwA5BdBbADkF0FsAOQXQWwA5BdBbADkF0FsAOQXQWwA5BdBbADkF0FsAOQXQWwA5BdBbADkF0FsAOQXQWwA5BdBbADkF0FsAOQXQWwA5BdBdAD3a8bkj4rgTM2PAmjty5or5I+L4FzNHzV/LfKB9OGb4rfJP0iO49xvL/pB9CGAMfljIxgLoLUR+WMjGAmgtT3yx0awJ4DWdsgfG8HOog+6D1eBntR8WLNB/sFzlKtDnfw3BNDa65rfp2+I3hfBo5rL5B9UBFttcoNzP35qk8vfLxZ9sCs9OnHdG6Kvps8e3TXiVzWPp88Ut3k1OLr1vFpz6Z31/LbmntMDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAO/wLvsR65mx80NAAAAABJRU5ErkJggg=="; -const PUBLIC_OK = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAABS3GwHAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAEZ0FNQQAAsY58+1GTAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAA+lJREFUeNrt3bFrFgccx+GLlSDi4JDBITiJZHBwEBGRIoqKoIu6iVMd3OosCg6W0sm/wEFUDDgpCDoIDoqOKqIoHUrp4CDFoUMRB39HLotoeXMpMXff54EfFE0ivv1+kpQGrmkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIBJTHkJGIhddT/V7ajbUPey7l7dlbpPAmCs1tb9Wne2++cvPa07Vfd7nw/+g9eXVT7+m3Wn69Z8421m6w7WXa37KADGNv4TE7ztTN36uvtL/UPWeJ0Z+PgXnejzBwmAMYx/8VuhTQIgcfy9CYCxjP9D3TsBkPqZf95XAFLH3372vyAAEsf/T93Ruvd93tn/CWbo4z9c96jvBxAAseMXANHjFwDR4xcA0eMXANHjFwDR4xcA0eMXANHjFwDR4xcA0eMXANHjFwDR4xcA0eMXANHjFwDR4xcA0eMXANHjFwDR4xcA0eMXANHjFwDR4xcA0eMXANHjFwDR4xcA0eMXANHjFwDR4xcA0eP/HgG0z3f9uVl45uu2ZuGBBu3zXn9rej7mEuMfSgDtA46v1c195ff+rbtU94stGv9KWqnHpLaPsXxSt/k//iXsq9vY9HjUJca/2gNoH2e/c4K32yUC4x9bAOvqrjeTP41GBMY/qgC2151Z4vuIwPhXxEo8I2xdz/c7W3fZXo1/6F8B/q471/N9fSUw/sEH8LEb8hYRGH9iAK3HdafrpkVg/IkBtA8yflt3bBn/3SEC4x9sAK3Xda9EYPypAYjA+OMDEIHxxwcgAuOPD0AExh8fgAiMPz4AERh/fAAiMP74AERg/PEBiMD44wMQgfHHByAC448PQATGHx+ACIw/PgARGH98AMkRGL8AYiMwfgHERmD8AoiNwPgFEBuB8QsgNgLjF0BsBMYvgNgIjF8AsREYvwBiIzB+AcRGYPwCiI3A+AUQG4HxCyA2AuMXQGwExi+A2AiMXwCxERi/AGIjMH4BjDaCTXUP6j59423aJ2PeMH4BjDWCHd24n9f9+cXvHa+7U7fb+Fe/qeC/ezvU+e5bleX40A11pm6u+xapMX5fARK+Eix+u7O1brbp/1Bw4xfAoCP4Pxi/AGIjMH4BxEZg/AKIjcD4BRAbgfELIDYC4xdAbATGL4DYCIxfAIOL4EXdkbrpZX6sd3WH6p56WQUwJG/qbtX92Cz8EFwfD+sO1L31cq4uU16CibU/M3Sy7nzdlgnf51ndxbrbXj4BjCmEPXX76/Y2Cz8DNNP9+l91f3Sf8e92AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAzKZwK1uX4kZ6mnAAAAAElFTkSuQmCC"; -const PUBLIC_BACK = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAABS3GwHAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAEZ0FNQQAAsY58+1GTAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAA8VJREFUeNrt3LFLlHEYwPFXz0GiIZpEoikkwsFRIiK3gqCigxIC/4Kmhv6OoChouaGoqKCgCKducGh0cDAIamhwiCaHCIeelztpUszee/vl8/nAM3Vd8nufr+fddVYVAAAAAAAAAAAAAAAAAAAAAABQijFH0KhrMd2Y2ZitmNWYRzHLjkYAB9lUzMOYizv8eS/mZsymoypLxxE0svzvY07vcpu5mOmY145LAAdx+U/u4bZzwx+JPjq2cow7glaWf1vXsQkg6/JvPwoggJTLjwDSL/8nRyiAzN/5nzpGAWRd/n7MM0cpgIzLvx6z6CjL453gdpZ/IWbDcQrA8iMAy48ALD8CsPwIwPIjAMuPACw/ArD8CMDyIwDLjwAsPwKw/AjA8iMAy48ALD8CsPwIwPIjAMuPACw/ArD85A3A8pM2AMtP2gAsP2kDsPykDcDykzYAy0/aACw/aQOw/KQNwPKTNgDLT9oALD9pA7D8pA3A8pM2AMtP2gAsP2kDsPykDcDykzYAy0/aACw/aQOw/KQNwPKTNgDLT9oALD9pA7D8pA3A8pM2AMtP2gAsP2kDsPykDcDykzYAy0/aACw/aQOw/KQNwPLz3xlv6H4mYp5YfrI+AizF9BwnI/AlZi3mbsxy03feaeh+HsQcc60YgSMxMzE3YmZj3sX8LOlHoPoLnHedaEE35n5pzwF856dN9SPBpZICmHRNaNnlkgL46nrQsvmSAqhftlx1TWjR4ZICqPVcE1q0XloA96rBa7XQhl5pAWzFXKm8i8vo9WMeN3VnnQa/sO8xL2POxEy7Toxo+RdjNpu6w1F9HuBqNXi99lw1eKMM9utHzIeYV8MftbccCQAAAAAAsBdt/XLc+sPy9W+MmPqL+1iJuVA1+C4gdFr6d77FvK0GH2nb739lPR5zNuZ51eBnQhFAJQIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIE8M8jmBlGgABSRnAqZiXms+MUQNYIDnkUKMu4I/gj6zELMRv7/PsnHKEAMkcw6fgEkDmCNUcngMwRvHFsngRnfWJcL/9tRyaAgxrB+ZijO9ymH7MUs+m4yjLmCBozEXMr5nr1+9We1ZgXMXccDwAAAAAAAAAAAAAAAAAAAAAAwO5+AfVgtqHKRnawAAAAAElFTkSuQmCC"; -export class EditableTitleBar extends ViewPU { - constructor(e, t, A, i = -1) { - super(e, A, i); - this.leftIconStyle = void 0; - this.title = void 0; - this.menuItems = void 0; - this.onSave = void 0; - this.onCancel = void 0; - this.__titleMaxWidth = new ObservedPropertySimplePU(0, this, "titleMaxWidth"); - this.setInitiallyProvidedValue(t) - } - setInitiallyProvidedValue(e) { - void 0 !== e.leftIconStyle && (this.leftIconStyle = e.leftIconStyle); - void 0 !== e.title && (this.title = e.title); - void 0 !== e.menuItems && (this.menuItems = e.menuItems); - void 0 !== e.onSave && (this.onSave = e.onSave); - void 0 !== e.onCancel && (this.onCancel = e.onCancel); - void 0 !== e.titleMaxWidth && (this.titleMaxWidth = e.titleMaxWidth) - } - updateStateVars(e) {} - purgeVariableDependenciesOnElmtId(e) { - this.__titleMaxWidth.purgeDependencyOnElmtId(e) - } - aboutToBeDeleted() { - this.__titleMaxWidth.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - get titleMaxWidth() { - return this.__titleMaxWidth.get() - } - set titleMaxWidth(e) { - this.__titleMaxWidth.set(e) - } - initialRender() { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Flex.create({ - justifyContent: FlexAlign.SpaceBetween, - alignItems: ItemAlign.Stretch - }); - Flex.width("100%"); - Flex.height(EditableTitleBar.totalHeight); - Flex.backgroundColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - }); - Flex.onAreaChange(((e, t) => { - let A = Number(t.width); - A = A - EditableTitleBar.leftPadding - EditableTitleBar.rightPadding - EditableTitleBar.titlePadding; - A = A - ImageMenuItem.imageHotZoneWidth - ImageMenuItem.imageHotZoneWidth; - void 0 !== this.menuItems ? this.menuItems.length > EditableTitleBar.maxCountOfExtraItems ? this.titleMaxWidth = A - ImageMenuItem.imageHotZoneWidth * EditableTitleBar.maxCountOfExtraItems : this.titleMaxWidth = A - ImageMenuItem.imageHotZoneWidth * this.menuItems.length : this.titleMaxWidth = A - })); - t || Flex.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.margin({ - left: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_default_padding_start"], - bundleName: "", - moduleName: "" - } - }); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.leftIconStyle == EditableLeftIconType.Back ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Navigator.create(); - t || Navigator.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - t ? ViewPU.create(new ImageMenuItem(this, { - item: { - value: PUBLIC_BACK, - isEnabled: !0 - } - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })); - Navigator.pop() - })) : this.ifElseBranchUpdateFunction(1, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - t ? ViewPU.create(new ImageMenuItem(this, { - item: { - value: PUBLIC_CANCEL, - isEnabled: !0, - action: () => this.onCancel && this.onCancel() - } - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })) - })); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.justifyContent(FlexAlign.Start); - Column.alignItems(HorizontalAlign.Start); - Column.constraintSize({ - maxWidth: this.titleMaxWidth - }); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.title); - Text.fontWeight(FontWeight.Medium); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_headline8"], - bundleName: "", - moduleName: "" - }); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_text"], - bundleName: "", - moduleName: "" - }); - Text.maxLines(1); - Text.textOverflow({ - overflow: TextOverflow.Ellipsis - }); - Text.constraintSize({ - maxWidth: this.titleMaxWidth - }); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - Column.pop(); - Row.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - t ? ViewPU.create(new EditableTitleBarMenuSection(this, { - menuItems: this.menuItems, - onSave: this.onSave - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })); - Flex.pop() - } - rerender() { - this.updateDirtyElements() - } -} -EditableTitleBar.maxCountOfExtraItems = 2; -EditableTitleBar.totalHeight = 56; -EditableTitleBar.leftPadding = 12; -EditableTitleBar.rightPadding = 12; -EditableTitleBar.titlePadding = 16; -class EditableTitleBarMenuSection extends ViewPU { - constructor(e, t, A, i = -1) { - super(e, A, i); - this.menuItems = void 0; - this.onSave = void 0; - this.setInitiallyProvidedValue(t) - } - setInitiallyProvidedValue(e) { - void 0 !== e.menuItems && (this.menuItems = e.menuItems); - void 0 !== e.onSave && (this.onSave = e.onSave) - } - updateStateVars(e) {} - purgeVariableDependenciesOnElmtId(e) {} - aboutToBeDeleted() { - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - initialRender() { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.margin({ - left: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_elements_margin_vertical_l"], - bundleName: "", - moduleName: "" - }, - right: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_default_padding_end"], - bundleName: "", - moduleName: "" - } - }); - Column.justifyContent(FlexAlign.Center); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - void 0 !== this.menuItems && this.menuItems.length > 0 ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - ForEach.create(); - this.forEachUpdateFunction(e, this.menuItems.slice(0, EditableTitleBar.maxCountOfExtraItems), (e => { - const t = e; - this.observeComponentCreation(((e, A) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - A ? ViewPU.create(new ImageMenuItem(this, { - item: t - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })) - })); - t || ForEach.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - ForEach.pop() - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - t ? ViewPU.create(new ImageMenuItem(this, { - item: { - value: PUBLIC_OK, - isEnabled: !0, - action: () => this.onSave && this.onSave() - } - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop(); - Column.pop() - } - rerender() { - this.updateDirtyElements() - } -} -class ImageMenuItem extends ViewPU { - constructor(e, t, A, i = -1) { - super(e, A, i); - this.item = void 0; - this.__isOnFocus = new ObservedPropertySimplePU(!1, this, "isOnFocus"); - this.__isOnHover = new ObservedPropertySimplePU(!1, this, "isOnHover"); - this.__isOnClick = new ObservedPropertySimplePU(!1, this, "isOnClick"); - this.setInitiallyProvidedValue(t) - } - setInitiallyProvidedValue(e) { - void 0 !== e.item && (this.item = e.item); - void 0 !== e.isOnFocus && (this.isOnFocus = e.isOnFocus); - void 0 !== e.isOnHover && (this.isOnHover = e.isOnHover); - void 0 !== e.isOnClick && (this.isOnClick = e.isOnClick) - } - updateStateVars(e) {} - purgeVariableDependenciesOnElmtId(e) { - this.__isOnFocus.purgeDependencyOnElmtId(e); - this.__isOnHover.purgeDependencyOnElmtId(e); - this.__isOnClick.purgeDependencyOnElmtId(e) - } - aboutToBeDeleted() { - this.__isOnFocus.aboutToBeDeleted(); - this.__isOnHover.aboutToBeDeleted(); - this.__isOnClick.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - get isOnFocus() { - return this.__isOnFocus.get() - } - set isOnFocus(e) { - this.__isOnFocus.set(e) - } - get isOnHover() { - return this.__isOnHover.get() - } - set isOnHover(e) { - this.__isOnHover.set(e) - } - get isOnClick() { - return this.__isOnClick.get() - } - set isOnClick(e) { - this.__isOnClick.set(e) - } - getFgColor() { - return this.isOnClick ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_icon_pressed"], - bundleName: "", - moduleName: "" - } : { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_icon"], - bundleName: "", - moduleName: "" - } - } - getBgColor() { - return this.isOnClick ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_click_effect"], - bundleName: "", - moduleName: "" - } : this.isOnHover ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - } : Color.Transparent - } - initialRender() { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.width(ImageMenuItem.imageHotZoneWidth); - Row.height(ImageMenuItem.imageHotZoneWidth); - Row.borderRadius(ImageMenuItem.buttonBorderRadius); - Row.foregroundColor(this.getFgColor()); - Row.backgroundColor(this.getBgColor()); - Row.justifyContent(FlexAlign.Center); - Row.opacity(this.item.isEnabled ? 1 : ImageMenuItem.disabledImageOpacity); - Row.border(this.isOnFocus ? { - width: ImageMenuItem.focusBorderWidth, - color: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_emphasize"], - bundleName: "", - moduleName: "" - }, - style: BorderStyle.Solid - } : { - width: 0 - }); - Row.onFocus((() => { - this.item.isEnabled && (this.isOnFocus = !0) - })); - Row.onBlur((() => this.isOnFocus = !1)); - Row.onHover((e => { - this.item.isEnabled && (this.isOnHover = e) - })); - Row.onKeyEvent((e => { - if (this.item.isEnabled && (e.keyCode === KeyCode.KEYCODE_ENTER || e.keyCode === KeyCode.KEYCODE_SPACE)) { - e.type === KeyType.Down && (this.isOnClick = !0); - e.type === KeyType.Up && (this.isOnClick = !1) - } - })); - Row.onTouch((e => { - if (this.item.isEnabled) { - e.type === TouchType.Down && (this.isOnClick = !0); - e.type === TouchType.Up && (this.isOnClick = !1) - } - })); - Row.onClick((() => this.item.isEnabled && this.item.action && this.item.action())); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(this.item.value); - Image.width(ImageMenuItem.imageSize); - Image.height(ImageMenuItem.imageSize); - Image.focusable(this.item.isEnabled); - t || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop() - } - rerender() { - this.updateDirtyElements() - } -} -ImageMenuItem.imageSize = 24; -ImageMenuItem.imageHotZoneWidth = 48; -ImageMenuItem.buttonBorderRadius = 8; -ImageMenuItem.focusBorderWidth = 2; -ImageMenuItem.disabledImageOpacity = .4; -export default { - EditableLeftIconType: EditableLeftIconType, - EditableTitleBar: EditableTitleBar -}; \ No newline at end of file diff --git a/interface/filter/filter.js b/interface/filter/filter.js deleted file mode 100644 index efb762d647bf544548b05f6d7f0486a026da32ba..0000000000000000000000000000000000000000 --- a/interface/filter/filter.js +++ /dev/null @@ -1,2169 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const curves = requireNativeModule('ohos.curves'); -const measure = requireNapi('measure'); - -var __decorate = this && this.__decorate || function (o, e, t, r) { - var i, s = arguments.length, n = s < 3 ? e : null === r ? r = Object.getOwnPropertyDescriptor(e, t) : r; - if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(o, e, t, r); else for (var a = o.length - 1;a >= 0; a--) (i = o[a]) && (n = (s < 3 ? i(n) : s > 3 ? i(e, t, n) : i(e, t)) || n); - return s > 3 && n && Object.defineProperty(e, t, n), n -}; - -const TEXT_HOT_AREA_WIDTH = 8; -const LIST_ROW_HEIGHT = 40; -const ARROW_IMG_SIZE = 24; -const MULTI_LINE_PADDING = 24; -const BAR_ANIMATION_DURATION = 150; -const ARROW_ANIMATION_DURATION = 200; -const ANIMATION_DURATION_250 = 250; -const ANIMATION_DURATION_100 = 100; -const FILTER_TOP_PADDING = 8; -const SEPARATOR_HEIGHT = 16; -const SEPARATOR_WIDTH = 1; -const FLOAT_OPACITY = .95; -const FILTER_FONT_SIZE = 12; -const FOCUS_BORDER_WIDTH = 2; -const ARROW_SHOW_DELAY = 300; -const PERCENT_100 = "100%"; -const SHARP_CUBIC_BEZIER = curves.cubicBezierCurve(.33, 0, .67, 1); -const INTER_POLATING_SPRING = curves.interpolatingSpring(0, 1, 328, 34); -const FRICTION_CUBIC_BEZIER = curves.cubicBezierCurve(.2, 0, .2, 1); -const TRANS_COLOR = "#00FFFFFF"; -const KEYCODE_SPACE = 2050; -const KEYCODE_ENTER = 2054; - -export var FilterType; -!function(o){ - o[o.MULTI_LINE_FILTER=0] = "MULTI_LINE_FILTER"; - o[o.LIST_FILTER=1] = "LIST_FILTER" -}(FilterType || (FilterType = {})); -let FontWeightArray = class extends Array { -}; -FontWeightArray = __decorate([Observed], FontWeightArray); -let ResourceArray = class extends Array { -}; -ResourceArray = __decorate([Observed], ResourceArray); -let BooleanArray = class extends Array { -}; -BooleanArray = __decorate([Observed], BooleanArray); -let ObservedBoolean = class { - constructor(o) { - this.value = o - } -}; -ObservedBoolean = __decorate([Observed], ObservedBoolean); - -export { ObservedBoolean }; -let ObservedNumber = class { - constructor(o) { - this.value = o - } -}; -ObservedNumber = __decorate([Observed], ObservedNumber); - -class ListFilterRow extends ViewPU { - constructor(o, e, t, r = -1) { - super(o, t, r); - this.__colorRow = new SynchedPropertyNesedObjectPU(e.colorRow, this, "colorRow"); - this.__fontWeightRow = new SynchedPropertyNesedObjectPU(e.fontWeightRow, this, "fontWeightRow"); - this.__backgroundColorRow = new SynchedPropertyNesedObjectPU(e.backgroundColorRow, this, "backgroundColorRow"); - this.__isBackgroundHoverRow = new SynchedPropertyNesedObjectPU(e.isBackgroundHoverRow, this, "isBackgroundHoverRow"); - this.filterRow = void 0; - this.onItemClick = void 0; - this.setInitiallyProvidedValue(e) - } - - setInitiallyProvidedValue(o) { - this.__colorRow.set(o.colorRow); - this.__fontWeightRow.set(o.fontWeightRow); - this.__backgroundColorRow.set(o.backgroundColorRow); - this.__isBackgroundHoverRow.set(o.isBackgroundHoverRow); - void 0 !== o.filterRow && (this.filterRow = o.filterRow); - void 0 !== o.onItemClick && (this.onItemClick = o.onItemClick) - } - - updateStateVars(o) { - this.__colorRow.set(o.colorRow); - this.__fontWeightRow.set(o.fontWeightRow); - this.__backgroundColorRow.set(o.backgroundColorRow); - this.__isBackgroundHoverRow.set(o.isBackgroundHoverRow) - } - - purgeVariableDependenciesOnElmtId(o) { - this.__colorRow.purgeDependencyOnElmtId(o); - this.__fontWeightRow.purgeDependencyOnElmtId(o); - this.__backgroundColorRow.purgeDependencyOnElmtId(o); - this.__isBackgroundHoverRow.purgeDependencyOnElmtId(o) - } - - aboutToBeDeleted() { - this.__colorRow.aboutToBeDeleted(); - this.__fontWeightRow.aboutToBeDeleted(); - this.__backgroundColorRow.aboutToBeDeleted(); - this.__isBackgroundHoverRow.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - - get colorRow() { - return this.__colorRow.get() - } - - get fontWeightRow() { - return this.__fontWeightRow.get() - } - - get backgroundColorRow() { - return this.__backgroundColorRow.get() - } - - get isBackgroundHoverRow() { - return this.__isBackgroundHoverRow.get() - } - - initialRender() { - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - List.create(); - List.listDirection(Axis.Horizontal); - List.margin({ left: -16 }); - List.scrollBar(BarState.Off); - List.width("100%"); - List.height(40); - List.align(Alignment.Start); - e || List.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - ForEach.create(); - this.forEachUpdateFunction(o, this.filterRow.options, ((o, e) => { - const t = o; - { - const o = !0; - const r = (t, r) => { - ViewStackProcessor.StartGetAccessRecordingFor(t); - ListItem.create(s, o); - ListItem.height("100%"); - ListItem.onClick((() => { - this.onItemClick(e) - })); - ListItem.focusable(!0); - ViewStackProcessor.visualState("focused"); - ListItem.border({ - radius: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_clicked"], - bundleName: "", - moduleName: "" - }, - width: 2, - color: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_focused_outline"], - bundleName: "", - moduleName: "" - }, - style: BorderStyle.Solid - }); - ListItem.padding({ left: 6, right: 6 }); - ViewStackProcessor.visualState("normal"); - ListItem.border({ - radius: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_clicked"], - bundleName: "", - moduleName: "" - }, - width: 0 - }); - ListItem.padding({ left: 8, right: 8 }); - ViewStackProcessor.visualState(); - ListItem.backgroundColor(this.isBackgroundHoverRow[e] ? this.backgroundColorRow[e] : "#00FFFFFF"); - ListItem.onHover((o => { - Context.animateTo({ curve: FRICTION_CUBIC_BEZIER, duration: 250 }, (() => { - if (o) { - this.backgroundColorRow[e] = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - }; - this.isBackgroundHoverRow[e] = !0 - } else this.isBackgroundHoverRow[e] = !1 - })) - })); - ListItem.onTouch((o => { - o.type === TouchType.Down ? Context.animateTo({ curve: SHARP_CUBIC_BEZIER, duration: 100 }, (() => { - this.backgroundColorRow[e] = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_click_effect"], - bundleName: "", - moduleName: "" - }; - this.isBackgroundHoverRow[e] = !0 - })) : o.type === TouchType.Up && Context.animateTo({ curve: SHARP_CUBIC_BEZIER, duration: 100 }, (() => { - this.isBackgroundHoverRow[e] = !1 - })) - })); - r || ListItem.pop(); - ViewStackProcessor.StopGetAccessRecording() - }; - const i = () => { - this.observeComponentCreation(r); - this.observeComponentCreation(((o, r) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Text.create(t.toString()); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body3"], - bundleName: "", - moduleName: "" - }); - Text.fontColor(this.colorRow[e]); - Text.fontWeight(this.fontWeightRow[e]); - Text.focusable(!0); - r || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - ListItem.pop() - }; - const s = (o, i) => { - r(o, i); - this.updateFuncByElmtId.set(o, r); - this.observeComponentCreation(((o, r) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Text.create(t.toString()); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body3"], - bundleName: "", - moduleName: "" - }); - Text.fontColor(this.colorRow[e]); - Text.fontWeight(this.fontWeightRow[e]); - Text.focusable(!0); - r || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - ListItem.pop() - }; - o ? (() => { - this.observeComponentCreation(r); - ListItem.pop() - })() : i() - } - }), void 0,!0,!1); - e || ForEach.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - ForEach.pop(); - List.pop() - } - - rerender() { - this.updateDirtyElements() - } -} - -class MultiFilterRow extends ViewPU { - constructor(o, e, t, r = -1) { - super(o, t, r); - this.__colorRow = new SynchedPropertyNesedObjectPU(e.colorRow, this, "colorRow"); - this.__fontWeightRow = new SynchedPropertyNesedObjectPU(e.fontWeightRow, this, "fontWeightRow"); - this.__backgroundColorRow = new SynchedPropertyNesedObjectPU(e.backgroundColorRow, this, "backgroundColorRow"); - this.__isBackgroundHoverRow = new SynchedPropertyNesedObjectPU(e.isBackgroundHoverRow, this, "isBackgroundHoverRow"); - this.__twoLineModeItemNumRow = new SynchedPropertyNesedObjectPU(e.twoLineModeItemNumRow, this, "twoLineModeItemNumRow"); - this.__twoLineModeItemNumRecordRow = new SynchedPropertyNesedObjectPU(e.twoLineModeItemNumRecordRow, this, "twoLineModeItemNumRecordRow"); - this.__arrowShowStateRow = new SynchedPropertyNesedObjectPU(e.arrowShowStateRow, this, "arrowShowStateRow"); - this.__isArrowIconDown = new SynchedPropertyNesedObjectPU(e.isArrowIconDown, this, "isArrowIconDown"); - this.filterRow = null; - this.onItemClick = void 0; - this.__arrowBgColorRow = new ObservedPropertyObjectPU({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - }, this, "arrowBgColorRow"); - this.__isArrowBgHoverRow = new ObservedPropertySimplePU(!1, this, "isArrowBgHoverRow"); - this.filterColumnWidth = 0; - this.setInitiallyProvidedValue(e) - } - - setInitiallyProvidedValue(o) { - this.__colorRow.set(o.colorRow); - this.__fontWeightRow.set(o.fontWeightRow); - this.__backgroundColorRow.set(o.backgroundColorRow); - this.__isBackgroundHoverRow.set(o.isBackgroundHoverRow); - this.__twoLineModeItemNumRow.set(o.twoLineModeItemNumRow); - this.__twoLineModeItemNumRecordRow.set(o.twoLineModeItemNumRecordRow); - this.__arrowShowStateRow.set(o.arrowShowStateRow); - this.__isArrowIconDown.set(o.isArrowIconDown); - void 0 !== o.filterRow && (this.filterRow = o.filterRow); - void 0 !== o.onItemClick && (this.onItemClick = o.onItemClick); - void 0 !== o.arrowBgColorRow && (this.arrowBgColorRow = o.arrowBgColorRow); - void 0 !== o.isArrowBgHoverRow && (this.isArrowBgHoverRow = o.isArrowBgHoverRow); - void 0 !== o.filterColumnWidth && (this.filterColumnWidth = o.filterColumnWidth) - } - - updateStateVars(o) { - this.__colorRow.set(o.colorRow); - this.__fontWeightRow.set(o.fontWeightRow); - this.__backgroundColorRow.set(o.backgroundColorRow); - this.__isBackgroundHoverRow.set(o.isBackgroundHoverRow); - this.__twoLineModeItemNumRow.set(o.twoLineModeItemNumRow); - this.__twoLineModeItemNumRecordRow.set(o.twoLineModeItemNumRecordRow); - this.__arrowShowStateRow.set(o.arrowShowStateRow); - this.__isArrowIconDown.set(o.isArrowIconDown) - } - - purgeVariableDependenciesOnElmtId(o) { - this.__colorRow.purgeDependencyOnElmtId(o); - this.__fontWeightRow.purgeDependencyOnElmtId(o); - this.__backgroundColorRow.purgeDependencyOnElmtId(o); - this.__isBackgroundHoverRow.purgeDependencyOnElmtId(o); - this.__twoLineModeItemNumRow.purgeDependencyOnElmtId(o); - this.__twoLineModeItemNumRecordRow.purgeDependencyOnElmtId(o); - this.__arrowShowStateRow.purgeDependencyOnElmtId(o); - this.__isArrowIconDown.purgeDependencyOnElmtId(o); - this.__arrowBgColorRow.purgeDependencyOnElmtId(o); - this.__isArrowBgHoverRow.purgeDependencyOnElmtId(o) - } - - aboutToBeDeleted() { - this.__colorRow.aboutToBeDeleted(); - this.__fontWeightRow.aboutToBeDeleted(); - this.__backgroundColorRow.aboutToBeDeleted(); - this.__isBackgroundHoverRow.aboutToBeDeleted(); - this.__twoLineModeItemNumRow.aboutToBeDeleted(); - this.__twoLineModeItemNumRecordRow.aboutToBeDeleted(); - this.__arrowShowStateRow.aboutToBeDeleted(); - this.__isArrowIconDown.aboutToBeDeleted(); - this.__arrowBgColorRow.aboutToBeDeleted(); - this.__isArrowBgHoverRow.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - - get colorRow() { - return this.__colorRow.get() - } - - get fontWeightRow() { - return this.__fontWeightRow.get() - } - - get backgroundColorRow() { - return this.__backgroundColorRow.get() - } - - get isBackgroundHoverRow() { - return this.__isBackgroundHoverRow.get() - } - - get twoLineModeItemNumRow() { - return this.__twoLineModeItemNumRow.get() - } - - get twoLineModeItemNumRecordRow() { - return this.__twoLineModeItemNumRecordRow.get() - } - - get arrowShowStateRow() { - return this.__arrowShowStateRow.get() - } - - get isArrowIconDown() { - return this.__isArrowIconDown.get() - } - - get arrowBgColorRow() { - return this.__arrowBgColorRow.get() - } - - set arrowBgColorRow(o) { - this.__arrowBgColorRow.set(o) - } - - get isArrowBgHoverRow() { - return this.__isArrowBgHoverRow.get() - } - - set isArrowBgHoverRow(o) { - this.__isArrowBgHoverRow.set(o) - } - - calcMultiFilterRowItemNum() { - var o = this.filterColumnWidth - vp2px(24); - var e = 0; - var t = 1; - for (var r = 0;r < this.filterRow.options.length; r++) { - let i = this.filterRow.options[r]; - let s = measure.measureText({ textContent: i, fontSize: 12 }); - if (0 !== r) { - s += vp2px(16); - if (o - s > 0) { - o -= s; - e += 1 - } else { - if (0 === e) { - e++; - o = 0 - } - if (1 !== t) break; - t += 1; - o = this.filterColumnWidth - vp2px(24) - vp2px(24); - r-- - } - } - } - return e - } - - DownAndUpArrow(o = null) { - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Row.create(); - Row.border({ - radius: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_clicked"], - bundleName: "", - moduleName: "" - } - }); - Row.height(40); - Row.width(24); - Row.backgroundColor(this.isArrowBgHoverRow ? this.arrowBgColorRow : "#00FFFFFF"); - Row.focusable(!0); - Row.visibility(this.arrowShowStateRow.value ? Visibility.Visible : Visibility.Hidden); - Row.onHover((o => { - Context.animateTo({ curve: FRICTION_CUBIC_BEZIER, duration: 250 }, (() => { - if (o) { - this.arrowBgColorRow = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - }; - this.isArrowBgHoverRow = !0 - } else this.isArrowBgHoverRow = !1 - })) - })); - Row.onTouch((o => { - o.type === TouchType.Down ? Context.animateTo({ curve: SHARP_CUBIC_BEZIER, duration: 100 }, (() => { - this.arrowBgColorRow = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_click_effect"], - bundleName: "", - moduleName: "" - }; - this.isArrowBgHoverRow = !0 - })) : o.type === TouchType.Up && Context.animateTo({ curve: SHARP_CUBIC_BEZIER, duration: 100 }, (() => { - this.isArrowBgHoverRow = !1 - })) - })); - Row.onClick((() => { - if (this.isArrowIconDown.value) { - this.isArrowIconDown.value = !1; - this.arrowShowStateRow.value = !1; - Context.animateTo({ curve: INTER_POLATING_SPRING }, (() => { - this.twoLineModeItemNumRow.value = this.filterRow.options.length - })); - Context.animateTo({ delay: 300, duration: 200, curve: SHARP_CUBIC_BEZIER }, (() => { - this.arrowShowStateRow.value = !0 - })) - } else { - this.isArrowIconDown.value = !0; - this.arrowShowStateRow.value = !1; - Context.animateTo({ curve: INTER_POLATING_SPRING }, (() => { - this.twoLineModeItemNumRow.value = this.twoLineModeItemNumRecordRow.value - })); - Context.animateTo({ delay: 300, duration: 200, curve: SHARP_CUBIC_BEZIER }, (() => { - this.arrowShowStateRow.value = !0 - })) - } - })); - e || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Image.create(this.isArrowIconDown.value ? { - id: -1, - type: 2e4, - params: ["sys.media.ohos_ic_public_arrow_down"], - bundleName: "", - moduleName: "" - } : { - id: -1, - type: 2e4, - params: ["sys.media.ohos_ic_public_arrow_up"], - bundleName: "", - moduleName: "" - }); - Image.width(24); - Image.height(40); - Image.fillColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_tertiary"], - bundleName: "", - moduleName: "" - }); - Image.focusable(!0); - ViewStackProcessor.visualState("focused"); - Image.border({ - radius: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_clicked"], - bundleName: "", - moduleName: "" - }, - width: 2, - color: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_focused_outline"], - bundleName: "", - moduleName: "" - }, - style: BorderStyle.Solid - }); - Image.width(28); - Image.offset({ x: -2 }); - ViewStackProcessor.visualState("normal"); - Image.border({ - radius: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_clicked"], - bundleName: "", - moduleName: "" - }, - width: 0 - }); - Image.width(24); - Image.offset({ x: 0 }); - ViewStackProcessor.visualState(); - e || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop() - } - - initialRender() { - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Row.create(); - Row.width("100%"); - Row.alignItems(VerticalAlign.Top); - Row.padding({ - left: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_max_padding_start"], - bundleName: "", - moduleName: "" - }, - right: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_max_padding_end"], - bundleName: "", - moduleName: "" - } - }); - e || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - If.create(); - this.filterRow.options && this.filterRow.options.length > 0 ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Text.create(this.filterRow.options[0].toString()); - Text.height(40); - Text.width(px2vp(measure.measureText({ - textContent: this.filterRow.options[0].toString(), - fontSize: 12 - })) + 16); - Text.margin({ left: -8 }); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body3"], - bundleName: "", - moduleName: "" - }); - Text.fontColor(this.colorRow[0]); - Text.fontWeight(this.fontWeightRow[0]); - Text.backgroundColor(this.isBackgroundHoverRow[0] ? this.backgroundColorRow[0] : "#00FFFFFF"); - Text.onClick((() => { - this.onItemClick(0) - })); - Text.focusable(!0); - Text.onHover((o => { - Context.animateTo({ curve: FRICTION_CUBIC_BEZIER, duration: 250 }, (() => { - if (o) { - this.backgroundColorRow[0] = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - }; - this.isBackgroundHoverRow[0] = !0 - } else this.isBackgroundHoverRow[0] = !1 - })) - })); - Text.onTouch((o => { - o.type === TouchType.Down ? Context.animateTo({ curve: SHARP_CUBIC_BEZIER, duration: 100 }, (() => { - this.backgroundColorRow[0] = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_click_effect"], - bundleName: "", - moduleName: "" - }; - this.isBackgroundHoverRow[0] = !0 - })) : o.type === TouchType.Up && Context.animateTo({ curve: SHARP_CUBIC_BEZIER, duration: 100 }, (() => { - this.isBackgroundHoverRow[0] = !1 - })) - })); - ViewStackProcessor.visualState("focused"); - Text.border({ - radius: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_clicked"], - bundleName: "", - moduleName: "" - }, - width: 2, - color: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_focused_outline"], - bundleName: "", - moduleName: "" - }, - style: BorderStyle.Solid - }); - Text.padding({ left: 6, right: 6 }); - ViewStackProcessor.visualState("normal"); - Text.border({ - radius: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_clicked"], - bundleName: "", - moduleName: "" - }, - width: 0 - }); - Text.padding({ left: 8, right: 8 }); - ViewStackProcessor.visualState(); - e || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop() - })) : If.branchId(1); - e || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Row.create(); - Row.width("100%"); - Row.padding({ - right: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_max_padding_end"], - bundleName: "", - moduleName: "" - } - }); - Row.onAreaChange(((o, e) => { - this.filterColumnWidth = vp2px(parseInt(e.width.toString(), 0)); - if (0 === this.twoLineModeItemNumRow.value) { - var t = this.calcMultiFilterRowItemNum(); - this.twoLineModeItemNumRow.value = t; - this.twoLineModeItemNumRecordRow.value = t; - t < this.filterRow.options.length - 1 ? this.arrowShowStateRow.value = !0 : this.arrowShowStateRow.value = !1 - } - })); - e || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Flex.create({ direction: FlexDirection.Row, wrap: FlexWrap.Wrap }); - Flex.alignSelf(ItemAlign.Stretch); - e || Flex.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - ForEach.create(); - this.forEachUpdateFunction(o, this.filterRow.options.slice(0, this.twoLineModeItemNumRow.value + 1), ((o, e) => { - const t = o; - this.observeComponentCreation(((o, r) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - If.create(); - e > 0 ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((o, r) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Text.create(t.toString()); - Text.transition(TransitionEffect.OPACITY); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body3"], - bundleName: "", - moduleName: "" - }); - Text.height(40); - Text.fontColor(this.colorRow[e]); - Text.fontWeight(this.fontWeightRow[e]); - Text.backgroundColor(this.isBackgroundHoverRow[e] ? this.backgroundColorRow[e] : "#00FFFFFF"); - Text.onClick((() => { - this.onItemClick(e) - })); - Text.onHover((o => { - Context.animateTo({ curve: FRICTION_CUBIC_BEZIER, duration: 250 }, (() => { - if (o) { - this.backgroundColorRow[e] = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - }; - this.isBackgroundHoverRow[e] = !0 - } else this.isBackgroundHoverRow[e] = !1 - })) - })); - Text.onTouch((o => { - o.type === TouchType.Down ? Context.animateTo({ curve: SHARP_CUBIC_BEZIER, duration: 100 }, (() => { - this.backgroundColorRow[e] = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_click_effect"], - bundleName: "", - moduleName: "" - }; - this.isBackgroundHoverRow[e] = !0 - })) : o.type === TouchType.Up && Context.animateTo({ - curve: SHARP_CUBIC_BEZIER, - duration: 100 - }, (() => { - this.isBackgroundHoverRow[e] = !1 - })) - })); - Text.focusable(!0); - ViewStackProcessor.visualState("focused"); - Text.border({ - radius: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_clicked"], - bundleName: "", - moduleName: "" - }, - width: 2, - color: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_focused_outline"], - bundleName: "", - moduleName: "" - }, - style: BorderStyle.Solid - }); - Text.padding({ left: 6, right: 6 }); - ViewStackProcessor.visualState("normal"); - Text.border({ - radius: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_clicked"], - bundleName: "", - moduleName: "" - }, - width: 0 - }); - Text.padding({ left: 8, right: 8 }); - ViewStackProcessor.visualState(); - r || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop() - })) : If.branchId(1); - r || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop() - }), void 0,!0,!1); - e || ForEach.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - ForEach.pop(); - this.DownAndUpArrow.bind(this)(); - Flex.pop(); - Row.pop(); - Row.pop() - } - - rerender() { - this.updateDirtyElements() - } -} - -export class Filter extends ViewPU { - constructor(o, e, t, r = -1) { - super(o, t, r); - this.container = void 0; - this.__multiFilters = new SynchedPropertyObjectOneWayPU(e.multiFilters, this, "multiFilters"); - this.__additionFilters = new SynchedPropertyObjectOneWayPU(e.additionFilters, this, "additionFilters"); - this.onFilterChanged = null; - this.__filterType = new SynchedPropertySimpleOneWayPU(e.filterType, this, "filterType"); - this.selectedFilters = null; - this.__colorArr = new ObservedPropertyObjectPU(null, this, "colorArr"); - this.__fontWeightArr = new ObservedPropertyObjectPU(null, this, "fontWeightArr"); - this.__backgroundColorArr = new ObservedPropertyObjectPU(null, this, "backgroundColorArr"); - this.__isBackgroundHover = new ObservedPropertyObjectPU(null, this, "isBackgroundHover"); - this.__floatArrowBgColor = new ObservedPropertyObjectPU(null, this, "floatArrowBgColor"); - this.__isFloatArrowBgHover = new ObservedPropertySimplePU(!1, this, "isFloatArrowBgHover"); - this.__isArrowIconDownArr = new ObservedPropertyObjectPU(null, this, "isArrowIconDownArr"); - this.__additionColorArr = new ObservedPropertyObjectPU(null, this, "additionColorArr"); - this.__additionFontWeightArr = new ObservedPropertyObjectPU(null, this, "additionFontWeightArr"); - this.__additionBackgroundColorArr = new ObservedPropertyObjectPU(null, this, "additionBackgroundColorArr"); - this.__isAdditionBackgroundHover = new ObservedPropertyObjectPU(null, this, "isAdditionBackgroundHover"); - this.__colorRefresh = new ObservedPropertySimplePU(!1, this, "colorRefresh"); - this.__isFloatBarShow = new ObservedPropertySimplePU(!1, this, "isFloatBarShow"); - this.isFloatBarShowWithoutAnimation = !1; - this.__isFloatShowAllFilter = new ObservedPropertySimplePU(!1, this, "isFloatShowAllFilter"); - this.isFloatShowAllFilterWithoutAnimation = !1; - this.__floatFilterPosition = new ObservedPropertySimplePU(0, this, "floatFilterPosition"); - this.__floatFilterBarHeight = new ObservedPropertySimplePU(0, this, "floatFilterBarHeight"); - this.__floatFilterBarPosition = new ObservedPropertySimplePU(0, this, "floatFilterBarPosition"); - this.filterDynamicHeight = 0; - this.__twoLineModeItemNum = new ObservedPropertyObjectPU(null, this, "twoLineModeItemNum"); - this.__twoLineModeItemNumRecord = new ObservedPropertyObjectPU(null, this, "twoLineModeItemNumRecord"); - this.__downArrowShowState = new ObservedPropertyObjectPU(null, this, "downArrowShowState"); - this.listScroller = new Scroller; - this.setInitiallyProvidedValue(e) - } - - setInitiallyProvidedValue(o) { - void 0 !== o.container && (this.container = o.container); - void 0 !== o.multiFilters ? this.__multiFilters.set(o.multiFilters) : this.__multiFilters.set([]); - void 0 !== o.additionFilters ? this.__additionFilters.set(o.additionFilters) : this.__additionFilters.set(null); - void 0 !== o.onFilterChanged && (this.onFilterChanged = o.onFilterChanged); - void 0 !== o.filterType ? this.__filterType.set(o.filterType) : this.__filterType.set(FilterType.LIST_FILTER); - void 0 !== o.selectedFilters && (this.selectedFilters = o.selectedFilters); - void 0 !== o.colorArr && (this.colorArr = o.colorArr); - void 0 !== o.fontWeightArr && (this.fontWeightArr = o.fontWeightArr); - void 0 !== o.backgroundColorArr && (this.backgroundColorArr = o.backgroundColorArr); - void 0 !== o.isBackgroundHover && (this.isBackgroundHover = o.isBackgroundHover); - void 0 !== o.floatArrowBgColor && (this.floatArrowBgColor = o.floatArrowBgColor); - void 0 !== o.isFloatArrowBgHover && (this.isFloatArrowBgHover = o.isFloatArrowBgHover); - void 0 !== o.isArrowIconDownArr && (this.isArrowIconDownArr = o.isArrowIconDownArr); - void 0 !== o.additionColorArr && (this.additionColorArr = o.additionColorArr); - void 0 !== o.additionFontWeightArr && (this.additionFontWeightArr = o.additionFontWeightArr); - void 0 !== o.additionBackgroundColorArr && (this.additionBackgroundColorArr = o.additionBackgroundColorArr); - void 0 !== o.isAdditionBackgroundHover && (this.isAdditionBackgroundHover = o.isAdditionBackgroundHover); - void 0 !== o.colorRefresh && (this.colorRefresh = o.colorRefresh); - void 0 !== o.isFloatBarShow && (this.isFloatBarShow = o.isFloatBarShow); - void 0 !== o.isFloatBarShowWithoutAnimation && (this.isFloatBarShowWithoutAnimation = o.isFloatBarShowWithoutAnimation); - void 0 !== o.isFloatShowAllFilter && (this.isFloatShowAllFilter = o.isFloatShowAllFilter); - void 0 !== o.isFloatShowAllFilterWithoutAnimation && (this.isFloatShowAllFilterWithoutAnimation = o.isFloatShowAllFilterWithoutAnimation); - void 0 !== o.floatFilterPosition && (this.floatFilterPosition = o.floatFilterPosition); - void 0 !== o.floatFilterBarHeight && (this.floatFilterBarHeight = o.floatFilterBarHeight); - void 0 !== o.floatFilterBarPosition && (this.floatFilterBarPosition = o.floatFilterBarPosition); - void 0 !== o.filterDynamicHeight && (this.filterDynamicHeight = o.filterDynamicHeight); - void 0 !== o.twoLineModeItemNum && (this.twoLineModeItemNum = o.twoLineModeItemNum); - void 0 !== o.twoLineModeItemNumRecord && (this.twoLineModeItemNumRecord = o.twoLineModeItemNumRecord); - void 0 !== o.downArrowShowState && (this.downArrowShowState = o.downArrowShowState); - void 0 !== o.listScroller && (this.listScroller = o.listScroller) - } - - updateStateVars(o) { - this.__multiFilters.reset(o.multiFilters); - this.__additionFilters.reset(o.additionFilters); - this.__filterType.reset(o.filterType) - } - - purgeVariableDependenciesOnElmtId(o) { - this.__multiFilters.purgeDependencyOnElmtId(o); - this.__additionFilters.purgeDependencyOnElmtId(o); - this.__filterType.purgeDependencyOnElmtId(o); - this.__colorArr.purgeDependencyOnElmtId(o); - this.__fontWeightArr.purgeDependencyOnElmtId(o); - this.__backgroundColorArr.purgeDependencyOnElmtId(o); - this.__isBackgroundHover.purgeDependencyOnElmtId(o); - this.__floatArrowBgColor.purgeDependencyOnElmtId(o); - this.__isFloatArrowBgHover.purgeDependencyOnElmtId(o); - this.__isArrowIconDownArr.purgeDependencyOnElmtId(o); - this.__additionColorArr.purgeDependencyOnElmtId(o); - this.__additionFontWeightArr.purgeDependencyOnElmtId(o); - this.__additionBackgroundColorArr.purgeDependencyOnElmtId(o); - this.__isAdditionBackgroundHover.purgeDependencyOnElmtId(o); - this.__colorRefresh.purgeDependencyOnElmtId(o); - this.__isFloatBarShow.purgeDependencyOnElmtId(o); - this.__isFloatShowAllFilter.purgeDependencyOnElmtId(o); - this.__floatFilterPosition.purgeDependencyOnElmtId(o); - this.__floatFilterBarHeight.purgeDependencyOnElmtId(o); - this.__floatFilterBarPosition.purgeDependencyOnElmtId(o); - this.__twoLineModeItemNum.purgeDependencyOnElmtId(o); - this.__twoLineModeItemNumRecord.purgeDependencyOnElmtId(o); - this.__downArrowShowState.purgeDependencyOnElmtId(o) - } - - aboutToBeDeleted() { - this.__multiFilters.aboutToBeDeleted(); - this.__additionFilters.aboutToBeDeleted(); - this.__filterType.aboutToBeDeleted(); - this.__colorArr.aboutToBeDeleted(); - this.__fontWeightArr.aboutToBeDeleted(); - this.__backgroundColorArr.aboutToBeDeleted(); - this.__isBackgroundHover.aboutToBeDeleted(); - this.__floatArrowBgColor.aboutToBeDeleted(); - this.__isFloatArrowBgHover.aboutToBeDeleted(); - this.__isArrowIconDownArr.aboutToBeDeleted(); - this.__additionColorArr.aboutToBeDeleted(); - this.__additionFontWeightArr.aboutToBeDeleted(); - this.__additionBackgroundColorArr.aboutToBeDeleted(); - this.__isAdditionBackgroundHover.aboutToBeDeleted(); - this.__colorRefresh.aboutToBeDeleted(); - this.__isFloatBarShow.aboutToBeDeleted(); - this.__isFloatShowAllFilter.aboutToBeDeleted(); - this.__floatFilterPosition.aboutToBeDeleted(); - this.__floatFilterBarHeight.aboutToBeDeleted(); - this.__floatFilterBarPosition.aboutToBeDeleted(); - this.__twoLineModeItemNum.aboutToBeDeleted(); - this.__twoLineModeItemNumRecord.aboutToBeDeleted(); - this.__downArrowShowState.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - - get multiFilters() { - return this.__multiFilters.get() - } - - set multiFilters(o) { - this.__multiFilters.set(o) - } - - get additionFilters() { - return this.__additionFilters.get() - } - - set additionFilters(o) { - this.__additionFilters.set(o) - } - - get filterType() { - return this.__filterType.get() - } - - set filterType(o) { - this.__filterType.set(o) - } - - get colorArr() { - return this.__colorArr.get() - } - - set colorArr(o) { - this.__colorArr.set(o) - } - - get fontWeightArr() { - return this.__fontWeightArr.get() - } - - set fontWeightArr(o) { - this.__fontWeightArr.set(o) - } - - get backgroundColorArr() { - return this.__backgroundColorArr.get() - } - - set backgroundColorArr(o) { - this.__backgroundColorArr.set(o) - } - - get isBackgroundHover() { - return this.__isBackgroundHover.get() - } - - set isBackgroundHover(o) { - this.__isBackgroundHover.set(o) - } - - get floatArrowBgColor() { - return this.__floatArrowBgColor.get() - } - - set floatArrowBgColor(o) { - this.__floatArrowBgColor.set(o) - } - - get isFloatArrowBgHover() { - return this.__isFloatArrowBgHover.get() - } - - set isFloatArrowBgHover(o) { - this.__isFloatArrowBgHover.set(o) - } - - get isArrowIconDownArr() { - return this.__isArrowIconDownArr.get() - } - - set isArrowIconDownArr(o) { - this.__isArrowIconDownArr.set(o) - } - - get additionColorArr() { - return this.__additionColorArr.get() - } - - set additionColorArr(o) { - this.__additionColorArr.set(o) - } - - get additionFontWeightArr() { - return this.__additionFontWeightArr.get() - } - - set additionFontWeightArr(o) { - this.__additionFontWeightArr.set(o) - } - - get additionBackgroundColorArr() { - return this.__additionBackgroundColorArr.get() - } - - set additionBackgroundColorArr(o) { - this.__additionBackgroundColorArr.set(o) - } - - get isAdditionBackgroundHover() { - return this.__isAdditionBackgroundHover.get() - } - - set isAdditionBackgroundHover(o) { - this.__isAdditionBackgroundHover.set(o) - } - - get colorRefresh() { - return this.__colorRefresh.get() - } - - set colorRefresh(o) { - this.__colorRefresh.set(o) - } - - get isFloatBarShow() { - return this.__isFloatBarShow.get() - } - - set isFloatBarShow(o) { - this.__isFloatBarShow.set(o) - } - - get isFloatShowAllFilter() { - return this.__isFloatShowAllFilter.get() - } - - set isFloatShowAllFilter(o) { - this.__isFloatShowAllFilter.set(o) - } - - get floatFilterPosition() { - return this.__floatFilterPosition.get() - } - - set floatFilterPosition(o) { - this.__floatFilterPosition.set(o) - } - - get floatFilterBarHeight() { - return this.__floatFilterBarHeight.get() - } - - set floatFilterBarHeight(o) { - this.__floatFilterBarHeight.set(o) - } - - get floatFilterBarPosition() { - return this.__floatFilterBarPosition.get() - } - - set floatFilterBarPosition(o) { - this.__floatFilterBarPosition.set(o) - } - - get twoLineModeItemNum() { - return this.__twoLineModeItemNum.get() - } - - set twoLineModeItemNum(o) { - this.__twoLineModeItemNum.set(o) - } - - get twoLineModeItemNumRecord() { - return this.__twoLineModeItemNumRecord.get() - } - - set twoLineModeItemNumRecord(o) { - this.__twoLineModeItemNumRecord.set(o) - } - - get downArrowShowState() { - return this.__downArrowShowState.get() - } - - set downArrowShowState(o) { - this.__downArrowShowState.set(o) - } - - textColor(o, e) { - return this.selectedFilters.length > o && this.selectedFilters[o].index === e ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary_activated"], - bundleName: "", - moduleName: "" - } : { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary"], - bundleName: "", - moduleName: "" - } - } - - aboutToAppear() { - this.initParams() - } - - filterItemClick(o, e) { - let t = this.multiFilters[o].options[e]; - if (e != this.selectedFilters[o].index) { - this.colorArr[o][e] = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary_activated"], - bundleName: "", - moduleName: "" - }; - this.colorArr[o][this.selectedFilters[o].index] = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary"], - bundleName: "", - moduleName: "" - }; - this.fontWeightArr[o][e] = FontWeight.Medium; - this.fontWeightArr[o][this.selectedFilters[o].index] = FontWeight.Regular; - this.colorRefresh = !this.colorRefresh; - this.selectedFilters[o].value = t; - this.selectedFilters[o].index = e; - this.onFilterChanged && this.onFilterChanged(this.selectedFilters) - } - } - - initParams() { - if (!this.selectedFilters) { - this.selectedFilters = []; - for (let e of this.multiFilters) { - var o = { name: e.name, index: -1, value: null }; - if (e.options.length > 0) { - o.index = 0; - o.value = e.options[0] - } - this.selectedFilters.push(o) - } - if (this.additionFilters && this.additionFilters.name) { - o = { name: this.additionFilters.name, index: -1, value: null }; - this.selectedFilters.push(o) - } - } - if (!this.colorArr) { - this.colorArr = []; - this.backgroundColorArr = []; - this.isBackgroundHover = []; - this.fontWeightArr = []; - this.isArrowIconDownArr = []; - this.floatArrowBgColor = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - }; - for (let o of this.multiFilters) { - var e = new ResourceArray; - var t = new FontWeightArray; - var r = new ResourceArray; - var i = new BooleanArray; - for (let i of o.options.keys()) { - if (0 === i) { - e.push({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary_activated"], - bundleName: "", - moduleName: "" - }); - t.push(FontWeight.Medium) - } else { - e.push({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary"], - bundleName: "", - moduleName: "" - }); - t.push(FontWeight.Regular) - } - r.push({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - }) - } - this.colorArr.push(e); - this.fontWeightArr.push(t); - this.backgroundColorArr.push(r); - this.isBackgroundHover.push(i); - this.isArrowIconDownArr.push(new ObservedBoolean(!0)) - } - } - if (this.additionFilters && this.additionFilters.options) { - this.additionColorArr = []; - this.additionFontWeightArr = []; - this.additionBackgroundColorArr = []; - this.isAdditionBackgroundHover = []; - for (let o = 0;o < this.additionFilters.options.length; o++) { - this.additionColorArr.push({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary"], - bundleName: "", - moduleName: "" - }); - this.additionFontWeightArr.push(FontWeight.Regular); - this.additionBackgroundColorArr.push({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - }); - this.isAdditionBackgroundHover.push(!1) - } - } - if (!this.twoLineModeItemNum) { - this.twoLineModeItemNum = []; - this.twoLineModeItemNumRecord = []; - this.downArrowShowState = []; - for (let o = 0;o < this.multiFilters.length; o++) { - this.twoLineModeItemNum.push(new ObservedNumber(0)); - this.twoLineModeItemNumRecord.push(new ObservedNumber(0)); - this.downArrowShowState.push(new ObservedBoolean(!1)) - } - } - } - - ListFilter(o = null) { - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Column.create(); - Column.width("100%"); - Column.align(Alignment.Start); - Column.padding({ - left: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_max_padding_start"], - bundleName: "", - moduleName: "" - } - }); - Column.onAreaChange(((o, e) => { - if (!this.isFloatShowAllFilterWithoutAnimation && !this.isFloatBarShowWithoutAnimation) { - null != this.additionFilters ? this.filterDynamicHeight = parseInt(e.height.toString(), 0) + 40 + 8 : this.filterDynamicHeight = parseInt(e.height.toString(), 0) + 8; - this.floatFilterPosition = -this.filterDynamicHeight - } - })); - e || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - ForEach.create(); - this.forEachUpdateFunction(o, this.multiFilters, ((o, e) => { - const t = o; - this.observeComponentCreation(((o, r) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - r ? ViewPU.create(new ListFilterRow(this, { - colorRow: this.colorArr[e], - fontWeightRow: this.fontWeightArr[e], - backgroundColorRow: this.backgroundColorArr[e], - isBackgroundHoverRow: this.isBackgroundHover[e], - filterRow: t, - onItemClick: o => { - this.filterItemClick(e, o) - } - }, void 0, o)) : this.updateStateVarsOfChildByElmtId(o, { - colorRow: this.colorArr[e], - fontWeightRow: this.fontWeightArr[e], - backgroundColorRow: this.backgroundColorArr[e], - isBackgroundHoverRow: this.isBackgroundHover[e] - }); - ViewStackProcessor.StopGetAccessRecording() - })) - }), void 0,!0,!1); - e || ForEach.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - ForEach.pop(); - Column.pop() - } - - MultiLineFilter(o = null) { - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Column.create(); - Column.width("100%"); - Column.onAreaChange(((o, e) => { - null != this.additionFilters ? this.filterDynamicHeight = parseInt(e.height.toString(), 0) + 40 + 8 : this.filterDynamicHeight = parseInt(e.height.toString(), 0) + 8; - this.isFloatBarShowWithoutAnimation || this.isFloatShowAllFilterWithoutAnimation || (this.floatFilterPosition = -this.filterDynamicHeight) - })); - e || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - ForEach.create(); - this.forEachUpdateFunction(o, this.multiFilters, ((o, e) => { - const t = o; - this.observeComponentCreation(((o, r) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - r ? ViewPU.create(new MultiFilterRow(this, { - colorRow: this.colorArr[e], - fontWeightRow: this.fontWeightArr[e], - backgroundColorRow: this.backgroundColorArr[e], - isBackgroundHoverRow: this.isBackgroundHover[e], - arrowShowStateRow: this.downArrowShowState[e], - twoLineModeItemNumRow: this.twoLineModeItemNum[e], - twoLineModeItemNumRecordRow: this.twoLineModeItemNumRecord[e], - isArrowIconDown: this.isArrowIconDownArr[e], - filterRow: t, - onItemClick: o => { - this.filterItemClick(e, o) - } - }, void 0, o)) : this.updateStateVarsOfChildByElmtId(o, { - colorRow: this.colorArr[e], - fontWeightRow: this.fontWeightArr[e], - backgroundColorRow: this.backgroundColorArr[e], - isBackgroundHoverRow: this.isBackgroundHover[e], - arrowShowStateRow: this.downArrowShowState[e], - twoLineModeItemNumRow: this.twoLineModeItemNum[e], - twoLineModeItemNumRecordRow: this.twoLineModeItemNumRecord[e], - isArrowIconDown: this.isArrowIconDownArr[e] - }); - ViewStackProcessor.StopGetAccessRecording() - })) - }), void 0,!0,!1); - e || ForEach.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - ForEach.pop(); - Column.pop() - } - - additionItemClick(o) { - let e = this.multiFilters.length; - if (this.selectedFilters[e].index != o) if (-1 === this.selectedFilters[e].index) { - this.additionColorArr[o] = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary_activated"], - bundleName: "", - moduleName: "" - }; - this.additionFontWeightArr[o] = FontWeight.Medium; - this.selectedFilters[e].value = this.additionFilters.options[o]; - this.selectedFilters[e].index = o - } else { - let t = this.selectedFilters[e].index; - this.additionColorArr[t] = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary"], - bundleName: "", - moduleName: "" - }; - this.additionColorArr[o] = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary_activated"], - bundleName: "", - moduleName: "" - }; - this.additionFontWeightArr[t] = FontWeight.Regular; - this.additionFontWeightArr[o] = FontWeight.Medium; - this.selectedFilters[e].value = this.additionFilters.options[o]; - this.selectedFilters[e].index = o - } else { - this.additionColorArr[o] = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary"], - bundleName: "", - moduleName: "" - }; - this.additionFontWeightArr[o] = FontWeight.Regular; - this.selectedFilters[e].value = null; - this.selectedFilters[e].index = -1 - } - this.onFilterChanged && this.onFilterChanged(this.selectedFilters); - this.colorRefresh = !this.colorRefresh - } - - AdditionFilterList(o = null) { - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - If.create(); - this.additionFilters && this.additionFilters.name && this.additionFilters.options && 0 != this.additionFilters.options.length ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - List.create(); - List.listDirection(Axis.Horizontal); - List.scrollBar(BarState.Off); - List.padding({ - left: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_max_padding_start"], - bundleName: "", - moduleName: "" - } - }); - List.margin({ left: -16 }); - List.width("100%"); - List.height(40); - e || List.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - { - const o = !0; - const e = (e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - ListItem.create(r, o); - ListItem.height("100%"); - t || ListItem.pop(); - ViewStackProcessor.StopGetAccessRecording() - }; - const t = () => { - this.observeComponentCreation(e); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Row.create(); - e || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Text.create(this.additionFilters.name.toString()); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body3"], - bundleName: "", - moduleName: "" - }); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_secondary"], - bundleName: "", - moduleName: "" - }); - Text.margin({ left: 8, right: 8 }); - e || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Row.create(); - Row.width(1); - Row.height(16); - Row.backgroundColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_list_separator"], - bundleName: "", - moduleName: "" - }); - e || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop(); - Row.pop(); - ListItem.pop() - }; - const r = (o, t) => { - e(o, t); - this.updateFuncByElmtId.set(o, e); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Row.create(); - e || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Text.create(this.additionFilters.name.toString()); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body3"], - bundleName: "", - moduleName: "" - }); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_secondary"], - bundleName: "", - moduleName: "" - }); - Text.margin({ left: 8, right: 8 }); - e || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Row.create(); - Row.width(1); - Row.height(16); - Row.backgroundColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_list_separator"], - bundleName: "", - moduleName: "" - }); - e || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop(); - Row.pop(); - ListItem.pop() - }; - o ? (() => { - this.observeComponentCreation(e); - ListItem.pop() - })() : t() - } - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - ForEach.create(); - this.forEachUpdateFunction(o, this.additionFilters.options, ((o, e) => { - const t = o; - { - const o = !0; - const r = (t, r) => { - ViewStackProcessor.StartGetAccessRecordingFor(t); - ListItem.create(s, o); - ListItem.height("100%"); - ListItem.backgroundColor(this.isAdditionBackgroundHover[e] ? this.additionBackgroundColorArr[e] : "#00FFFFFF"); - ListItem.onHover((o => { - Context.animateTo({ curve: FRICTION_CUBIC_BEZIER, duration: 250 }, (() => { - if (o) { - this.additionBackgroundColorArr[e] = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - }; - this.isAdditionBackgroundHover[e] = !0 - } else this.isAdditionBackgroundHover[e] = !1 - })) - })); - ListItem.onTouch((o => { - o.type === TouchType.Down ? Context.animateTo({ curve: SHARP_CUBIC_BEZIER, duration: 100 }, (() => { - this.additionBackgroundColorArr[e] = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_click_effect"], - bundleName: "", - moduleName: "" - }; - this.isAdditionBackgroundHover[e] = !0 - })) : o.type === TouchType.Up && Context.animateTo({ - curve: SHARP_CUBIC_BEZIER, - duration: 100 - }, (() => { - this.isAdditionBackgroundHover[e] = !1 - })) - })); - ListItem.focusable(!0); - ViewStackProcessor.visualState("focused"); - ListItem.border({ - radius: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_clicked"], - bundleName: "", - moduleName: "" - }, - width: 2, - color: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_focused_outline"], - bundleName: "", - moduleName: "" - }, - style: BorderStyle.Solid - }); - ListItem.padding({ left: 6, right: 6 }); - ViewStackProcessor.visualState("normal"); - ListItem.border({ - radius: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_clicked"], - bundleName: "", - moduleName: "" - }, - width: 0 - }); - ListItem.padding({ left: 8, right: 8 }); - ViewStackProcessor.visualState(); - ListItem.onClick((() => { - this.additionItemClick(e) - })); - r || ListItem.pop(); - ViewStackProcessor.StopGetAccessRecording() - }; - const i = () => { - this.observeComponentCreation(r); - this.observeComponentCreation(((o, r) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Text.create(t.toString()); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body3"], - bundleName: "", - moduleName: "" - }); - Text.fontColor(this.additionColorArr[e]); - Text.fontWeight(this.additionFontWeightArr[e]); - Text.focusable(!0); - r || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - ListItem.pop() - }; - const s = (o, i) => { - r(o, i); - this.updateFuncByElmtId.set(o, r); - this.observeComponentCreation(((o, r) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Text.create(t.toString()); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body3"], - bundleName: "", - moduleName: "" - }); - Text.fontColor(this.additionColorArr[e]); - Text.fontWeight(this.additionFontWeightArr[e]); - Text.focusable(!0); - r || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - ListItem.pop() - }; - o ? (() => { - this.observeComponentCreation(r); - ListItem.pop() - })() : i() - } - }), void 0,!0,!1); - e || ForEach.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - ForEach.pop(); - List.pop() - })) : If.branchId(1); - e || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop() - } - - FilterHeader(o = null) { - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Column.create(); - Column.padding({ top: 8 }); - Column.onVisibleAreaChange([0, 1], ((o, e) => { - if (e > 0) { - this.isFloatShowAllFilter = !1; - this.isFloatShowAllFilterWithoutAnimation = !1; - this.isFloatBarShowWithoutAnimation = !1; - Context.animateTo({ curve: INTER_POLATING_SPRING, onFinish: () => { - this.isFloatBarShowWithoutAnimation || (this.isFloatBarShow = !1) - } }, (() => { - this.floatFilterBarHeight = 0 - })) - } else { - this.isFloatBarShow = !0; - this.isFloatBarShowWithoutAnimation = !0; - Context.animateTo({ curve: INTER_POLATING_SPRING }, (() => { - this.floatFilterBarHeight = 48 - })) - } - })); - e || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - If.create(); - this.filterType === FilterType.LIST_FILTER ? this.ifElseBranchUpdateFunction(0, (() => { - this.ListFilter.bind(this)() - })) : this.ifElseBranchUpdateFunction(1, (() => { - this.MultiLineFilter.bind(this)() - })); - e || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.AdditionFilterList.bind(this)(); - Column.pop() - } - - FloatFilterHeader(o = null) { - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Column.create(); - Column.padding({ top: 8 }); - Column.width("100%"); - Column.clip(!0); - Column.backgroundColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - }); - Column.opacity(.95); - Column.backgroundBlurStyle(BlurStyle.Thin); - Column.visibility(this.isFloatShowAllFilter ? Visibility.Visible : Visibility.Hidden); - Column.position({ x: 0, y: this.floatFilterPosition }); - Column.zIndex(2); - e || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - If.create(); - this.filterType === FilterType.LIST_FILTER ? this.ifElseBranchUpdateFunction(0, (() => { - this.ListFilter.bind(this)() - })) : this.ifElseBranchUpdateFunction(1, (() => { - this.MultiLineFilter.bind(this)() - })); - e || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.AdditionFilterList.bind(this)(); - Column.pop() - } - - FloatFilterBar(o = null) { - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Row.create(); - Row.width("100%"); - Row.padding({ - right: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_max_padding_end"], - bundleName: "", - moduleName: "" - } - }); - Row.height(this.floatFilterBarHeight); - Row.backgroundColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - }); - Row.opacity(.95); - Row.clip(!0); - Row.backgroundBlurStyle(BlurStyle.Thin); - Row.visibility(this.isFloatBarShow ? Visibility.Visible : Visibility.Hidden); - Row.alignItems(VerticalAlign.Bottom); - Row.position({ x: 0, y: this.floatFilterBarPosition }); - Row.zIndex(1); - e || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Column.create(); - Column.alignItems(HorizontalAlign.Center); - Column.width("100%"); - Column.height(40); - e || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Row.create(); - Row.height("100%"); - Row.alignItems(VerticalAlign.Center); - e || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - ForEach.create(); - this.forEachUpdateFunction(o, this.selectedFilters.slice(0, (this.colorRefresh, this.selectedFilters.length)), ((o, e) => { - const t = o; - this.observeComponentCreation(((o, r) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - If.create(); - 0 != e && null != t.value ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Text.create("/"); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary"], - bundleName: "", - moduleName: "" - }); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body3"], - bundleName: "", - moduleName: "" - }); - e || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop() - })) : If.branchId(1); - r || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Text.create(t.value); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary"], - bundleName: "", - moduleName: "" - }); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body3"], - bundleName: "", - moduleName: "" - }); - e || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop() - }), void 0,!0,!1); - e || ForEach.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - ForEach.pop(); - Row.pop(); - Column.pop(); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Row.create(); - Row.height(40); - Row.margin({ left: -24 }); - Row.backgroundColor(this.isFloatArrowBgHover ? this.floatArrowBgColor : "#00FFFFFF"); - Row.focusable(!0); - ViewStackProcessor.visualState("focused"); - Row.border({ - radius: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_clicked"], - bundleName: "", - moduleName: "" - }, - width: 2, - color: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_focused_outline"], - bundleName: "", - moduleName: "" - }, - style: BorderStyle.Solid - }); - Row.width(28); - Row.offset({ x: -2 }); - ViewStackProcessor.visualState("normal"); - Row.border({ - radius: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_clicked"], - bundleName: "", - moduleName: "" - }, - width: 0 - }); - Row.width(24); - Row.offset({ x: 0 }); - ViewStackProcessor.visualState(); - Row.onHover((o => { - o ? Context.animateTo({ curve: FRICTION_CUBIC_BEZIER, duration: 250 }, (() => { - this.floatArrowBgColor = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - }; - this.isFloatArrowBgHover = !0 - })) : Context.animateTo({ curve: FRICTION_CUBIC_BEZIER, duration: 250 }, (() => { - this.isFloatArrowBgHover = !1 - })) - })); - Row.onTouch((o => { - o.type === TouchType.Down ? Context.animateTo({ curve: SHARP_CUBIC_BEZIER, duration: 100 }, (() => { - this.floatArrowBgColor = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_click_effect"], - bundleName: "", - moduleName: "" - }; - this.isFloatArrowBgHover = !0 - })) : o.type === TouchType.Up && Context.animateTo({ curve: SHARP_CUBIC_BEZIER, duration: 100 }, (() => { - this.isFloatArrowBgHover = !1 - })) - })); - Row.onClick((() => { - Context.animateTo({ duration: 150, curve: SHARP_CUBIC_BEZIER }, (() => { - this.isFloatBarShow = !1; - this.isFloatBarShowWithoutAnimation = !1 - })); - this.isFloatShowAllFilter = !0; - this.isFloatShowAllFilterWithoutAnimation = !0; - Context.animateTo({ curve: INTER_POLATING_SPRING }, (() => { - this.floatFilterPosition = 0; - this.floatFilterBarPosition = this.filterDynamicHeight - })) - })); - e || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Image.create({ - id: -1, - type: 2e4, - params: ["sys.media.ohos_ic_public_arrow_down"], - bundleName: "", - moduleName: "" - }); - Image.width(24); - Image.height(24); - Image.fillColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_tertiary"], - bundleName: "", - moduleName: "" - }); - Image.focusable(!0); - e || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop(); - Row.pop() - } - - initialRender() { - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Stack.create({ alignContent: Alignment.Top }); - Stack.clip(!0); - e || Stack.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.FloatFilterBar.bind(this)(); - this.FloatFilterHeader.bind(this)(); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Column.create(); - Column.zIndex(0); - e || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((o, e) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - List.create({ initialIndex: 0, scroller: this.listScroller }); - List.listDirection(Axis.Vertical); - List.width("100%"); - List.height("100%"); - List.edgeEffect(EdgeEffect.Spring); - List.onScroll(((o, e) => { - if (this.isFloatShowAllFilterWithoutAnimation && e == ScrollState.Scroll) { - this.isFloatBarShowWithoutAnimation = !0; - this.isFloatShowAllFilterWithoutAnimation = !1; - Context.animateTo({ duration: 150, curve: SHARP_CUBIC_BEZIER }, (() => { - this.isFloatBarShow = !0 - })); - Context.animateTo({ curve: INTER_POLATING_SPRING, onFinish: () => { - this.isFloatShowAllFilterWithoutAnimation || (this.isFloatShowAllFilter = !1) - } }, (() => { - this.floatFilterPosition = -this.filterDynamicHeight; - this.floatFilterBarPosition = 0 - })) - } - })); - e || List.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - { - const o = !0; - const e = (e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - ListItem.create(r, o); - ListItem.focusable(!0); - ListItem.onFocus((() => { - this.listScroller.scrollToIndex(0,!0) - })); - t || ListItem.pop(); - ViewStackProcessor.StopGetAccessRecording() - }; - const t = () => { - this.observeComponentCreation(e); - this.FilterHeader.bind(this)(); - ListItem.pop() - }; - const r = (o, t) => { - e(o, t); - this.updateFuncByElmtId.set(o, e); - this.FilterHeader.bind(this)(); - ListItem.pop() - }; - o ? (() => { - this.observeComponentCreation(e); - ListItem.pop() - })() : t() - } - { - const o = !0; - const e = (e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - ListItem.create(r, o); - ListItem.focusable(!0); - ListItem.onFocus((() => { - this.listScroller.scrollToIndex(1,!0) - })); - t || ListItem.pop(); - ViewStackProcessor.StopGetAccessRecording() - }; - const t = () => { - this.observeComponentCreation(e); - this.container.bind(this)(); - ListItem.pop() - }; - const r = (o, t) => { - e(o, t); - this.updateFuncByElmtId.set(o, e); - this.container.bind(this)(); - ListItem.pop() - }; - o ? (() => { - this.observeComponentCreation(e); - ListItem.pop() - })() : t() - } - List.pop(); - Column.pop(); - Stack.pop() - } - - rerender() { - this.updateDirtyElements() - } -} - -export default { - Filter, FilterType -}; \ No newline at end of file diff --git a/interface/progressbutton/progressbutton.cpp b/interface/progressbutton/progressbutton.cpp deleted file mode 100644 index 4a3fc1d439f895d59fda803b31e037c2feb6187c..0000000000000000000000000000000000000000 --- a/interface/progressbutton/progressbutton.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "native_engine/native_engine.h" - -#include "napi/native_api.h" -#include "napi/native_node_api.h" - -extern const char _binary_progressbutton_abc_start[]; -extern const char _binary_progressbutton_abc_end[]; - -// Napi get abc code function -extern "C" __attribute__((visibility("default"))) -void NAPI_arkui_advanced_ProgressButton_GetABCCode(const char **buf, int *buflen) -{ - if (buf != nullptr) { - *buf = _binary_progressbutton_abc_start; - } - if (buflen != nullptr) { - *buflen = _binary_progressbutton_abc_end - _binary_progressbutton_abc_start; - } -} - -/* - * Module define - */ -static napi_module progressbuttonModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_modname = "arkui.advanced.ProgressButton", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; -/* - * Module register function - */ -extern "C" __attribute__((constructor)) void progressbuttonRegisterModule(void) -{ - napi_module_register(&progressbuttonModule); -} diff --git a/interface/progressbutton/progressbutton.js b/interface/progressbutton/progressbutton.js deleted file mode 100644 index 9a3bd18ad9c6fe0e5fb32c2bdc260432b66a8ff9..0000000000000000000000000000000000000000 --- a/interface/progressbutton/progressbutton.js +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const EMPTY_STRING = ''; -const MAX_PROGRESS = 100; -const MAX_PERCENTAGE = '100%'; -const MIN_PERCENTAGE = '0%'; -const TEXT_OPACITY = 0.4; -const BUTTON_NORMARL_WIDTH = 44; -const BUTTON_NORMARL_HEIGHT = 28; -const BUTTON_BORDER_RADIUS = 14; -const BUTTON_BORDER_WIDTH = 0.5; - -export class ProgressButton extends ViewPU { - constructor(e, t, s, r = -1) { - super(e, s, r); - this.__progress = new SynchedPropertySimpleOneWayPU(t.progress, this, 'progress'); - this.__textProgress = new ObservedPropertySimplePU('', this, 'textProgress'); - this.__content = new SynchedPropertySimpleOneWayPU(t.content, this, 'content'); - this.__isLoading = new ObservedPropertySimplePU(!1, this, 'isLoading'); - this.__enable = new SynchedPropertySimpleOneWayPU(t.enable, this, 'enable'); - this.progressButtonWidth = 44; - this.clickCallback = null; - this.setInitiallyProvidedValue(t); - this.declareWatch('progress', this.getProgressContext); - } - - setInitiallyProvidedValue(e) { - void 0 !== e.textProgress && (this.textProgress = e.textProgress); - void 0 !== e.content ? this.__content.set(e.content) : this.__content.set(''); - void 0 !== e.isLoading && (this.isLoading = e.isLoading); - void 0 !== e.enable ? this.__enable.set(e.enable) : this.__enable.set(!0); - void 0 !== e.progressButtonWidth && (this.progressButtonWidth = e.progressButtonWidth); - void 0 !== e.clickCallback && (this.clickCallback = e.clickCallback); - } - - updateStateVars(e) { - this.__progress.reset(e.progress); - this.__content.reset(e.content); - this.__enable.reset(e.enable); - } - - purgeVariableDependenciesOnElmtId(e) { - this.__progress.purgeDependencyOnElmtId(e); - this.__textProgress.purgeDependencyOnElmtId(e); - this.__content.purgeDependencyOnElmtId(e); - this.__isLoading.purgeDependencyOnElmtId(e); - this.__enable.purgeDependencyOnElmtId(e); - } - - aboutToBeDeleted() { - this.__progress.aboutToBeDeleted(); - this.__textProgress.aboutToBeDeleted(); - this.__content.aboutToBeDeleted(); - this.__isLoading.aboutToBeDeleted(); - this.__enable.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal(); - } - - get progress() { - return this.__progress.get(); - } - - set progress(e) { - this.__progress.set(e); - } - - get textProgress() { - return this.__textProgress.get(); - } - - set textProgress(e) { - this.__textProgress.set(e); - } - - get content() { - return this.__content.get(); - } - - set content(e) { - this.__content.set(e); - } - - get isLoading() { - return this.__isLoading.get(); - } - - set isLoading(e) { - this.__isLoading.set(e); - } - - get enable() { - return this.__enable.get(); - } - - set enable(e) { - this.__enable.set(e); - } - - getButtonProgress() { - return this.progress < 0 ? 0 : this.progress > MAX_PROGRESS ? MAX_PROGRESS : this.progress; - } - - getProgressContext() { - if (this.progress < 0) { - this.isLoading = !1; - this.textProgress = '0%'; - } else if (this.progress >= MAX_PROGRESS) { - this.isLoading = !1; - this.textProgress = '100%'; - } else { - this.textProgress = Math.floor(this.progress / MAX_PROGRESS * MAX_PROGRESS).toString() + '%'; - } - } - - initialRender() { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Button.createWithChild(); - Button.borderRadius(BUTTON_BORDER_RADIUS); - Button.clip(!1); - Button.hoverEffect(HoverEffect.None); - Button.backgroundColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_foreground_contrary'], - bundleName: '', - moduleName: '' - }); - Button.border({ - width: BUTTON_BORDER_WIDTH, - color: this.enable ? { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_toolbar_text_actived'], - bundleName: '', - moduleName: '' - } : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_foreground_contrary_disable'], - bundleName: '', - moduleName: '' - } - }); - Button.constraintSize({ minWidth: 44 }); - Button.width(this.progressButtonWidth < BUTTON_NORMARL_WIDTH ? BUTTON_NORMARL_WIDTH : this.progressButtonWidth); - Button.stateEffect(this.enable); - Button.onClick((() => { - if (this.enable) { - this.progress < MAX_PROGRESS && (this.isLoading = !this.isLoading); - this.clickCallback && this.clickCallback(); - } - })); - t || Button.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Stack.create(); - t || Stack.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Progress.create({ value: this.getButtonProgress(), total: MAX_PROGRESS, style: ProgressStyle.Capsule }); - Progress.height(BUTTON_NORMARL_HEIGHT); - Progress.borderRadius(BUTTON_BORDER_RADIUS); - Progress.width('100%'); - Progress.hoverEffect(HoverEffect.None); - Progress.clip(!1); - Progress.enabled(this.enable); - t || Progress.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.isLoading ? this.textProgress : this.content); - Text.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_button3'], - bundleName: '', - moduleName: '' - }); - Text.fontWeight(FontWeight.Medium); - Text.fontColor(this.isLoading ? { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary'], - bundleName: '', - moduleName: '' - } : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_emphasize'], - bundleName: '', - moduleName: '' - }); - Text.maxLines(1); - Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - Text.padding({ left: 8, right: 8 }); - Text.opacity(this.enable ? 1 : TEXT_OPACITY); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Text.pop(); - Row.pop(); - Stack.pop(); - Button.pop(); - } - - rerender() { - this.updateDirtyElements(); - } -} -export default { ProgressButton }; \ No newline at end of file diff --git a/interface/selecttitlebar/selecttitlebar.cpp b/interface/selecttitlebar/selecttitlebar.cpp deleted file mode 100644 index 9d11696a697cbe84eaf1fdb9b553f8893586342c..0000000000000000000000000000000000000000 --- a/interface/selecttitlebar/selecttitlebar.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "native_engine/native_engine.h" - -#include "napi/native_api.h" -#include "napi/native_node_api.h" - -extern const char _binary_selecttitlebar_abc_start[]; -extern const char _binary_selecttitlebar_abc_end[]; - -// Napi get abc code function -extern "C" __attribute__((visibility("default"))) -void NAPI_arkui_advanced_SelectTitleBar_GetABCCode(const char **buf, int *buflen) - { - if (buf != nullptr) { - *buf = _binary_selecttitlebar_abc_start; - } - if (buflen != nullptr) { - *buflen = _binary_selecttitlebar_abc_end - _binary_selecttitlebar_abc_start; - } - } - - -static napi_module selecttitlebarModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_modname = "arkui.advanced.SelectTitleBar", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; - -extern "C" __attribute__((constructor)) void selecttitlebarRegisterModule(void) -{ - napi_module_register(&selecttitlebarModule); -} \ No newline at end of file diff --git a/interface/selecttitlebar/selecttitlebar.js b/interface/selecttitlebar/selecttitlebar.js deleted file mode 100644 index 08d5151565a1d38a68e9453c638e9c185413565d..0000000000000000000000000000000000000000 --- a/interface/selecttitlebar/selecttitlebar.js +++ /dev/null @@ -1,785 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var __decorate = this && this.__decorate || function(e, t, o, i) { - var s, r = arguments.length, - n = r < 3 ? t : null === i ? i = Object.getOwnPropertyDescriptor(t, o) : i; - if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(e, t, o, i); - else - for (var c = e.length - 1; c >= 0; c--)(s = e[c]) && (n = (r < 3 ? s(n) : r > 3 ? s(t, o, n) : s(t, o)) || n); - return r > 3 && n && Object.defineProperty(t, o, n), n -}; -const KeyCode = requireNapi('multimodalInput.keyCode').KeyCode; -const PUBLIC_MORE = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAABS3GwHAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAEZ0FNQQAAsY58+1GTAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOxAAADsQBlSsOGwAABEZJREFUeNrt3D1rFFEUBuAxhmAhFlYpUohYiYWFRcAmKAhWK2pjo1iKf8BCMIKFf8BarCyMhVj4VZhGSKEg2FqJyCKWIhYWnstMINgYsh+cmfs88BICydxw7jmzu2HvNg0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADBN+3r6dx+LXIqsRpa7FF8j48hm5Fn3Peo9mAEYRdYjJ3f582Vj7nZfUe/eDsCRyMPI2h5/fyNyI/JDT6v3Tvt7sBllE15ETkxwjeORi5G3ke/6W737MgBnI68jh6ZwrcORq5HnhkC9+zAA5YXXy8jBKV5zKXIu8jjyS7+rd+YBeNVtyrSVO9PRyBM9r94LSTfjWuTUDK9/eYIXeENUbb0zDsBi5PYc1rmj79U74wCszuih+F/ljrSi/+uud8YBGA10rayqrnfGAVgb6FpZVV3vjAOwPNC1sqq63hkHYGWga2VVdb0XKt/8Rf1fd70zDsB4jmt5u3Tl9a59AMb6v+56ZxyArYGulVXV9c44ABtzXOup/q+73hkH4N2cHio/Rj7r/7rrnXEAfkfuz2Gddb2v3ln/DfpgxneLzaY9xE3l9c46AH8iVyI/Z3Dt8nB/Xc+rd5H5QMy3yJemPVs6zY0edc9HUe/0Z4I/dQ/N5Vjd0oTXKp9QcKFpD2qj3r0YgO1NeRM507TH6/bifeR85IMeV++d+vTBWOV9JDcjt5rdv6uw3M3uRR7pa/Xu+wBsOxA53bTnTP/3UX1b3fNQ1BsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKqyr6d/97HIpchqZLlL8TUyjmxGnnXfo96DGYBRZD1ycpc/XzbmbvcV9e7tAByJPIys7fH3NyI3Ij/0tHrvtL8Hm1E24UXkxATXOB65GHkb+a6/1bsvA3A28jpyaArXOhy5GnluCNS7DwNQXni9jByc4jWXIucijyO/9Lt6Zx6AV92mTFu5Mx2NPNHz6r2QdDOuRU7N8PqXJ3iBN0TV1jvjACxGbs9hnTv6Xr0zDsDqjB6K/1XuSCv6v+56ZxyA0UDXyqrqemccgLWBrpVV1fXOOADLA10rq6rrnXEAVga6VlZV13uh8s1f1P911zvjAIznuJa3S1de79oHYKz/6653xgHYGuhaWVVd74wDsDHHtZ7q/7rrnXEA3s3pofJj5LP+r7veGQfgd+T+HNZZ1/vqnfXfoA9mfLfYbNpD3FRe76wD8CdyJfJzBtcuD/fX9bx6F5kPxHyLfGnas6XT3OhR93wU9U5/JvhT99BcjtUtTXit8gkFF5r2oDbq3YsB2N6UN5EzTXu8bi/eR85HPuhx9d6pTx+MVd5HcjNyq9n9uwrL3exe5JG+Vu++D8C2A5HTTXvO9H8f1bfVPQ9FvQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgCn7C9HjBtwWfXpKAAAAAElFTkSuQmCC"; -const PUBLIC_BACK = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAABS3GwHAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAEZ0FNQQAAsY58+1GTAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAA8VJREFUeNrt3LFLlHEYwPFXz0GiIZpEoikkwsFRIiK3gqCigxIC/4Kmhv6OoChouaGoqKCgCKducGh0cDAIamhwiCaHCIeelztpUszee/vl8/nAM3Vd8nufr+fddVYVAAAAAAAAAAAAAAAAAAAAAABQijFH0KhrMd2Y2ZitmNWYRzHLjkYAB9lUzMOYizv8eS/mZsymoypLxxE0svzvY07vcpu5mOmY145LAAdx+U/u4bZzwx+JPjq2cow7glaWf1vXsQkg6/JvPwoggJTLjwDSL/8nRyiAzN/5nzpGAWRd/n7MM0cpgIzLvx6z6CjL453gdpZ/IWbDcQrA8iMAy48ALD8CsPwIwPIjAMuPACw/ArD8CMDyIwDLjwAsPwKw/AjA8iMAy48ALD8CsPwIwPIjAMuPACw/ArD85A3A8pM2AMtP2gAsP2kDsPykDcDykzYAy0/aACw/aQOw/KQNwPKTNgDLT9oALD9pA7D8pA3A8pM2AMtP2gAsP2kDsPykDcDykzYAy0/aACw/aQOw/KQNwPKTNgDLT9oALD9pA7D8pA3A8pM2AMtP2gAsP2kDsPykDcDykzYAy0/aACw/aQOw/KQNwPLz3xlv6H4mYp5YfrI+AizF9BwnI/AlZi3mbsxy03feaeh+HsQcc60YgSMxMzE3YmZj3sX8LOlHoPoLnHedaEE35n5pzwF856dN9SPBpZICmHRNaNnlkgL46nrQsvmSAqhftlx1TWjR4ZICqPVcE1q0XloA96rBa7XQhl5pAWzFXKm8i8vo9WMeN3VnnQa/sO8xL2POxEy7Toxo+RdjNpu6w1F9HuBqNXi99lw1eKMM9utHzIeYV8MftbccCQAAAAAAsBdt/XLc+sPy9W+MmPqL+1iJuVA1+C4gdFr6d77FvK0GH2nb739lPR5zNuZ51eBnQhFAJQIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIE8M8jmBlGgABSRnAqZiXms+MUQNYIDnkUKMu4I/gj6zELMRv7/PsnHKEAMkcw6fgEkDmCNUcngMwRvHFsngRnfWJcL/9tRyaAgxrB+ZijO9ymH7MUs+m4yjLmCBozEXMr5nr1+9We1ZgXMXccDwAAAAAAAAAAAAAAAAAAAAAAwO5+AfVgtqHKRnawAAAAAElFTkSuQmCC"; -export class SelectTitleBar extends ViewPU { - constructor(e, t, o, i = -1) { - super(e, o, i); - this.__selected = new ObservedPropertySimplePU(0, this, "selected"); - this.options = void 0; - this.menuItems = void 0; - this.subtitle = void 0; - this.badgeValue = void 0; - this.hidesBackButton = void 0; - this.onSelected = void 0; - this.__selectMaxWidth = new ObservedPropertySimplePU(0, this, "selectMaxWidth"); - this.setInitiallyProvidedValue(t) - } - setInitiallyProvidedValue(e) { - void 0 !== e.selected && (this.selected = e.selected); - void 0 !== e.options && (this.options = e.options); - void 0 !== e.menuItems && (this.menuItems = e.menuItems); - void 0 !== e.subtitle && (this.subtitle = e.subtitle); - void 0 !== e.badgeValue && (this.badgeValue = e.badgeValue); - void 0 !== e.hidesBackButton && (this.hidesBackButton = e.hidesBackButton); - void 0 !== e.onSelected && (this.onSelected = e.onSelected); - void 0 !== e.selectMaxWidth && (this.selectMaxWidth = e.selectMaxWidth) - } - updateStateVars(e) {} - purgeVariableDependenciesOnElmtId(e) { - this.__selected.purgeDependencyOnElmtId(e); - this.__selectMaxWidth.purgeDependencyOnElmtId(e) - } - aboutToBeDeleted() { - this.__selected.aboutToBeDeleted(); - this.__selectMaxWidth.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - get selected() { - return this.__selected.get() - } - set selected(e) { - this.__selected.set(e) - } - get selectMaxWidth() { - return this.__selectMaxWidth.get() - } - set selectMaxWidth(e) { - this.__selectMaxWidth.set(e) - } - initialRender() { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Flex.create({ - justifyContent: FlexAlign.SpaceBetween, - alignItems: ItemAlign.Stretch - }); - Flex.width("100%"); - Flex.height(SelectTitleBar.totalHeight); - Flex.backgroundColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - }); - Flex.onAreaChange(((e, t) => { - let o = Number(t.width); - if (!this.hidesBackButton) { - o -= ImageMenuItem.imageHotZoneWidth; - o += SelectTitleBar.leftPadding; - o -= SelectTitleBar.leftPaddingWithBack - } - if (void 0 !== this.menuItems) { - let e = this.menuItems.length; - e >= CollapsibleMenuSection.maxCountOfVisibleItems ? o -= ImageMenuItem.imageHotZoneWidth * CollapsibleMenuSection.maxCountOfVisibleItems : e > 0 && (o -= ImageMenuItem.imageHotZoneWidth * e) - } - void 0 !== this.badgeValue ? this.selectMaxWidth = o - SelectTitleBar.badgeSize - SelectTitleBar.leftPadding - SelectTitleBar.rightPadding - SelectTitleBar.badgePadding : this.selectMaxWidth = o - SelectTitleBar.leftPadding - SelectTitleBar.rightPadding - })); - t || Flex.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.margin({ - left: this.hidesBackButton ? { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_max_padding_start"], - bundleName: "", - moduleName: "" - } : { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_default_padding_start"], - bundleName: "", - moduleName: "" - } - }); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.hidesBackButton ? If.branchId(1) : this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Navigator.create(); - t || Navigator.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - t ? ViewPU.create(new ImageMenuItem(this, { - item: { - value: PUBLIC_BACK, - isEnabled: !0 - } - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })); - Navigator.pop() - })); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.justifyContent(FlexAlign.Start); - Column.alignItems(HorizontalAlign.Start); - Column.constraintSize({ - maxWidth: this.selectMaxWidth - }); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - void 0 !== this.badgeValue ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Badge.create({ - count: this.badgeValue, - position: BadgePosition.Right, - style: { - badgeSize: SelectTitleBar.badgeSize, - badgeColor: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_emphasize"], - bundleName: "", - moduleName: "" - }, - borderColor: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_emphasize"], - bundleName: "", - moduleName: "" - }, - borderWidth: 0 - } - }); - t || Badge.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.justifyContent(FlexAlign.Start); - Row.margin({ - right: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_elements_margin_horizontal_l"], - bundleName: "", - moduleName: "" - } - }); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Select.create(this.options); - Select.selected(this.selected); - Select.value(this.selected < this.options.length ? this.options[this.selected].value.toString() : ""); - Select.font({ - size: this.hidesBackButton && void 0 === this.subtitle ? { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_headline7"], - bundleName: "", - moduleName: "" - } : { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_headline8"], - bundleName: "", - moduleName: "" - } - }); - Select.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_text"], - bundleName: "", - moduleName: "" - }); - Select.backgroundColor(Color.Transparent); - Select.onSelect(this.onSelected); - Select.constraintSize({ - maxWidth: this.selectMaxWidth - }); - Select.offset({ - x: -4 - }); - t || Select.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Select.pop(); - Row.pop(); - Badge.pop() - })) : this.ifElseBranchUpdateFunction(1, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.justifyContent(FlexAlign.Start); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Select.create(this.options); - Select.selected(this.selected); - Select.value(this.selected < this.options.length ? this.options[this.selected].value.toString() : ""); - Select.font({ - size: this.hidesBackButton && void 0 === this.subtitle ? { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_headline7"], - bundleName: "", - moduleName: "" - } : { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_headline8"], - bundleName: "", - moduleName: "" - } - }); - Select.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_text"], - bundleName: "", - moduleName: "" - }); - Select.backgroundColor(Color.Transparent); - Select.onSelect(this.onSelected); - Select.constraintSize({ - maxWidth: this.selectMaxWidth - }); - Select.offset({ - x: -4 - }); - t || Select.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Select.pop(); - Row.pop() - })); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - void 0 !== this.subtitle ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.justifyContent(FlexAlign.Start); - Row.margin({ - left: SelectTitleBar.subtitleLeftPadding - }); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.subtitle); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_over_line"], - bundleName: "", - moduleName: "" - }); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_subtitle_text"], - bundleName: "", - moduleName: "" - }); - Text.maxLines(1); - Text.textOverflow({ - overflow: TextOverflow.Ellipsis - }); - Text.constraintSize({ - maxWidth: this.selectMaxWidth - }); - Text.offset({ - y: -4 - }); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - Row.pop() - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - Column.pop(); - Row.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - void 0 !== this.menuItems && this.menuItems.length > 0 ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - t ? ViewPU.create(new CollapsibleMenuSection(this, { - menuItems: this.menuItems - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })) - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - Flex.pop() - } - rerender() { - this.updateDirtyElements() - } -} -SelectTitleBar.badgeSize = 16; -SelectTitleBar.totalHeight = 56; -SelectTitleBar.leftPadding = 24; -SelectTitleBar.leftPaddingWithBack = 12; -SelectTitleBar.rightPadding = 24; -SelectTitleBar.badgePadding = 16; -SelectTitleBar.subtitleLeftPadding = 4; -class CollapsibleMenuSection extends ViewPU { - constructor(e, t, o, i = -1) { - super(e, o, i); - this.menuItems = void 0; - this.__isPopupShown = new ObservedPropertySimplePU(!1, this, "isPopupShown"); - this.__isMoreIconOnFocus = new ObservedPropertySimplePU(!1, this, "isMoreIconOnFocus"); - this.__isMoreIconOnHover = new ObservedPropertySimplePU(!1, this, "isMoreIconOnHover"); - this.__isMoreIconOnClick = new ObservedPropertySimplePU(!1, this, "isMoreIconOnClick"); - this.setInitiallyProvidedValue(t) - } - setInitiallyProvidedValue(e) { - void 0 !== e.menuItems && (this.menuItems = e.menuItems); - void 0 !== e.isPopupShown && (this.isPopupShown = e.isPopupShown); - void 0 !== e.isMoreIconOnFocus && (this.isMoreIconOnFocus = e.isMoreIconOnFocus); - void 0 !== e.isMoreIconOnHover && (this.isMoreIconOnHover = e.isMoreIconOnHover); - void 0 !== e.isMoreIconOnClick && (this.isMoreIconOnClick = e.isMoreIconOnClick) - } - updateStateVars(e) {} - purgeVariableDependenciesOnElmtId(e) { - this.__isPopupShown.purgeDependencyOnElmtId(e); - this.__isMoreIconOnFocus.purgeDependencyOnElmtId(e); - this.__isMoreIconOnHover.purgeDependencyOnElmtId(e); - this.__isMoreIconOnClick.purgeDependencyOnElmtId(e) - } - aboutToBeDeleted() { - this.__isPopupShown.aboutToBeDeleted(); - this.__isMoreIconOnFocus.aboutToBeDeleted(); - this.__isMoreIconOnHover.aboutToBeDeleted(); - this.__isMoreIconOnClick.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - get isPopupShown() { - return this.__isPopupShown.get() - } - set isPopupShown(e) { - this.__isPopupShown.set(e) - } - get isMoreIconOnFocus() { - return this.__isMoreIconOnFocus.get() - } - set isMoreIconOnFocus(e) { - this.__isMoreIconOnFocus.set(e) - } - get isMoreIconOnHover() { - return this.__isMoreIconOnHover.get() - } - set isMoreIconOnHover(e) { - this.__isMoreIconOnHover.set(e) - } - get isMoreIconOnClick() { - return this.__isMoreIconOnClick.get() - } - set isMoreIconOnClick(e) { - this.__isMoreIconOnClick.set(e) - } - getMoreIconFgColor() { - return this.isMoreIconOnClick ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_icon_pressed"], - bundleName: "", - moduleName: "" - } : { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_icon"], - bundleName: "", - moduleName: "" - } - } - getMoreIconBgColor() { - return this.isMoreIconOnClick ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_click_effect"], - bundleName: "", - moduleName: "" - } : this.isMoreIconOnHover ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - } : Color.Transparent - } - initialRender() { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.height("100%"); - Column.margin({ - right: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_default_padding_end"], - bundleName: "", - moduleName: "" - } - }); - Column.justifyContent(FlexAlign.Center); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.menuItems.length <= CollapsibleMenuSection.maxCountOfVisibleItems ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - ForEach.create(); - this.forEachUpdateFunction(e, this.menuItems, (e => { - const t = e; - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - o ? ViewPU.create(new ImageMenuItem(this, { - item: t - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })) - })); - t || ForEach.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - ForEach.pop() - })) : this.ifElseBranchUpdateFunction(1, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - ForEach.create(); - this.forEachUpdateFunction(e, this.menuItems.slice(0, CollapsibleMenuSection.maxCountOfVisibleItems - 1), (e => { - const t = e; - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - o ? ViewPU.create(new ImageMenuItem(this, { - item: t - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })) - })); - t || ForEach.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - ForEach.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.width(ImageMenuItem.imageHotZoneWidth); - Row.height(ImageMenuItem.imageHotZoneWidth); - Row.borderRadius(ImageMenuItem.buttonBorderRadius); - Row.foregroundColor(this.getMoreIconFgColor()); - Row.backgroundColor(this.getMoreIconBgColor()); - Row.justifyContent(FlexAlign.Center); - Row.border(this.isMoreIconOnFocus ? { - width: ImageMenuItem.focusBorderWidth, - color: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_emphasize"], - bundleName: "", - moduleName: "" - }, - style: BorderStyle.Solid - } : { - width: 0 - }); - Row.onFocus((() => this.isMoreIconOnFocus = !0)); - Row.onBlur((() => this.isMoreIconOnFocus = !1)); - Row.onHover((e => this.isMoreIconOnHover = e)); - Row.onKeyEvent((e => { - if (e.keyCode === KeyCode.KEYCODE_ENTER || e.keyCode === KeyCode.KEYCODE_SPACE) { - e.type === KeyType.Down && (this.isMoreIconOnClick = !0); - e.type === KeyType.Up && (this.isMoreIconOnClick = !1) - } - })); - Row.onTouch((e => { - e.type === TouchType.Down && (this.isMoreIconOnClick = !0); - e.type === TouchType.Up && (this.isMoreIconOnClick = !1) - })); - Row.onClick((() => this.isPopupShown = !0)); - Row.bindPopup(this.isPopupShown, { - builder: { - builder: this.popupBuilder.bind(this) - }, - placement: Placement.Bottom, - popupColor: Color.White, - enableArrow: !1, - onStateChange: e => this.isPopupShown = e.isVisible - }); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(PUBLIC_MORE); - Image.width(ImageMenuItem.imageSize); - Image.height(ImageMenuItem.imageSize); - Image.focusable(!0); - t || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop() - })); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - Row.pop(); - Column.pop() - } - popupBuilder(e = null) { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.width(ImageMenuItem.imageHotZoneWidth + CollapsibleMenuSection.focusPadding * CollapsibleMenuSection.marginsNum); - Column.margin({ - top: CollapsibleMenuSection.focusPadding, - bottom: CollapsibleMenuSection.focusPadding - }); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - ForEach.create(); - this.forEachUpdateFunction(e, this.menuItems.slice(CollapsibleMenuSection.maxCountOfVisibleItems - 1, this.menuItems.length), ((e, t) => { - const o = e; - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - t ? ViewPU.create(new ImageMenuItem(this, { - item: o - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })) - }), void 0, !0, !1); - t || ForEach.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - ForEach.pop(); - Column.pop() - } - rerender() { - this.updateDirtyElements() - } -} -CollapsibleMenuSection.maxCountOfVisibleItems = 3; -CollapsibleMenuSection.focusPadding = 4; -CollapsibleMenuSection.marginsNum = 2; -__decorate([], CollapsibleMenuSection.prototype, "popupBuilder", null); -class ImageMenuItem extends ViewPU { - constructor(e, t, o, i = -1) { - super(e, o, i); - this.item = void 0; - this.__isOnFocus = new ObservedPropertySimplePU(!1, this, "isOnFocus"); - this.__isOnHover = new ObservedPropertySimplePU(!1, this, "isOnHover"); - this.__isOnClick = new ObservedPropertySimplePU(!1, this, "isOnClick"); - this.setInitiallyProvidedValue(t) - } - setInitiallyProvidedValue(e) { - void 0 !== e.item && (this.item = e.item); - void 0 !== e.isOnFocus && (this.isOnFocus = e.isOnFocus); - void 0 !== e.isOnHover && (this.isOnHover = e.isOnHover); - void 0 !== e.isOnClick && (this.isOnClick = e.isOnClick) - } - updateStateVars(e) {} - purgeVariableDependenciesOnElmtId(e) { - this.__isOnFocus.purgeDependencyOnElmtId(e); - this.__isOnHover.purgeDependencyOnElmtId(e); - this.__isOnClick.purgeDependencyOnElmtId(e) - } - aboutToBeDeleted() { - this.__isOnFocus.aboutToBeDeleted(); - this.__isOnHover.aboutToBeDeleted(); - this.__isOnClick.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - get isOnFocus() { - return this.__isOnFocus.get() - } - set isOnFocus(e) { - this.__isOnFocus.set(e) - } - get isOnHover() { - return this.__isOnHover.get() - } - set isOnHover(e) { - this.__isOnHover.set(e) - } - get isOnClick() { - return this.__isOnClick.get() - } - set isOnClick(e) { - this.__isOnClick.set(e) - } - getFgColor() { - return this.isOnClick ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_icon_pressed"], - bundleName: "", - moduleName: "" - } : { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_icon"], - bundleName: "", - moduleName: "" - } - } - getBgColor() { - return this.isOnClick ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_click_effect"], - bundleName: "", - moduleName: "" - } : this.isOnHover ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - } : Color.Transparent - } - initialRender() { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.width(ImageMenuItem.imageHotZoneWidth); - Row.height(ImageMenuItem.imageHotZoneWidth); - Row.borderRadius(ImageMenuItem.buttonBorderRadius); - Row.foregroundColor(this.getFgColor()); - Row.backgroundColor(this.getBgColor()); - Row.justifyContent(FlexAlign.Center); - Row.opacity(this.item.isEnabled ? 1 : ImageMenuItem.disabledImageOpacity); - Row.border(this.isOnFocus ? { - width: ImageMenuItem.focusBorderWidth, - color: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_emphasize"], - bundleName: "", - moduleName: "" - }, - style: BorderStyle.Solid - } : { - width: 0 - }); - Row.onFocus((() => { - this.item.isEnabled && (this.isOnFocus = !0) - })); - Row.onBlur((() => this.isOnFocus = !1)); - Row.onHover((e => { - this.item.isEnabled && (this.isOnHover = e) - })); - Row.onKeyEvent((e => { - if (this.item.isEnabled && (e.keyCode === KeyCode.KEYCODE_ENTER || e.keyCode === KeyCode.KEYCODE_SPACE)) { - e.type === KeyType.Down && (this.isOnClick = !0); - e.type === KeyType.Up && (this.isOnClick = !1) - } - })); - Row.onTouch((e => { - if (this.item.isEnabled) { - e.type === TouchType.Down && (this.isOnClick = !0); - e.type === TouchType.Up && (this.isOnClick = !1) - } - })); - Row.onClick((() => this.item.isEnabled && this.item.action && this.item.action())); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(this.item.value); - Image.width(ImageMenuItem.imageSize); - Image.height(ImageMenuItem.imageSize); - Image.focusable(this.item.isEnabled); - t || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop() - } - rerender() { - this.updateDirtyElements() - } -} -ImageMenuItem.imageSize = 24; -ImageMenuItem.imageHotZoneWidth = 48; -ImageMenuItem.buttonBorderRadius = 8; -ImageMenuItem.focusBorderWidth = 2; -ImageMenuItem.disabledImageOpacity = .4; -export default { - SelectTitleBar: SelectTitleBar -}; \ No newline at end of file diff --git a/interface/splitlayout/BUILD.gn b/interface/splitlayout/BUILD.gn deleted file mode 100644 index 8a0a21c80ba59b788cd1a3af7518cb754a48ef4b..0000000000000000000000000000000000000000 --- a/interface/splitlayout/BUILD.gn +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (c) 2023-2023 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") -import("//foundation/arkui/ace_engine/ace_config.gni") -import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") - -es2abc_gen_abc("gen_splitlayout_abc") { - src_js = rebase_path("splitlayout.js") - dst_file = rebase_path(target_out_dir + "/splitlayout.abc") - in_puts = [ "splitlayout.js" ] - out_puts = [ target_out_dir + "/splitlayout.abc" ] - extra_args = [ "--module" ] -} - -gen_js_obj("splitlayout_abc") { - input = get_label_info(":gen_splitlayout_abc", "target_out_dir") + "/splitlayout.abc" - output = target_out_dir + "/splitlayout_abc.o" - dep = ":gen_splitlayout_abc" -} - -ohos_shared_library("splitlayout") { - sources = [ "splitlayout.cpp" ] - - deps = [ ":splitlayout_abc" ] - - external_deps = [ - "hilog:libhilog", - "napi:ace_napi", - ] - - subsystem_name = "arkui" - part_name = "advanced_ui_component" - - relative_install_dir = "module/arkui/advanced" -} \ No newline at end of file diff --git a/interface/splitlayout/splitlayout.js b/interface/splitlayout/splitlayout.js deleted file mode 100644 index 85792d46d53f9fc24d95792467d9c3435098c7d9..0000000000000000000000000000000000000000 --- a/interface/splitlayout/splitlayout.js +++ /dev/null @@ -1,524 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export class splitlayout extends ViewPU { - constructor(e, t, o, r = -1) { - super(e, o, r); - this.container = void 0; - this.__sizeValue = new ObservedPropertySimplePU("", this, "sizeValue"); - this.__areaWidth = new ObservedPropertySimplePU(0, this, "areaWidth"); - this.__imageBackgroundColor = new ObservedPropertySimplePU("#FFFFFF", this, "imageBackgroundColor"); - this.__mainImage = new SynchedPropertyObjectOneWayPU(t.mainImage, this, "mainImage"); - this.__primaryText = new SynchedPropertySimpleOneWayPU(t.primaryText, this, "primaryText"); - this.secondaryText = "私人订制新歌精选站,为你推荐专属优质新歌;为你推荐专属优质新歌"; - this.tertiaryText = "每日更新"; - this.setInitiallyProvidedValue(t) - } - - setInitiallyProvidedValue(e) { - void 0 !== e.container && (this.container = e.container); - void 0 !== e.sizeValue && (this.sizeValue = e.sizeValue); - void 0 !== e.areaWidth && (this.areaWidth = e.areaWidth); - void 0 !== e.imageBackgroundColor && (this.imageBackgroundColor = e.imageBackgroundColor); - void 0 !== e.mainImage ? this.__mainImage.set(e.mainImage) : this.__mainImage.set({ - id: -1, - type: 2e4, - params: ["app.media.music"], - bundleName: "", - moduleName: "" - }); - void 0 !== e.primaryText ? this.__primaryText.set(e.primaryText) : this.__primaryText.set("新歌推荐"); - void 0 !== e.secondaryText && (this.secondaryText = e.secondaryText); - void 0 !== e.tertiaryText && (this.tertiaryText = e.tertiaryText) - } - - updateStateVars(e) { - this.__mainImage.reset(e.mainImage); - this.__primaryText.reset(e.primaryText) - } - - purgeVariableDependenciesOnElmtId(e) { - this.__sizeValue.purgeDependencyOnElmtId(e); - this.__areaWidth.purgeDependencyOnElmtId(e); - this.__imageBackgroundColor.purgeDependencyOnElmtId(e); - this.__mainImage.purgeDependencyOnElmtId(e); - this.__primaryText.purgeDependencyOnElmtId(e) - } - - aboutToBeDeleted() { - this.__sizeValue.aboutToBeDeleted(); - this.__areaWidth.aboutToBeDeleted(); - this.__imageBackgroundColor.aboutToBeDeleted(); - this.__mainImage.aboutToBeDeleted(); - this.__primaryText.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - - get sizeValue() { - return this.__sizeValue.get() - } - - set sizeValue(e) { - this.__sizeValue.set(e) - } - - get areaWidth() { - return this.__areaWidth.get() - } - - set areaWidth(e) { - this.__areaWidth.set(e) - } - - get imageBackgroundColor() { - return this.__imageBackgroundColor.get() - } - - set imageBackgroundColor(e) { - this.__imageBackgroundColor.set(e) - } - - get mainImage() { - return this.__mainImage.get() - } - - set mainImage(e) { - this.__mainImage.set(e) - } - - get primaryText() { - return this.__primaryText.get() - } - - set primaryText(e) { - this.__primaryText.set(e) - } - - initialRender() { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.onAreaChange(((e, t) => { - console.info(`Ace: on area change, oldValue is ${JSON.stringify(e)} value is ${JSON.stringify(t)}`); - this.sizeValue = JSON.stringify(t); - this.areaWidth = parseInt(t.width.toString(), 0); - console.info("pingAce: on area change, oldValue is" + this.areaWidth); - console.info("pingAce: on area change, oldValue is" + parseInt(t.height.toString(), 0)) - })); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.areaWidth < 600 ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - GridRow.create({ - columns: 4, - breakpoints: { reference: BreakpointsReference.WindowSize }, - direction: GridRowDirection.Row - }); - t || GridRow.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - GridCol.create({ span: { xs: 4, sm: 4, md: 4, lg: 4 } }); - t || GridCol.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Stack.create({ alignContent: Alignment.Bottom }); - Stack.height("34%"); - Stack.width("100%"); - t || Stack.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(this.mainImage); - t || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.alignItems(HorizontalAlign.Center); - Column.margin({ - left: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_max_padding_start"], - bundleName: "", - moduleName: "" - }, - right: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_max_padding_end"], - bundleName: "", - moduleName: "" - } - }); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.primaryText); - Text.textAlign(TextAlign.Center); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_headline7"], - bundleName: "", - moduleName: "" - }); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary"], - bundleName: "", - moduleName: "" - }); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.secondaryText); - Text.textAlign(TextAlign.Center); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body2"], - bundleName: "", - moduleName: "" - }); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary"], - bundleName: "", - moduleName: "" - }); - Text.margin({ top: 4, bottom: 8 }); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.tertiaryText); - Text.textAlign(TextAlign.Center); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_caption"], - bundleName: "", - moduleName: "" - }); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_secondary"], - bundleName: "", - moduleName: "" - }); - Text.margin({ bottom: 24 }); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - Column.pop(); - Stack.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.height("66%"); - Column.width("100%"); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.container.bind(this)(); - Column.pop(); - Column.pop(); - GridCol.pop(); - GridRow.pop() - })) : 600 < this.areaWidth && this.areaWidth < 840 ? this.ifElseBranchUpdateFunction(1, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - GridRow.create({ - columns: 8, - breakpoints: { reference: BreakpointsReference.WindowSize }, - direction: GridRowDirection.Row - }); - t || GridRow.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - GridCol.create({ span: { xs: 8, sm: 8, md: 8, lg: 8 } }); - t || GridCol.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.backgroundColor(this.imageBackgroundColor); - Row.height("34%"); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(this.mainImage); - Image.margin({ left: 96, right: 36 }); - Image.height("60%"); - Image.width("20%"); - t || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.alignItems(HorizontalAlign.Start); - Column.margin({ right: 96 }); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.primaryText); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_headline7"], - bundleName: "", - moduleName: "" - }); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary"], - bundleName: "", - moduleName: "" - }); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.secondaryText); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body2"], - bundleName: "", - moduleName: "" - }); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary"], - bundleName: "", - moduleName: "" - }); - Text.margin({ top: 4, bottom: 8 }); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.tertiaryText); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_caption"], - bundleName: "", - moduleName: "" - }); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_secondary"], - bundleName: "", - moduleName: "" - }); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - Column.pop(); - Row.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.height("66%"); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.container.bind(this)(); - Column.pop(); - Column.pop(); - GridCol.pop(); - GridRow.pop() - })) : this.areaWidth > 840 && this.ifElseBranchUpdateFunction(2, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - GridRow.create({ - columns: 12, - breakpoints: { reference: BreakpointsReference.WindowSize }, - direction: GridRowDirection.Row - }); - t || GridRow.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - GridCol.create({ span: { xs: 4, sm: 4, md: 4, lg: 4 } }); - GridCol.height("100%"); - t || GridCol.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.height("100%"); - Column.backgroundColor(this.imageBackgroundColor); - Column.justifyContent(FlexAlign.Center); - Column.alignItems(HorizontalAlign.Center); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(this.mainImage); - Image.height("17%"); - Image.width("34%"); - Image.margin({ bottom: 36 }); - t || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.primaryText); - Text.textAlign(TextAlign.Center); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_headline7"], - bundleName: "", - moduleName: "" - }); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary"], - bundleName: "", - moduleName: "" - }); - Text.margin({ left: 48, right: 48 }); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.secondaryText); - Text.textAlign(TextAlign.Center); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body1"], - bundleName: "", - moduleName: "" - }); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary"], - bundleName: "", - moduleName: "" - }); - Text.margin({ top: 4, bottom: 8, left: 48, right: 48 }); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.tertiaryText); - Text.textAlign(TextAlign.Center); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body2"], - bundleName: "", - moduleName: "" - }); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_secondary"], - bundleName: "", - moduleName: "" - }); - Text.margin({ bottom: 24, left: 48, right: 48 }); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - Column.pop(); - GridCol.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - GridCol.create({ span: { xs: 8, sm: 8, md: 8, lg: 8 } }); - t || GridCol.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.container.bind(this)(); - GridCol.pop(); - GridRow.pop() - })); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - Column.pop() - } - - rerender() { - this.updateDirtyElements() - } -} \ No newline at end of file diff --git a/interface/subheader/BUILD.gn b/interface/subheader/BUILD.gn deleted file mode 100644 index 926d6edf6873178ce3e75db5947d2e87e7b6c97f..0000000000000000000000000000000000000000 --- a/interface/subheader/BUILD.gn +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (c) 2023-2023 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") -import("//foundation/arkui/ace_engine/ace_config.gni") -import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") - -es2abc_gen_abc("gen_subheader_abc") { - src_js = rebase_path("subheader.js") - dst_file = rebase_path(target_out_dir + "/subheader.abc") - in_puts = [ "subheader.js" ] - out_puts = [ target_out_dir + "/subheader.abc" ] - extra_args = [ "--module" ] -} - -gen_js_obj("subheader_abc") { - input = get_label_info(":gen_subheader_abc", "target_out_dir") + "/subheader.abc" - output = target_out_dir + "/subheader_abc.o" - dep = ":gen_subheader_abc" -} - -ohos_shared_library("subheader") { - sources = [ "subheader.cpp" ] - - deps = [ ":subheader_abc" ] - - external_deps = [ - "hilog:libhilog", - "napi:ace_napi", - ] - - subsystem_name = "arkui" - part_name = "advanced_ui_component" - - relative_install_dir = "module/arkui/advanced" -} \ No newline at end of file diff --git a/interface/subheader/subheader.js b/interface/subheader/subheader.js deleted file mode 100644 index 651a883665ca2a54feff52e463ff701497412666..0000000000000000000000000000000000000000 --- a/interface/subheader/subheader.js +++ /dev/null @@ -1,1141 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const SPACE_MARGIN = 8; -const MARGIN_NUM = 4; -const IMAGE_WIDTH_NUM = 16; -const IMAGE_HEIGHT_NUM = 24; -const BUTTON_SIZE = 32; -const SINGLE_LINE_HEIGHT = 48; -const DOUBLE_LINE_HEIGHT = 64; -const BUTTON_HEIGHT = 28; -const IMAGE_WIDTH = 12; -const BORDER_WIDTH = 2; -const SINGLE_LINE_NUM = 1; -const DOUBLE_LINE_NUM = 2; -const MIN_FONT_SIZE = 14; -const MAIN_TEXT_SIZE = 10; -const MIN_CONSTRAINT_WIDTH = 3; - -export var OperationType; -!function(e){ - e[e.TEXT_ARROW=0] = "TEXT_ARROW"; - e[e.BUTTON=1] = "BUTTON"; - e[e.ICON_GROUP=2] = "ICON_GROUP"; - e[e.LOADING=3] = "LOADING" -}(OperationType || (OperationType = {})); - -class ButtonStyle extends ViewPU { - constructor(e, o, t, s = -1) { - super(e, t, s); - this.__buttonBgColor = new ObservedPropertyObjectPU({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - }, this, "buttonBgColor"); - this.__isButtonFocus = new ObservedPropertySimplePU(!1, this, "isButtonFocus"); - this.button = void 0; - this.focusBorderWidth = 2; - this.setInitiallyProvidedValue(o) - } - - setInitiallyProvidedValue(e) { - void 0 !== e.buttonBgColor && (this.buttonBgColor = e.buttonBgColor); - void 0 !== e.isButtonFocus && (this.isButtonFocus = e.isButtonFocus); - void 0 !== e.button && (this.button = e.button); - void 0 !== e.focusBorderWidth && (this.focusBorderWidth = e.focusBorderWidth) - } - - updateStateVars(e) { - } - - purgeVariableDependenciesOnElmtId(e) { - this.__buttonBgColor.purgeDependencyOnElmtId(e); - this.__isButtonFocus.purgeDependencyOnElmtId(e) - } - - aboutToBeDeleted() { - this.__buttonBgColor.aboutToBeDeleted(); - this.__isButtonFocus.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - - get buttonBgColor() { - return this.__buttonBgColor.get() - } - - set buttonBgColor(e) { - this.__buttonBgColor.set(e) - } - - get isButtonFocus() { - return this.__isButtonFocus.get() - } - - set isButtonFocus(e) { - this.__isButtonFocus.set(e) - } - - initialRender() { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.align(Alignment.End); - Row.justifyContent(FlexAlign.Center); - Row.focusable(!0); - Row.height(28); - Row.margin({ left: 8, right: 8 }); - Row.borderRadius(16); - Row.backgroundColor(ObservedObject.GetRawObject(this.buttonBgColor)); - Row.onTouch((e => { - if (e.type === TouchType.Down) { - this.button.action && this.button.action(); - this.buttonBgColor = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_click_effect"], - bundleName: "", - moduleName: "" - } - } - e.type === TouchType.Up && (this.buttonBgColor = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - }) - })); - Row.onHover((e => { - this.buttonBgColor = e ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - } : { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - } - })); - Row.border(this.isButtonFocus ? { - width: this.focusBorderWidth, - color: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_focused_outline"], - bundleName: "", - moduleName: "" - }, - style: BorderStyle.Solid - } : { width: 0 }); - Row.onFocus((() => { - this.isButtonFocus = !0 - })); - Row.onBlur((() => { - this.isButtonFocus = !1 - })); - Row.onKeyEvent((e => { - 2054 !== e.keyCode && 2050 !== e.keyCode || this.button.action && this.button.action() - })); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.button.value); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary_activated"], - bundleName: "", - moduleName: "" - }); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_button2"], - bundleName: "", - moduleName: "" - }); - Text.fontWeight(FontWeight.Medium); - Text.margin({ left: 8, right: 8 }); - Text.focusable(!0); - Text.maxLines(2); - o || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - Row.pop() - } - - rerender() { - this.updateDirtyElements() - } -} - -class IconGroup extends ViewPU { - constructor(e, o, t, s = -1) { - super(e, t, s); - this.__bgColor = new ObservedPropertyObjectPU({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - }, this, "bgColor"); - this.__isFocus = new ObservedPropertySimplePU(!1, this, "isFocus"); - this.item = void 0; - this.focusBorderWidth = 2; - this.setInitiallyProvidedValue(o) - } - - setInitiallyProvidedValue(e) { - void 0 !== e.bgColor && (this.bgColor = e.bgColor); - void 0 !== e.isFocus && (this.isFocus = e.isFocus); - void 0 !== e.item && (this.item = e.item); - void 0 !== e.focusBorderWidth && (this.focusBorderWidth = e.focusBorderWidth) - } - - updateStateVars(e) { - } - - purgeVariableDependenciesOnElmtId(e) { - this.__bgColor.purgeDependencyOnElmtId(e); - this.__isFocus.purgeDependencyOnElmtId(e) - } - - aboutToBeDeleted() { - this.__bgColor.aboutToBeDeleted(); - this.__isFocus.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - - get bgColor() { - return this.__bgColor.get() - } - - set bgColor(e) { - this.__bgColor.set(e) - } - - get isFocus() { - return this.__isFocus.get() - } - - set isFocus(e) { - this.__isFocus.set(e) - } - - initialRender() { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.focusable(!0); - Row.width(32); - Row.height(32); - Row.margin({ right: 8 }); - Row.justifyContent(FlexAlign.Center); - Row.borderRadius({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_clicked"], - bundleName: "", - moduleName: "" - }); - Row.backgroundColor(ObservedObject.GetRawObject(this.bgColor)); - Row.onTouch((e => { - if (e.type === TouchType.Down) { - this.item.action && this.item.action(); - this.bgColor = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_click_effect"], - bundleName: "", - moduleName: "" - } - } - e.type === TouchType.Up && (this.bgColor = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - }) - })); - Row.onHover((e => { - this.bgColor = e ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - } : { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - } - })); - Row.border(this.isFocus ? { - width: this.focusBorderWidth, - color: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_emphasize"], - bundleName: "", - moduleName: "" - }, - style: BorderStyle.Solid - } : { width: 0 }); - Row.onFocus((() => { - this.isFocus = !0 - })); - Row.onBlur((() => { - this.isFocus = !1 - })); - Row.onKeyEvent((e => { - 2054 !== e.keyCode && 2050 !== e.keyCode || this.item.action && this.item.action() - })); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(this.item.value); - Image.fillColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_primary"], - bundleName: "", - moduleName: "" - }); - Image.width(24); - Image.height(24); - Image.focusable(!0); - o || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop() - } - - rerender() { - this.updateDirtyElements() - } -} - -export class SubHeader extends ViewPU { - constructor(e, o, t, s = -1) { - super(e, t, s); - this.__icon = new SynchedPropertyObjectOneWayPU(o.icon, this, "icon"); - this.__primaryTitle = new SynchedPropertySimpleOneWayPU(o.primaryTitle, this, "primaryTitle"); - this.__secondaryTitle = new SynchedPropertySimpleOneWayPU(o.secondaryTitle, this, "secondaryTitle"); - this.__select = new SynchedPropertyObjectOneWayPU(o.select, this, "select"); - this.__operationType = new SynchedPropertySimpleOneWayPU(o.operationType, this, "operationType"); - this.operationItem = void 0; - this.__isDuplicateLine = new ObservedPropertySimplePU(!1, this, "isDuplicateLine"); - this.__textArrowBgColor = new ObservedPropertyObjectPU({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - }, this, "textArrowBgColor"); - this.__buttonBgColor = new ObservedPropertyObjectPU({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - }, this, "buttonBgColor"); - this.__iconBgColor = new ObservedPropertyObjectPU({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - }, this, "iconBgColor"); - this.__firstIconBgColor = new ObservedPropertyObjectPU({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - }, this, "firstIconBgColor"); - this.__SecondaryIconBgColor = new ObservedPropertyObjectPU({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - }, this, "SecondaryIconBgColor"); - this.__thirdIconBgColor = new ObservedPropertyObjectPU({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - }, this, "thirdIconBgColor"); - this.__flag = new ObservedPropertySimplePU(!1, this, "flag"); - this.__isTextArrowFocus = new ObservedPropertySimplePU(!1, this, "isTextArrowFocus"); - this.focusBorderWidth = 2; - this.setInitiallyProvidedValue(o) - } - - setInitiallyProvidedValue(e) { - void 0 !== e.operationType ? this.__operationType.set(e.operationType) : this.__operationType.set(OperationType.BUTTON); - void 0 !== e.operationItem && (this.operationItem = e.operationItem); - void 0 !== e.isDuplicateLine && (this.isDuplicateLine = e.isDuplicateLine); - void 0 !== e.textArrowBgColor && (this.textArrowBgColor = e.textArrowBgColor); - void 0 !== e.buttonBgColor && (this.buttonBgColor = e.buttonBgColor); - void 0 !== e.iconBgColor && (this.iconBgColor = e.iconBgColor); - void 0 !== e.firstIconBgColor && (this.firstIconBgColor = e.firstIconBgColor); - void 0 !== e.SecondaryIconBgColor && (this.SecondaryIconBgColor = e.SecondaryIconBgColor); - void 0 !== e.thirdIconBgColor && (this.thirdIconBgColor = e.thirdIconBgColor); - void 0 !== e.flag && (this.flag = e.flag); - void 0 !== e.isTextArrowFocus && (this.isTextArrowFocus = e.isTextArrowFocus); - void 0 !== e.focusBorderWidth && (this.focusBorderWidth = e.focusBorderWidth) - } - - updateStateVars(e) { - this.__icon.reset(e.icon); - this.__primaryTitle.reset(e.primaryTitle); - this.__secondaryTitle.reset(e.secondaryTitle); - this.__select.reset(e.select); - this.__operationType.reset(e.operationType) - } - - purgeVariableDependenciesOnElmtId(e) { - this.__icon.purgeDependencyOnElmtId(e); - this.__primaryTitle.purgeDependencyOnElmtId(e); - this.__secondaryTitle.purgeDependencyOnElmtId(e); - this.__select.purgeDependencyOnElmtId(e); - this.__operationType.purgeDependencyOnElmtId(e); - this.__isDuplicateLine.purgeDependencyOnElmtId(e); - this.__textArrowBgColor.purgeDependencyOnElmtId(e); - this.__buttonBgColor.purgeDependencyOnElmtId(e); - this.__iconBgColor.purgeDependencyOnElmtId(e); - this.__firstIconBgColor.purgeDependencyOnElmtId(e); - this.__SecondaryIconBgColor.purgeDependencyOnElmtId(e); - this.__thirdIconBgColor.purgeDependencyOnElmtId(e); - this.__flag.purgeDependencyOnElmtId(e); - this.__isTextArrowFocus.purgeDependencyOnElmtId(e) - } - - aboutToBeDeleted() { - this.__icon.aboutToBeDeleted(); - this.__primaryTitle.aboutToBeDeleted(); - this.__secondaryTitle.aboutToBeDeleted(); - this.__select.aboutToBeDeleted(); - this.__operationType.aboutToBeDeleted(); - this.__isDuplicateLine.aboutToBeDeleted(); - this.__textArrowBgColor.aboutToBeDeleted(); - this.__buttonBgColor.aboutToBeDeleted(); - this.__iconBgColor.aboutToBeDeleted(); - this.__firstIconBgColor.aboutToBeDeleted(); - this.__SecondaryIconBgColor.aboutToBeDeleted(); - this.__thirdIconBgColor.aboutToBeDeleted(); - this.__flag.aboutToBeDeleted(); - this.__isTextArrowFocus.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - - get icon() { - return this.__icon.get() - } - - set icon(e) { - this.__icon.set(e) - } - - get primaryTitle() { - return this.__primaryTitle.get() - } - - set primaryTitle(e) { - this.__primaryTitle.set(e) - } - - get secondaryTitle() { - return this.__secondaryTitle.get() - } - - set secondaryTitle(e) { - this.__secondaryTitle.set(e) - } - - get select() { - return this.__select.get() - } - - set select(e) { - this.__select.set(e) - } - - get operationType() { - return this.__operationType.get() - } - - set operationType(e) { - this.__operationType.set(e) - } - - get isDuplicateLine() { - return this.__isDuplicateLine.get() - } - - set isDuplicateLine(e) { - this.__isDuplicateLine.set(e) - } - - get textArrowBgColor() { - return this.__textArrowBgColor.get() - } - - set textArrowBgColor(e) { - this.__textArrowBgColor.set(e) - } - - get buttonBgColor() { - return this.__buttonBgColor.get() - } - - set buttonBgColor(e) { - this.__buttonBgColor.set(e) - } - - get iconBgColor() { - return this.__iconBgColor.get() - } - - set iconBgColor(e) { - this.__iconBgColor.set(e) - } - - get firstIconBgColor() { - return this.__firstIconBgColor.get() - } - - set firstIconBgColor(e) { - this.__firstIconBgColor.set(e) - } - - get SecondaryIconBgColor() { - return this.__SecondaryIconBgColor.get() - } - - set SecondaryIconBgColor(e) { - this.__SecondaryIconBgColor.set(e) - } - - get thirdIconBgColor() { - return this.__thirdIconBgColor.get() - } - - set thirdIconBgColor(e) { - this.__thirdIconBgColor.set(e) - } - - get flag() { - return this.__flag.get() - } - - set flag(e) { - this.__flag.set(e) - } - - get isTextArrowFocus() { - return this.__isTextArrowFocus.get() - } - - set isTextArrowFocus(e) { - this.__isTextArrowFocus.set(e) - } - - ListTextStyle(e, o = null) { - this.observeComponentCreation(((o, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Text.create(e.content); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_secondary"], - bundleName: "", - moduleName: "" - }); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_sub_title3"], - bundleName: "", - moduleName: "" - }); - Text.maxLines(2); - Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - Text.margin({ - left: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_max_padding_end"], - bundleName: "", - moduleName: "" - }, - bottom: 8, - right: 4 - }); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop() - } - - ListIconStyle(e, o, t = null) { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.margin({ - left: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_max_padding_end"], - bundleName: "", - moduleName: "" - }, - bottom: 8, - right: 4 - }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(o); - Image.width(16); - Image.height(16); - Image.margin({ right: 8 }); - t || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((o, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Text.create(e.content); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_secondary"], - bundleName: "", - moduleName: "" - }); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_sub_title3"], - bundleName: "", - moduleName: "" - }); - Text.maxLines(2); - Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - Row.pop() - } - - ContentTextStyle(e, o = null) { - this.observeComponentCreation(((o, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Text.create(e.content); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary"], - bundleName: "", - moduleName: "" - }); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_sub_title2"], - bundleName: "", - moduleName: "" - }); - Text.maxLines(2); - Text.maxFontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_sub_title2"], - bundleName: "", - moduleName: "" - }); - Text.minFontSize(14); - Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - Text.margin({ - left: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_max_padding_start"], - bundleName: "", - moduleName: "" - }, - right: 4, - bottom: 8 - }); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop() - } - - SubTextStyle(e, o = null) { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.alignItems(HorizontalAlign.Start); - Column.onAppear((() => { - this.isDuplicateLine = !0 - })); - Column.margin({ - left: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_max_padding_start"], - bundleName: "", - moduleName: "" - }, - right: 4, - bottom: 8 - }); - o || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((o, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Text.create(e.content); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary"], - bundleName: "", - moduleName: "" - }); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_sub_title2"], - bundleName: "", - moduleName: "" - }); - Text.maxLines(1); - Text.maxFontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_sub_title2"], - bundleName: "", - moduleName: "" - }); - Text.minFontSize(14); - Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - this.observeComponentCreation(((o, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Text.create(e.subContent); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_secondary"], - bundleName: "", - moduleName: "" - }); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_sub_title3"], - bundleName: "", - moduleName: "" - }); - Text.maxLines(1); - Text.maxFontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_sub_title3"], - bundleName: "", - moduleName: "" - }); - Text.minFontSize(10); - Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - Column.pop() - } - - SelectStyle(e, o = null) { - this.observeComponentCreation(((o, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Select.create(e.options); - Select.selected(e.selected); - Select.value(e.value); - Select.onSelect(((o, t) => { - e.onSelect && e.onSelect(o, t) - })); - Select.margin({ - left: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_default_padding_start"], - bundleName: "", - moduleName: "" - }, - right: 4 - }); - t || Select.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Select.pop() - } - - LoadingProcessStyle(e = null) { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - LoadingProgress.create(); - LoadingProgress.width(24); - LoadingProgress.height(24); - LoadingProgress.focusable(!0); - LoadingProgress.margin({ - right: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_default_padding_end"], - bundleName: "", - moduleName: "" - } - }); - o || LoadingProgress.pop(); - ViewStackProcessor.StopGetAccessRecording() - })) - } - - TextArrowStyle(e, o = null) { - this.observeComponentCreation(((o, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Row.create(); - Row.focusable(!0); - Row.margin({ left: 4, right: 4, bottom: 4 }); - Row.borderRadius({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_subtab"], - bundleName: "", - moduleName: "" - }); - Row.backgroundColor(ObservedObject.GetRawObject(this.textArrowBgColor)); - Row.onTouch((o => { - if (o.type === TouchType.Down) { - e.action && e.action(); - this.textArrowBgColor = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_click_effect"], - bundleName: "", - moduleName: "" - } - } - o.type === TouchType.Up && (this.textArrowBgColor = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - }) - })); - Row.onHover((e => { - this.textArrowBgColor = e ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - } : { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - } - })); - Row.border(this.isTextArrowFocus ? { - width: this.focusBorderWidth, - color: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_focused_outline"], - bundleName: "", - moduleName: "" - }, - style: BorderStyle.Solid - } : { width: 0 }); - Row.onFocus((() => { - this.isTextArrowFocus = !0 - })); - Row.onBlur((() => { - this.isTextArrowFocus = !1 - })); - Row.onKeyEvent((o => { - 2054 !== o.keyCode && 2050 !== o.keyCode || e.action && e.action() - })); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.margin({ left: 8, right: 8 }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((o, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Text.create(e.value); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_secondary"], - bundleName: "", - moduleName: "" - }); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body2"], - bundleName: "", - moduleName: "" - }); - Text.margin({ right: 4 }); - Text.focusable(!0); - Text.maxLines(2); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create({ - id: -1, - type: 2e4, - params: ["sys.media.ohos_ic_public_arrow_right"], - bundleName: "", - moduleName: "" - }); - Image.fillColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_tertiary"], - bundleName: "", - moduleName: "" - }); - Image.width(12); - Image.height(24); - Image.focusable(!0); - o || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop(); - Row.pop() - } - - initialRender() { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Flex.create({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.End }); - Flex.padding({ - right: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_default_padding_end"], - bundleName: "", - moduleName: "" - } - }); - Flex.height(this.isDuplicateLine ? 64 : 48); - o || Flex.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - null != this.secondaryTitle && null != this.icon ? this.ifElseBranchUpdateFunction(0, (() => { - this.ListIconStyle.bind(this)({ content: this.secondaryTitle }, ObservedObject.GetRawObject(this.icon)) - })) : null != this.secondaryTitle && null != this.primaryTitle ? this.ifElseBranchUpdateFunction(1, (() => { - this.SubTextStyle.bind(this)(makeBuilderParameterProxy("SubTextStyle", { - content: () => this.__primaryTitle ? this.__primaryTitle : this.primaryTitle, - subContent: () => this.__secondaryTitle ? this.__secondaryTitle : this.secondaryTitle - })) - })) : null != this.secondaryTitle ? this.ifElseBranchUpdateFunction(2, (() => { - this.ListTextStyle.bind(this)(makeBuilderParameterProxy("ListTextStyle", { - content: () => this.__secondaryTitle ? this.__secondaryTitle : this.secondaryTitle - })) - })) : null != this.select ? this.ifElseBranchUpdateFunction(3, (() => { - this.SelectStyle.bind(this)(ObservedObject.GetRawObject(this.select)) - })) : null != this.primaryTitle && this.ifElseBranchUpdateFunction(4, (() => { - this.ContentTextStyle.bind(this)(makeBuilderParameterProxy("ContentTextStyle", { - content: () => this.__primaryTitle ? this.__primaryTitle : this.primaryTitle - })) - })); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.operationType === OperationType.BUTTON && null != this.operationItem ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - __Common__.create(); - __Common__.margin({ bottom: 4 }); - o || __Common__.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - o ? ViewPU.create(new ButtonStyle(this, { - button: this.operationItem[0] - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })); - __Common__.pop() - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.operationType === OperationType.ICON_GROUP && null != this.operationItem ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.margin({ bottom: 4 }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - ForEach.create(); - this.forEachUpdateFunction(e, this.operationItem, ((e, o) => { - const t = e; - this.observeComponentCreation(((e, s) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - 0 == o ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - o ? ViewPU.create(new IconGroup(this, { - item: t - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })) - })) : If.branchId(1); - s || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, s) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - 1 == o ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - o ? ViewPU.create(new IconGroup(this, { - item: t - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })) - })) : If.branchId(1); - s || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, s) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - 2 == o ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - o ? ViewPU.create(new IconGroup(this, { - item: t - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })) - })) : If.branchId(1); - s || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop() - }), void 0,!0,!1); - o || ForEach.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - ForEach.pop(); - Row.pop() - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.operationType === OperationType.TEXT_ARROW && null != this.operationItem ? this.ifElseBranchUpdateFunction(0, (() => { - this.TextArrowStyle.bind(this)(this.operationItem[0]) - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.operationType === OperationType.LOADING ? this.ifElseBranchUpdateFunction(0, (() => { - this.LoadingProcessStyle.bind(this)() - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - Flex.pop() - } - - rerender() { - this.updateDirtyElements() - } -} - -export default { OperationStyle, SubHeader } \ No newline at end of file diff --git a/interface/swiperefresher/BUILD.gn b/interface/swiperefresher/BUILD.gn deleted file mode 100644 index 785f9a4c33b6301295e3b2974d8ce95bbaddc823..0000000000000000000000000000000000000000 --- a/interface/swiperefresher/BUILD.gn +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (c) 2023-2023 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") -import("//foundation/arkui/ace_engine/ace_config.gni") -import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") - -es2abc_gen_abc("gen_swiperefresher_abc") { - src_js = rebase_path("swiperefresher.js") - dst_file = rebase_path(target_out_dir + "/swiperefresher.abc") - in_puts = [ "swiperefresher.js" ] - out_puts = [ target_out_dir + "/swiperefresher.abc" ] - extra_args = [ "--module" ] -} - -gen_js_obj("swiperefresher_abc") { - input = get_label_info(":gen_swiperefresher_abc", "target_out_dir") + "/swiperefresher.abc" - output = target_out_dir + "/swiperefresher_abc.o" - dep = ":gen_swiperefresher_abc" -} - -ohos_shared_library("swiperefresher") { - sources = [ "swiperefresher.cpp" ] - - deps = [ ":swiperefresher_abc" ] - - external_deps = [ - "hilog:libhilog", - "napi:ace_napi", - ] - - subsystem_name = "arkui" - part_name = "advanced_ui_component" - - relative_install_dir = "module/arkui/advanced" -} diff --git a/interface/swiperefresher/swiperefresher.cpp b/interface/swiperefresher/swiperefresher.cpp deleted file mode 100644 index 8d5726b4027783ed945ad90afe5ad7532225990b..0000000000000000000000000000000000000000 --- a/interface/swiperefresher/swiperefresher.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "native_engine/native_engine.h" - -#include "napi/native_api.h" -#include "napi/native_node_api.h" - -extern const char _binary_swiperefresher_abc_start[]; -extern const char _binary_swiperefresher_abc_end[]; - -// Napi get abc code function -extern "C" __attribute__((visibility("default"))) -void NAPI_arkui_advanced_swiperefresher_GetABCCode(const char **buf, int *buflen) - { - if (buf != nullptr) { - *buf = _binary_swiperefresher_abc_start; - } - if (buflen != nullptr) { - *buflen = _binary_swiperefresher_abc_end - _binary_swiperefresher_abc_start; - } - } - - -static napi_module swiperefresherModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_modname = "arkui.advanced.SwipeRefresher", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; - -extern "C" __attribute__((constructor)) void swiperefresherRegisterModule(void) -{ - napi_module_register(&swiperefresherModule); -} \ No newline at end of file diff --git a/interface/swiperefresher/swiperefresher.js b/interface/swiperefresher/swiperefresher.js deleted file mode 100644 index d34c05fcf0740e25b2e9d71122a0218b53b3ba24..0000000000000000000000000000000000000000 --- a/interface/swiperefresher/swiperefresher.js +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const LOADINGPROGRESS_SIZE = 24; -const DEFAULT_MARGIN = 16; -const ITEM_SPACE = 4; - -export class SwipeRefresher extends ViewPU { - constructor(e, t, o, s = -1) { - super(e, o, s); - this.__content = new SynchedPropertySimpleOneWayPU(t.content, this, "content"); - this.__isLoading = new SynchedPropertySimpleOneWayPU(t.isLoading, this, "isLoading"); - this.setInitiallyProvidedValue(t) - } - - setInitiallyProvidedValue(e) { - void 0 !== e.content ? this.__content.set(e.content) : this.__content.set(null); - void 0 !== e.isLoading ? this.__isLoading.set(e.isLoading) : this.__isLoading.set(!1) - } - - updateStateVars(e) { - this.__content.reset(e.content); - this.__isLoading.reset(e.isLoading) - } - - purgeVariableDependenciesOnElmtId(e) { - this.__content.purgeDependencyOnElmtId(e); - this.__isLoading.purgeDependencyOnElmtId(e) - } - - aboutToBeDeleted() { - this.__content.aboutToBeDeleted(); - this.__isLoading.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - - get content() { - return this.__content.get() - } - - set content(e) { - this.__content.set(e) - } - - get isLoading() { - return this.__isLoading.get() - } - - set isLoading(e) { - this.__isLoading.set(e) - } - - initialRender() { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Flex.create({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }); - Flex.margin({ top: 16, bottom: 16 }); - t || Flex.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.isLoading ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - LoadingProgress.create(); - LoadingProgress.height(24); - LoadingProgress.width(24); - LoadingProgress.margin({ right: 4 }); - t || LoadingProgress.pop(); - ViewStackProcessor.StopGetAccessRecording() - })) - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.content); - Text.fontColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_secondary"], - bundleName: "", - moduleName: "" - }); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body2"], - bundleName: "", - moduleName: "" - }); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - Flex.pop() - } - - rerender() { - this.updateDirtyElements() - } -} \ No newline at end of file diff --git a/interface/tabtitlebar/BUILD.gn b/interface/tabtitlebar/BUILD.gn deleted file mode 100755 index 5a1effe98c24f25161e623eece952459602727ce..0000000000000000000000000000000000000000 --- a/interface/tabtitlebar/BUILD.gn +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (c) 2023-2023 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") -import("//foundation/arkui/ace_engine/ace_config.gni") -import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") - -es2abc_gen_abc("gen_tabtitlebar_abc") { - src_js = rebase_path("tabtitlebar.js") - dst_file = rebase_path(target_out_dir + "/tabtitlebar.abc") - in_puts = [ "tabtitlebar.js" ] - out_puts = [ target_out_dir + "/tabtitlebar.abc" ] - extra_args = [ "--module" ] -} - -gen_js_obj("tabtitlebar_abc") { - input = get_label_info(":gen_tabtitlebar_abc", "target_out_dir") + "/tabtitlebar.abc" - output = target_out_dir + "/tabtitlebar_abc.o" - dep = ":gen_tabtitlebar_abc" -} - -ohos_shared_library("tabtitlebar") { - sources = [ "tabtitlebar.cpp" ] - - deps = [ ":tabtitlebar_abc" ] - - external_deps = [ - "hilog:libhilog", - "napi:ace_napi", - ] - - subsystem_name = "arkui" - part_name = "advanced_ui_component" - - relative_install_dir = "module/arkui/advanced" -} diff --git a/interface/tabtitlebar/tabtitlebar.cpp b/interface/tabtitlebar/tabtitlebar.cpp deleted file mode 100644 index 8cc4eb39b9c45621a7ce4a28a76243ec2e014fef..0000000000000000000000000000000000000000 --- a/interface/tabtitlebar/tabtitlebar.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "native_engine/native_engine.h" - -#include "napi/native_api.h" -#include "napi/native_node_api.h" - -extern const char _binary_tabtitlebar_abc_start[]; -extern const char _binary_tabtitlebar_abc_end[]; - -// Napi get abc code function -extern "C" __attribute__((visibility("default"))) -void NAPI_arkui_advanced_TabTitleBar_GetABCCode(const char **buf, int *buflen) - { - if (buf != nullptr) { - *buf = _binary_tabtitlebar_abc_start; - } - if (buflen != nullptr) { - *buflen = _binary_tabtitlebar_abc_end - _binary_tabtitlebar_abc_start; - } - } - - -static napi_module tabtitlebarModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_modname = "arkui.advanced.TabTitleBar", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; - -extern "C" __attribute__((constructor)) void tabtitlebarRegisterModule(void) -{ - napi_module_register(&tabtitlebarModule); -} \ No newline at end of file diff --git a/interface/tabtitlebar/tabtitlebar.js b/interface/tabtitlebar/tabtitlebar.js deleted file mode 100644 index f2b8bc11b9aa373f533231ce58ea965ff7540033..0000000000000000000000000000000000000000 --- a/interface/tabtitlebar/tabtitlebar.js +++ /dev/null @@ -1,930 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var __decorate = this && this.__decorate || function(e, t, o, i) { - var s, r = arguments.length, - n = r < 3 ? t : null === i ? i = Object.getOwnPropertyDescriptor(t, o) : i; - if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(e, t, o, i); - else - for (var c = e.length - 1; c >= 0; c--)(s = e[c]) && (n = (r < 3 ? s(n) : r > 3 ? s(t, o, n) : s(t, o)) || n); - return r > 3 && n && Object.defineProperty(t, o, n), n -}; -const KeyCode = requireNapi('multimodalInput.keyCode').KeyCode; -const PUBLIC_MORE = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAABS3GwHAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAEZ0FNQQAAsY58+1GTAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOxAAADsQBlSsOGwAABEZJREFUeNrt3D1rFFEUBuAxhmAhFlYpUohYiYWFRcAmKAhWK2pjo1iKf8BCMIKFf8BarCyMhVj4VZhGSKEg2FqJyCKWIhYWnstMINgYsh+cmfs88BICydxw7jmzu2HvNg0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADBN+3r6dx+LXIqsRpa7FF8j48hm5Fn3Peo9mAEYRdYjJ3f582Vj7nZfUe/eDsCRyMPI2h5/fyNyI/JDT6v3Tvt7sBllE15ETkxwjeORi5G3ke/6W737MgBnI68jh6ZwrcORq5HnhkC9+zAA5YXXy8jBKV5zKXIu8jjyS7+rd+YBeNVtyrSVO9PRyBM9r94LSTfjWuTUDK9/eYIXeENUbb0zDsBi5PYc1rmj79U74wCszuih+F/ljrSi/+uud8YBGA10rayqrnfGAVgb6FpZVV3vjAOwPNC1sqq63hkHYGWga2VVdb0XKt/8Rf1fd70zDsB4jmt5u3Tl9a59AMb6v+56ZxyArYGulVXV9c44ABtzXOup/q+73hkH4N2cHio/Rj7r/7rrnXEAfkfuz2Gddb2v3ln/DfpgxneLzaY9xE3l9c46AH8iVyI/Z3Dt8nB/Xc+rd5H5QMy3yJemPVs6zY0edc9HUe/0Z4I/dQ/N5Vjd0oTXKp9QcKFpD2qj3r0YgO1NeRM507TH6/bifeR85IMeV++d+vTBWOV9JDcjt5rdv6uw3M3uRR7pa/Xu+wBsOxA53bTnTP/3UX1b3fNQ1BsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKqyr6d/97HIpchqZLlL8TUyjmxGnnXfo96DGYBRZD1ycpc/XzbmbvcV9e7tAByJPIys7fH3NyI3Ij/0tHrvtL8Hm1E24UXkxATXOB65GHkb+a6/1bsvA3A28jpyaArXOhy5GnluCNS7DwNQXni9jByc4jWXIucijyO/9Lt6Zx6AV92mTFu5Mx2NPNHz6r2QdDOuRU7N8PqXJ3iBN0TV1jvjACxGbs9hnTv6Xr0zDsDqjB6K/1XuSCv6v+56ZxyA0UDXyqrqemccgLWBrpVV1fXOOADLA10rq6rrnXEAVga6VlZV13uh8s1f1P911zvjAIznuJa3S1de79oHYKz/6653xgHYGuhaWVVd74wDsDHHtZ7q/7rrnXEA3s3pofJj5LP+r7veGQfgd+T+HNZZ1/vqnfXfoA9mfLfYbNpD3FRe76wD8CdyJfJzBtcuD/fX9bx6F5kPxHyLfGnas6XT3OhR93wU9U5/JvhT99BcjtUtTXit8gkFF5r2oDbq3YsB2N6UN5EzTXu8bi/eR85HPuhx9d6pTx+MVd5HcjNyq9n9uwrL3exe5JG+Vu++D8C2A5HTTXvO9H8f1bfVPQ9FvQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgCn7C9HjBtwWfXpKAAAAAElFTkSuQmCC"; -export class TabTitleBar extends ViewPU { - constructor(e, t, o, i = -1) { - super(e, o, i); - this.tabItems = void 0; - this.menuItems = void 0; - this.swiperContent = void 0; - this.__tabWidth = new ObservedPropertySimplePU(0, this, "tabWidth"); - this.__currentIndex = new ObservedPropertySimplePU(0, this, "currentIndex"); - this.menuSectionWidth = 0; - this.scroller = new Scroller; - this.swiperController = new SwiperController; - this.settings = new RenderingContextSettings(!0); - this.leftContext2D = new CanvasRenderingContext2D(this.settings); - this.rightContext2D = new CanvasRenderingContext2D(this.settings); - this.setInitiallyProvidedValue(t) - } - setInitiallyProvidedValue(e) { - void 0 !== e.tabItems && (this.tabItems = e.tabItems); - void 0 !== e.menuItems && (this.menuItems = e.menuItems); - void 0 !== e.swiperContent && (this.swiperContent = e.swiperContent); - void 0 !== e.tabWidth && (this.tabWidth = e.tabWidth); - void 0 !== e.currentIndex && (this.currentIndex = e.currentIndex); - void 0 !== e.menuSectionWidth && (this.menuSectionWidth = e.menuSectionWidth); - void 0 !== e.scroller && (this.scroller = e.scroller); - void 0 !== e.swiperController && (this.swiperController = e.swiperController); - void 0 !== e.settings && (this.settings = e.settings); - void 0 !== e.leftContext2D && (this.leftContext2D = e.leftContext2D); - void 0 !== e.rightContext2D && (this.rightContext2D = e.rightContext2D) - } - updateStateVars(e) {} - purgeVariableDependenciesOnElmtId(e) { - this.__tabWidth.purgeDependencyOnElmtId(e); - this.__currentIndex.purgeDependencyOnElmtId(e) - } - aboutToBeDeleted() { - this.__tabWidth.aboutToBeDeleted(); - this.__currentIndex.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - get tabWidth() { - return this.__tabWidth.get() - } - set tabWidth(e) { - this.__tabWidth.set(e) - } - get currentIndex() { - return this.__currentIndex.get() - } - set currentIndex(e) { - this.__currentIndex.set(e) - } - GradientMask(e, t, o, i, s, r = null) { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.width(TabTitleBar.gradientMaskWidth); - Column.height(TabTitleBar.totalHeight); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((r, n) => { - ViewStackProcessor.StartGetAccessRecordingFor(r); - Canvas.create(e); - Canvas.width(TabTitleBar.gradientMaskWidth); - Canvas.height(TabTitleBar.totalHeight); - Canvas.onReady((() => { - var r = e.createLinearGradient(t, o, i, s); - r.addColorStop(0, "#ffffffff"); - r.addColorStop(1, "#00ffffff"); - e.fillStyle = r; - e.fillRect(0, 0, TabTitleBar.gradientMaskWidth, TabTitleBar.totalHeight) - })); - n || Canvas.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Canvas.pop(); - Column.pop() - } - initialRender() { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Flex.create({ - justifyContent: FlexAlign.SpaceBetween, - alignItems: ItemAlign.Stretch - }); - Flex.backgroundColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - }); - Flex.margin({ - right: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_max_padding_end"], - bundleName: "", - moduleName: "" - } - }); - Flex.onAreaChange(((e, t) => { - this.tabWidth = Number(t.width) - this.menuSectionWidth - })); - t || Flex.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Stack.create({ - alignContent: Alignment.End - }); - t || Stack.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Stack.create({ - alignContent: Alignment.Start - }); - t || Stack.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - List.create({ - initialIndex: 0, - scroller: this.scroller, - space: 0 - }); - List.width("100%"); - List.height(TabTitleBar.totalHeight); - List.constraintSize({ - maxWidth: this.tabWidth - }); - List.edgeEffect(EdgeEffect.Spring); - List.listDirection(Axis.Horizontal); - List.scrollBar(BarState.Off); - t || List.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - ForEach.create(); - this.forEachUpdateFunction(e, this.tabItems, ((e, t) => { - const o = e; - { - const e = !0; - const i = (t, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(t); - ListItem.create(r, e); - o || ListItem.pop(); - ViewStackProcessor.StopGetAccessRecording() - }; - const s = () => { - this.observeComponentCreation(i); - this.observeComponentCreation(((e, i) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - i ? ViewPU.create(new TabContentItem(this, { - item: o, - index: t, - maxIndex: this.tabItems.length - 1, - currentIndex: this.currentIndex, - onCustomClick: () => this.currentIndex = t - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, { - currentIndex: this.currentIndex - }); - ViewStackProcessor.StopGetAccessRecording() - })); - ListItem.pop() - }; - const r = (e, s) => { - i(e, s); - this.updateFuncByElmtId.set(e, i); - this.observeComponentCreation(((e, i) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - i ? ViewPU.create(new TabContentItem(this, { - item: o, - index: t, - maxIndex: this.tabItems.length - 1, - currentIndex: this.currentIndex, - onCustomClick: () => this.currentIndex = t - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, { - currentIndex: this.currentIndex - }); - ViewStackProcessor.StopGetAccessRecording() - })); - ListItem.pop() - }; - e ? (() => { - this.observeComponentCreation(i); - ListItem.pop() - })() : s() - } - }), void 0, !0, !1); - t || ForEach.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - ForEach.pop(); - List.pop(); - Column.pop(); - this.GradientMask.bind(this)(this.leftContext2D, 0, TabTitleBar.totalHeight / 2, TabTitleBar.gradientMaskWidth, TabTitleBar.totalHeight / 2); - Stack.pop(); - this.GradientMask.bind(this)(this.rightContext2D, TabTitleBar.gradientMaskWidth, TabTitleBar.totalHeight / 2, 0, TabTitleBar.totalHeight / 2); - Stack.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - void 0 !== this.menuItems && this.menuItems.length > 0 ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - __Common__.create(); - __Common__.height(TabTitleBar.totalHeight); - __Common__.onAreaChange(((e, t) => { - this.menuSectionWidth = Number(t.width) - })); - t || __Common__.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - t ? ViewPU.create(new CollapsibleMenuSection(this, { - menuItems: this.menuItems - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })); - __Common__.pop() - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - Flex.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Swiper.create(this.swiperController); - Swiper.index(this.currentIndex); - Swiper.itemSpace(0); - Swiper.indicator(!1); - Swiper.width("100%"); - Swiper.height("100%"); - Swiper.curve(Curve.Friction); - Swiper.onChange((e => { - this.currentIndex = e; - this.scroller.scrollToIndex(this.currentIndex); - this.scroller.scrollBy(TabTitleBar.correctionOffset, 0) - })); - Swiper.onAppear((() => { - this.scroller.scrollToIndex(this.currentIndex); - this.scroller.scrollBy(TabTitleBar.correctionOffset, 0) - })); - t || Swiper.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.swiperContent.bind(this)(); - Swiper.pop(); - Column.pop(); - Column.pop() - } - rerender() { - this.updateDirtyElements() - } -} -TabTitleBar.totalHeight = 56; -TabTitleBar.correctionOffset = -40; -TabTitleBar.gradientMaskWidth = 24; -__decorate([], TabTitleBar.prototype, "GradientMask", null); -class CollapsibleMenuSection extends ViewPU { - constructor(e, t, o, i = -1) { - super(e, o, i); - this.menuItems = void 0; - this.__isPopupShown = new ObservedPropertySimplePU(!1, this, "isPopupShown"); - this.__isMoreIconOnFocus = new ObservedPropertySimplePU(!1, this, "isMoreIconOnFocus"); - this.__isMoreIconOnHover = new ObservedPropertySimplePU(!1, this, "isMoreIconOnHover"); - this.__isMoreIconOnClick = new ObservedPropertySimplePU(!1, this, "isMoreIconOnClick"); - this.setInitiallyProvidedValue(t) - } - setInitiallyProvidedValue(e) { - void 0 !== e.menuItems && (this.menuItems = e.menuItems); - void 0 !== e.isPopupShown && (this.isPopupShown = e.isPopupShown); - void 0 !== e.isMoreIconOnFocus && (this.isMoreIconOnFocus = e.isMoreIconOnFocus); - void 0 !== e.isMoreIconOnHover && (this.isMoreIconOnHover = e.isMoreIconOnHover); - void 0 !== e.isMoreIconOnClick && (this.isMoreIconOnClick = e.isMoreIconOnClick) - } - updateStateVars(e) {} - purgeVariableDependenciesOnElmtId(e) { - this.__isPopupShown.purgeDependencyOnElmtId(e); - this.__isMoreIconOnFocus.purgeDependencyOnElmtId(e); - this.__isMoreIconOnHover.purgeDependencyOnElmtId(e); - this.__isMoreIconOnClick.purgeDependencyOnElmtId(e) - } - aboutToBeDeleted() { - this.__isPopupShown.aboutToBeDeleted(); - this.__isMoreIconOnFocus.aboutToBeDeleted(); - this.__isMoreIconOnHover.aboutToBeDeleted(); - this.__isMoreIconOnClick.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - get isPopupShown() { - return this.__isPopupShown.get() - } - set isPopupShown(e) { - this.__isPopupShown.set(e) - } - get isMoreIconOnFocus() { - return this.__isMoreIconOnFocus.get() - } - set isMoreIconOnFocus(e) { - this.__isMoreIconOnFocus.set(e) - } - get isMoreIconOnHover() { - return this.__isMoreIconOnHover.get() - } - set isMoreIconOnHover(e) { - this.__isMoreIconOnHover.set(e) - } - get isMoreIconOnClick() { - return this.__isMoreIconOnClick.get() - } - set isMoreIconOnClick(e) { - this.__isMoreIconOnClick.set(e) - } - getMoreIconFgColor() { - return this.isMoreIconOnClick ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_icon_pressed"], - bundleName: "", - moduleName: "" - } : { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_icon"], - bundleName: "", - moduleName: "" - } - } - getMoreIconBgColor() { - return this.isMoreIconOnClick ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_click_effect"], - bundleName: "", - moduleName: "" - } : this.isMoreIconOnHover ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - } : Color.Transparent - } - initialRender() { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.height("100%"); - Column.justifyContent(FlexAlign.Center); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.menuItems.length <= CollapsibleMenuSection.maxCountOfVisibleItems ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - ForEach.create(); - this.forEachUpdateFunction(e, this.menuItems, (e => { - const t = e; - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - o ? ViewPU.create(new ImageMenuItem(this, { - item: t - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })) - })); - t || ForEach.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - ForEach.pop() - })) : this.ifElseBranchUpdateFunction(1, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - ForEach.create(); - this.forEachUpdateFunction(e, this.menuItems.slice(0, CollapsibleMenuSection.maxCountOfVisibleItems - 1), (e => { - const t = e; - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - o ? ViewPU.create(new ImageMenuItem(this, { - item: t - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })) - })); - t || ForEach.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - ForEach.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.width(ImageMenuItem.imageHotZoneWidth); - Row.height(ImageMenuItem.imageHotZoneWidth); - Row.borderRadius(ImageMenuItem.buttonBorderRadius); - Row.foregroundColor(this.getMoreIconFgColor()); - Row.backgroundColor(this.getMoreIconBgColor()); - Row.justifyContent(FlexAlign.Center); - Row.border(this.isMoreIconOnFocus ? { - width: ImageMenuItem.focusBorderWidth, - color: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_emphasize"], - bundleName: "", - moduleName: "" - }, - style: BorderStyle.Solid - } : { - width: 0 - }); - Row.onFocus((() => this.isMoreIconOnFocus = !0)); - Row.onBlur((() => this.isMoreIconOnFocus = !1)); - Row.onHover((e => this.isMoreIconOnHover = e)); - Row.onKeyEvent((e => { - if (e.keyCode === KeyCode.KEYCODE_ENTER || e.keyCode === KeyCode.KEYCODE_SPACE) { - e.type === KeyType.Down && (this.isMoreIconOnClick = !0); - e.type === KeyType.Up && (this.isMoreIconOnClick = !1) - } - })); - Row.onTouch((e => { - e.type === TouchType.Down && (this.isMoreIconOnClick = !0); - e.type === TouchType.Up && (this.isMoreIconOnClick = !1) - })); - Row.onClick((() => this.isPopupShown = !0)); - Row.bindPopup(this.isPopupShown, { - builder: { - builder: this.popupBuilder.bind(this) - }, - placement: Placement.Bottom, - popupColor: Color.White, - enableArrow: !1, - onStateChange: e => this.isPopupShown = e.isVisible - }); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(PUBLIC_MORE); - Image.width(ImageMenuItem.imageSize); - Image.height(ImageMenuItem.imageSize); - Image.focusable(!0); - t || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop() - })); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - Row.pop(); - Column.pop() - } - popupBuilder(e = null) { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.width(ImageMenuItem.imageHotZoneWidth + CollapsibleMenuSection.focusPadding * CollapsibleMenuSection.marginsNum); - Column.margin({ - top: CollapsibleMenuSection.focusPadding, - bottom: CollapsibleMenuSection.focusPadding - }); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - ForEach.create(); - this.forEachUpdateFunction(e, this.menuItems.slice(CollapsibleMenuSection.maxCountOfVisibleItems - 1, this.menuItems.length), ((e, t) => { - const o = e; - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - t ? ViewPU.create(new ImageMenuItem(this, { - item: o - }, void 0, e)) : this.updateStateVarsOfChildByElmtId(e, {}); - ViewStackProcessor.StopGetAccessRecording() - })) - }), void 0, !0, !1); - t || ForEach.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - ForEach.pop(); - Column.pop() - } - rerender() { - this.updateDirtyElements() - } -} -CollapsibleMenuSection.maxCountOfVisibleItems = 1; -CollapsibleMenuSection.focusPadding = 4; -CollapsibleMenuSection.marginsNum = 2; -__decorate([], CollapsibleMenuSection.prototype, "popupBuilder", null); -class TabContentItem extends ViewPU { - constructor(e, t, o, i = -1) { - super(e, o, i); - this.item = void 0; - this.index = void 0; - this.maxIndex = void 0; - this.onCustomClick = void 0; - this.__currentIndex = new SynchedPropertySimpleOneWayPU(t.currentIndex, this, "currentIndex"); - this.__isOnFocus = new ObservedPropertySimplePU(!1, this, "isOnFocus"); - this.__isOnHover = new ObservedPropertySimplePU(!1, this, "isOnHover"); - this.__isOnClick = new ObservedPropertySimplePU(!1, this, "isOnClick"); - this.setInitiallyProvidedValue(t) - } - setInitiallyProvidedValue(e) { - void 0 !== e.item && (this.item = e.item); - void 0 !== e.index && (this.index = e.index); - void 0 !== e.maxIndex && (this.maxIndex = e.maxIndex); - void 0 !== e.onCustomClick && (this.onCustomClick = e.onCustomClick); - void 0 !== e.isOnFocus && (this.isOnFocus = e.isOnFocus); - void 0 !== e.isOnHover && (this.isOnHover = e.isOnHover); - void 0 !== e.isOnClick && (this.isOnClick = e.isOnClick) - } - updateStateVars(e) { - this.__currentIndex.reset(e.currentIndex) - } - purgeVariableDependenciesOnElmtId(e) { - this.__currentIndex.purgeDependencyOnElmtId(e); - this.__isOnFocus.purgeDependencyOnElmtId(e); - this.__isOnHover.purgeDependencyOnElmtId(e); - this.__isOnClick.purgeDependencyOnElmtId(e) - } - aboutToBeDeleted() { - this.__currentIndex.aboutToBeDeleted(); - this.__isOnFocus.aboutToBeDeleted(); - this.__isOnHover.aboutToBeDeleted(); - this.__isOnClick.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - get currentIndex() { - return this.__currentIndex.get() - } - set currentIndex(e) { - this.__currentIndex.set(e) - } - get isOnFocus() { - return this.__isOnFocus.get() - } - set isOnFocus(e) { - this.__isOnFocus.set(e) - } - get isOnHover() { - return this.__isOnHover.get() - } - set isOnHover(e) { - this.__isOnHover.set(e) - } - get isOnClick() { - return this.__isOnClick.get() - } - set isOnClick(e) { - this.__isOnClick.set(e) - } - getBgColor() { - return this.isOnClick ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_click_effect"], - bundleName: "", - moduleName: "" - } : this.isOnHover ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - } : Color.Transparent - } - initialRender() { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.height(TabTitleBar.totalHeight); - Row.alignItems(VerticalAlign.Center); - Row.justifyContent(FlexAlign.Center); - Row.margin({ - left: 0 === this.index ? 16 : 0, - right: this.index === this.maxIndex ? 12 : 0 - }); - Row.borderRadius(TabContentItem.buttonBorderRadius); - Row.backgroundColor(this.getBgColor()); - Row.border(this.isOnFocus ? { - width: TabContentItem.focusBorderWidth, - color: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_emphasize"], - bundleName: "", - moduleName: "" - }, - style: BorderStyle.Solid - } : { - width: 0 - }); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.justifyContent(FlexAlign.Center); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - void 0 === this.item.icon ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.item.title); - Text.fontSize(this.index === this.currentIndex ? { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_headline7"], - bundleName: "", - moduleName: "" - } : { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_headline9"], - bundleName: "", - moduleName: "" - }); - Text.fontColor(this.index === this.currentIndex ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_text"], - bundleName: "", - moduleName: "" - } : { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_text_off"], - bundleName: "", - moduleName: "" - }); - Text.fontWeight(FontWeight.Medium); - Text.focusable(!0); - Text.padding({ - top: this.index === this.currentIndex ? 6 : 10, - left: 8, - bottom: 2, - right: 8 - }); - Text.onFocus((() => this.isOnFocus = !0)); - Text.onBlur((() => this.isOnFocus = !1)); - Text.onHover((e => this.isOnHover = e)); - Text.onKeyEvent((e => { - if (e.keyCode === KeyCode.KEYCODE_ENTER || e.keyCode === KeyCode.KEYCODE_SPACE) { - e.type === KeyType.Down && (this.isOnClick = !0); - e.type === KeyType.Up && (this.isOnClick = !1) - } - })); - Text.onTouch((e => { - e.type === TouchType.Down && (this.isOnClick = !0); - e.type === TouchType.Up && (this.isOnClick = !1) - })); - Text.onClick((() => this.onCustomClick && this.onCustomClick())); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop() - })) : this.ifElseBranchUpdateFunction(1, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.width(TabContentItem.imageHotZoneWidth); - Row.height(TabContentItem.imageHotZoneWidth); - Row.justifyContent(FlexAlign.Center); - Row.onFocus((() => this.isOnFocus = !0)); - Row.onBlur((() => this.isOnFocus = !1)); - Row.onHover((e => this.isOnHover = e)); - Row.onKeyEvent((e => { - if (e.keyCode === KeyCode.KEYCODE_ENTER || e.keyCode === KeyCode.KEYCODE_SPACE) { - e.type === KeyType.Down && (this.isOnClick = !0); - e.type === KeyType.Up && (this.isOnClick = !1) - } - })); - Row.onTouch((e => { - e.type === TouchType.Down && (this.isOnClick = !0); - e.type === TouchType.Up && (this.isOnClick = !1) - })); - Row.onClick((() => this.onCustomClick && this.onCustomClick())); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(this.item.icon); - Image.alt(this.item.title); - Image.height(TabContentItem.imageSize); - Image.focusable(!0); - Image.scale({ - x: this.index === this.currentIndex ? TabContentItem.imageMagnificationFactor : 1, - y: this.index === this.currentIndex ? TabContentItem.imageMagnificationFactor : 1 - }); - t || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop() - })); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - Column.pop(); - Row.pop() - } - rerender() { - this.updateDirtyElements() - } -} -TabContentItem.imageSize = 24; -TabContentItem.imageHotZoneWidth = 48; -TabContentItem.imageMagnificationFactor = 1.4; -TabContentItem.buttonBorderRadius = 8; -TabContentItem.focusBorderWidth = 2; -class ImageMenuItem extends ViewPU { - constructor(e, t, o, i = -1) { - super(e, o, i); - this.item = void 0; - this.__isOnFocus = new ObservedPropertySimplePU(!1, this, "isOnFocus"); - this.__isOnHover = new ObservedPropertySimplePU(!1, this, "isOnHover"); - this.__isOnClick = new ObservedPropertySimplePU(!1, this, "isOnClick"); - this.setInitiallyProvidedValue(t) - } - setInitiallyProvidedValue(e) { - void 0 !== e.item && (this.item = e.item); - void 0 !== e.isOnFocus && (this.isOnFocus = e.isOnFocus); - void 0 !== e.isOnHover && (this.isOnHover = e.isOnHover); - void 0 !== e.isOnClick && (this.isOnClick = e.isOnClick) - } - updateStateVars(e) {} - purgeVariableDependenciesOnElmtId(e) { - this.__isOnFocus.purgeDependencyOnElmtId(e); - this.__isOnHover.purgeDependencyOnElmtId(e); - this.__isOnClick.purgeDependencyOnElmtId(e) - } - aboutToBeDeleted() { - this.__isOnFocus.aboutToBeDeleted(); - this.__isOnHover.aboutToBeDeleted(); - this.__isOnClick.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - get isOnFocus() { - return this.__isOnFocus.get() - } - set isOnFocus(e) { - this.__isOnFocus.set(e) - } - get isOnHover() { - return this.__isOnHover.get() - } - set isOnHover(e) { - this.__isOnHover.set(e) - } - get isOnClick() { - return this.__isOnClick.get() - } - set isOnClick(e) { - this.__isOnClick.set(e) - } - getFgColor() { - return this.isOnClick ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_icon_pressed"], - bundleName: "", - moduleName: "" - } : { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_titlebar_icon"], - bundleName: "", - moduleName: "" - } - } - getBgColor() { - return this.isOnClick ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_click_effect"], - bundleName: "", - moduleName: "" - } : this.isOnHover ? { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - } : Color.Transparent - } - initialRender() { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.width(ImageMenuItem.imageHotZoneWidth); - Row.height(ImageMenuItem.imageHotZoneWidth); - Row.borderRadius(ImageMenuItem.buttonBorderRadius); - Row.foregroundColor(this.getFgColor()); - Row.backgroundColor(this.getBgColor()); - Row.justifyContent(FlexAlign.Center); - Row.opacity(this.item.isEnabled ? 1 : ImageMenuItem.disabledImageOpacity); - Row.border(this.isOnFocus ? { - width: ImageMenuItem.focusBorderWidth, - color: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_emphasize"], - bundleName: "", - moduleName: "" - }, - style: BorderStyle.Solid - } : { - width: 0 - }); - Row.onFocus((() => { - this.item.isEnabled && (this.isOnFocus = !0) - })); - Row.onBlur((() => this.isOnFocus = !1)); - Row.onHover((e => { - this.item.isEnabled && (this.isOnHover = e) - })); - Row.onKeyEvent((e => { - if (this.item.isEnabled && (e.keyCode === KeyCode.KEYCODE_ENTER || e.keyCode === KeyCode.KEYCODE_SPACE)) { - e.type === KeyType.Down && (this.isOnClick = !0); - e.type === KeyType.Up && (this.isOnClick = !1) - } - })); - Row.onTouch((e => { - if (this.item.isEnabled) { - e.type === TouchType.Down && (this.isOnClick = !0); - e.type === TouchType.Up && (this.isOnClick = !1) - } - })); - Row.onClick((() => this.item.isEnabled && this.item.action && this.item.action())); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(this.item.value); - Image.width(ImageMenuItem.imageSize); - Image.height(ImageMenuItem.imageSize); - Image.focusable(this.item.isEnabled); - t || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop() - } - rerender() { - this.updateDirtyElements() - } -} -ImageMenuItem.imageSize = 24; -ImageMenuItem.imageHotZoneWidth = 48; -ImageMenuItem.buttonBorderRadius = 8; -ImageMenuItem.focusBorderWidth = 2; -ImageMenuItem.disabledImageOpacity = .4; -export default { - TabTitleBar: TabTitleBar -}; \ No newline at end of file diff --git a/interface/toolbar/BUILD.gn b/interface/toolbar/BUILD.gn deleted file mode 100644 index 956cede18d59972b5b6127b3e2058816264d1b23..0000000000000000000000000000000000000000 --- a/interface/toolbar/BUILD.gn +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (c) 2023-2023 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") -import("//foundation/arkui/ace_engine/ace_config.gni") -import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") - -es2abc_gen_abc("gen_toolbar_abc") { - src_js = rebase_path("toolbar.js") - dst_file = rebase_path(target_out_dir + "/toolbar.abc") - in_puts = [ "toolbar.js" ] - out_puts = [ target_out_dir + "/toolbar.abc" ] - extra_args = [ "--module" ] -} - -gen_js_obj("toolbar_abc") { - input = get_label_info(":gen_toolbar_abc", "target_out_dir") + "/toolbar.abc" - output = target_out_dir + "/toolbar_abc.o" - dep = ":gen_toolbar_abc" -} - -ohos_shared_library("toolbar") { - sources = [ "toolbar.cpp" ] - - deps = [ ":toolbar_abc" ] - - external_deps = [ - "hilog:libhilog", - "napi:ace_napi", - ] - - subsystem_name = "arkui" - part_name = "advanced_ui_component" - - relative_install_dir = "module/arkui/advanced" -} \ No newline at end of file diff --git a/interface/toolbar/toolbar.js b/interface/toolbar/toolbar.js deleted file mode 100644 index 5c34c872c15356f303172890a646034859207a3b..0000000000000000000000000000000000000000 --- a/interface/toolbar/toolbar.js +++ /dev/null @@ -1,477 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const REFLECT_MAX_COUNT = 3; -const IMAGE_SIZE_WIDTH_HEIGHT = 24; -const TEXT_MIN_SIZE = 9; -const DISABLE_OPACITY = 0.4; -const TEXT_MAX_LINES = 2; -const TOOLBAR_LIST_LENGTH = 5; -const TOOLBAR_LIST_NORMORL = 4; -const ITEM_DISABLE_STATE = 2; -const ITEM_DISABLE_ACTIVATE = 3; - -let __decorate = this && this.__decorate || function (e, t, o, r) { - let s; - let i = arguments.length; - let a = i < REFLECT_MAX_COUNT ? t : null === r ? r = Object.getOwnPropertyDescriptor(t, o) : r; - if ('object' === typeof Reflect && 'function' === typeof Reflect.decorate) { - a = Reflect.decorate(e, t, o, r); - } else { - for (let n = e.length - 1; n >= 0; n--) { - (s = e[n]) && (a = (i < REFLECT_MAX_COUNT ? s(a) : i > REFLECT_MAX_COUNT ? s(t, o, a) : s(t, o)) || a); - } - } - return i > REFLECT_MAX_COUNT && a && Object.defineProperty(t, o, a), a; -}; -export let ItemState; -!function(e) { - e[e.ENABLE = 1] = 'ENABLE'; - e[e.DISABLE = 2] = 'DISABLE'; - e[e.ACTIVATE = 3] = 'ACTIVATE'; -}(ItemState || (ItemState = {})); -const PUBLIC_MORE = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAA' + - 'IGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAEZ0FNQQAAsY58+1GTAAAAAXNSR0IAr' + - 's4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAYFJREFUeNrt3CFLQ1EUB/CpCwYRo8' + - 'G4j2IwCNrUYjH4AfwcfgBBwWZRMNgtFqPdILJgEhGDweAZvDjmJnfv3I3fD/5l3DfOfWdv23vhdDoAAAAAAAAwzxa' + - 'm9L5rkePIdmSjee05chu5iHxXej5ar3saDdiJXDabGaYfOYg8VHbyU+peKryJvch1ZHnEmtXIYeQ+8lrJyU+re7Hg' + - 'JtYj52Ou7Uau/thwW1LrLtmAk8jKBOsH37FHFTQgte6SDdht6ZjSUusu2YBeS8eUllr3YvLmuzP6971bYwP6/zjmpY' + - 'KTmVp3yQbctXRMaal1l2zAaeRngvUfkbMKGpBad8kbsffIZ2RrzPX7kacKGpBad+k74cfmE7I54ur6au4obyr6UU2r' + - 'e1oP43rNDc6wh1qDS/6t0n83s1o3AAAAAAAAAAAAAEAysyKS6zYrIrlusyKS6zYrwqyIdGZFJDMrIplZETPIrIh5qdu' + - 'sCLMi0pkVkcysiAqYFVEJsyIAAAAAAAAAKOYXUlF8EUcdfbsAAAAASUVORK5CYII='; -let ToolBarOption = class { - constructor() { - this.state = 1; - } -}; -ToolBarOption = __decorate([Observed], ToolBarOption); - -export { ToolBarOption }; -let ToolBarOptions = class extends Array { -}; -ToolBarOptions = __decorate([Observed], ToolBarOptions); - -export { ToolBarOptions }; - -export class ToolBar extends ViewPU { - constructor(e, t, o, r = -1) { - super(e, o, r); - this.__toolBarList = new SynchedPropertyNesedObjectPU(t.toolBarList, this, 'toolBarList'); - this.controller = void 0; - this.__activateIndex = new SynchedPropertySimpleOneWayPU(t.activateIndex, this, 'activateIndex'); - this.__menuContent = new ObservedPropertyObjectPU([], this, 'menuContent'); - this.toolBarItemBackground = []; - this.__itemBackground = new ObservedPropertyObjectPU({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_toolbar_bg'], - bundleName: '', - moduleName: '' - }, this, 'itemBackground'); - this.setInitiallyProvidedValue(t); - } - - setInitiallyProvidedValue(e) { - this.__toolBarList.set(e.toolBarList); - void 0 !== e.controller && (this.controller = e.controller); - void 0 !== e.activateIndex ? this.__activateIndex.set(e.activateIndex) : this.__activateIndex.set(-1); - void 0 !== e.menuContent && (this.menuContent = e.menuContent); - void 0 !== e.toolBarItemBackground && (this.toolBarItemBackground = e.toolBarItemBackground); - void 0 !== e.itemBackground && (this.itemBackground = e.itemBackground); - } - - updateStateVars(e) { - this.__toolBarList.set(e.toolBarList); - this.__activateIndex.reset(e.activateIndex); - } - - purgeVariableDependenciesOnElmtId(e) { - this.__toolBarList.purgeDependencyOnElmtId(e); - this.__activateIndex.purgeDependencyOnElmtId(e); - this.__menuContent.purgeDependencyOnElmtId(e); - this.__itemBackground.purgeDependencyOnElmtId(e); - } - - aboutToBeDeleted() { - this.__toolBarList.aboutToBeDeleted(); - this.__activateIndex.aboutToBeDeleted(); - this.__menuContent.aboutToBeDeleted(); - this.__itemBackground.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal(); - } - - get toolBarList() { - return this.__toolBarList.get(); - } - - get activateIndex() { - return this.__activateIndex.get(); - } - - set activateIndex(e) { - this.__activateIndex.set(e); - } - - get menuContent() { - return this.__menuContent.get(); - } - - set menuContent(e) { - this.__menuContent.set(e); - } - - get itemBackground() { - return this.__itemBackground.get(); - } - - set itemBackground(e) { - this.__itemBackground.set(e); - } - - MoreTabBuilder(e, t = null) { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.width('100%'); - Column.height('100%'); - Column.bindMenu(ObservedObject.GetRawObject(this.menuContent), { offset: { x: 5, y: -10 } }); - Column.padding({ left: 4, right: 4 }); - Column.borderRadius({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_corner_radius_clicked'], - bundleName: '', - moduleName: '' - }); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(PUBLIC_MORE); - Image.width(IMAGE_SIZE_WIDTH_HEIGHT); - Image.height(IMAGE_SIZE_WIDTH_HEIGHT); - Image.fillColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_toolbar_icon'], - bundleName: '', - moduleName: '' - }); - Image.margin({ top: 8, bottom: 2 }); - Image.objectFit(ImageFit.Contain); - t || Image.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create({ - id: -1, - type: 10003, - params: ['app.string.id_string_more'], - bundleName: '', - moduleName: '' - }); - Text.fontColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_toolbar_text'], - bundleName: '', - moduleName: '' - }); - Text.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_caption'], - bundleName: '', - moduleName: '' - }); - Text.fontWeight(FontWeight.Medium); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Text.pop(); - Column.pop(); - } - - TabBuilder(e, t = null) { - this.observeComponentCreation(((t, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(t); - Column.create(); - Column.width('100%'); - Column.height('100%'); - Column.focusable(!(ITEM_DISABLE_STATE === this.toolBarList[e].state)); - Column.focusOnTouch(!(ITEM_DISABLE_STATE === this.toolBarList[e].state)); - Column.padding({ left: 4, right: 4 }); - Column.borderRadius({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_corner_radius_clicked'], - bundleName: '', - moduleName: '' - }); - Column.backgroundColor(ObservedObject.GetRawObject(this.itemBackground)); - Column.onClick((() => { - ITEM_DISABLE_ACTIVATE === this.toolBarList[e].state && (this.activateIndex === e ? this.activateIndex = -1 : this.activateIndex = e); - ITEM_DISABLE_STATE !== this.toolBarList[e].state && this.toolBarList[e].action && this.toolBarList[e].action(); - })); - Column.onHover((t => { - this.toolBarItemBackground[e] = t ? ITEM_DISABLE_STATE === this.toolBarList[e].state ? { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_toolbar_bg'], - bundleName: '', - moduleName: '' - } : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_hover'], - bundleName: '', - moduleName: '' - } : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_toolbar_bg'], - bundleName: '', - moduleName: '' - }; - this.itemBackground = this.toolBarItemBackground[e]; - })); - ViewStackProcessor.visualState('pressed'); - Column.backgroundColor(ITEM_DISABLE_STATE === this.toolBarList[e].state ? this.toolBarItemBackground[e] : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_click_effect'], - bundleName: '', - moduleName: '' - }); - ViewStackProcessor.visualState('normal'); - Column.backgroundColor(this.toolBarItemBackground[e]); - ViewStackProcessor.visualState(); - o || Column.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((t, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(t); - Image.create(this.toolBarList[e].icon); - Image.width(IMAGE_SIZE_WIDTH_HEIGHT); - Image.height(IMAGE_SIZE_WIDTH_HEIGHT); - Image.fillColor(this.activateIndex === e && ITEM_DISABLE_STATE !== this.toolBarList[e].state ? { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_text_primary_activated'], - bundleName: '', - moduleName: '' - } : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_primary'], - bundleName: '', - moduleName: '' - }); - Image.opacity(ITEM_DISABLE_STATE === this.toolBarList[e].state ? DISABLE_OPACITY : 1); - Image.margin({ top: 8, bottom: 2 }); - Image.objectFit(ImageFit.Contain); - o || Image.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((t, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(t); - Text.create(this.toolBarList[e].content); - Text.fontColor(this.activateIndex === e && ITEM_DISABLE_STATE !== this.toolBarList[e].state ? { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_toolbar_text_actived'], - bundleName: '', - moduleName: '' - } : { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_toolbar_text'], - bundleName: '', - moduleName: '' - }); - Text.fontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_caption'], - bundleName: '', - moduleName: '' - }); - Text.maxFontSize({ - id: -1, - type: 10002, - params: ['sys.float.ohos_id_text_size_caption'], - bundleName: '', - moduleName: '' - }); - Text.minFontSize(TEXT_MIN_SIZE); - Text.fontWeight(FontWeight.Medium); - Text.maxLines(TEXT_MAX_LINES); - Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - Text.opacity(ITEM_DISABLE_STATE === this.toolBarList[e].state ? DISABLE_OPACITY : 1); - o || Text.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - Text.pop(); - Column.pop(); - } - - refreshData() { - this.menuContent = []; - for (let e = 0; e < this.toolBarList.length; e++) { - if (e >= TOOLBAR_LIST_NORMORL && this.toolBarList.length > TOOLBAR_LIST_LENGTH) { - this.menuContent[e - TOOLBAR_LIST_NORMORL] = { - value: this.toolBarList[e].content, - action: this.toolBarList[e].action - }; - } else { - this.toolBarItemBackground[e] = { - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_toolbar_bg'], - bundleName: '', - moduleName: '' - }; - this.menuContent = []; - } - } - return !0; - } - - aboutToAppear() { - this.refreshData(); - } - - initialRender() { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Divider.create(); - Divider.width('100%'); - Divider.height(1); - t || Divider.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.width('100%'); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Tabs.create({ barPosition: BarPosition.End, controller: this.controller }); - Tabs.vertical(!1); - Tabs.constraintSize({ minHeight: 56, maxHeight: 56 }); - Tabs.barMode(BarMode.Fixed); - Tabs.onChange((e => { - })); - Tabs.width('100%'); - Tabs.backgroundColor({ - id: -1, - type: 10001, - params: ['sys.color.ohos_id_color_toolbar_bg'], - bundleName: '', - moduleName: '' - }); - t || Tabs.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - ForEach.create(); - this.forEachUpdateFunction(e, this.toolBarList, ((e, t) => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.toolBarList.length <= TOOLBAR_LIST_LENGTH ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, r) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - TabContent.create(); - TabContent.tabBar({ - builder: () => { - this.TabBuilder.call(this, t); - } - }); - TabContent.enabled(!(ITEM_DISABLE_STATE === this.toolBarList[t].state)); - TabContent.focusOnTouch(!(ITEM_DISABLE_STATE === this.toolBarList[t].state)); - r || TabContent.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - TabContent.pop(); - })) : t < TOOLBAR_LIST_NORMORL && this.ifElseBranchUpdateFunction(1, (() => { - this.observeComponentCreation(((e, r) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - TabContent.create(); - TabContent.tabBar({ - builder: () => { - this.TabBuilder.call(this, t); - } - }); - TabContent.enabled(!(ITEM_DISABLE_STATE === this.toolBarList[t].state)); - TabContent.focusOnTouch(!(ITEM_DISABLE_STATE === this.toolBarList[t].state)); - r || TabContent.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - TabContent.pop(); - })); - r || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - If.pop(); - }), void 0, !0, !1); - t || ForEach.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - ForEach.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.refreshData() && this.toolBarList.length > TOOLBAR_LIST_LENGTH ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - TabContent.create(); - TabContent.tabBar({ - builder: () => { - this.MoreTabBuilder.call(this, TOOLBAR_LIST_NORMORL); - } - }); - t || TabContent.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - TabContent.pop(); - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording(); - })); - If.pop(); - Tabs.pop(); - Column.pop(); - Column.pop(); - } - - rerender() { - this.updateDirtyElements(); - } -} -export default { ToolBarOptions, ToolBar }; \ No newline at end of file diff --git a/interface/treeview/treeview.js b/interface/treeview/treeview.js deleted file mode 100644 index 25425d8930229517f51a916aa1c2d6390bf50070..0000000000000000000000000000000000000000 --- a/interface/treeview/treeview.js +++ /dev/null @@ -1,3666 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var __decorate = this && this.__decorate || function (e, t, o, i) { - var s, a = arguments.length, d = a < 3 ? t : null === i ? i = Object.getOwnPropertyDescriptor(t, o) : i; - if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) d = Reflect.decorate(e, t, o, i); else for (var r = e.length - 1;r >= 0; r--) (s = e[r]) && (d = (a < 3 ? s(d) : a > 3 ? s(t, o, d) : s(t, o)) || d); - return a > 3 && d && Object.defineProperty(t, o, d), d -}; - -export var TreeView; -!function(e){ - const t = "#00000000"; - const o = "#FFFFFF"; - - class i { - constructor() { - this._events = [] - } - - on(e, t) { - if (Array.isArray(e)) for (let o = 0, - i = e.length;o < i; o++) this.on(e[o], t); else (this._events[e] || (this._events[e] = [])).push(t) - } - - once(e, t) { - let o = this; - - function i() { - o.off(e, i); - t.apply(null, [e, t]) - } - - i.callback = t; - this.on(e, i) - } - - off(e, t) { - null == e && (this._events = []); - if (Array.isArray(e)) for (let o = 0, i = e.length;o < i; o++) this.off(e[o], t); - const o = this._events[e]; - if (!o) return; - null == t && (this._events[e] = null); - let i, s = o.length; - for (; s--; ) { - i = o[s]; - if (i === t || i.callback === t) { - o.splice(s, 1); - break - } - } - } - - emit(e, t) { - let o = this; - if (!this._events[e]) return; - let i = [...this._events[e]]; - if (i) for (let e = 0, s = i.length;e < s; e++) try { - i[e].apply(o, t) - } catch (e) { - new Error(e) - } - } - } - - e.TreeListener = i; - let s; - !function(e){ - e.NODE_ADD = "NodeAdd"; - e.NODE_DELETE = "NodeDelete"; - e.NODE_MODIFY = "NodeModify"; - e.NODE_MOVE = "NodeMove"; - e.NODE_CLICK = "NodeClick" - }(s = e.TreeListenType || (e.TreeListenType = {})); - - class a { - constructor() { - this.appEventBus = new i - } - - static getInstance() { - null == AppStorage.Get(this.APP_KEY_EVENT_BUS) && AppStorage.SetOrCreate(this.APP_KEY_EVENT_BUS, new a); - return AppStorage.Get(this.APP_KEY_EVENT_BUS) - } - - getTreeListener() { - return this.appEventBus - } - } - - a.APP_KEY_EVENT_BUS = "app_key_event_bus"; - e.TreeListenerManager = a; - - class d { - constructor() { - this.listeners = [] - } - - totalCount() { - return 0 - } - - getData(e) { - } - - registerDataChangeListener(e) { - this.listeners.indexOf(e) < 0 && this.listeners.push(e) - } - - unregisterDataChangeListener(e) { - const t = this.listeners.indexOf(e); - t >= 0 && this.listeners.splice(t, 1) - } - - notifyDataReload() { - this.listeners.forEach((e => { - e.onDataReloaded() - })) - } - - notifyDataAdd(e) { - this.listeners.forEach((t => { - t.onDataAdd(e) - })) - } - - notifyDataChange(e) { - this.listeners.forEach((t => { - t.onDataChange(e) - })) - } - - notifyDataDelete(e) { - this.listeners.forEach((t => { - t.onDataDelete(e) - })) - } - - notifyDataMove(e, t) { - this.listeners.forEach((o => { - o.onDataMove(e, t) - })) - } - } - - let r; - !function(e){ - e[e.TOUCH_DOWN=0] = "TOUCH_DOWN"; - e[e.TOUCH_UP=1] = "TOUCH_UP"; - e[e.HOVER=3] = "HOVER"; - e[e.HOVER_OVER=4] = "HOVER_OVER"; - e[e.FOCUS=5] = "FOCUS"; - e[e.BLUR=6] = "BLUR"; - e[e.MOUSE_BUTTON_RIGHT=7] = "MOUSE_BUTTON_RIGHT"; - e[e.DRAG=8] = "DRAG" - }(r = e.Event || (e.Event = {})); - let n; - !function(e){ - e[e.ADD_NODE=0] = "ADD_NODE"; - e[e.REMOVE_NODE=1] = "REMOVE_NODE"; - e[e.MODIFY_NODE=2] = "MODIFY_NODE"; - e[e.COMMIT_NODE=3] = "COMMIT_NODE" - }(n = e.MenuOperation || (e.MenuOperation = {})); - let l; - !function(e){ - e[e.HINTS=0] = "HINTS"; - e[e.WARNINGS=1] = "WARNINGS" - }(l = e.PopUpType || (e.PopUpType = {})); - let h; - !function(e){ - e[e.INVALID_ERROR=0] = "INVALID_ERROR"; - e[e.LENGTH_ERROR=1] = "LENGTH_ERROR"; - e[e.NONE=2] = "NONE" - }(h = e.InputError || (e.InputError = {})); - let g; - !function(e){ - e[e.DOWN_FLAG=0] = "DOWN_FLAG"; - e[e.UP_FLAG=1] = "UP_FLAG"; - e[e.NONE=2] = "NONE" - }(g = e.Flag || (e.Flag = {})); - - class c { - constructor(e) { - this.data = e; - this.nodeLevel = -1; - this.parentNodeId = -1; - this.nodeItem = { imageNode: null, mainTitleNode: null, imageCollapse: null }; - this.childNodeInfo = { isHasChildNode: !1, childNum: 0, allChildNum: 0 }; - this.menu = e.menu; - e.icon && (this.nodeItem.imageNode = new p(e.icon, e.selectedIcon, e.editIcon, { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_alpha_content_fourth"], - bundleName: "", - moduleName: "" - }, 24, 24)); - e.primaryTitle && (this.nodeItem.mainTitleNode = new m(e.primaryTitle)); - this.children = [] - } - - addImageCollapse(e) { - if (e) { - this.nodeItem.imageCollapse = new p({ - id: -1, - type: 2e4, - params: ["sys.media.ohos_ic_public_arrow_right"], - bundleName: "", - moduleName: "" - }, null, null, { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_alpha_content_tertiary"], - bundleName: "", - moduleName: "" - }, 24, 24); - this.nodeItem.imageCollapse.itemRightMargin = { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_paragraph_margin_xs"], - bundleName: "", - moduleName: "" - } - } else this.nodeItem.imageCollapse = null - } - - getNodeItem() { - return this.nodeItem - } - - getChildNodeInfo() { - return this.childNodeInfo - } - - getMenu() { - return this.menu - } - - getCurrentNodeId() { - return this.currentNodeId - } - - getIsFolder() { - return this.data.isFolder - } - } - - e.NodeItem = c; - - class N { - constructor() { - } - - set itemWidth(e) { - this.width = e - } - - get itemWidth() { - return this.width - } - - set itemHeight(e) { - this.height = e - } - - get itemHeight() { - return this.height - } - - set itemRightMargin(e) { - this.rightMargin = e - } - - get itemRightMargin() { - return this.rightMargin - } - } - - let I; - !function(e){ - e[e.Expand=0] = "Expand"; - e[e.Collapse=1] = "Collapse" - }(I = e.NodeStatus || (e.NodeStatus = {})); - let u; - !function(e){ - e[e.Normal=0] = "Normal"; - e[e.Selected=1] = "Selected"; - e[e.Edit=2] = "Edit"; - e[e.FinishEdit=3] = "FinishEdit"; - e[e.DragInsert=4] = "DragInsert"; - e[e.FinishDragInsert=5] = "FinishDragInsert" - }(u = e.InteractionStatus || (e.InteractionStatus = {})); - - class p extends N { - constructor(e, t, o, i, s, a) { - super(); - this.rightMargin = { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_elements_margin_horizontal_m"], - bundleName: "", - moduleName: "" - }; - this.imageSource = e; - this.imageNormalSource = e; - this.imageSelectedSource = null != t ? t : this.imageNormalSource; - this.imageEditSource = null != o ? o : this.imageNormalSource; - this.imageOpacity = i; - this.itemWidth = s; - this.itemHeight = a; - this.imageCollapseSource = e; - this.imageCollapseDownSource = { - id: -1, - type: 2e4, - params: ["sys.media.ohos_ic_public_arrow_down"], - bundleName: "", - moduleName: "" - }; - this.imageCollapseRightSource = { - id: -1, - type: 2e4, - params: ["sys.media.ohos_ic_public_arrow_right"], - bundleName: "", - moduleName: "" - }; - this.isImageCollapse = !0 - } - - get source() { - return this.imageSource - } - - get normalSource() { - return this.imageNormalSource - } - - get selectedSource() { - return this.imageSelectedSource - } - - get editSource() { - return this.imageEditSource - } - - get opacity() { - return this.imageOpacity - } - - get noOpacity() { - return 1 - } - - get collapseSource() { - return this.imageCollapseSource - } - - get isCollapse() { - return this.isImageCollapse - } - - changeImageCollapseSource(e) { - e == I.Expand ? this.imageCollapseSource = this.imageCollapseDownSource : e == I.Collapse && (this.imageCollapseSource = this.imageCollapseRightSource) - } - - setImageCollapseSource(e, t) { - if (e === u.Edit || e === u.DragInsert) { - this.imageCollapseDownSource = { - id: -1, - type: 2e4, - params: ["sys.media.ohos_ic_public_arrow_down"], - bundleName: "", - moduleName: "" - }; - this.imageCollapseRightSource = { - id: -1, - type: 2e4, - params: ["sys.media.ohos_ic_public_arrow_right"], - bundleName: "", - moduleName: "" - }; - this.isImageCollapse = !1 - } else if (e === u.FinishEdit || e === u.FinishDragInsert) { - this.imageCollapseDownSource = { - id: -1, - type: 2e4, - params: ["sys.media.ohos_ic_public_arrow_down"], - bundleName: "", - moduleName: "" - }; - this.imageCollapseRightSource = { - id: -1, - type: 2e4, - params: ["sys.media.ohos_ic_public_arrow_right"], - bundleName: "", - moduleName: "" - }; - this.isImageCollapse = !0 - } - this.imageCollapseSource = t == I.Collapse ? this.imageCollapseRightSource : this.imageCollapseDownSource - } - - setImageSource(e) { - switch (e) { - case u.Normal: - this.imageSource = this.imageNormalSource; - this.currentInteractionStatus = e; - break; - case u.Selected: - if (this.currentInteractionStatus !== u.Edit) { - this.imageSource = this.imageSelectedSource; - this.currentInteractionStatus = e - } - break; - case u.Edit: - this.imageSource = this.imageEditSource; - this.currentInteractionStatus = e; - break; - case u.FinishEdit: - this.imageSource = this.imageSelectedSource; - this.currentInteractionStatus = e; - break; - case u.DragInsert: - this.imageSource = this.imageEditSource; - this.currentInteractionStatus = e; - break; - case u.FinishDragInsert: - this.imageSource = this.imageNormalSource; - this.currentInteractionStatus = e - } - } - } - - e.ImageNode = p; - - class m extends N { - constructor(e) { - super(); - this.mainTitleName = e; - this.itemWidth = 0; - this.itemHeight = 44; - this.rightMargin = { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_paragraph_margin_xs"], - bundleName: "", - moduleName: "" - }; - this.mainTitleSetting = { - fontColor: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_primary"], - bundleName: "", - moduleName: "" - }, - fontSize: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body1"], - bundleName: "", - moduleName: "" - }, - fontWeight: FontWeight.Normal - }; - this.showPopUpTimeout = 0 - } - - setMainTitleSelected(e) { - this.mainTitleSetting = e ? { - fontColor: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary_activated"], - bundleName: "", - moduleName: "" - }, - fontSize: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body1"], - bundleName: "", - moduleName: "" - }, - fontWeight: FontWeight.Regular - } : { - fontColor: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_primary"], - bundleName: "", - moduleName: "" - }, - fontSize: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body1"], - bundleName: "", - moduleName: "" - }, - fontWeight: FontWeight.Normal - } - } - - set title(e) { - this.mainTitleName = e - } - - get title() { - return this.mainTitleName - } - - set popUpTimeout(e) { - this.showPopUpTimeout = e - } - - get popUpTimeout() { - return this.showPopUpTimeout - } - - get color() { - return this.mainTitleSetting.fontColor - } - - get size() { - return this.mainTitleSetting.fontSize - } - - get weight() { - return this.mainTitleSetting.fontWeight - } - - setMainTitleHighLight(e) { - this.mainTitleSetting = e ? { - fontColor: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_primary_contrary"], - bundleName: "", - moduleName: "" - }, - fontSize: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body1"], - bundleName: "", - moduleName: "" - }, - fontWeight: FontWeight.Regular - } : { - fontColor: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_primary"], - bundleName: "", - moduleName: "" - }, - fontSize: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body1"], - bundleName: "", - moduleName: "" - }, - fontWeight: FontWeight.Normal - } - } - } - - e.MainTitleNode = m; - - class f extends N { - constructor() { - super(); - this.statusColor = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - }; - this.editItemColor = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_emphasize"], - bundleName: "", - moduleName: "" - }; - this.radius = { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_default_xs"], - bundleName: "", - moduleName: "" - }; - this.itemWidth = 0; - this.itemHeight = 32; - this.rightMargin = { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_paragraph_margin_xs"], - bundleName: "", - moduleName: "" - }; - this.inputTextSetting = { - fontColor: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_primary"], - bundleName: "", - moduleName: "" - }, - fontSize: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body1"], - bundleName: "", - moduleName: "" - }, - fontWeight: FontWeight.Normal - } - } - - get color() { - return this.inputTextSetting.fontColor - } - - get size() { - return this.inputTextSetting.fontSize - } - - get weight() { - return this.inputTextSetting.fontWeight - } - - get borderRadius() { - return this.radius - } - - get backgroundColor() { - return this.statusColor - } - - get editColor() { - return this.editItemColor - } - - get textInputStatusColor() { - return this.status - } - } - - e.InputText = f; - - class S { - constructor(e) { - this.borderWidth = { has: 2, none: 0 }; - this.canShowFlagLine = !1; - this.isOverBorder = !1; - this.canShowBottomFlagLine = !1; - this.isHighLight = !1; - this.isModify = !1; - this.childNodeInfo = e.getChildNodeInfo(); - this.nodeItem = { imageNode: null, inputText: null, mainTitleNode: null, imageCollapse: null }; - this.popUpInfo = { - popUpIsShow: !1, - popUpEnableArrow: !1, - popUpColor: null, - popUpText: "", - popUpTextColor: null - }; - this.nodeItem.imageNode = e.getNodeItem().imageNode; - this.nodeItem.inputText = new f; - this.nodeItem.mainTitleNode = e.getNodeItem().mainTitleNode; - this.nodeItem.imageCollapse = e.getNodeItem().imageCollapse; - this.menu = e.menu; - this.parentNodeId = e.parentNodeId; - this.currentNodeId = e.currentNodeId; - this.nodeHeight = 44; - this.nodeLevel = e.nodeLevel; - this.nodeLeftPadding = 12 * e.nodeLevel + 8; - this.nodeColor = { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - }; - this.nodeIsShow = !(this.nodeLevel > 0); - this.listItemHeight = this.nodeLevel > 0 ? 0 : 48; - this.isShowTitle = !0; - this.isShowInputText = !1; - this.isSelected = !1; - this.status = { - normal: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background_transparent"], - bundleName: "", - moduleName: "" - }, - hover: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_hover"], - bundleName: "", - moduleName: "" - }, - press: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_click_effect"], - bundleName: "", - moduleName: "" - }, - selected: "#1A0A59F7", - highLight: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_activated"], - bundleName: "", - moduleName: "" - } - }; - this.nodeBorder = { - borderWidth: 0, - borderColor: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_focused_outline"], - bundleName: "", - moduleName: "" - }, - borderRadius: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_clicked"], - bundleName: "", - moduleName: "" - } - }; - this.flagLineLeftMargin = 12 * e.nodeLevel + 8; - this.node = e; - this.nodeParam = e.data - } - - getPopUpInfo() { - return this.popUpInfo - } - - setPopUpIsShow(e) { - this.popUpInfo.popUpIsShow = e - } - - setPopUpEnableArrow(e) { - this.popUpInfo.popUpEnableArrow = e - } - - setPopUpColor(e) { - this.popUpInfo.popUpColor = e - } - - setPopUpText(e) { - this.popUpInfo.popUpText = e - } - - setPopUpTextColor(e) { - this.popUpInfo.popUpTextColor = e - } - - getIsShowTitle() { - return this.isShowTitle - } - - getIsShowInputText() { - return this.isShowInputText - } - - setTitleAndInputTextStatus(e) { - if (e) { - this.isShowTitle = !1; - this.isShowInputText = !0 - } else { - this.isShowTitle = !0; - this.isShowInputText = !1 - } - } - - handleImageCollapseAfterAddNode(e) { - if (e) { - this.nodeItem.imageCollapse = new p({ - id: -1, - type: 2e4, - params: ["sys.media.ohos_ic_public_arrow_down"], - bundleName: "", - moduleName: "" - }, null, null, { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_alpha_content_tertiary"], - bundleName: "", - moduleName: "" - }, 24, 24); - this.nodeItem.imageCollapse.itemRightMargin = { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_paragraph_margin_xs"], - bundleName: "", - moduleName: "" - } - } else this.nodeItem.imageCollapse = null - } - - setNodeColor(e) { - this.nodeColor = e - } - - getNodeColor() { - return this.nodeColor - } - - setListItemHeight(e) { - this.listItemHeight = e - } - - getListItemHeight() { - return this.listItemHeight - } - - getNodeCurrentNodeId() { - return this.currentNodeId - } - - getNodeParentNodeId() { - return this.parentNodeId - } - - getNodeLeftPadding() { - return this.nodeLeftPadding - } - - getNodeHeight() { - return this.nodeHeight - } - - setNodeIsShow(e) { - this.nodeIsShow = e - } - - getNodeIsShow() { - return this.nodeIsShow - } - - getNodeItem() { - return this.nodeItem - } - - getNodeStatus() { - return this.status - } - - getNodeBorder() { - return this.nodeBorder - } - - setNodeBorder(e) { - this.nodeBorder.borderWidth = e ? this.borderWidth.has : this.borderWidth.none - } - - getChildNodeInfo() { - return this.childNodeInfo - } - - getCurrentNodeId() { - return this.currentNodeId - } - - getMenu() { - return this.menu - } - - setIsSelected(e) { - this.isSelected = e - } - - getIsSelected() { - return this.isSelected - } - - getNodeInfoData() { - return this.nodeParam - } - - getNodeInfoNode() { - return this.node - } - - getIsFolder() { - return this.nodeParam.isFolder - } - - setCanShowFlagLine(e) { - this.canShowFlagLine = e - } - - getCanShowFlagLine() { - return this.canShowFlagLine - } - - setFlagLineLeftMargin(e) { - this.flagLineLeftMargin = 12 * e + 8 - } - - getFlagLineLeftMargin() { - return this.flagLineLeftMargin - } - - getNodeLevel() { - return this.nodeLevel - } - - setIsOverBorder(e) { - this.isOverBorder = e - } - - getIsOverBorder() { - return this.isOverBorder - } - - setCanShowBottomFlagLine(e) { - this.canShowBottomFlagLine = e - } - - getCanShowBottomFlagLine() { - return this.canShowBottomFlagLine - } - - setIsHighLight(e) { - this.isHighLight = e - } - - getIsHighLight() { - return this.isHighLight - } - - setIsModify(e) { - this.isModify = e - } - - getIsModify() { - return this.isModify - } - } - - e.NodeInfo = S; - - class C { - constructor() { - this.MaxNodeLevel = 50; - this.MAX_CN_LENGTH = 254; - this.MAX_EN_LENGTH = 255; - this.INITIAL_INVALID_VALUE = -1; - this._root = new c({}); - this._root.nodeLevel = -1; - this._root.parentNodeId = -1; - this._root.currentNodeId = -1 - } - - getNewNodeId() { - return this.addNewNodeId - } - - traverseNodeDF(e, t = this._root) { - let o = [], i = !1; - o.unshift(t); - let s = o.shift(); - for (;!i && s; ) { - i = !0 === e(s); - if (!i) { - o.unshift(...s.children); - s = o.shift() - } - } - } - - traverseNodeBF(e) { - let t = []; - let o = !1; - t.push(this._root); - let i = t.shift(); - for (;!o && i; ) { - try { - o = e(i) - } catch (e) { - e.name, e.message - } - if (!o) { - t.push(...i.children); - i = t.shift() - } - } - } - - contains(e, t) { - t.call(this, e,!0) - } - - updateParentChildNum(e, t, o) { - let i = e.parentNodeId; - for (; i >= 0; ) this.traverseNodeDF((e => { - if (e.currentNodeId == i) { - e.getChildNodeInfo().allChildNum = t ? e.getChildNodeInfo().allChildNum + o : e.getChildNodeInfo() - .allChildNum - o; - i = e.parentNodeId; - return !1 - } - return !1 - })) - } - - findParentNodeId(e) { - let t = null; - this.contains((function (o) { - if (o.currentNodeId == e) { - t = o; - return !0 - } - return !1 - }), this.traverseNodeBF); - return t.parentNodeId - } - - addNode(e, t, o) { - if (null === this._root) { - this._root = new c({}); - this._root.nodeLevel = -1; - this._root.parentNodeId = -1; - this._root.currentNodeId = -1 - } - let i = null; - this.contains((function (t) { - if (t.currentNodeId == e) { - i = t; - return !0 - } - return !1 - }), this.traverseNodeBF); - if (i) { - let s = new c(o); - if (i.nodeLevel > this.MaxNodeLevel) throw new Error("ListNodeUtils[addNode]: The level of the tree view cannot exceed 50."); - s.nodeLevel = i.nodeLevel + 1; - s.parentNodeId = e; - s.currentNodeId = t; - i.children.push(s); - i.getChildNodeInfo().isHasChildNode = !0; - i.getChildNodeInfo().childNum = i.children.length; - i.getChildNodeInfo().allChildNum += 1; - i.addImageCollapse(i.getChildNodeInfo().isHasChildNode); - this.updateParentChildNum(i,!0, 1); - return this - } - throw new Error("ListNodeUtils[addNode]: Parent node not found.") - } - - findNodeIndex(e, t) { - let o = this.INITIAL_INVALID_VALUE; - for (let i = 0, s = e.length;i < s; i++) if (e[i].currentNodeId === t) { - o = i; - break - } - return o - } - - freeNodeMemory(e, t) { - let o = []; - this.traverseNodeDF((function (e) { - o.push(e); - return !1 - }), e); - o.forEach((e => { - t.push(e.currentNodeId); - e = null - })) - } - - removeNode(e, t, o) { - let i = null; - this.contains((function (e) { - if (e.currentNodeId == t) { - i = e; - return !0 - } - return !1 - }), o); - if (i) { - let t = []; - let o = this.findNodeIndex(i.children, e); - if (o < 0) throw new Error("Node does not exist."); - { - var s = i.children[o].getChildNodeInfo().allChildNum + 1; - this.freeNodeMemory(i.children[o], t); - let e = i.children.splice(o, 1); - e = null; - 0 == i.children.length && i.addImageCollapse(!1) - } - i.getChildNodeInfo().childNum = i.children.length; - i.getChildNodeInfo().allChildNum -= s; - this.updateParentChildNum(i,!1, s); - return t - } - throw new Error("Parent does not exist.") - } - - getNewNodeInfo(e) { - let t = null; - this.contains((function (o) { - if (o.currentNodeId == e) { - t = o; - return !0 - } - return !1 - }), this.traverseNodeBF); - let o = { - isFolder: !0, - icon: null, - selectedIcon: null, - editIcon: null, - menu: null, - secondaryTitle: "" - }; - if (t) if (0 === t.children.length) if (null != t.getNodeItem().imageNode) { - o.icon = t.getNodeItem().imageNode.normalSource; - o.selectedIcon = t.getNodeItem().imageNode.selectedSource; - o.editIcon = t.getNodeItem().imageNode.editSource; - o.menu = t.getMenu() - } else { - o.icon = null; - o.selectedIcon = null; - o.editIcon = null; - o.menu = t.getMenu() - } else if (t.children.length > 0) if (null != t.getNodeItem().imageNode) { - o.icon = null != t.children[0].getNodeItem().imageNode ? t.children[0].getNodeItem() - .imageNode - .normalSource : null; - o.selectedIcon = null != t.children[0].getNodeItem().imageNode ? t.children[0].getNodeItem() - .imageNode - .selectedSource : null; - o.editIcon = null != t.children[0].getNodeItem().imageNode ? t.children[0].getNodeItem() - .imageNode - .editSource : null; - o.menu = t.children[0].getMenu() - } else { - o.icon = null; - o.selectedIcon = null; - o.editIcon = null; - o.menu = t.children[0].getMenu() - } - return o - } - - getClickChildId(e) { - let t = null; - this.contains((function (o) { - if (o.currentNodeId == e) { - t = o; - return !0 - } - return !1 - }), this.traverseNodeBF); - if (t) { - if (0 === t.children.length) return []; - if (t.children.length > 0) { - var o = new Array(t.children.length); - for (let e = 0;e < o.length; e++) o[e] = 0; - for (let e = 0;e < t.children.length && e < o.length; e++) o[e] = t.children[e].currentNodeId; - return o - } - } - return [] - } - - getClickNodeChildrenInfo(e) { - let t = null; - this.contains((function (o) { - if (o.currentNodeId == e) { - t = o; - return !0 - } - return !1 - }), this.traverseNodeBF); - if (t) { - if (0 === t.children.length) return []; - if (t.children.length > 0) { - var o = new Array(t.children.length); - for (let e = 0;e < o.length; e++) o[e] = { itemId: null, itemIcon: null, itemTitle: null, isFolder: null }; - for (let e = 0;e < t.children.length && e < o.length; e++) { - o[e].itemId = t.children[e].currentNodeId; - t.children[e].getNodeItem().imageNode && (o[e].itemIcon = t.children[e].getNodeItem().imageNode.source); - t.children[e].getNodeItem().mainTitleNode && (o[e].itemTitle = t.children[e].getNodeItem() - .mainTitleNode - .title); - o[e].isFolder = t.children[e].getIsFolder() - } - return o - } - } - return [] - } - - checkMainTitleIsValid(e) { - let t = /^[\u4e00-\u9fa5]+$/; - return!/[\\\/:*?"<>|]/.test(e) && !(t.test(e) && e.length > this.MAX_CN_LENGTH || !t.test(e) && e.length > this.MAX_EN_LENGTH) - } - - dragTraverseNodeDF(e, t = this._root, o) { - let i = [], s = !1; - i.unshift(t); - let a = i.shift(); - for (;!s && a; ) { - s = !0 === e(a, o); - if (!s) { - i.unshift(...a.children); - a = i.shift() - } - } - } - - addDragNode(e, t, o, i, s) { - if (null === this._root) { - this._root = new c({}); - this._root.nodeLevel = this.INITIAL_INVALID_VALUE; - this._root.parentNodeId = this.INITIAL_INVALID_VALUE; - this._root.currentNodeId = this.INITIAL_INVALID_VALUE - } - let a = null; - this.contains((function (t) { - if (t.currentNodeId == e) { - a = t; - return !0 - } - return !1 - }), this.traverseNodeBF); - if (a) { - let d = new c(s); - if (a.nodeLevel > this.MaxNodeLevel) throw new Error("ListNodeUtils[addNode]: The level of the tree view cannot exceed 50."); - d.nodeLevel = a.nodeLevel + 1; - d.parentNodeId = e; - d.currentNodeId = t; - let r = this.INITIAL_INVALID_VALUE; - if (a.children.length) { - for (let e = 0;e < a.children.length; e++) if (a.children[e].getCurrentNodeId() == o) { - r = e; - break - } - i ? a.children.splice(r + 1, 0, d) : a.children.splice(r, 0, d) - } else a.children.push(d); - a.getChildNodeInfo().isHasChildNode = !0; - a.getChildNodeInfo().childNum = a.children.length; - a.getChildNodeInfo().allChildNum += 1; - a.addImageCollapse(a.getChildNodeInfo().isHasChildNode); - this.updateParentChildNum(a,!0, 1); - return this - } - throw new Error("ListNodeUtils[addNode]: Parent node not found.") - } - } - - e.ListNodeUtils = C; - - class D extends d { - constructor() { - super(...arguments); - this.ROOT_NODE_ID = -1; - this.listNodeUtils = new C; - this.listNode = []; - this.INITIAL_INVALID_VALUE = -1; - this.lastIndex = -1; - this.thisIndex = -1; - this.modifyNodeIndex = -1; - this.modifyNodeId = -1; - this.expandAndCollapseInfo = new Map; - this.loadedNodeIdAndIndexMap = new Map; - this.isTouchDown = !1; - this.appEventBus = a.getInstance().getTreeListener(); - this.isInnerDrag = !1; - this.isDrag = !1; - this.draggingCurrentNodeId = this.INITIAL_INVALID_VALUE; - this.draggingParentNodeId = this.INITIAL_INVALID_VALUE; - this.currentNodeInfo = null; - this.listItemOpacity = 1; - this.lastPassIndex = this.INITIAL_INVALID_VALUE; - this.lastPassId = this.INITIAL_INVALID_VALUE; - this.thisPassIndex = this.INITIAL_INVALID_VALUE; - this.lastDelayExpandIndex = this.INITIAL_INVALID_VALUE; - this.timeoutExpandId = this.INITIAL_INVALID_VALUE; - this.lastTimeoutExpandId = this.INITIAL_INVALID_VALUE; - this.clearTimeoutExpandId = this.INITIAL_INVALID_VALUE; - this.timeoutHighLightId = this.INITIAL_INVALID_VALUE; - this.lastTimeoutHighLightId = this.INITIAL_INVALID_VALUE; - this.clearTimeoutHighLightId = this.INITIAL_INVALID_VALUE; - this.lastDelayHighLightIndex = this.INITIAL_INVALID_VALUE; - this.lastDelayHighLightId = this.INITIAL_INVALID_VALUE; - this.nodeIdAndSubtitleMap = new Map; - this.flag = g.NONE; - this.selectedParentNodeId = this.INITIAL_INVALID_VALUE; - this.selectedParentNodeSubtitle = ""; - this.insertNodeSubtitle = ""; - this.currentFocusNodeId = this.INITIAL_INVALID_VALUE; - this.lastFocusNodeId = this.INITIAL_INVALID_VALUE; - this.addFocusNodeId = this.INITIAL_INVALID_VALUE; - this.FLAG_LINE = { - flagLineHeight: "1.5vp", - flagLineColor: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_activated"], - bundleName: "", - moduleName: "" - }, - xOffset: "0vp", - yTopOffset: "2.75vp", - yBottomOffset: "-1.25vp", - yBasePlateOffset: "1.5vp" - }; - this.DRAG_POPUP = { - floorConstraintSize: { minWidth: "128vp", maxWidth: "208vp" }, - textConstraintSize: { minWidth1: "80vp", maxWidth1: "160vp", minWidth2: "112vp", maxWidth2: "192vp" }, - padding: { left: "8vp", right: "8vp" }, - backgroundColor: o, - height: "48", - shadow: { - radius: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_default_m"], - bundleName: "", - moduleName: "" - }, - color: "#00001E", - offsetX: 0, - offsetY: 10 - }, - borderRadius: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_corner_radius_clicked"], - bundleName: "", - moduleName: "" - }, - fontColor: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_primary"], - bundleName: "", - moduleName: "" - }, - fontSize: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body1"], - bundleName: "", - moduleName: "" - }, - fontWeight: FontWeight.Regular, - imageOpacity: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_alpha_content_fourth"], - bundleName: "", - moduleName: "" - } - }; - this.subTitle = { - normalFontColor: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_secondary"], - bundleName: "", - moduleName: "" - }, - highLightFontColor: { - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_primary_contrary"], - bundleName: "", - moduleName: "" - }, - fontSize: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body2"], - bundleName: "", - moduleName: "" - }, - fontWeight: FontWeight.Regular, - margin: { left: "4vp", right: "24" } - } - } - - changeNodeColor(e, t) { - this.listNode[e].setNodeColor(t) - } - - getNodeColor(e) { - return this.listNode[e].getNodeColor() - } - - handleFocusEffect(e, t) { - this.listNode[e].getNodeIsShow() && this.listNode[e].setNodeBorder(t) - } - - setImageSource(e, t) { - let o = this.listNode[e]; - o.setIsSelected(t === u.Selected || t === u.Edit || t === u.FinishEdit); - null != o.getNodeItem().mainTitleNode && t != u.DragInsert && t != u.FinishDragInsert && o.getNodeItem() - .mainTitleNode - .setMainTitleSelected(t === u.Selected || t === u.FinishEdit); - null != o.getNodeItem().imageNode && o.getNodeItem().imageNode.setImageSource(t) - } - - setImageCollapseSource(e, t) { - let o = this.listNode[e]; - null != o.getNodeItem().imageCollapse && o.getNodeItem() - .imageCollapse - .setImageCollapseSource(t, this.expandAndCollapseInfo.get(o.getCurrentNodeId())) - } - - clearLastIndexStatus() { - if (!(-1 == this.lastIndex || this.lastIndex >= this.listNode.length)) { - this.setImageSource(this.lastIndex, u.Normal); - this.changeNodeColor(this.lastIndex, this.listNode[this.lastIndex].getNodeStatus().normal); - this.handleFocusEffect(this.lastIndex,!1); - this.notifyDataChange(this.loadedNodeIdAndIndexMap.get(this.listNode[this.lastIndex].getCurrentNodeId())) - } - } - - changeNodeStatus(e) { - let t = e; - let o = this.ListNode; - let i = o[e].getCurrentNodeId(); - if (this.expandAndCollapseInfo.get(i) == I.Expand) { - this.expandAndCollapseInfo.set(i, I.Collapse); - o[t].getNodeItem().imageCollapse.changeImageCollapseSource(I.Collapse) - } else if (this.expandAndCollapseInfo.get(i) == I.Collapse) { - this.expandAndCollapseInfo.set(i, I.Expand); - o[t].getNodeItem().imageCollapse.changeImageCollapseSource(I.Expand) - } - } - - handleExpandAndCollapse(e) { - let t = e; - let o = this.ListNode; - let i = o[t].getCurrentNodeId(); - if (!this.expandAndCollapseInfo.has(i)) return; - let s = this.expandAndCollapseInfo.get(i); - if (o[t].getChildNodeInfo().isHasChildNode && s == I.Collapse) { - for (var a = 0;a < o[t].getChildNodeInfo().allChildNum; a++) { - o[t + 1+a].setNodeIsShow(!1); - o[t + 1+a].setListItemHeight(0) - } - this.notifyDataReload(); - return - } - let d = new Array(o[t].getChildNodeInfo().childNum); - d[0] = t + 1; - let r = 1; - for (; r < o[t].getChildNodeInfo().childNum; ) { - d[r] = d[r-1] + o[d[r-1]].getChildNodeInfo().allChildNum + 1; - r++ - } - if (s == I.Expand) for (a = 0; a < d.length; a++) { - o[d[a]].setNodeIsShow(!0); - o[d[a]].setListItemHeight(48); - let e = o[d[a]].getCurrentNodeId(); - this.expandAndCollapseInfo.get(e) == I.Expand && this.handleExpandAndCollapse(d[a]) - } - d = null; - this.notifyDataReload() - } - - init(e) { - let t = 0; - this.listNode = []; - this.listNodeUtils = e; - this.loadedNodeIdAndIndexMap.clear(); - this.listNodeUtils.traverseNodeDF((e => { - if (e.currentNodeId >= 0) { - var o = new S(e); - this.listNode.push(o); - o.getChildNodeInfo().isHasChildNode && this.expandAndCollapseInfo.set(o.getCurrentNodeId(), I.Collapse); - o.getNodeIsShow() && this.loadedNodeIdAndIndexMap.set(o.getCurrentNodeId(), t++); - o.getIsFolder() && this.nodeIdAndSubtitleMap.set(o.getCurrentNodeId(), o.getNodeInfoData() - .secondaryTitle || 0 == o.getNodeInfoData() - .secondaryTitle ? o.getNodeInfoData().secondaryTitle : "") - } - return !1 - })) - } - - refreshRemoveNodeData(e, t) { - let o = []; - for (let t = 0;t < e.length; t++) for (let i = 0;i < this.listNode.length; i++) if (this.listNode[i].getNodeCurrentNodeId() == e[t]) { - let s = this.listNode[i].getNodeCurrentNodeId(); - this.loadedNodeIdAndIndexMap.has(s) && o.push(this.loadedNodeIdAndIndexMap.get(s)); - let a = this.listNode.splice(i, 1); - a = null; - this.expandAndCollapseInfo.has(e[t]) && this.expandAndCollapseInfo.delete(e[t]); - break - } - o.forEach((e => { - this.notifyDataDelete(e); - this.notifyDataChange(e) - })); - for (let e = 0;e < this.listNode.length; e++) if (this.listNode[e].getNodeCurrentNodeId() == t.getNodeCurrentNodeId()) { - if (null == t.getNodeItem().imageCollapse) { - this.listNode[e].handleImageCollapseAfterAddNode(!1); - this.expandAndCollapseInfo.delete(t.getNodeCurrentNodeId()); - this.notifyDataChange(this.loadedNodeIdAndIndexMap.get(this.listNode[e].getNodeCurrentNodeId())) - } - break - } - let i = { currentNodeId: t.getNodeCurrentNodeId(), parentNodeId: t.getNodeParentNodeId() }; - this.appEventBus.emit(s.NODE_DELETE, [i]) - } - - refreshAddNodeData(e) { - var t; - this.listNodeUtils.traverseNodeDF((o => { - if (o.currentNodeId === e[0]) { - t = new S(o); - return !0 - } - return !1 - })); - t.setIsModify(!0); - let o = 0; - for (let e = 0;e < this.listNode.length; e++) if (this.listNode[e].getNodeCurrentNodeId() == t.getNodeParentNodeId()) { - o = e; - if (null == this.listNode[e].getNodeItem().imageCollapse) { - this.listNode[e].handleImageCollapseAfterAddNode(!0); - this.notifyDataChange(o) - } else this.expandAndCollapseInfo.get(this.listNode[e].getNodeCurrentNodeId()) == I.Collapse && this.changeNodeStatus(o); - this.listNode.splice(e + 1, 0, t); - this.listNode[e+1].setTitleAndInputTextStatus(!0); - this.listNode[e+1].setNodeIsShow(!0); - this.listNode[e+1].setListItemHeight(48); - this.setImageSource(e + 1, u.Edit); - this.currentOperation = n.ADD_NODE; - this.notifyDataAdd(e + 1); - this.notificationNodeInfo(e + 1, this.currentOperation); - break - } - this.modifyNodeIndex = o + 1; - this.expandAndCollapseInfo.set(t.getNodeParentNodeId(), I.Expand); - this.handleExpandAndCollapse(o) - } - - refreshData(e, t, o, i) { - let s; - this.listNodeUtils = e; - this.listNodeUtils.traverseNodeDF((e => { - if (e.currentNodeId == o) { - s = new S(e); - return !0 - } - return !1 - })); - if (t === n.REMOVE_NODE) { - this.nodeIdAndSubtitleMap.set(o, this.selectedParentNodeSubtitle); - this.notifyDataChange(this.loadedNodeIdAndIndexMap.get(o)); - this.refreshRemoveNodeData(i, s) - } - if (t === n.ADD_NODE) { - this.addFocusNodeId = i[0]; - this.nodeIdAndSubtitleMap.set(this.getClickNodeId(), this.selectedParentNodeSubtitle); - this.nodeIdAndSubtitleMap.set(i[0], this.insertNodeSubtitle); - this.refreshAddNodeData(i) - } - } - - setClickIndex(e) { - this.thisIndex = e - } - - getClickNodeId() { - return this.thisIndex < 0 || this.thisIndex >= this.ListNode.length ? -1 : this.ListNode[this.thisIndex].getCurrentNodeId() - } - - expandAndCollapseNode(e) { - this.changeNodeStatus(e); - this.handleExpandAndCollapse(e) - } - - getIsTouchDown() { - return this.isTouchDown - } - - getLastIndex() { - return this.lastIndex - } - - handleEvent(e, t) { - if (this.isDrag) return; - e !== r.TOUCH_DOWN && e !== r.TOUCH_UP && e !== r.MOUSE_BUTTON_RIGHT || t != this.lastIndex && this.clearLastIndexStatus(); - let o = this.loadedNodeIdAndIndexMap.get(this.listNode[t].getCurrentNodeId()); - switch (e) { - case r.TOUCH_DOWN: - this.isTouchDown = !0; - this.changeNodeColor(t, this.listNode[t].getNodeStatus().press); - break; - case r.TOUCH_UP: { - this.isInnerDrag && (this.isInnerDrag = !1); - this.isTouchDown = !1; - let e = this.listNode[t]; - this.setImageSource(t, u.Selected); - this.lastIndex = t; - this.changeNodeColor(t, e.getNodeStatus().selected); - this.notifyDataChange(o); - break - } - case r.HOVER: - if (this.getNodeColor(t) != this.listNode[t].getNodeStatus().selected) { - this.changeNodeColor(t, this.listNode[t].getNodeStatus().hover); - this.notifyDataChange(o) - } - break; - case r.HOVER_OVER: - if (this.getNodeColor(t) != this.listNode[t].getNodeStatus().selected) { - this.changeNodeColor(t, this.listNode[t].getNodeStatus().normal); - this.notifyDataChange(o) - } - break; - case r.FOCUS: - this.handleFocusEffect(t,!0); - this.notifyDataChange(o); - break; - case r.BLUR: - this.handleFocusEffect(t,!1); - this.notifyDataChange(o); - break; - case r.MOUSE_BUTTON_RIGHT: - this.lastIndex = t; - this.finishEditing(); - break; - case r.DRAG: - this.isTouchDown = !1; - let e = this.listNode[t]; - this.setImageSource(t, u.Selected); - this.lastIndex = t; - this.changeNodeColor(t, e.getNodeStatus().selected); - this.notifyDataChange(o) - } - } - - notificationNodeInfo(e, t) { - if (t === n.MODIFY_NODE) { - let e = this.listNode[this.modifyNodeIndex]; - let t = { currentNodeId: e.getNodeCurrentNodeId(), parentNodeId: e.getNodeParentNodeId() }; - this.appEventBus.emit(s.NODE_MODIFY, [t]) - } else if (t === n.ADD_NODE) { - let t = this.listNode[e]; - null != t.getNodeItem().imageNode && t.getNodeItem().imageNode.source; - null != t.getNodeItem().imageNode && t.getNodeItem().imageNode.selectedSource; - null != t.getNodeItem().imageNode && t.getNodeItem().imageNode.editSource; - let o = { currentNodeId: t.getNodeCurrentNodeId(), parentNodeId: t.getNodeParentNodeId() }; - this.appEventBus.emit(s.NODE_ADD, [o]) - } - } - - finishEditing() { - if (-1 != this.modifyNodeIndex) { - this.setImageSource(this.modifyNodeIndex, u.FinishEdit); - this.setImageCollapseSource(this.modifyNodeIndex, u.FinishEdit); - this.listNode[this.modifyNodeIndex].setIsModify(!1); - this.listNode[this.modifyNodeIndex].setTitleAndInputTextStatus(!1); - this.notificationNodeInfo(this.modifyNodeIndex, this.currentOperation); - this.notifyDataChange(this.modifyNodeIndex) - } - } - - setItemVisibilityOnEdit(e, t) { - let o = -1; - if (-1 != e) { - if (t === n.MODIFY_NODE) { - for (let t = 0;t < this.listNode.length; t++) if (this.listNode[t].getCurrentNodeId() == e) { - o = t; - break - } - let t = this.listNode[o]; - t.setIsModify(!0); - if (null === t.getNodeItem().mainTitleNode) return; - this.currentOperation = n.MODIFY_NODE; - t.setTitleAndInputTextStatus(!0); - this.setImageSource(o, u.Edit); - this.setImageCollapseSource(o, u.Edit); - this.modifyNodeIndex = o; - t.getNodeItem().inputText && (null != t.getNodeItem().imageCollapse ? t.getNodeItem() - .inputText - .rightMargin = { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_paragraph_margin_xs"], - bundleName: "", - moduleName: "" - } : t.getNodeItem().inputText.rightMargin = { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_elements_margin_horizontal_m"], - bundleName: "", - moduleName: "" - }); - this.notifyDataChange(this.loadedNodeIdAndIndexMap.get(e)) - } - o = e; - if (t === n.COMMIT_NODE) { - let e = this.listNode[o]; - e.setTitleAndInputTextStatus(!1); - e.setIsModify(!1); - this.setImageSource(o, u.FinishEdit); - this.setImageCollapseSource(o, u.FinishEdit); - this.notificationNodeInfo(this.modifyNodeIndex, this.currentOperation); - this.notifyDataChange(this.loadedNodeIdAndIndexMap.get(e.getCurrentNodeId())) - } - } - } - - setPopUpInfo(e, t, o, i) { - let s = this.listNode[i]; - s.setPopUpIsShow(o); - let a = this.loadedNodeIdAndIndexMap.get(s.getCurrentNodeId()); - if (o) { - if (e === l.HINTS) { - if (null != s.getNodeItem().mainTitleNode) s.setPopUpText(s.getNodeItem().mainTitleNode.title); else { - s.setPopUpText(""); - s.setPopUpIsShow(!1) - } - s.setPopUpEnableArrow(!1); - s.setPopUpColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_background"], - bundleName: "", - moduleName: "" - }); - s.setPopUpTextColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_secondary"], - bundleName: "", - moduleName: "" - }) - } else if (e === l.WARNINGS && null != s.getNodeItem().inputText) { - t === h.INVALID_ERROR ? s.setPopUpText("invalid error") : t === h.LENGTH_ERROR && s.setPopUpText("length error"); - s.setPopUpEnableArrow(!0); - s.setPopUpColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_help_tip_bg"], - bundleName: "", - moduleName: "" - }); - s.setPopUpTextColor({ - id: -1, - type: 10001, - params: ["sys.color.ohos_id_color_text_hint_contrary"], - bundleName: "", - moduleName: "" - }) - } - this.notifyDataChange(a) - } else this.notifyDataChange(a) - } - - setShowPopUpTimeout(e, t) { - null != this.listNode[t].getNodeItem().mainTitleNode && (this.listNode[t].getNodeItem() - .mainTitleNode - .popUpTimeout = e); - let o = this.loadedNodeIdAndIndexMap.get(this.listNode[t].getCurrentNodeId()); - this.notifyDataChange(o) - } - - setMainTitleNameOnEdit(e, t) { - this.modifyNodeIndex = e; - if (null != this.listNode[e].getNodeItem().mainTitleNode) { - this.listNode[e].getNodeItem().mainTitleNode.title = t; - let o = this.loadedNodeIdAndIndexMap.get(this.listNode[e].getCurrentNodeId()); - this.notifyDataChange(o) - } - } - - get ListNode() { - return this.listNode - } - - totalCount() { - let e = 0; - let t = 0; - this.loadedNodeIdAndIndexMap.clear(); - for (let o = 0;o < this.listNode.length; o++) if (this.listNode[o].getNodeIsShow()) { - this.loadedNodeIdAndIndexMap.set(this.listNode[o].getCurrentNodeId(), t++); - e++ - } - return e - } - - getData(e) { - let t = 0; - for (let o = 0;o < this.listNode.length; o++) if (this.listNode[o].getNodeIsShow()) { - if (e == t) return this.listNode[o]; - t++ - } - return null - } - - addData(e, t) { - this.listNode.splice(e, 0, t); - this.notifyDataAdd(e) - } - - pushData(e) { - this.listNode.push(e); - this.notifyDataAdd(this.listNode.length - 1) - } - - setIsInnerDrag(e) { - this.isInnerDrag = e - } - - getIsInnerDrag() { - return this.isInnerDrag - } - - setIsDrag(e) { - this.isDrag = e - } - - getIsDrag() { - return this.isDrag - } - - setCurrentNodeInfo(e) { - this.currentNodeInfo = e - } - - getCurrentNodeInfo() { - return this.currentNodeInfo - } - - setDraggingParentNodeId(e) { - this.draggingParentNodeId = e - } - - getDraggingParentNodeId() { - return this.draggingParentNodeId - } - - getDraggingCurrentNodeId() { - return this.draggingCurrentNodeId - } - - setDraggingCurrentNodeId(e) { - this.draggingCurrentNodeId = e - } - - setListItemOpacity(e) { - this.listItemOpacity = e - } - - getListItemOpacity(e) { - return e.getCurrentNodeId() == this.getDraggingCurrentNodeId() ? this.listItemOpacity : 1 - } - - getDragPopupPara() { - return this.DRAG_POPUP - } - - setLastPassIndex(e) { - this.lastPassIndex = e - } - - getLastPassIndex() { - return this.lastPassIndex - } - - getIsParentOfInsertNode(e) { - let t = this.currentNodeInfo.getNodeInfoNode(); - let o = !1; - this.listNodeUtils.traverseNodeDF((function (t) { - if (t.currentNodeId == e) { - o = !0; - return !0 - } - return !1 - }), t); - return o - } - - setPassIndex(e) { - this.thisPassIndex = e - } - - getPassIndex() { - return this.thisPassIndex - } - - clearTimeOutAboutDelayHighLightAndExpand(e) { - if (this.lastPassId != this.INITIAL_INVALID_VALUE && this.loadedNodeIdAndIndexMap.has(this.lastPassId)) { - let e = this.loadedNodeIdAndIndexMap.get(this.lastPassId); - let t = this; - this.ListNode.forEach((function (e) { - e.getNodeCurrentNodeId() == t.lastPassId && e.setCanShowFlagLine(!1) - })); - this.notifyDataChange(e) - } - if (this.lastTimeoutHighLightId != this.INITIAL_INVALID_VALUE && this.clearTimeoutHighLightId != this.lastTimeoutHighLightId) { - clearTimeout(this.lastTimeoutHighLightId); - if (this.lastDelayHighLightIndex != this.INITIAL_INVALID_VALUE) { - this.clearHighLight(this.lastDelayHighLightIndex); - let e = this.loadedNodeIdAndIndexMap.get(this.listNode[this.lastDelayHighLightIndex].getCurrentNodeId()); - this.notifyDataChange(e) - } - this.clearTimeoutHighLightId = this.lastTimeoutHighLightId - } - this.lastTimeoutHighLightId = this.timeoutHighLightId; - this.lastDelayHighLightIndex = e; - if (this.lastTimeoutExpandId != this.INITIAL_INVALID_VALUE && this.clearTimeoutExpandId != this.lastTimeoutExpandId) { - clearTimeout(this.lastTimeoutExpandId); - this.clearTimeoutExpandId = this.lastTimeoutExpandId - } - this.lastTimeoutExpandId = this.timeoutExpandId; - this.lastDelayExpandIndex = this.INITIAL_INVALID_VALUE - } - - clearHighLight(e) { - this.changeNodeColor(e, this.listNode[e].getNodeStatus().normal); - this.changeNodeHighLightColor(e,!1); - this.setImageSource(e, u.FinishDragInsert); - this.setImageCollapseSource(e, u.FinishDragInsert); - this.listNode[e].setIsHighLight(!1) - } - - changeNodeHighLightColor(e, t) { - this.listNode[e].getNodeItem() - .mainTitleNode && this.listNode[e].getIsShowTitle() && this.listNode[e].getNodeItem() - .mainTitleNode - .setMainTitleHighLight(t) - } - - setVisibility(e, t, o) { - let i = this.thisPassIndex != t || this.flag != e; - this.thisPassIndex = t; - if ((i || o) && this.isInnerDrag) { - this.flag = e; - let o = this.getData(t).getCurrentNodeId(); - let i = this.expandAndCollapseInfo.get(o) == I.Expand && this.flag == g.DOWN_FLAG ? this.getData(t) - .getNodeLevel() + 1 : this.getData(t) - .getNodeLevel(); - if (this.lastPassId != this.INITIAL_INVALID_VALUE && this.loadedNodeIdAndIndexMap.has(this.lastPassId)) { - let e = this.loadedNodeIdAndIndexMap.get(this.lastPassId); - let t = this; - this.ListNode.forEach((function (e) { - e.getNodeCurrentNodeId() == t.lastPassId && e.setCanShowFlagLine(!1) - })); - this.notifyDataChange(e) - } - if (this.flag == g.DOWN_FLAG && t < this.totalCount() - 1) { - this.getData(t).setCanShowFlagLine(!1); - this.getData(t + 1).setCanShowFlagLine(!0); - this.getData(t).setCanShowBottomFlagLine(!1); - this.getData(t + 1).setFlagLineLeftMargin(i); - this.notifyDataChange(t); - this.notifyDataChange(t + 1); - this.lastPassId = this.getData(t + 1).getNodeCurrentNodeId() - } else if (this.flag == g.UP_FLAG && t < this.totalCount() - 1) { - this.getData(t).setCanShowFlagLine(!0); - this.getData(t + 1).setCanShowFlagLine(!1); - this.getData(t).setCanShowBottomFlagLine(!1); - this.getData(t).setFlagLineLeftMargin(i); - this.notifyDataChange(t); - this.notifyDataChange(t + 1); - this.lastPassId = this.getData(t).getNodeCurrentNodeId() - } else if (t >= this.totalCount() - 1) { - if (this.flag == g.DOWN_FLAG) { - this.getData(t).setCanShowFlagLine(!1); - this.getData(t).setCanShowBottomFlagLine(!0) - } else { - this.getData(t).setCanShowFlagLine(!0); - this.getData(t).setCanShowBottomFlagLine(!1) - } - this.getData(t).setFlagLineLeftMargin(i); - this.notifyDataChange(t); - this.lastPassId = this.getData(t).getNodeCurrentNodeId() - } - } - } - - delayHighLightAndExpandNode(e, t, o) { - let i = e != this.lastDelayExpandIndex; - let s = this.getData(o).getIsOverBorder(); - this.lastDelayExpandIndex = s ? this.INITIAL_INVALID_VALUE : e; - if (s || i) { - let i = this; - if (!s && (!this.isInnerDrag || this.expandAndCollapseInfo.get(t) == I.Collapse && this.isInnerDrag || !this.expandAndCollapseInfo.has(t) && this.listNode[e].getIsFolder())) { - this.changeNodeColor(e, this.listNode[e].getNodeStatus().hover); - this.notifyDataChange(o); - let t = this.isInnerDrag ? 1e3 : 0; - this.timeoutHighLightId = setTimeout((function () { - i.delayHighLight(e) - }), t) - } - if (s || this.lastTimeoutHighLightId != this.INITIAL_INVALID_VALUE && this.clearTimeoutHighLightId != this.lastTimeoutHighLightId) { - clearTimeout(this.lastTimeoutHighLightId); - if (this.lastDelayHighLightIndex != this.INITIAL_INVALID_VALUE) { - this.clearHighLight(this.lastDelayHighLightIndex); - this.notifyDataReload() - } - this.clearTimeoutHighLightId = this.lastTimeoutHighLightId - } - this.lastTimeoutHighLightId = this.timeoutHighLightId; - this.lastDelayHighLightIndex = e; - if (!s && this.expandAndCollapseInfo.get(t) == I.Collapse) { - let t = this.getData(o).getNodeInfoNode().children[0].currentNodeId; - let s = 2e3; - this.timeoutExpandId = setTimeout((function () { - i.clearHighLight(i.lastDelayHighLightIndex); - i.alterFlagLineAndExpandNode(e, t) - }), s) - } - if (s || this.lastTimeoutExpandId != this.INITIAL_INVALID_VALUE && this.clearTimeoutExpandId != this.lastTimeoutExpandId) { - clearTimeout(this.lastTimeoutExpandId); - this.clearTimeoutExpandId = this.lastTimeoutExpandId - } - this.lastTimeoutExpandId = this.timeoutExpandId - } - } - - delayHighLight(e) { - let t = this; - this.ListNode.forEach((function (e) { - if (e.getNodeCurrentNodeId() == t.lastPassId) { - e.setCanShowFlagLine(!1); - e.setCanShowBottomFlagLine(!1) - } - })); - this.changeNodeColor(e, this.listNode[e].getNodeStatus().highLight); - this.listNode[e].setIsHighLight(!0); - this.changeNodeHighLightColor(e,!0); - this.setImageSource(e, u.DragInsert); - this.setImageCollapseSource(e, u.DragInsert); - this.notifyDataReload() - } - - alterFlagLineAndExpandNode(e, t) { - let o = this; - this.ListNode.forEach((function (e) { - if (e.getNodeCurrentNodeId() == o.lastPassId) { - e.setCanShowFlagLine(!1); - e.setCanShowBottomFlagLine(!1) - } - })); - this.ListNode.forEach((function (e) { - o.isInnerDrag && e.getNodeCurrentNodeId() == t && e.setCanShowFlagLine(!0) - })); - this.changeNodeStatus(e); - this.handleExpandAndCollapse(e); - this.lastPassId = t - } - - hideLastLine() { - if (this.lastPassId != this.INITIAL_INVALID_VALUE && this.loadedNodeIdAndIndexMap.has(this.lastPassId)) { - let e = this; - this.ListNode.forEach((function (t) { - if (t.getNodeCurrentNodeId() == e.lastPassId) { - t.setCanShowFlagLine(!1); - t.setCanShowBottomFlagLine(!1) - } - })); - let t = this.loadedNodeIdAndIndexMap.get(this.lastPassId); - this.notifyDataChange(t) - } - } - - clearLastTimeoutHighLight() { - if (this.lastTimeoutHighLightId != this.INITIAL_INVALID_VALUE && this.clearTimeoutHighLightId != this.lastTimeoutHighLightId) { - clearTimeout(this.lastTimeoutHighLightId); - this.lastDelayHighLightIndex != this.INITIAL_INVALID_VALUE && this.clearHighLight(this.lastDelayHighLightIndex) - } - } - - clearLastTimeoutExpand() { - this.lastTimeoutExpandId != this.INITIAL_INVALID_VALUE && this.clearTimeoutExpandId != this.lastTimeoutExpandId && clearTimeout(this.lastTimeoutExpandId) - } - - getSubtitle(e) { - return this.nodeIdAndSubtitleMap.has(e) ? "number" == typeof this.nodeIdAndSubtitleMap.get(e) ? this.nodeIdAndSubtitleMap.get(e) - .toString() : this.nodeIdAndSubtitleMap.get(e) : "" - } - - hasSubtitle(e) { - return this.nodeIdAndSubtitleMap.has(e) - } - - initialParameterAboutDelayHighLightAndExpandIndex() { - this.lastDelayHighLightIndex = this.INITIAL_INVALID_VALUE; - this.lastDelayExpandIndex = this.INITIAL_INVALID_VALUE; - this.lastPassIndex = this.INITIAL_INVALID_VALUE; - this.draggingCurrentNodeId = this.INITIAL_INVALID_VALUE; - this.flag = g.NONE - } - - refreshSubtitle(e) { - this.nodeIdAndSubtitleMap.set(this.selectedParentNodeId, this.selectedParentNodeSubtitle); - this.nodeIdAndSubtitleMap.set(e, this.insertNodeSubtitle); - this.notifyDataChange(this.loadedNodeIdAndIndexMap.get(this.selectedParentNodeId)); - this.notifyDataChange(this.loadedNodeIdAndIndexMap.get(e)) - } - - setNodeSubtitlePara(e, t, o) { - this.selectedParentNodeId = e; - this.selectedParentNodeSubtitle = t; - this.insertNodeSubtitle = o - } - - getInsertNodeSubtitle() { - return this.insertNodeSubtitle - } - - getExpandAndCollapseInfo(e) { - return this.expandAndCollapseInfo.get(e) - } - - getLastDelayHighLightId() { - return this.lastDelayHighLightId - } - - setLastDelayHighLightId() { - this.ListNode.forEach(((e, t) => { - t == this.lastDelayHighLightIndex && (this.lastDelayHighLightId = e.getCurrentNodeId()) - })) - } - - setLastPassId(e) { - this.lastPassId = e - } - - setLastDelayHighLightIndex(e) { - this.lastDelayHighLightIndex = e - } - - alterDragNode(e, t, o, i, a, d) { - let r = []; - let n = e; - let l = a; - let h = d.getNodeInfoData(); - let c = null; - let N = d.getNodeInfoNode(); - let u = !1; - let p = this.INITIAL_INVALID_VALUE; - let m = this.INITIAL_INVALID_VALUE; - let f = this.flag == g.DOWN_FLAG; - m = this.getChildIndex(i, a); - p = this.getChildIndex(e, t); - p = e != i ? f ? p + 1 : p : p > m ? f ? p : p - 1 : f ? p + 1 : p; - for (let e = 0;e < this.listNode.length; e++) if (this.listNode[e].getCurrentNodeId() == t) { - u = this.listNode[e].getIsHighLight(); - if (this.flag == g.DOWN_FLAG && this.expandAndCollapseInfo.get(t) == I.Expand) { - n = t; - p = 0 - } else if (this.flag == g.UP_FLAG && this.expandAndCollapseInfo.get(t) == I.Expand && 0 == this.listNode[e].getCanShowFlagLine()) { - n = t; - p = 0 - } else if (u) { - n = t; - p = 0 - } - break - } - let S = { currentNodeId: l, parentNodeId: n, childIndex: p }; - this.appEventBus.emit(s.NODE_MOVE, [S]); - r.push({ parentId: n, currentId: l, data: h }); - let C = null; - this.listNodeUtils.dragTraverseNodeDF((function (e, t) { - if (e) { - C = e; - n = C.parentNodeId; - l = C.currentNodeId; - for (let e = 0;e < t.length; e++) if (t[e].getNodeCurrentNodeId() == l) { - c = t[e]; - break - } - h = c.getNodeInfoData(); - n != i && r.push({ parentId: n, currentId: l, data: h }); - return !1 - } - return !1 - }), N, this.listNode); - this.listNodeUtils.removeNode(a, i, this.listNodeUtils.traverseNodeBF); - let D = t; - let _ = f; - if (this.expandAndCollapseInfo.get(t) == I.Expand) { - _ = !1; - this.listNode.forEach((e => { - e.getCurrentNodeId() == t && 0 == e.getCanShowFlagLine() && (D = e.getNodeInfoNode() - .children - .length ? e.getNodeInfoNode() - .children[0] - .currentNodeId : this.INITIAL_INVALID_VALUE) - })) - } else !this.expandAndCollapseInfo.get(t) && u && this.expandAndCollapseInfo.set(t, I.Expand); - this.listNodeUtils.addDragNode(r[0].parentId, r[0].currentId, D, _, r[0].data); - for (let e = 1;e < r.length; e++) this.listNodeUtils.addNode(r[e].parentId, r[e].currentId, r[e].data); - for (let e = 0;e < this.listNode.length; e++) if (this.listNode[e].getCurrentNodeId() == i && null == this.listNode[e].getNodeInfoNode() - .getNodeItem() - .imageCollapse) { - this.listNode[e].handleImageCollapseAfterAddNode(!1); - this.expandAndCollapseInfo.delete(i); - break - } - let T = [...this.listNode]; - this.reloadListNode(this.listNodeUtils, T) - } - - reloadListNode(e, t) { - let o = 0; - this.listNode = []; - this.listNodeUtils = e; - this.loadedNodeIdAndIndexMap.clear(); - this.listNodeUtils.traverseNodeDF((e => { - if (e.currentNodeId >= 0) { - var i = new S(e); - this.listNode.push(i); - this.expandAndCollapseInfo.get(e.currentNodeId) == I.Expand ? i.getNodeItem() - .imageCollapse - .changeImageCollapseSource(I.Expand) : this.expandAndCollapseInfo.get(e.currentNodeId) == I.Collapse && i.getNodeItem() - .imageCollapse - .changeImageCollapseSource(I.Collapse); - for (let e = 0;e < t.length; e++) if (t[e].getCurrentNodeId() == i.getCurrentNodeId()) { - i.setNodeIsShow(t[e].getNodeIsShow()); - i.setListItemHeight(t[e].getListItemHeight()); - i.getNodeItem().mainTitleNode && i.getIsShowTitle() && (i.getNodeItem() - .mainTitleNode - .title = t[e].getNodeItem().mainTitleNode.title); - break - } - i.getNodeIsShow() && this.loadedNodeIdAndIndexMap.set(i.getCurrentNodeId(), o++) - } - return !1 - })) - } - - getFlagLine() { - return this.FLAG_LINE - } - - getVisibility(e) { - let t = this.loadedNodeIdAndIndexMap.get(e.getCurrentNodeId()) - 1; - if (t > this.INITIAL_INVALID_VALUE) { - let o = this.getData(t); - return 1 != e.getCanShowFlagLine() || e.getIsHighLight() || o.getIsHighLight() ? Visibility.Hidden : Visibility.Visible - } - return 1 != e.getCanShowFlagLine() || e.getIsHighLight() ? Visibility.Hidden : Visibility.Visible - } - - getSubTitlePara() { - return this.subTitle - } - - getIsFolder(e) { - return!!this.loadedNodeIdAndIndexMap.has(e) && this.getData(this.loadedNodeIdAndIndexMap.get(e)).getIsFolder() - } - - getSubTitleFontColor(e) { - return e ? this.subTitle.highLightFontColor : this.subTitle.normalFontColor - } - - getChildIndex(e, t) { - let o = this.INITIAL_INVALID_VALUE; - this.listNodeUtils.traverseNodeBF((function (i) { - if (i.getCurrentNodeId() == e) { - i.children.forEach(((e, i) => { - e.getCurrentNodeId() == t && (o = i) - })); - return !0 - } - return !1 - })); - return o - } - - setCurrentFocusNodeId(e) { - this.currentFocusNodeId = e - } - - getCurrentFocusNodeId() { - return this.currentFocusNodeId - } - - setLastFocusNodeId(e) { - this.lastFocusNodeId = e - } - - getLastFocusNodeId() { - return this.lastFocusNodeId - } - - getAddFocusNodeId() { - return this.addFocusNodeId - } - - setFlag(e) { - this.flag = e - } - } - - e.ListNodeDataSource = D; - - function _(e) { - let t = 0; - this.listNodeDataSource.ListNode.forEach((function (o, i) { - o.getNodeCurrentNodeId() == e && (t = i) - })); - return t - } - - class T extends ViewPU { - constructor(e, t, o, i = -1) { - super(e, o, i); - this.listNodeDataSource = void 0; - this.treeController = void 0; - this.__dropSelectedIndex = new ObservedPropertySimplePU(0, this, "dropSelectedIndex"); - this.listTreeViewMenu = null; - this.__listTreeViewWidth = new SynchedPropertySimpleOneWayPU(t.listTreeViewWidth, this, "listTreeViewWidth"); - this.__listTreeViewHeight = new SynchedPropertySimpleOneWayPU(t.listTreeViewHeight, this, "listTreeViewHeight"); - this.MAX_CN_LENGTH = 254; - this.MAX_EN_LENGTH = 255; - this.INITIAL_INVALID_VALUE = -1; - this.MAX_TOUCH_DOWN_COUNT = 0; - this.isMultiPress = !1; - this.touchDownCount = this.INITIAL_INVALID_VALUE; - this.appEventBus = a.getInstance().getTreeListener(); - this.itemPadding = { - left: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_card_margin_middle"], - bundleName: "", - moduleName: "" - }, - right: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_card_margin_middle"], - bundleName: "", - moduleName: "" - }, - top: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_margin_vertical"], - bundleName: "", - moduleName: "" - }, - bottom: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_margin_vertical"], - bundleName: "", - moduleName: "" - } - }; - this.textInputPadding = { left: "0vp", right: "0vp", top: "0vp", bottom: "0vp" }; - this.setInitiallyProvidedValue(t) - } - - setInitiallyProvidedValue(e) { - void 0 !== e.listNodeDataSource && (this.listNodeDataSource = e.listNodeDataSource); - void 0 !== e.treeController && (this.treeController = e.treeController); - void 0 !== e.dropSelectedIndex && (this.dropSelectedIndex = e.dropSelectedIndex); - void 0 !== e.listTreeViewMenu && (this.listTreeViewMenu = e.listTreeViewMenu); - void 0 !== e.MAX_CN_LENGTH && (this.MAX_CN_LENGTH = e.MAX_CN_LENGTH); - void 0 !== e.MAX_EN_LENGTH && (this.MAX_EN_LENGTH = e.MAX_EN_LENGTH); - void 0 !== e.INITIAL_INVALID_VALUE && (this.INITIAL_INVALID_VALUE = e.INITIAL_INVALID_VALUE); - void 0 !== e.MAX_TOUCH_DOWN_COUNT && (this.MAX_TOUCH_DOWN_COUNT = e.MAX_TOUCH_DOWN_COUNT); - void 0 !== e.isMultiPress && (this.isMultiPress = e.isMultiPress); - void 0 !== e.touchDownCount && (this.touchDownCount = e.touchDownCount); - void 0 !== e.appEventBus && (this.appEventBus = e.appEventBus); - void 0 !== e.itemPadding && (this.itemPadding = e.itemPadding); - void 0 !== e.textInputPadding && (this.textInputPadding = e.textInputPadding) - } - - updateStateVars(e) { - this.__listTreeViewWidth.reset(e.listTreeViewWidth); - this.__listTreeViewHeight.reset(e.listTreeViewHeight) - } - - purgeVariableDependenciesOnElmtId(e) { - this.__dropSelectedIndex.purgeDependencyOnElmtId(e); - this.__listTreeViewWidth.purgeDependencyOnElmtId(e); - this.__listTreeViewHeight.purgeDependencyOnElmtId(e) - } - - aboutToBeDeleted() { - this.__dropSelectedIndex.aboutToBeDeleted(); - this.__listTreeViewWidth.aboutToBeDeleted(); - this.__listTreeViewHeight.aboutToBeDeleted(); - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal() - } - - get dropSelectedIndex() { - return this.__dropSelectedIndex.get() - } - - set dropSelectedIndex(e) { - this.__dropSelectedIndex.set(e) - } - - get listTreeViewWidth() { - return this.__listTreeViewWidth.get() - } - - set listTreeViewWidth(e) { - this.__listTreeViewWidth.set(e) - } - - get listTreeViewHeight() { - return this.__listTreeViewHeight.get() - } - - set listTreeViewHeight(e) { - this.__listTreeViewHeight.set(e) - } - - aboutToAppear() { - this.listTreeViewWidth = void 0 === this.listTreeViewWidth ? 200 : this.listTreeViewWidth; - this.listNodeDataSource = this.treeController.getListNodeDataSource() - } - - checkInvalidPattern(e) { - return /[\\\/:*?"<>|]/.test(e) - } - - checkIsAllCN(e) { - return /^[\u4e00-\u9fa5]+$/.test(e) - } - - popupForShowTitle(e, t, o, i = null) { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.backgroundColor(t); - Row.border({ - radius: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_elements_margin_horizontal_l"], - bundleName: "", - moduleName: "" - } - }); - Row.padding({ - left: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_elements_margin_horizontal_l"], - bundleName: "", - moduleName: "" - }, - right: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_elements_margin_horizontal_l"], - bundleName: "", - moduleName: "" - }, - top: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_card_margin_middle"], - bundleName: "", - moduleName: "" - }, - bottom: { - id: -1, - type: 10002, - params: ["sys.float.ohos_id_card_margin_middle"], - bundleName: "", - moduleName: "" - } - }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((t, i) => { - ViewStackProcessor.StartGetAccessRecordingFor(t); - Text.create(e); - Text.fontSize({ - id: -1, - type: 10002, - params: ["sys.float.ohos_id_text_size_body2"], - bundleName: "", - moduleName: "" - }); - Text.fontWeight("regular"); - Text.fontColor(o); - i || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - Row.pop() - } - - builder(e = null) { - this.listTreeViewMenu.bind(this)() - } - - draggingPopup(e, o = null) { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.constraintSize({ - minWidth: this.listNodeDataSource.getDragPopupPara().floorConstraintSize.minWidth, - maxWidth: this.listNodeDataSource.getDragPopupPara().floorConstraintSize.maxWidth - }); - Row.height(this.listNodeDataSource.getDragPopupPara().height); - Row.backgroundColor(this.listNodeDataSource.getDragPopupPara().backgroundColor); - Row.padding({ - left: this.listNodeDataSource.getDragPopupPara().padding.left, - right: this.listNodeDataSource.getDragPopupPara().padding.right - }); - Row.shadow({ - radius: this.listNodeDataSource.getDragPopupPara().shadow.radius, - color: this.listNodeDataSource.getDragPopupPara().shadow.color, - offsetY: this.listNodeDataSource.getDragPopupPara().shadow.offsetY - }); - Row.borderRadius(this.listNodeDataSource.getDragPopupPara().borderRadius); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((o, i) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - If.create(); - e.getNodeItem().imageNode ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((o, i) => { - ViewStackProcessor.StartGetAccessRecordingFor(o); - Row.create(); - Row.backgroundColor(t); - Row.margin({ right: e.getNodeItem().imageNode.itemRightMargin }); - Row.height(e.getNodeItem().imageNode.itemHeight); - Row.width(e.getNodeItem().imageNode.itemWidth); - i || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((t, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(t); - Image.create(e.getNodeItem().imageNode.normalSource); - Image.objectFit(ImageFit.Contain); - Image.height(e.getNodeItem().imageNode.itemHeight); - Image.width(e.getNodeItem().imageNode.itemWidth); - Image.opacity(this.listNodeDataSource.getDragPopupPara().imageOpacity); - o || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop() - })) : If.branchId(1); - i || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((t, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(t); - Row.create(); - Row.constraintSize({ - minWidth: e.getNodeItem().imageNode ? this.listNodeDataSource.getDragPopupPara() - .textConstraintSize - .minWidth1 : this.listNodeDataSource.getDragPopupPara() - .textConstraintSize - .minWidth2, - maxWidth: e.getNodeItem().imageNode ? this.listNodeDataSource.getDragPopupPara() - .textConstraintSize - .maxWidth1 : this.listNodeDataSource.getDragPopupPara() - .textConstraintSize - .maxWidth2 - }); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((t, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(t); - If.create(); - e.getNodeItem().mainTitleNode && e.getIsShowTitle() ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((t, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(t); - Text.create(e.getNodeItem().mainTitleNode.title); - Text.maxLines(1); - Text.fontSize(e.getNodeItem().mainTitleNode.size); - Text.fontColor(this.listNodeDataSource.getDragPopupPara().fontColor); - Text.fontWeight(this.listNodeDataSource.getDragPopupPara().fontWeight); - Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - o || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop() - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - Row.pop(); - Row.pop() - } - - initialRender() { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - List.create({}); - List.width(this.listTreeViewWidth); - List.height(this.listTreeViewHeight); - List.onDragMove((e => { - if (this.isMultiPress) { - console.error("drag error, a item has been dragged"); - return - } - let t = Math.floor(e.getY() / 24) % 2 ? g.DOWN_FLAG : g.UP_FLAG; - let o = Math.floor(e.getY() / 48); - let i = !1; - if (o >= this.listNodeDataSource.totalCount()) { - t = g.DOWN_FLAG; - o = this.listNodeDataSource.totalCount() - 1; - this.listNodeDataSource.getData(o).setIsOverBorder(!0); - i = !0 - } else this.listNodeDataSource.getData(o).setIsOverBorder(!1); - let s = this.listNodeDataSource.getData(o).getCurrentNodeId(); - if (o != this.listNodeDataSource.getLastPassIndex() && this.listNodeDataSource.getIsInnerDrag()) { - if (this.listNodeDataSource.getIsParentOfInsertNode(s)) { - this.listNodeDataSource.setPassIndex(o); - let e = this; - this.listNodeDataSource.clearTimeOutAboutDelayHighLightAndExpand(_.call(e, s)); - this.listNodeDataSource.setFlag(g.NONE); - return - } - } - this.listNodeDataSource.setLastPassIndex(o); - this.listNodeDataSource.setVisibility(t, o, i); - if (s != this.listNodeDataSource.getDraggingCurrentNodeId()) { - let e = this; - this.listNodeDataSource.delayHighLightAndExpandNode(_.call(e, s), s, o) - } - })); - List.onDragEnter(((e, t) => { - if (this.listNodeDataSource.getIsInnerDrag()) { - this.listNodeDataSource.setIsDrag(!0); - let e = .4; - this.listNodeDataSource.setListItemOpacity(e) - } - })); - List.onDragLeave(((e, t) => { - this.listNodeDataSource.hideLastLine(); - this.listNodeDataSource.clearLastTimeoutHighLight(); - this.listNodeDataSource.clearLastTimeoutExpand(); - this.listNodeDataSource.setListItemOpacity(1); - this.listNodeDataSource.setIsDrag(!1); - this.listNodeDataSource.notifyDataReload() - })); - List.onDrop(((e, t) => { - this.listNodeDataSource.clearLastTimeoutExpand(); - this.listNodeDataSource.setListItemOpacity(1); - let o = this.listNodeDataSource.getPassIndex(); - let i = this.dropSelectedIndex; - if (i - 1 > this.listNodeDataSource.totalCount() || null == i) { - console.error("drag error, currentNodeIndex is not found"); - this.listNodeDataSource.setIsDrag(!1); - return - } - if (o == this.listNodeDataSource.totalCount()) { - console.log("need to insert into the position of the last line, now insertNodeIndex = insertNodeIndex - 1"); - o -= 1 - } - let s = this.listNodeDataSource.getData(o); - let a = s.getNodeCurrentNodeId(); - if (!this.listNodeDataSource.getIsDrag() || !this.listNodeDataSource.getIsInnerDrag()) { - this.listNodeDataSource.clearLastTimeoutHighLight(); - this.listNodeDataSource.setIsInnerDrag(!1); - this.listNodeDataSource.hideLastLine(); - this.listNodeDataSource.initialParameterAboutDelayHighLightAndExpandIndex(); - this.listNodeDataSource.refreshSubtitle(a); - this.listNodeDataSource.notifyDataReload(); - return - } - let d = this.listNodeDataSource.getCurrentNodeInfo(); - let n = s.getNodeParentNodeId(); - let l = this.listNodeDataSource.getDraggingCurrentNodeId(); - let h = this.listNodeDataSource.getDraggingParentNodeId(); - if (this.listNodeDataSource.getIsParentOfInsertNode(a)) { - this.listNodeDataSource.clearLastTimeoutHighLight(); - this.listNodeDataSource.setIsInnerDrag(!1); - this.listNodeDataSource.hideLastLine(); - this.listNodeDataSource.notifyDataChange(o); - this.listNodeDataSource.initialParameterAboutDelayHighLightAndExpandIndex(); - this.listNodeDataSource.setIsDrag(!1); - let e = this; - let t = _.call(e, l); - this.listNodeDataSource.setClickIndex(t); - this.listNodeDataSource.handleEvent(r.DRAG, t); - return - } - if (this.listNodeDataSource.getExpandAndCollapseInfo(l) == I.Expand) { - let e = this; - this.listNodeDataSource.expandAndCollapseNode(_.call(e, l)) - } - if (this.listNodeDataSource.getExpandAndCollapseInfo(a) == I.Collapse) { - let e = this; - let t = _.call(e, a); - this.listNodeDataSource.ListNode[t].getIsHighLight() && this.listNodeDataSource.expandAndCollapseNode(t) - } - this.listNodeDataSource.setLastDelayHighLightId(); - if (l != a) { - this.listNodeDataSource.alterDragNode(n, a, s, h, l, d); - this.listNodeDataSource.hideLastLine() - } else { - this.listNodeDataSource.hideLastLine(); - this.listNodeDataSource.setLastPassId(l); - this.listNodeDataSource.hideLastLine() - } - let g = _.call(this, this.listNodeDataSource.getLastDelayHighLightId()); - this.listNodeDataSource.setLastDelayHighLightIndex(g); - this.listNodeDataSource.clearLastTimeoutHighLight(); - this.listNodeDataSource.initialParameterAboutDelayHighLightAndExpandIndex(); - this.listNodeDataSource.setIsDrag(!1); - let c = _.call(this, l); - this.listNodeDataSource.setClickIndex(c); - this.listNodeDataSource.handleEvent(r.DRAG, c); - this.listNodeDataSource.setIsInnerDrag(!1); - this.listNodeDataSource.notifyDataReload() - })); - t || List.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - { - const e = e => { - const i = e; - { - const e = void 0 !== globalThis.__lazyForEachItemGenFunction && !0; - const a = (t, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(t); - ListItem.create(g, e); - ListItem.width("100%"); - ListItem.height(i.getListItemHeight()); - ListItem.padding({ left: this.itemPadding.left, right: this.itemPadding.right }); - ListItem.align(Alignment.Start); - ListItem.onDragStart(((e, t) => { - if (this.listNodeDataSource.getIsDrag() || this.listNodeDataSource.getIsInnerDrag() || this.isMultiPress) { - console.error("drag error, a item has been dragged"); - return - } - this.dropSelectedIndex = JSON.parse(t).selectedIndex; - let o = JSON.parse(t).selectedIndex; - let s = this.listNodeDataSource.getData(o); - let a = i.getNodeCurrentNodeId(); - if (o >= this.listNodeDataSource.totalCount() || null == o) { - console.error("drag error, currentNodeIndex is not found in onDragStart"); - return - } - this.listNodeDataSource.setIsInnerDrag(!0); - this.listNodeDataSource.setIsDrag(!0); - this.listNodeDataSource.setCurrentNodeInfo(s); - this.listNodeDataSource.setDraggingCurrentNodeId(s.getNodeCurrentNodeId()); - this.listNodeDataSource.setDraggingParentNodeId(s.getNodeParentNodeId()); - this.listNodeDataSource.setListItemOpacity(.4); - this.listNodeDataSource.notifyDataChange(o); - if (a == s.getNodeCurrentNodeId()) return { builder: () => { - this.draggingPopup.call(this, s) - } }; - console.error("drag is too fast,it attribute a fault to OH"); - this.listNodeDataSource.setIsDrag(!1) - })); - o || ListItem.pop(); - ViewStackProcessor.StopGetAccessRecording() - }; - const d = () => { - this.observeComponentCreation(a); - this.observeComponentCreation(((e, a) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - i.getNodeIsShow() ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.focusable(!0); - Column.onMouse((e => { - let t = this; - let o = _.call(t, i.getNodeCurrentNodeId()); - if (e.button == MouseButton.Right) { - t.listNodeDataSource.handleEvent(r.MOUSE_BUTTON_RIGHT, _.call(t, i.getNodeCurrentNodeId())); - this.listTreeViewMenu = i.getMenu(); - t.listNodeDataSource.setClickIndex(o); - t.listNodeDataSource.setPopUpInfo(l.HINTS, h.NONE,!1, o); - clearTimeout(i.getNodeItem().mainTitleNode.popUpTimeout) - } - e.stopPropagation() - })); - Column.padding({ top: this.itemPadding.top, bottom: this.itemPadding.bottom }); - Column.bindPopup(i.getPopUpInfo().popUpIsShow, { - builder: { builder: () => { - this.popupForShowTitle.call(this, i.getPopUpInfo().popUpText, i.getPopUpInfo() - .popUpColor, i.getPopUpInfo().popUpTextColor) - } }, - placement: Placement.BottomLeft, - placementOnTop: !1, - popupColor: i.getPopUpInfo().popUpColor, - autoCancel: !0, - enableArrow: i.getPopUpInfo().popUpEnableArrow - }); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Divider.create(); - Divider.height(this.listNodeDataSource.getFlagLine().flagLineHeight); - Divider.color(this.listNodeDataSource.getFlagLine().flagLineColor); - Divider.visibility(this.listNodeDataSource.getVisibility(i)); - Divider.lineCap(LineCapStyle.Round); - Divider.margin({ left: i.getFlagLineLeftMargin() }); - Divider.markAnchor({ - x: this.listNodeDataSource.getFlagLine().xOffset, - y: this.listNodeDataSource.getFlagLine().yTopOffset - }); - t || Divider.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create({}); - Row.opacity(this.listNodeDataSource.getListItemOpacity(i)); - Row.markAnchor({ - x: this.listNodeDataSource.getFlagLine().xOffset, - y: this.listNodeDataSource.getFlagLine().yBasePlateOffset - }); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create({}); - Row.width("100%"); - Row.onTouch((e => { - let t = this; - let o = _.call(t, i.getNodeCurrentNodeId()); - let a = i.getNodeCurrentNodeId(); - t.listNodeDataSource.setClickIndex(o); - if (e.type === TouchType.Down) { - this.touchDownCount++; - this.isMultiPress = this.touchDownCount > this.MAX_TOUCH_DOWN_COUNT; - this.listNodeDataSource.getIsTouchDown() || t.listNodeDataSource.handleEvent(r.TOUCH_DOWN, o) - } - if (e.type === TouchType.Up) { - this.touchDownCount--; - this.touchDownCount < this.MAX_TOUCH_DOWN_COUNT && (this.isMultiPress = !1); - let e = { currentNodeId: a }; - this.appEventBus.emit(s.NODE_CLICK, [e]); - t.listNodeDataSource.handleEvent(r.TOUCH_UP, o) - } - })); - Row.onHover((e => { - let t = this; - let o = _.call(t, i.getNodeCurrentNodeId()); - e ? t.listNodeDataSource.handleEvent(r.HOVER, o) : t.listNodeDataSource.getIsTouchDown() || t.listNodeDataSource.handleEvent(r.HOVER_OVER, o) - })); - Gesture.create(GesturePriority.Low); - TapGesture.create({ count: 2 }); - TapGesture.onAction((e => { - this.listNodeDataSource.expandAndCollapseNode(_.call(this, i.getNodeCurrentNodeId())) - })); - TapGesture.pop(); - Gesture.pop(); - Row.height(i.getNodeHeight()); - Row.padding({ left: i.getNodeLeftPadding() }); - Row.backgroundColor(i.getNodeItem().mainTitleNode && i.getNodeItem() - .inputText && i.getIsShowInputText() ? i.getNodeItem().inputText.editColor : i.getNodeColor()); - Row.border({ - width: i.getNodeBorder().borderWidth, - color: i.getNodeBorder().borderColor, - radius: i.getNodeBorder().borderRadius - }); - Row.bindContextMenu({ builder: this.builder.bind(this) }, ResponseType.RightClick); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - i.getNodeItem().imageNode ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.backgroundColor(t); - Row.margin({ right: i.getNodeItem().imageNode.itemRightMargin }); - Row.height(i.getNodeItem().imageNode.itemHeight); - Row.width(i.getNodeItem().imageNode.itemWidth); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(i.getNodeItem().imageNode.source); - Image.objectFit(ImageFit.Contain); - Image.height(i.getNodeItem().imageNode.itemHeight); - Image.width(i.getNodeItem().imageNode.itemWidth); - Image.opacity(i.getIsSelected() || i.getIsHighLight() ? i.getNodeItem() - .imageNode - .noOpacity : i.getNodeItem() - .imageNode - .opacity); - Image.focusable(null == i.getNodeItem().mainTitleNode); - Image.onFocus((() => { - this.listNodeDataSource.handleEvent(r.FOCUS, _.call(this, i.getNodeCurrentNodeId())) - })); - Image.onBlur((() => { - this.listNodeDataSource.handleEvent(r.BLUR, _.call(this, i.getNodeCurrentNodeId())) - })); - t || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop() - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.layoutWeight(1); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - i.getNodeItem().mainTitleNode && i.getIsShowTitle() ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(i.getNodeItem().mainTitleNode.title); - Text.maxLines(1); - Text.fontSize(i.getNodeItem().mainTitleNode.size); - Text.fontColor(i.getNodeItem().mainTitleNode.color); - Text.margin({ right: i.getNodeItem().mainTitleNode.itemRightMargin }); - Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - Text.fontWeight(i.getNodeItem().mainTitleNode.weight); - Text.focusable(!0); - Text.onFocus((() => { - this.listNodeDataSource.handleEvent(r.FOCUS, _.call(this, i.getNodeCurrentNodeId())) - })); - Text.onBlur((() => { - this.listNodeDataSource.handleEvent(r.BLUR, _.call(this, i.getNodeCurrentNodeId())) - })); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop() - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - i.getNodeItem().mainTitleNode && i.getNodeItem() - .inputText && i.getIsShowInputText() ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.backgroundColor(i.getNodeItem().inputText.backgroundColor); - Row.borderRadius(i.getNodeItem().inputText.borderRadius); - Row.margin({ right: i.getNodeItem().inputText.itemRightMargin }); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - TextInput.create({ text: i.getNodeItem().mainTitleNode.title }); - TextInput.height(i.getNodeItem().inputText.itemHeight); - TextInput.fontSize(i.getNodeItem().inputText.size); - TextInput.fontColor(i.getNodeItem().inputText.color); - TextInput.borderRadius(i.getNodeItem().inputText.borderRadius); - TextInput.backgroundColor(i.getNodeItem().inputText.backgroundColor); - TextInput.enterKeyType(EnterKeyType.Done); - TextInput.padding({ - left: this.textInputPadding.left, - right: this.textInputPadding.right, - top: this.textInputPadding.top, - bottom: this.textInputPadding.bottom - }); - TextInput.onChange((e => { - let t = this; - var o = _.call(t, i.getNodeCurrentNodeId()); - let s = ""; - let a = !1; - let d = !1; - if (t.checkInvalidPattern(e)) { - for (let o = 0;o < e.length; o++) t.checkInvalidPattern(e[o]) || (s += e[o]); - a = !0; - t.listNodeDataSource.setPopUpInfo(l.WARNINGS, h.INVALID_ERROR,!0, o) - } else { - s = e; - a = !1; - t.listNodeDataSource.setPopUpInfo(l.WARNINGS, h.INVALID_ERROR,!1, o) - } - if (t.checkIsAllCN(s) && s.length > this.MAX_CN_LENGTH || !t.checkIsAllCN(s) && s.length > this.MAX_EN_LENGTH) { - s = t.checkIsAllCN(s) ? s.substr(0, this.MAX_CN_LENGTH) : s.substr(0, this.MAX_EN_LENGTH); - d = !0; - t.listNodeDataSource.setPopUpInfo(l.WARNINGS, h.LENGTH_ERROR,!0, o) - } else d = !1; - if (!d && !a) { - t.listNodeDataSource.setPopUpInfo(l.WARNINGS, h.LENGTH_ERROR,!1, o); - t.listNodeDataSource.setMainTitleNameOnEdit(o, s) - } - })); - TextInput.onSubmit((e => { - let t = this; - var o = _.call(t, i.getNodeCurrentNodeId()); - t.listNodeDataSource.setPopUpInfo(l.WARNINGS, h.NONE,!1, o); - t.listNodeDataSource.setItemVisibilityOnEdit(o, n.COMMIT_NODE) - })); - t || TextInput.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop() - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Blank.create(); - t || Blank.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Blank.pop(); - Row.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.listNodeDataSource.hasSubtitle(i.getCurrentNodeId()) ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.margin({ - left: this.listNodeDataSource.getSubTitlePara().margin.left, - right: i.getNodeItem().imageCollapse ? 0 : this.listNodeDataSource.getSubTitlePara() - .margin - .right - }); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.listNodeDataSource.getSubtitle(i.getCurrentNodeId())); - Text.fontSize(this.listNodeDataSource.getSubTitlePara().fontSize); - Text.fontColor(this.listNodeDataSource.getSubTitleFontColor(i.getIsHighLight() || i.getIsModify())); - Text.fontWeight(this.listNodeDataSource.getSubTitlePara().fontWeight); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - Row.pop() - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, s) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - i.getNodeItem().imageCollapse ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.backgroundColor(t); - Row.height(i.getNodeItem().imageCollapse.itemHeight); - Row.width(i.getNodeItem().imageCollapse.itemWidth); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, s) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(i.getNodeItem().imageCollapse.collapseSource); - Image.fillColor(i.getNodeItem().imageCollapse.isCollapse ? t : o); - Image.align(Alignment.End); - Image.objectFit(ImageFit.Contain); - Image.height(i.getNodeItem().imageCollapse.itemHeight); - Image.width(i.getNodeItem().imageCollapse.itemWidth); - Image.opacity(i.getIsHighLight() ? i.getNodeItem().imageCollapse.noOpacity : i.getNodeItem() - .imageCollapse - .opacity); - Image.onTouch((e => { - if (e.type === TouchType.Down) { - let e = this; - e.listNodeDataSource.expandAndCollapseNode(_.call(e, i.getNodeCurrentNodeId())); - this.listNodeDataSource.setCurrentFocusNodeId(i.getCurrentNodeId()) - } - e.stopPropagation() - })); - s || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop() - })) : If.branchId(1); - s || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - Row.pop(); - Row.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - i.getCanShowBottomFlagLine() ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.listNodeDataSource.getPassIndex() != this.listNodeDataSource.totalCount() - 1 || i.getIsHighLight() ? If.branchId(1) : this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Divider.create(); - Divider.height(this.listNodeDataSource.getFlagLine().flagLineHeight); - Divider.color(this.listNodeDataSource.getFlagLine().flagLineColor); - Divider.visibility(Visibility.Visible); - Divider.lineCap(LineCapStyle.Round); - Divider.margin({ left: i.getFlagLineLeftMargin() }); - Divider.markAnchor({ - x: this.listNodeDataSource.getFlagLine().xOffset, - y: this.listNodeDataSource.getFlagLine().yBottomOffset - }); - t || Divider.pop(); - ViewStackProcessor.StopGetAccessRecording() - })) - })); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop() - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - Column.pop() - })) : If.branchId(1); - a || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - ListItem.pop() - }; - const g = (e, d) => { - a(e, d); - this.updateFuncByElmtId.set(e, a); - this.observeComponentCreation(((e, a) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - i.getNodeIsShow() ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Column.create(); - Column.focusable(!0); - Column.onMouse((e => { - let t = this; - let o = _.call(t, i.getNodeCurrentNodeId()); - if (e.button == MouseButton.Right) { - t.listNodeDataSource.handleEvent(r.MOUSE_BUTTON_RIGHT, _.call(t, i.getNodeCurrentNodeId())); - this.listTreeViewMenu = i.getMenu(); - t.listNodeDataSource.setClickIndex(o); - t.listNodeDataSource.setPopUpInfo(l.HINTS, h.NONE,!1, o); - clearTimeout(i.getNodeItem().mainTitleNode.popUpTimeout) - } - e.stopPropagation() - })); - Column.padding({ top: this.itemPadding.top, bottom: this.itemPadding.bottom }); - Column.bindPopup(i.getPopUpInfo().popUpIsShow, { - builder: { builder: () => { - this.popupForShowTitle.call(this, i.getPopUpInfo().popUpText, i.getPopUpInfo() - .popUpColor, i.getPopUpInfo().popUpTextColor) - } }, - placement: Placement.BottomLeft, - placementOnTop: !1, - popupColor: i.getPopUpInfo().popUpColor, - autoCancel: !0, - enableArrow: i.getPopUpInfo().popUpEnableArrow - }); - t || Column.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Divider.create(); - Divider.height(this.listNodeDataSource.getFlagLine().flagLineHeight); - Divider.color(this.listNodeDataSource.getFlagLine().flagLineColor); - Divider.visibility(this.listNodeDataSource.getVisibility(i)); - Divider.lineCap(LineCapStyle.Round); - Divider.margin({ left: i.getFlagLineLeftMargin() }); - Divider.markAnchor({ - x: this.listNodeDataSource.getFlagLine().xOffset, - y: this.listNodeDataSource.getFlagLine().yTopOffset - }); - t || Divider.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create({}); - Row.opacity(this.listNodeDataSource.getListItemOpacity(i)); - Row.markAnchor({ - x: this.listNodeDataSource.getFlagLine().xOffset, - y: this.listNodeDataSource.getFlagLine().yBasePlateOffset - }); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create({}); - Row.width("100%"); - Row.onTouch((e => { - let t = this; - let o = _.call(t, i.getNodeCurrentNodeId()); - let a = i.getNodeCurrentNodeId(); - t.listNodeDataSource.setClickIndex(o); - if (e.type === TouchType.Down) { - this.touchDownCount++; - this.isMultiPress = this.touchDownCount > this.MAX_TOUCH_DOWN_COUNT; - this.listNodeDataSource.getIsTouchDown() || t.listNodeDataSource.handleEvent(r.TOUCH_DOWN, o) - } - if (e.type === TouchType.Up) { - this.touchDownCount--; - this.touchDownCount < this.MAX_TOUCH_DOWN_COUNT && (this.isMultiPress = !1); - let e = { currentNodeId: a }; - this.appEventBus.emit(s.NODE_CLICK, [e]); - t.listNodeDataSource.handleEvent(r.TOUCH_UP, o) - } - })); - Row.onHover((e => { - let t = this; - let o = _.call(t, i.getNodeCurrentNodeId()); - e ? t.listNodeDataSource.handleEvent(r.HOVER, o) : t.listNodeDataSource.getIsTouchDown() || t.listNodeDataSource.handleEvent(r.HOVER_OVER, o) - })); - Gesture.create(GesturePriority.Low); - TapGesture.create({ count: 2 }); - TapGesture.onAction((e => { - this.listNodeDataSource.expandAndCollapseNode(_.call(this, i.getNodeCurrentNodeId())) - })); - TapGesture.pop(); - Gesture.pop(); - Row.height(i.getNodeHeight()); - Row.padding({ left: i.getNodeLeftPadding() }); - Row.backgroundColor(i.getNodeItem().mainTitleNode && i.getNodeItem() - .inputText && i.getIsShowInputText() ? i.getNodeItem().inputText.editColor : i.getNodeColor()); - Row.border({ - width: i.getNodeBorder().borderWidth, - color: i.getNodeBorder().borderColor, - radius: i.getNodeBorder().borderRadius - }); - Row.bindContextMenu({ builder: this.builder.bind(this) }, ResponseType.RightClick); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - i.getNodeItem().imageNode ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.backgroundColor(t); - Row.margin({ right: i.getNodeItem().imageNode.itemRightMargin }); - Row.height(i.getNodeItem().imageNode.itemHeight); - Row.width(i.getNodeItem().imageNode.itemWidth); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(i.getNodeItem().imageNode.source); - Image.objectFit(ImageFit.Contain); - Image.height(i.getNodeItem().imageNode.itemHeight); - Image.width(i.getNodeItem().imageNode.itemWidth); - Image.opacity(i.getIsSelected() || i.getIsHighLight() ? i.getNodeItem() - .imageNode - .noOpacity : i.getNodeItem() - .imageNode - .opacity); - Image.focusable(null == i.getNodeItem().mainTitleNode); - Image.onFocus((() => { - this.listNodeDataSource.handleEvent(r.FOCUS, _.call(this, i.getNodeCurrentNodeId())) - })); - Image.onBlur((() => { - this.listNodeDataSource.handleEvent(r.BLUR, _.call(this, i.getNodeCurrentNodeId())) - })); - t || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop() - })) : If.branchId(1); - o || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.layoutWeight(1); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - i.getNodeItem().mainTitleNode && i.getIsShowTitle() ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(i.getNodeItem().mainTitleNode.title); - Text.maxLines(1); - Text.fontSize(i.getNodeItem().mainTitleNode.size); - Text.fontColor(i.getNodeItem().mainTitleNode.color); - Text.margin({ right: i.getNodeItem().mainTitleNode.itemRightMargin }); - Text.textOverflow({ overflow: TextOverflow.Ellipsis }); - Text.fontWeight(i.getNodeItem().mainTitleNode.weight); - Text.focusable(!0); - Text.onFocus((() => { - this.listNodeDataSource.handleEvent(r.FOCUS, _.call(this, i.getNodeCurrentNodeId())) - })); - Text.onBlur((() => { - this.listNodeDataSource.handleEvent(r.BLUR, _.call(this, i.getNodeCurrentNodeId())) - })); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop() - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - i.getNodeItem().mainTitleNode && i.getNodeItem() - .inputText && i.getIsShowInputText() ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.backgroundColor(i.getNodeItem().inputText.backgroundColor); - Row.borderRadius(i.getNodeItem().inputText.borderRadius); - Row.margin({ right: i.getNodeItem().inputText.itemRightMargin }); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - TextInput.create({ text: i.getNodeItem().mainTitleNode.title }); - TextInput.height(i.getNodeItem().inputText.itemHeight); - TextInput.fontSize(i.getNodeItem().inputText.size); - TextInput.fontColor(i.getNodeItem().inputText.color); - TextInput.borderRadius(i.getNodeItem().inputText.borderRadius); - TextInput.backgroundColor(i.getNodeItem().inputText.backgroundColor); - TextInput.enterKeyType(EnterKeyType.Done); - TextInput.padding({ - left: this.textInputPadding.left, - right: this.textInputPadding.right, - top: this.textInputPadding.top, - bottom: this.textInputPadding.bottom - }); - TextInput.onChange((e => { - let t = this; - var o = _.call(t, i.getNodeCurrentNodeId()); - let s = ""; - let a = !1; - let d = !1; - if (t.checkInvalidPattern(e)) { - for (let o = 0;o < e.length; o++) t.checkInvalidPattern(e[o]) || (s += e[o]); - a = !0; - t.listNodeDataSource.setPopUpInfo(l.WARNINGS, h.INVALID_ERROR,!0, o) - } else { - s = e; - a = !1; - t.listNodeDataSource.setPopUpInfo(l.WARNINGS, h.INVALID_ERROR,!1, o) - } - if (t.checkIsAllCN(s) && s.length > this.MAX_CN_LENGTH || !t.checkIsAllCN(s) && s.length > this.MAX_EN_LENGTH) { - s = t.checkIsAllCN(s) ? s.substr(0, this.MAX_CN_LENGTH) : s.substr(0, this.MAX_EN_LENGTH); - d = !0; - t.listNodeDataSource.setPopUpInfo(l.WARNINGS, h.LENGTH_ERROR,!0, o) - } else d = !1; - if (!d && !a) { - t.listNodeDataSource.setPopUpInfo(l.WARNINGS, h.LENGTH_ERROR,!1, o); - t.listNodeDataSource.setMainTitleNameOnEdit(o, s) - } - })); - TextInput.onSubmit((e => { - let t = this; - var o = _.call(t, i.getNodeCurrentNodeId()); - t.listNodeDataSource.setPopUpInfo(l.WARNINGS, h.NONE,!1, o); - t.listNodeDataSource.setItemVisibilityOnEdit(o, n.COMMIT_NODE) - })); - t || TextInput.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop() - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Blank.create(); - t || Blank.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Blank.pop(); - Row.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.listNodeDataSource.hasSubtitle(i.getCurrentNodeId()) ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.margin({ - left: this.listNodeDataSource.getSubTitlePara().margin.left, - right: i.getNodeItem().imageCollapse ? 0 : this.listNodeDataSource.getSubTitlePara() - .margin - .right - }); - t || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Text.create(this.listNodeDataSource.getSubtitle(i.getCurrentNodeId())); - Text.fontSize(this.listNodeDataSource.getSubTitlePara().fontSize); - Text.fontColor(this.listNodeDataSource.getSubTitleFontColor(i.getIsHighLight() || i.getIsModify())); - Text.fontWeight(this.listNodeDataSource.getSubTitlePara().fontWeight); - t || Text.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Text.pop(); - Row.pop() - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - this.observeComponentCreation(((e, s) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - i.getNodeItem().imageCollapse ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, o) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Row.create(); - Row.backgroundColor(t); - Row.height(i.getNodeItem().imageCollapse.itemHeight); - Row.width(i.getNodeItem().imageCollapse.itemWidth); - o || Row.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - this.observeComponentCreation(((e, s) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Image.create(i.getNodeItem().imageCollapse.collapseSource); - Image.fillColor(i.getNodeItem().imageCollapse.isCollapse ? t : o); - Image.align(Alignment.End); - Image.objectFit(ImageFit.Contain); - Image.height(i.getNodeItem().imageCollapse.itemHeight); - Image.width(i.getNodeItem().imageCollapse.itemWidth); - Image.opacity(i.getIsHighLight() ? i.getNodeItem().imageCollapse.noOpacity : i.getNodeItem() - .imageCollapse - .opacity); - Image.onTouch((e => { - if (e.type === TouchType.Down) { - let e = this; - e.listNodeDataSource.expandAndCollapseNode(_.call(e, i.getNodeCurrentNodeId())); - this.listNodeDataSource.setCurrentFocusNodeId(i.getCurrentNodeId()) - } - e.stopPropagation() - })); - s || Image.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - Row.pop() - })) : If.branchId(1); - s || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - Row.pop(); - Row.pop(); - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - i.getCanShowBottomFlagLine() ? this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - If.create(); - this.listNodeDataSource.getPassIndex() != this.listNodeDataSource.totalCount() - 1 || i.getIsHighLight() ? If.branchId(1) : this.ifElseBranchUpdateFunction(0, (() => { - this.observeComponentCreation(((e, t) => { - ViewStackProcessor.StartGetAccessRecordingFor(e); - Divider.create(); - Divider.height(this.listNodeDataSource.getFlagLine().flagLineHeight); - Divider.color(this.listNodeDataSource.getFlagLine().flagLineColor); - Divider.visibility(Visibility.Visible); - Divider.lineCap(LineCapStyle.Round); - Divider.margin({ left: i.getFlagLineLeftMargin() }); - Divider.markAnchor({ - x: this.listNodeDataSource.getFlagLine().xOffset, - y: this.listNodeDataSource.getFlagLine().yBottomOffset - }); - t || Divider.pop(); - ViewStackProcessor.StopGetAccessRecording() - })) - })); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop() - })) : If.branchId(1); - t || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - Column.pop() - })) : If.branchId(1); - a || If.pop(); - ViewStackProcessor.StopGetAccessRecording() - })); - If.pop(); - ListItem.pop() - }; - e ? (() => { - this.observeComponentCreation(a); - ListItem.pop() - })() : d() - } - }; - const i = e => JSON.stringify(e); - LazyForEach.create("1", this, this.listNodeDataSource, e, i); - LazyForEach.pop() - } - List.pop() - } - - rerender() { - this.updateDirtyElements() - } - } - - __decorate([], T.prototype, "popupForShowTitle", null); - __decorate([], T.prototype, "builder", null); - __decorate([], T.prototype, "draggingPopup", null); - e.TreeView = T; - e.TreeController = class { - constructor() { - this.ROOT_NODE_ID = -1; - this.nodeIdList = []; - this.listNodeUtils = new C; - this.listNodeDataSource = new D - } - - getListNodeDataSource() { - return this.listNodeDataSource - } - - getClickNodeChildrenInfo() { - let e = this.listNodeDataSource.getClickNodeId(); - return this.listNodeUtils.getClickNodeChildrenInfo(e) - } - - getChildrenId() { - let e = this.listNodeDataSource.getClickNodeId(); - return this.listNodeUtils.getClickChildId(e) - } - - removeNode() { - let e = this.listNodeDataSource.getClickNodeId(); - let t = this.listNodeUtils.findParentNodeId(e); - let o = this.listNodeUtils.removeNode(e, t, this.listNodeUtils.traverseNodeBF); - this.listNodeDataSource.refreshData(this.listNodeUtils, n.REMOVE_NODE, t, o); - this.nodeIdList.splice(this.nodeIdList.indexOf(e), 1) - } - - modifyNode() { - let e = this.listNodeDataSource.getClickNodeId(); - this.listNodeDataSource.setItemVisibilityOnEdit(e, n.MODIFY_NODE) - } - - add() { - let e = this.listNodeDataSource.getClickNodeId(); - if (e == this.listNodeDataSource.ROOT_NODE_ID || !this.listNodeDataSource.getIsFolder(e)) return; - let t = { - isFolder: !0, - icon: null, - selectedIcon: null, - editIcon: null, - menu: null, - secondaryTitle: "" - }; - t = this.listNodeUtils.getNewNodeInfo(e); - this.nodeIdList.push(this.nodeIdList[this.nodeIdList.length-1] + 1); - let o = this.nodeIdList[this.nodeIdList.length-1]; - this.listNodeUtils.addNewNodeId = o; - this.listNodeUtils.addNode(e, o, { - isFolder: t.isFolder, - icon: t.icon, - selectedIcon: t.selectedIcon, - editIcon: t.editIcon, - primaryTitle: "新建文件夹", - menu: t.menu, - secondaryTitle: t.secondaryTitle - }); - this.listNodeDataSource.refreshData(this.listNodeUtils, n.ADD_NODE, e, [o]) - } - - addNodeParam(e) { - if (null != e.primaryTitle && !this.listNodeUtils.checkMainTitleIsValid(e.primaryTitle)) throw new Error('ListTreeNode[addNode]: The directory name cannot contain the following characters /: *? "< > | or exceeds the maximum length.'); - if (null == e.primaryTitle && null == e.icon) throw new Error("ListTreeNode[addNode]: The icon and directory name cannot be empty at the same time."); - if (e.currentNodeId === this.ROOT_NODE_ID || null === e.currentNodeId) throw new Error("ListTreeNode[addNode]: currentNodeId can not be -1 or null."); - this.nodeIdList.push(e.currentNodeId); - this.listNodeUtils.addNode(e.parentNodeId, e.currentNodeId, e); - return this - } - - addNode(e) { - if (null != e) { - if (null != e.primaryTitle && !this.listNodeUtils.checkMainTitleIsValid(e.primaryTitle)) throw new Error('ListTreeNode[addNode]: The directory name cannot contain the following characters /: *? "< > | or exceeds the maximum length.'); - if (null == e.primaryTitle && null == e.icon) throw new Error("ListTreeNode[addNode]: The icon and directory name cannot be empty at the same time."); - if (e.currentNodeId === this.ROOT_NODE_ID || null === e.currentNodeId) throw new Error("ListTreeNode[addNode]: currentNodeId can not be -1 or null."); - this.nodeIdList.push(e.currentNodeId); - this.listNodeUtils.addNode(e.parentNodeId, e.currentNodeId, e); - return this - } - this.add() - } - - buildDone() { - this.listNodeDataSource.init(this.listNodeUtils); - this.nodeIdList.sort(((e, t) => e - t)) - } - - refreshNode(e, t = "", o = "") { - this.listNodeDataSource.setNodeSubtitlePara(e, t, o) - } - } -}(TreeView || (TreeView = {})); - -export default TreeView \ No newline at end of file diff --git a/interface/composetitlebar/BUILD.gn b/interstitialdialogaction/interfaces/BUILD.gn old mode 100755 new mode 100644 similarity index 34% rename from interface/composetitlebar/BUILD.gn rename to interstitialdialogaction/interfaces/BUILD.gn index f953441ede57fd1dc488916091599259282bd8ca..495c7cdb00833ee55783f0c50fe51161cd9c6ea1 --- a/interface/composetitlebar/BUILD.gn +++ b/interstitialdialogaction/interfaces/BUILD.gn @@ -1,46 +1,57 @@ -# Copyright (c) 2023-2023 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") -import("//foundation/arkui/ace_engine/ace_config.gni") -import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") - -es2abc_gen_abc("gen_composetitlebar_abc") { - src_js = rebase_path("composetitlebar.js") - dst_file = rebase_path(target_out_dir + "/composetitlebar.abc") - in_puts = [ "composetitlebar.js" ] - out_puts = [ target_out_dir + "/composetitlebar.abc" ] - extra_args = [ "--module" ] -} - -gen_js_obj("composetitlebar_abc") { - input = get_label_info(":gen_composetitlebar_abc", "target_out_dir") + "/composetitlebar.abc" - output = target_out_dir + "/composetitlebar_abc.o" - dep = ":gen_composetitlebar_abc" -} - -ohos_shared_library("composetitlebar") { - sources = [ "composetitlebar.cpp" ] - - deps = [ ":composetitlebar_abc" ] - - external_deps = [ - "hilog:libhilog", - "napi:ace_napi", - ] - - subsystem_name = "arkui" - part_name = "advanced_ui_component" - - relative_install_dir = "module/arkui/advanced" -} +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/config/components/ets_frontend/es2abc_config.gni") +import("//build/ohos.gni") +import("//foundation/arkui/advanced_ui_component/atomicservice_config.gni") + +es2abc_gen_abc("gen_interstitialdialogaction_abc") { + src_js = rebase_path("interstitialdialogaction.js") + dst_file = rebase_path(target_out_dir + "/interstitialdialogaction.abc") + in_puts = [ "interstitialdialogaction.js" ] + out_puts = [ target_out_dir + "/interstitialdialogaction.abc" ] + extra_args = [ "--module" ] +} + +gen_js_obj("interstitialdialogaction_abc") { + input = get_label_info(":gen_interstitialdialogaction_abc", + "target_out_dir") + "/interstitialdialogaction.abc" + output = target_out_dir + "/interstitialdialogaction_abc.o" + dep = ":gen_interstitialdialogaction_abc" +} + +gen_obj("interstitialdialogaction_abc_preview") { + input = get_label_info(":gen_interstitialdialogaction_abc", + "target_out_dir") + "/interstitialdialogaction.abc" + output = target_out_dir + "/interstitialdialogaction_abc.c" + snapshot_dep = [ ":gen_interstitialdialogaction_abc" ] +} + +ohos_shared_library("interstitialdialogaction") { + sources = [ "interstitialdialogaction.cpp" ] + + if (use_mingw_win || use_mac || use_linux) { + deps = [ ":gen_obj_src_interstitialdialogaction_abc_preview" ] + } else { + deps = [ ":interstitialdialogaction_abc" ] + } + + external_deps = [ + "hilog:libhilog", + "napi:ace_napi", + ] + + relative_install_dir = "module/atomicservice" + subsystem_name = "arkui" + part_name = "advanced_ui_component" +} diff --git a/interface/arkdialog/arkdialog.cpp b/interstitialdialogaction/interfaces/interstitialdialogaction.cpp similarity index 55% rename from interface/arkdialog/arkdialog.cpp rename to interstitialdialogaction/interfaces/interstitialdialogaction.cpp index 0db1e88b2881eae1823c18d88548f305a45e8d7d..5b65be04076d622c9e777023880d1e192c369c05 100644 --- a/interface/arkdialog/arkdialog.cpp +++ b/interstitialdialogaction/interfaces/interstitialdialogaction.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. + * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,41 +13,39 @@ * limitations under the License. */ -#include "native_engine/native_engine.h" - -#include "napi/native_api.h" #include "napi/native_node_api.h" -extern const char _binary_arkdialog_abc_start[]; -extern const char _binary_arkdialog_abc_end[]; +extern const char _binary_interstitialdialogaction_abc_start[]; +extern const char _binary_interstitialdialogaction_abc_end[]; // Napi get abc code function extern "C" __attribute__((visibility("default"))) -void NAPI_arkui_advanced_ArkDialog_GetABCCode(const char **buf, int *buflen) +void NAPI_atomicservice_InterstitialDialogAction_GetABCCode(const char **buf, int *buflen) { if (buf != nullptr) { - *buf = _binary_arkdialog_abc_start; + *buf = _binary_interstitialdialogaction_abc_start; } if (buflen != nullptr) { - *buflen = _binary_arkdialog_abc_end - _binary_arkdialog_abc_start; + *buflen = _binary_interstitialdialogaction_abc_end - _binary_interstitialdialogaction_abc_start; } } /* * Module define */ -static napi_module arkdialogModule = { +static napi_module InterstitialDialogActionModule = { .nm_version = 1, .nm_flags = 0, .nm_filename = nullptr, - .nm_modname = "arkui.advanced.ArkDialog", + .nm_modname = "atomicservice.InterstitialDialogAction", .nm_priv = ((void*)0), .reserved = { 0 }, }; + /* - * Module register function + * Module registerfunction */ -extern "C" __attribute__((constructor)) void arkdialogRegisterModule(void) +extern "C" __attribute__((constructor)) void InterstitialDialogActionRegisterModule(void) { - napi_module_register(&arkdialogModule); -} + napi_module_register(&InterstitialDialogActionModule); +} \ No newline at end of file diff --git a/interstitialdialogaction/interfaces/interstitialdialogaction.js b/interstitialdialogaction/interfaces/interstitialdialogaction.js new file mode 100644 index 0000000000000000000000000000000000000000..61bcff3534f93a3324be505f1665dd0ac99246c2 --- /dev/null +++ b/interstitialdialogaction/interfaces/interstitialdialogaction.js @@ -0,0 +1,267 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +const ComponentContent = requireNapi("arkui.node").ComponentContent; +const curves = requireNativeModule('ohos.curves'); +const DIALOG_BORDER_RADIUS = { "id": -1, "type": 10002, params: ['sys.float.ohos_id_corner_radius_default_m'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }; +const DIALOG_INNER_PADDING_SIZE = 16; +const DIALOG_MAX_WIDTH = 480; +const DIALOG_OFFSET_X = 0; +const DIALOG_OFFSET_Y_FOR_BAR = -88; +const DIALOG_OFFSET_Y_FOR_NONE = -44; +const STANDARD_MIN_COMPONENT_HEIGHT = 82; +const STANDARD_MAX_COMPONENT_HEIGHT = 94; +const DIALOG_SHADOW_RADIUS = 16; +const DIALOG_SHADOW_OFFSET_Y = 10; +const DIALOG_SHADOW_COLOR = '#19000000'; +const TITLE_LINE_DISTANCE = 2; +const TITLE_MAX_LINE = 2; +const SUBTITLE_MAX_LINE = 1; +const TEXT_LEFT_MARGIN_SIZE = 16; +const SUBTITLE_DEFAULT_COLOR = { "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_text_secondary_contrary'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }; +const TITLE_DEFAULT_COLOR = { "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_text_primary_contrary'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }; +const OPERATE_AREA_AVOID_WIDTH = 28; +const CLOSE_ICON_DARK_RESOURCE = { "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_tertiary'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }; +const CLOSE_ICON_LIGHT_RESOURCE = { "id": -1, "type": 10001, params: ['sys.color.ohos_id_color_primary_contrary'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }; +const CLOSE_BUTTON_BORDER_RADIUS = 8; +const CLOSE_BUTTON_ICON_SIZE = 16; +const CLOSE_BUTTON_HOT_SPOT_SIZE = 32; +const CLOSE_BUTTON_MARGIN = 8; +const CLOSE_BUTTON_ICON_OPACITY = 0.6; +const CLOSE_BUTTON_RESPONSE_REGION_OFFSET_X = -8; +const CLOSE_BUTTON_RESPONSE_REGION_OFFSET_Y = -8; +const CLOSE_BUTTON_OFFSET_X = 0; +const CLOSE_BUTTON_OFFSET_Y = -50; +const FOREGROUND_IMAGE_OFFSET_X = 4; +const FOREGROUND_IMAGE_OFFSET_Y = 0; +export var IconStyle; +(function (e2) { + e2[e2["DARK"] = 0] = "DARK"; + e2[e2["LIGHT"] = 1] = "LIGHT"; +})(IconStyle || (IconStyle = {})); +export var TitlePosition; +(function (d2) { + d2[d2["TOP"] = 0] = "TOP"; + d2[d2["BOTTOM"] = 1] = "BOTTOM"; +})(TitlePosition || (TitlePosition = {})); +export var BottomOffset; +(function (c2) { + c2[c2["OFFSET_FOR_BAR"] = 0] = "OFFSET_FOR_BAR"; + c2[c2["OFFSET_FOR_NONE"] = 1] = "OFFSET_FOR_NONE"; +})(BottomOffset || (BottomOffset = {})); +class DialogParams { + constructor(a2, b2) { + this.options = a2; + this.defaultCloseAction = b2; + } +} +function dialogBuilder(k, l = null) { + const m = k; + (l ? l : this).observeComponentCreation2((x1, y1, z1 = m) => { + Row.create(); + Row.backgroundColor('rgba(0,0,0,0)'); + Row.width('100%'); + Row.height(STANDARD_MAX_COMPONENT_HEIGHT); + Row.padding({ + left: DIALOG_INNER_PADDING_SIZE, + right: DIALOG_INNER_PADDING_SIZE + }); + Row.constraintSize({ + minHeight: STANDARD_MIN_COMPONENT_HEIGHT, + maxHeight: STANDARD_MAX_COMPONENT_HEIGHT, + maxWidth: DIALOG_MAX_WIDTH + }); + }, Row); + (l ? l : this).observeComponentCreation2((t1, u1, v1 = m) => { + Flex.create(); + Flex.backgroundColor(v1.options.backgroundImage === undefined ? '#EBEEF5' : 'rgba(0,0,0,0)'); + Flex.shadow({ + radius: DIALOG_SHADOW_RADIUS, + offsetX: 0, + offsetY: DIALOG_SHADOW_OFFSET_Y, + color: DIALOG_SHADOW_COLOR + }); + Flex.height(STANDARD_MIN_COMPONENT_HEIGHT); + Flex.width('100%'); + Flex.alignSelf(ItemAlign.End); + Flex.direction(Direction.Rtl); + Flex.zIndex(1); + Flex.borderRadius({ + topLeft: DIALOG_BORDER_RADIUS, + topRight: DIALOG_BORDER_RADIUS, + bottomLeft: DIALOG_BORDER_RADIUS, + bottomRight: DIALOG_BORDER_RADIUS + }); + Flex.onClick(() => { + if (v1.options.onDialogClick !== undefined) { + v1.options.onDialogClick(); + } + v1.defaultCloseAction(); + }); + }, Flex); + (l ? l : this).observeComponentCreation2((q1, r1, s1 = m) => { + Row.create(); + Row.padding({ left: OPERATE_AREA_AVOID_WIDTH }); + Row.direction(Direction.Rtl); + Row.defaultFocus(true); + Row.align(Alignment.End); + Row.alignSelf(ItemAlign.End); + Row.constraintSize({ + maxWidth: '50%', + minWidth: '40%' + }); + }, Row); + (l ? l : this).observeComponentCreation2((m1, n1, o1 = m) => { + SymbolGlyph.create({ "id": -1, "type": 40000, params: ['sys.symbol.xmark_circle_fill'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); + SymbolGlyph.fontColor([o1.options.iconStyle === IconStyle.DARK ? + CLOSE_ICON_DARK_RESOURCE : CLOSE_ICON_LIGHT_RESOURCE]); + SymbolGlyph.borderRadius(CLOSE_BUTTON_BORDER_RADIUS); + SymbolGlyph.width(CLOSE_BUTTON_ICON_SIZE); + SymbolGlyph.height(CLOSE_BUTTON_ICON_SIZE); + SymbolGlyph.opacity(CLOSE_BUTTON_ICON_OPACITY); + SymbolGlyph.draggable(false); + SymbolGlyph.focusable(true); + SymbolGlyph.responseRegion({ + x: CLOSE_BUTTON_RESPONSE_REGION_OFFSET_X, + y: CLOSE_BUTTON_RESPONSE_REGION_OFFSET_Y, + width: CLOSE_BUTTON_HOT_SPOT_SIZE, + height: CLOSE_BUTTON_HOT_SPOT_SIZE + }); + SymbolGlyph.margin(CLOSE_BUTTON_MARGIN); + SymbolGlyph.alignSelf(ItemAlign.End); + SymbolGlyph.offset({ + x: CLOSE_BUTTON_OFFSET_X, + y: CLOSE_BUTTON_OFFSET_Y + }); + SymbolGlyph.onClick(() => { + if (o1.options.onDialogClose !== undefined) { + o1.options.onDialogClose(); + } + o1.defaultCloseAction(); + }); + }, SymbolGlyph); + (l ? l : this).observeComponentCreation2((j1, k1, l1 = m) => { + Image.create(l1.options.foregroundImage); + Image.height(STANDARD_MAX_COMPONENT_HEIGHT); + Image.objectFit(ImageFit.Contain); + Image.fitOriginalSize(true); + Image.offset({ + x: FOREGROUND_IMAGE_OFFSET_X, + y: FOREGROUND_IMAGE_OFFSET_Y + }); + Image.alignSelf(ItemAlign.End); + }, Image); + Row.pop(); + (l ? l : this).observeComponentCreation2((g1, h1, i1 = m) => { + Flex.create({ + direction: i1.options.titlePosition === TitlePosition.BOTTOM ? + FlexDirection.ColumnReverse : FlexDirection.Column, + justifyContent: FlexAlign.Center + }); + Flex.constraintSize({ + maxWidth: '60%', + minWidth: '50%' + }); + Flex.flexGrow(1); + Flex.margin({ left: TEXT_LEFT_MARGIN_SIZE }); + }, Flex); + (l ? l : this).observeComponentCreation2((d1, e1, f1 = m) => { + Text.create(f1.options.title); + Text.alignSelf(ItemAlign.Start); + Text.maxFontSize({ "id": -1, "type": 10002, params: ['sys.float.ohos_id_text_size_sub_title1'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); + Text.minFontSize(16); + Text.fontColor(f1.options.titleColor !== undefined ? f1.options.titleColor : TITLE_DEFAULT_COLOR); + Text.fontWeight(FontWeight.Bold); + Text.margin(f1.options.titlePosition ? { top: TITLE_LINE_DISTANCE } : { bottom: TITLE_LINE_DISTANCE }); + Text.maxLines(TITLE_MAX_LINE); + Text.wordBreak(WordBreak.BREAK_WORD); + Text.textOverflow({ overflow: TextOverflow.Ellipsis }); + }, Text); + Text.pop(); + (l ? l : this).observeComponentCreation2((a1, b1, c1 = m) => { + Text.create(c1.options.subtitle); + Text.alignSelf(ItemAlign.Start); + Text.maxFontSize({ "id": -1, "type": 10002, params: ['sys.float.ohos_id_text_size_caption'], "bundleName": "__harDefaultBundleName__", "moduleName": "__harDefaultModuleName__" }); + Text.minFontSize(9); + Text.fontColor(c1.options.subtitleColor !== undefined ? c1.options.subtitleColor : SUBTITLE_DEFAULT_COLOR); + Text.maxLines(SUBTITLE_MAX_LINE); + Text.wordBreak(WordBreak.BREAK_WORD); + Text.textOverflow({ overflow: TextOverflow.Ellipsis }); + }, Text); + Text.pop(); + Flex.pop(); + Flex.pop(); + (l ? l : this).observeComponentCreation2((w, x, y = m) => { + Image.create(y.options.backgroundImage); + Image.width('100%'); + Image.height(STANDARD_MIN_COMPONENT_HEIGHT); + Image.offset({ x: '-100%', y: 0 }); + Image.borderRadius(DIALOG_BORDER_RADIUS); + Image.zIndex(0); + Image.alignSelf(ItemAlign.End); + Image.onClick(() => { + if (y.options.onDialogClose !== undefined) { + y.options.onDialogClose(); + } + y.defaultCloseAction(); + }); + }, Image); + Row.pop(); +} +export class InterstitialDialogAction { + constructor(i) { + this.uiContext = i.uiContext; + this.bottomOffsetType = i.bottomOffsetType; + this.dialogParam = new DialogParams(i, () => { + this.closeDialog(); + }); + this.contentNode = new ComponentContent(this.uiContext, wrapBuilder(dialogBuilder), this.dialogParam); + } + openDialog() { + if (this.contentNode !== null) { + this.uiContext.getPromptAction().openCustomDialog(this.contentNode, { + isModal: false, + autoCancel: false, + offset: { + dx: DIALOG_OFFSET_X, + dy: this.bottomOffsetType === BottomOffset.OFFSET_FOR_BAR ? + DIALOG_OFFSET_Y_FOR_BAR : DIALOG_OFFSET_Y_FOR_NONE + }, + alignment: DialogAlignment.Bottom, + transition: TransitionEffect.asymmetric(TransitionEffect.OPACITY.animation({ duration: 150, curve: Curve.Sharp }) + .combine(TransitionEffect.scale({ x: 0.85, y: 0.85, centerX: '50%', centerY: '85%' }) + .animation({ curve: curves.interpolatingSpring(0, 1, 228, 24) })), TransitionEffect.OPACITY.animation({ duration: 250, curve: Curve.Sharp }) + .combine(TransitionEffect.scale({ x: 0.85, y: 0.85, centerX: '50%', centerY: '85%' }) + .animation({ duration: 250, curve: Curve.Friction }))) + }) + .catch((f) => { + let g = f.message; + let h = f.code; + console.error(`${h}: ${g}`); + }); + } + } + closeDialog() { + if (this.contentNode !== null) { + this.uiContext.getPromptAction().closeCustomDialog(this.contentNode) + .catch((b) => { + let c = b.message; + let d = b.code; + console.error(`${d}: ${c}`); + }); + } + } +} + +export default { InterstitialDialogAction, IconStyle, TitlePosition, BottomOffset }; \ No newline at end of file diff --git a/interstitialdialogaction/source/interstitialdialogaction.ets b/interstitialdialogaction/source/interstitialdialogaction.ets new file mode 100644 index 0000000000000000000000000000000000000000..427e504b5fc650ef8589305f26aabccdb6cf1045 --- /dev/null +++ b/interstitialdialogaction/source/interstitialdialogaction.ets @@ -0,0 +1,296 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { UIContext } from '@ohos.arkui.UIContext'; +import { ComponentContent } from '@ohos.arkui.node'; +import { BusinessError } from '@ohos.base'; +import { curves } from '@kit.ArkUI'; + +const DIALOG_BORDER_RADIUS: Resource = $r('sys.float.ohos_id_corner_radius_default_m'); +const DIALOG_INNER_PADDING_SIZE: number = 16; +const DIALOG_MAX_WIDTH: number = 480; +const DIALOG_OFFSET_X: number = 0; +const DIALOG_OFFSET_Y_FOR_BAR: number = -88; +const DIALOG_OFFSET_Y_FOR_NONE: number = -44; + +const STANDARD_MIN_COMPONENT_HEIGHT: number = 82; +const STANDARD_MAX_COMPONENT_HEIGHT: number = 94; + +const DIALOG_SHADOW_RADIUS: number = 16; +const DIALOG_SHADOW_OFFSET_Y: number = 10; +const DIALOG_SHADOW_COLOR: ResourceStr = '#19000000'; + +const TITLE_LINE_DISTANCE: number = 2; +const TITLE_MAX_LINE: number = 2; +const SUBTITLE_MAX_LINE: number = 1; +const TEXT_LEFT_MARGIN_SIZE: number = 16; +const SUBTITLE_DEFAULT_COLOR: Resource = $r('sys.color.ohos_id_color_text_secondary_contrary'); +const TITLE_DEFAULT_COLOR: Resource = $r('sys.color.ohos_id_color_text_primary_contrary'); + +const OPERATE_AREA_AVOID_WIDTH: number = 28; + +const CLOSE_ICON_DARK_RESOURCE: Resource = $r('sys.color.ohos_id_color_tertiary'); +const CLOSE_ICON_LIGHT_RESOURCE: Resource = $r('sys.color.ohos_id_color_primary_contrary'); + +const CLOSE_BUTTON_BORDER_RADIUS: number = 8; +const CLOSE_BUTTON_ICON_SIZE: number = 16; +const CLOSE_BUTTON_HOT_SPOT_SIZE: number = 32; +const CLOSE_BUTTON_MARGIN: number = 8; +const CLOSE_BUTTON_ICON_OPACITY = 0.6; +const CLOSE_BUTTON_RESPONSE_REGION_OFFSET_X: number = -8; +const CLOSE_BUTTON_RESPONSE_REGION_OFFSET_Y: number = -8; +const CLOSE_BUTTON_OFFSET_X: number = 0; +const CLOSE_BUTTON_OFFSET_Y: number = -50; + +const FOREGROUND_IMAGE_OFFSET_X: number = 4; +const FOREGROUND_IMAGE_OFFSET_Y: number = 0; + +export enum IconStyle { + DARK = 0, + LIGHT = 1 +} + +export enum TitlePosition { + TOP = 0, + BOTTOM = 1 +} + +export enum BottomOffset { + OFFSET_FOR_BAR = 0, + OFFSET_FOR_NONE = 1 +} + +class DialogParams { + public options: DialogOptions; + public defaultCloseAction: Callback; + + constructor( + options: DialogOptions, + defaultCloseAction: Callback, + ) { + this.options = options; + this.defaultCloseAction = defaultCloseAction; + } +} + +@Builder +function dialogBuilder(params: DialogParams) { + Row() { + Flex() { + Row() { + SymbolGlyph($r('sys.symbol.xmark_circle_fill')) + .fontColor([params.options.iconStyle === IconStyle.DARK ? + CLOSE_ICON_DARK_RESOURCE : CLOSE_ICON_LIGHT_RESOURCE]) + .borderRadius(CLOSE_BUTTON_BORDER_RADIUS) + .width(CLOSE_BUTTON_ICON_SIZE) + .height(CLOSE_BUTTON_ICON_SIZE) + .opacity(CLOSE_BUTTON_ICON_OPACITY) + .draggable(false) + .focusable(true) + .responseRegion({ + x: CLOSE_BUTTON_RESPONSE_REGION_OFFSET_X, + y: CLOSE_BUTTON_RESPONSE_REGION_OFFSET_Y, + width: CLOSE_BUTTON_HOT_SPOT_SIZE, + height: CLOSE_BUTTON_HOT_SPOT_SIZE + }) + .margin(CLOSE_BUTTON_MARGIN) + .alignSelf(ItemAlign.End) + .offset({ + x: CLOSE_BUTTON_OFFSET_X, + y: CLOSE_BUTTON_OFFSET_Y + }) + .onClick(() => { + if (params.options.onDialogClose !== undefined) { + params.options.onDialogClose() + } + params.defaultCloseAction() + }) + + Image(params.options.foregroundImage) + .height(STANDARD_MAX_COMPONENT_HEIGHT) + .objectFit(ImageFit.Contain) + .fitOriginalSize(true) + .offset({ + x: FOREGROUND_IMAGE_OFFSET_X, + y: FOREGROUND_IMAGE_OFFSET_Y + }) + .alignSelf(ItemAlign.End) + } + .padding({ left: OPERATE_AREA_AVOID_WIDTH }) + .direction(Direction.Rtl) + .defaultFocus(true) + .align(Alignment.End) + .alignSelf(ItemAlign.End) + .constraintSize({ + maxWidth: '50%', + minWidth: '40%' + }) + + Flex({ + direction: params.options.titlePosition === TitlePosition.BOTTOM ? + FlexDirection.ColumnReverse : FlexDirection.Column, + justifyContent: FlexAlign.Center + }) { + Text(params.options.title) + .alignSelf(ItemAlign.Start) + .maxFontSize($r('sys.float.ohos_id_text_size_sub_title1')) + .minFontSize(16) + .fontColor(params.options.titleColor !== undefined ? params.options.titleColor : TITLE_DEFAULT_COLOR) + .fontWeight(FontWeight.Bold) + .margin(params.options.titlePosition ? { top: TITLE_LINE_DISTANCE } : { bottom: TITLE_LINE_DISTANCE }) + .maxLines(TITLE_MAX_LINE) + .wordBreak(WordBreak.BREAK_WORD) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + Text(params.options.subtitle) + .alignSelf(ItemAlign.Start) + .maxFontSize($r('sys.float.ohos_id_text_size_caption')) + .minFontSize(9) + .fontColor(params.options.subtitleColor !== undefined ? params.options.subtitleColor : SUBTITLE_DEFAULT_COLOR) + .maxLines(SUBTITLE_MAX_LINE) + .wordBreak(WordBreak.BREAK_WORD) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + } + .constraintSize({ + maxWidth: '60%', + minWidth: '50%' + }) + .flexGrow(1) + .margin({ left: TEXT_LEFT_MARGIN_SIZE }) + } + .backgroundColor(params.options.backgroundImage === undefined ? '#EBEEF5' : 'rgba(0,0,0,0)') + .shadow({ + radius: DIALOG_SHADOW_RADIUS, + offsetX: 0, + offsetY: DIALOG_SHADOW_OFFSET_Y, + color: DIALOG_SHADOW_COLOR + }) + .height(STANDARD_MIN_COMPONENT_HEIGHT) + .width('100%') + .alignSelf(ItemAlign.End) + .direction(Direction.Rtl) + .zIndex(1) + .borderRadius({ + topLeft: DIALOG_BORDER_RADIUS, + topRight: DIALOG_BORDER_RADIUS, + bottomLeft: DIALOG_BORDER_RADIUS, + bottomRight: DIALOG_BORDER_RADIUS + }) + .onClick(() => { + if (params.options.onDialogClick !== undefined) { + params.options.onDialogClick() + } + params.defaultCloseAction() + }) + + Image(params.options.backgroundImage) + .width('100%') + .height(STANDARD_MIN_COMPONENT_HEIGHT) + .offset({ x: '-100%', y: 0 }) + .borderRadius(DIALOG_BORDER_RADIUS) + .zIndex(0) + .alignSelf(ItemAlign.End) + .onClick(() => { + if (params.options.onDialogClose !== undefined) { + params.options.onDialogClose() + } + params.defaultCloseAction() + }) + } + .backgroundColor('rgba(0,0,0,0)') + .width('100%') + .height(STANDARD_MAX_COMPONENT_HEIGHT) + .padding({ + left: DIALOG_INNER_PADDING_SIZE, + right: DIALOG_INNER_PADDING_SIZE + }) + .constraintSize({ + minHeight: STANDARD_MIN_COMPONENT_HEIGHT, + maxHeight: STANDARD_MAX_COMPONENT_HEIGHT, + maxWidth: DIALOG_MAX_WIDTH + }) +} + +declare interface DialogOptions { + uiContext: UIContext, + bottomOffsetType?: BottomOffset, + title?: ResourceStr, + subtitle?: ResourceStr, + titleColor?: ResourceStr | Color, + subtitleColor?: ResourceStr | Color, + backgroundImage?: Resource, + foregroundImage?: Resource, + iconStyle?: IconStyle, + titlePosition?: TitlePosition, + onDialogClick?: Callback, + onDialogClose?: Callback +} + +export class InterstitialDialogAction { + private uiContext: UIContext; + private contentNode: ComponentContent; + private dialogParam: DialogParams; + private bottomOffsetType?: BottomOffset; + + constructor(dialogOptions: DialogOptions) { + this.uiContext = dialogOptions.uiContext; + this.bottomOffsetType = dialogOptions.bottomOffsetType; + this.dialogParam = new DialogParams( + dialogOptions, + () => { + this.closeDialog() + } + ); + this.contentNode = new ComponentContent(this.uiContext, wrapBuilder(dialogBuilder), this.dialogParam) + } + + openDialog() { + if (this.contentNode !== null) { + this.uiContext.getPromptAction().openCustomDialog(this.contentNode, { + isModal: false, + autoCancel: false, + offset: { + dx: DIALOG_OFFSET_X, + dy: this.bottomOffsetType === BottomOffset.OFFSET_FOR_BAR ? + DIALOG_OFFSET_Y_FOR_BAR : DIALOG_OFFSET_Y_FOR_NONE + }, + alignment: DialogAlignment.Bottom, + transition: TransitionEffect.asymmetric( + TransitionEffect.OPACITY.animation({ duration: 150, curve: Curve.Sharp }) + .combine(TransitionEffect.scale({ x: 0.85, y: 0.85, centerX: '50%', centerY: '85%' }) + .animation({ curve: curves.interpolatingSpring(0, 1, 228, 24)})) + , + TransitionEffect.OPACITY.animation({ duration: 250, curve: Curve.Sharp }) + .combine(TransitionEffect.scale({ x: 0.85, y: 0.85, centerX: '50%', centerY: '85%' }) + .animation({ duration: 250, curve: Curve.Friction })) + ) + }) + .catch((error: BusinessError) => { + let message = (error as BusinessError).message + let code = (error as BusinessError).code + console.error(`${code}: ${message}`); + }) + } + } + + closeDialog() { + if (this.contentNode !== null) { + this.uiContext.getPromptAction().closeCustomDialog(this.contentNode) + .catch((error: BusinessError) => { + let message = (error as BusinessError).message + let code = (error as BusinessError).code + console.error(`${code}: ${message}`); + }) + } + } +} \ No newline at end of file diff --git a/interface/treeview/BUILD.gn b/navpushpathhelper/BUILD.gn similarity index 30% rename from interface/treeview/BUILD.gn rename to navpushpathhelper/BUILD.gn index d8bdb0c3b9cd0a26acc53ade88a98f176e3bba9b..dcbf22dced03b694f6a105fb0456017d449e83f5 100644 --- a/interface/treeview/BUILD.gn +++ b/navpushpathhelper/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023-2023 Huawei Device Co., Ltd. +# Copyright (c) 2024 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -11,38 +11,64 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build/config/components/ets_frontend/es2abc_config.gni") import("//build/ohos.gni") -import("//foundation/arkui/ace_engine/ace_config.gni") -import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") - -es2abc_gen_abc("gen_treeview_abc") { - src_js = rebase_path("treeview.js") - dst_file = rebase_path(target_out_dir + "/treeview.abc") - in_puts = [ "treeview.js" ] - out_puts = [ target_out_dir + "/treeview.abc" ] +import("//foundation/arkui/advanced_ui_component/atomicservice_config.gni") + +es2abc_gen_abc("gen_navpushpathhelper_abc") { + src_js = rebase_path("navpushpathhelper.js") + dst_file = rebase_path(target_out_dir + "/navpushpathhelper.abc") + in_puts = [ "navpushpathhelper.js" ] + out_puts = [ target_out_dir + "/navpushpathhelper.abc" ] extra_args = [ "--module" ] } -gen_js_obj("treeview_abc") { - input = get_label_info(":gen_treeview_abc", "target_out_dir") + "/treeview.abc" - output = target_out_dir + "/treeview_abc.o" - dep = ":gen_treeview_abc" +gen_js_obj("navpushpathhelper_abc") { + input = get_label_info(":gen_navpushpathhelper_abc", "target_out_dir") + + "/navpushpathhelper.abc" + output = target_out_dir + "/navpushpathhelper_abc.o" + dep = ":gen_navpushpathhelper_abc" +} + +gen_obj("navpushpathhelper_abc_preview") { + input = get_label_info(":gen_navpushpathhelper_abc", "target_out_dir") + + "/navpushpathhelper.abc" + output = target_out_dir + "/navpushpathhelper_abc.c" + snapshot_dep = [ ":gen_navpushpathhelper_abc" ] } -ohos_shared_library("treeview") { - sources = [ "treeview.cpp" ] +additional_include_dirs = [ "${ace_root}" ] + +ohos_shared_library("navpushpathhelper") { + sources = [ + "src/hsp_silentinstall.cpp", + "src/hsp_silentinstall_napi.cpp", + "src/navpushpathhelper.cpp", + ] - deps = [ ":treeview_abc" ] + if (use_mingw_win || use_mac || use_linux) { + deps = [ ":gen_obj_src_navpushpathhelper_abc_preview" ] + } else { + deps = [ ":navpushpathhelper_abc" ] + } + + include_dirs = additional_include_dirs + include_dirs += [ "${ace_root}/frameworks" ] + deps += [ "$ace_root/build:libace_compatible" ] external_deps = [ + "ability_base:want", + "ability_runtime:abilitykit_native", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", "hilog:libhilog", + "ipc:ipc_core", "napi:ace_napi", + "samgr:samgr_proxy", ] + relative_install_dir = "module/atomicservice" subsystem_name = "arkui" part_name = "advanced_ui_component" - - relative_install_dir = "module/arkui/advanced" } - - diff --git a/interface/toolbar/toolbar.cpp b/navpushpathhelper/include/hsp_silentinstall.h similarity index 37% rename from interface/toolbar/toolbar.cpp rename to navpushpathhelper/include/hsp_silentinstall.h index db4ee6e1ea474dc87a483eb133ed84535642eecf..e3df82839c18310f3eca94d78816272f83417fc0 100644 --- a/interface/toolbar/toolbar.cpp +++ b/navpushpathhelper/include/hsp_silentinstall.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. + * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,41 +13,25 @@ * limitations under the License. */ -#include "native_engine/native_engine.h" +#ifndef ADVANCED_UI_COMPONENT_NAVPUSHPATHHELPER_INCLUDE_HSP_SILENTINSTALL_H +#define ADVANCED_UI_COMPONENT_NAVPUSHPATHHELPER_INCLUDE_HSP_SILENTINSTALL_H -#include "napi/native_api.h" -#include "napi/native_node_api.h" +#include "bundlemgr/bundle_mgr_interface.h" +#include "interfaces/inner_api/ace/ui_content.h" +namespace OHOS::NavPushPathHelper { -extern const char _binary_toolbar_abc_start[]; -extern const char _binary_toolbar_abc_end[]; +class HspSilentInstall { +public: + HspSilentInstall() = default; + ~HspSilentInstall() = default; -// Napi get abc code function -extern "C" __attribute__((visibility("default"))) -void NAPI_arkui_advanced_ToolBar_GetABCCode(const char **buf, int *buflen) -{ - if (buf != nullptr) { - *buf = _binary_toolbar_abc_start; - } - if (buflen != nullptr) { - *buflen = _binary_toolbar_abc_end - _binary_toolbar_abc_start; - } -} + static int32_t SilentInstall(const std::string& moduleName, const std::function& callback, + const std::function& silentInstallErrorCallBack); + static bool IsHspExist(const std::string& moduleName, const std::string& pathName); + static void UpdateRouteMap(); -/* - * Module define - */ -static napi_module toolbarModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_modname = "arkui.advanced.ToolBar", - .nm_priv = ((void*)0), - .reserved = { 0 }, +private: + static OHOS::sptr GetBundleManager(); }; -/* - * Module register function - */ -extern "C" __attribute__((constructor)) void toolbarRegisterModule(void) -{ - napi_module_register(&toolbarModule); -} +} // namespace OHOS::NavPushPathHelper +#endif \ No newline at end of file diff --git a/navpushpathhelper/include/hsp_silentinstall_napi.h b/navpushpathhelper/include/hsp_silentinstall_napi.h new file mode 100644 index 0000000000000000000000000000000000000000..86361b65b20ef54daf0afdcf1c51fe318cc2caa0 --- /dev/null +++ b/navpushpathhelper/include/hsp_silentinstall_napi.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ADVANCED_UI_COMPONENT_NAVPUSHPATHHELPER_INCLUDE_HSP_SILENT_INSTALL_NAPI_H +#define ADVANCED_UI_COMPONENT_NAVPUSHPATHHELPER_INCLUDE_HSP_SILENT_INSTALL_NAPI_H + +#include "native_engine/native_engine.h" + +#include "napi/native_api.h" +#include "napi/native_node_api.h" + +namespace OHOS::NavPushPathHelper { +class HspSilentInstallNapi { + public: + static napi_value SilentInstall(napi_env env, napi_callback_info info); + static napi_value IsHspExist(napi_env env, napi_callback_info info); + static napi_value UpdateRouteMap(napi_env env, napi_callback_info info); + + private: + struct CallbackData { + napi_env env = nullptr; + int32_t errCode = 0; + std::string errorMessage; + napi_ref successCallback = nullptr; + napi_ref failCallback = nullptr; + + ~CallbackData() + { + if (this->successCallback != nullptr) { + napi_delete_reference(this->env, this->successCallback); + this->successCallback = nullptr; + } + if (this->failCallback != nullptr) { + napi_delete_reference(this->env, this->failCallback); + this->failCallback = nullptr; + } + } + }; + + static void SendSuccessBackWork(uv_work_t *work, int statusIn); + static void SendFailBackWork(uv_work_t *work, int statusIn); + static napi_value CreateResultMessage(CallbackData *callbackData); + static napi_value getModuleName(napi_env env, napi_value args, std::string& moduleName); +}; +} + +#endif \ No newline at end of file diff --git a/navpushpathhelper/include/silent_install_callback.h b/navpushpathhelper/include/silent_install_callback.h new file mode 100644 index 0000000000000000000000000000000000000000..d7fec29ad127233626c124c08a1b02717ff71dbb --- /dev/null +++ b/navpushpathhelper/include/silent_install_callback.h @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ADVANCED_UI_COMPONENT_NAVPUSHPATHHELPER_INCLUDE_SILENT_INSTALL_CALLBACK_H +#define ADVANCED_UI_COMPONENT_NAVPUSHPATHHELPER_INCLUDE_SILENT_INSTALL_CALLBACK_H + +#include "atomic_service_status_callback.h" +#include "errors.h" +#include "iremote_broker.h" +#include "iremote_object.h" +#include "iremote_stub.h" +#include "base/log/log.h" +#include "want_params_wrapper.h" +#include "want.h" + +namespace OHOS::NavPushPathHelper { +constexpr int32_t SILENT_INSTALL_SUCCESS = 0; +constexpr int32_t SILENT_INSTALL_FAIL_CODE = 300001; +constexpr char SILENT_INSTALL_FAIL_MESSAGE[] = "hsp silent install fail"; + +/** + * @class IAtomicServiceStatusCallback + * IAtomicServiceStatusCallback is used to notify caller ability that free install is complete. + */ +class IAtomicServiceStatusCallback : public OHOS::IRemoteBroker { +public: + DECLARE_INTERFACE_DESCRIPTOR(u"ohos.IAtomicServiceStatusCallback"); + + /** + * @brief OnActionEvent. + */ + virtual int32_t OnActionEvent() = 0; + /** + * @brief OnError. + * @param code The code. + * @param msg The msg. + */ + virtual int32_t OnError(int32_t code, const std::string& msg) = 0; +}; + +/** + * @class AtomicServiceStatusCallbackStub + * AtomicServiceStatusCallbackStub. + */ +class AtomicServiceStatusCallbackStub : public OHOS::IRemoteStub { +public: + AtomicServiceStatusCallbackStub() + { + handleOnActionEventFunc_ = &AtomicServiceStatusCallbackStub::HandleOnActionEvent; + handleOnErrorFunc_ = &AtomicServiceStatusCallbackStub::HandleOnError; + } + ~AtomicServiceStatusCallbackStub() override + { + handleOnActionEventFunc_ = nullptr; + handleOnErrorFunc_ = nullptr; + } + + int32_t OnRemoteRequest(uint32_t code, OHOS::MessageParcel &data, OHOS::MessageParcel &reply, + OHOS::MessageOption &option) override + { + TAG_LOGD(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, + "AtomicServiceStatusCallbackStub::OnReceived, code = %{public}u, flags= %{public}d.", + code, option.GetFlags()); + std::u16string descriptor = AtomicServiceStatusCallbackStub::GetDescriptor(); + std::u16string remoteDescriptor = data.ReadInterfaceToken(); + if (descriptor != remoteDescriptor) { + TAG_LOGE(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, + "%{public}s failed, local descriptor is not equal to remote", __func__); + return OHOS::ERR_INVALID_VALUE; + } + + auto resultCode = data.ReadInt32(); + if (resultCode == SILENT_INSTALL_SUCCESS) { + if (handleOnActionEventFunc_ != nullptr) { + return (this->*handleOnActionEventFunc_)(); + } + } + + if (resultCode < SILENT_INSTALL_SUCCESS) { + if (handleOnErrorFunc_ != nullptr) { + return (this->*handleOnErrorFunc_)(); + } + } + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + +private: + int32_t HandleOnActionEvent() + { + return OnActionEvent(); + } + int32_t HandleOnError() + { + return OnError(SILENT_INSTALL_FAIL_CODE, SILENT_INSTALL_FAIL_MESSAGE); + } + + using HandleOnActionEventFunc = int32_t (AtomicServiceStatusCallbackStub::*)(); + HandleOnActionEventFunc handleOnActionEventFunc_; + + using HandleOnErrorFunc = int32_t (AtomicServiceStatusCallbackStub::*)(); + HandleOnErrorFunc handleOnErrorFunc_; + + DISALLOW_COPY_AND_MOVE(AtomicServiceStatusCallbackStub); +}; + +/** + * @class AtomicServiceStatusCallback + * AtomicServiceStatusCallback. + */ +class AtomicServiceStatusCallback : public AtomicServiceStatusCallbackStub { +public: + AtomicServiceStatusCallback() = default; + ~AtomicServiceStatusCallback() override = default; + + /** + * @brief OnActionEvent. + */ + int32_t OnActionEvent() override + { + if (!actionEventHandler_) { + TAG_LOGE(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, "actionEventHandler_ is null."); + return OHOS::ERR_INVALID_VALUE; + } + actionEventHandler_(); + return OHOS::ERR_OK; + } + /** + * @brief OnError. + * @param code The code. + * @param msg The msg. + */ + int32_t OnError(int32_t code, const std::string& msg) override + { + TAG_LOGI(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, "OnError code: %{public}d, msg: %{public}s", + code, msg.c_str()); + if (!errorEventHandler_) { + TAG_LOGE(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, "errorEventHandler_ is null"); + return OHOS::ERR_INVALID_VALUE; + } + + errorEventHandler_(code, msg); + return OHOS::ERR_OK; + } + + void SetActionEventHandler(const std::function& listener) + { + actionEventHandler_ = listener; + } + void SetErrorEventHandler(const std::function& listener) + { + errorEventHandler_ = listener; + } + +private: + std::function actionEventHandler_; + std::function errorEventHandler_; +}; +} +#endif \ No newline at end of file diff --git a/navpushpathhelper/navpushpathhelper.js b/navpushpathhelper/navpushpathhelper.js new file mode 100644 index 0000000000000000000000000000000000000000..e91df36f5c17b1a522abce1aa6aef26150bc4dc0 --- /dev/null +++ b/navpushpathhelper/navpushpathhelper.js @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const navPushPathHelperApi = requireInternal('atomicservice.NavPushPathHelper'); +const hilog = requireNapi('hilog'); + +const tag = 'NavPushPathHelper::JS::'; + +export class NavPushPathHelper { + static currentID = 0; + constructor(navPathStack) { + this.navPathStack_ = navPathStack; + this.currentHelperId_ = NavPushPathHelper.currentID; + NavPushPathHelper.currentID++; + } + + async pushPath(moduleName, info, optionParam) { + hilog.info(0x3900, tag, `pushPath -> currentID: ${this.currentHelperId_}`); + if (navPushPathHelperApi.isHspExist(moduleName, info.name)) { + this.navPathStack_?.pushPath(info, optionParam); + return; + } + return new Promise((resolve, reject) => { + navPushPathHelperApi.silentInstall(moduleName, () => { + navPushPathHelperApi.updateRouteMap(); + this.navPathStack_?.pushPath(info, optionParam); + resolve(); + }, + (error) => { + const err = new Error(error.message); + err.code = error.code; + reject(err); + }); + }); + } + + async pushDestination(moduleName, info, optionParam) { + hilog.info(0x3900, tag, `pushDestination -> currentID: ${this.currentHelperId_}`); + if (navPushPathHelperApi.isHspExist(moduleName, info.name)) { + await this.navPathStack_?.pushDestination(info, optionParam); + return; + } + return new Promise((resolve, reject) => { + navPushPathHelperApi.silentInstall(moduleName, () => { + navPushPathHelperApi.updateRouteMap(); + this.navPathStack_?.pushDestination(info, optionParam) + .then(resolve).catch(reject); + }, (error) => { + const err = new Error(error.message); + err.code = error.code; + reject(err); + }); + }); + } + + async pushPathByName(moduleName, name, param, onPop, optionParam) { + hilog.info(0x3900, tag, `pushPathByName -> currentID: ${this.currentHelperId_}`); + if (navPushPathHelperApi.isHspExist(moduleName, name)) { + this.navPathStack_?.pushPathByName(name, param, onPop, optionParam); + return; + } + return new Promise((resolve, reject) => { + navPushPathHelperApi.silentInstall(moduleName, () => { + hilog.info(0x3900, tag, `silentInstall success`); + navPushPathHelperApi.updateRouteMap(); + this.navPathStack_?.pushPathByName(name, param, onPop, optionParam); + resolve(); + }, (error) => { + const err = new Error(error.message); + err.code = error.code; + reject(err); + }); + }); + } + + async pushDestinationByName(moduleName, name, param, onPop, optionParam) { + hilog.info(0x3900, tag, `pushDestinationByName -> currentID: ${this.currentHelperId_}`); + if (navPushPathHelperApi.isHspExist(moduleName, name)) { + await this.navPathStack_?.pushDestinationByName(name, param, onPop, optionParam); + return; + } + return new Promise((resolve, reject) => { + navPushPathHelperApi.silentInstall(moduleName, () => { + navPushPathHelperApi.updateRouteMap(); + this.navPathStack_?.pushDestinationByName(name, param, onPop, optionParam) + .then(resolve).catch(reject); + }, (error) => { + const err = new Error(error.message); + err.code = error.code; + reject(err); + }); + }); + } + + async replacePath(moduleName, info, optionParam) { + hilog.info(0x3900, tag, `replacePath -> currentID: ${this.currentHelperId_}`); + if (navPushPathHelperApi.isHspExist(moduleName, info.name)) { + this.navPathStack_?.replacePath(info, optionParam); + return; + } + return new Promise((resolve, reject) => { + navPushPathHelperApi.silentInstall(moduleName, () => { + navPushPathHelperApi.updateRouteMap(); + this.navPathStack_?.replacePath(info, optionParam); + resolve(); + }, (error) => { + const err = new Error(error.message); + err.code = error.code; + reject(err); + }); + }); + } + + async replacePathByName(moduleName, name, param, optionParam) { + hilog.info(0x3900, tag, `replacePathByName -> currentID: ${this.currentHelperId_}`); + if (navPushPathHelperApi.isHspExist(moduleName, name)) { + this.navPathStack_?.replacePathByName(name, param, optionParam); + return; + } + return new Promise((resolve, reject) => { + navPushPathHelperApi.silentInstall(moduleName, () => { + hilog.info(0x3900, tag, `silentInstall success`); + navPushPathHelperApi.updateRouteMap(); + this.navPathStack_?.replacePathByName(name, param, optionParam); + resolve(); + }, (error) => { + const err = new Error(error.message); + err.code = error.code; + reject(err); + }); + }); + } +} + +export default { NavPushPathHelper }; \ No newline at end of file diff --git a/navpushpathhelper/src/hsp_silentinstall.cpp b/navpushpathhelper/src/hsp_silentinstall.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ac28f9ab1cee279e1902b3d007d64e14ab5512f7 --- /dev/null +++ b/navpushpathhelper/src/hsp_silentinstall.cpp @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "advanced_ui_component/navpushpathhelper/include/hsp_silentinstall.h" +#include "advanced_ui_component/navpushpathhelper/include/silent_install_callback.h" + +#include "iservice_registry.h" +#include "system_ability_definition.h" +#include "ability_runtime/context/context.h" +#include "want.h" +#include "adapter/ohos/entrance/ace_container.h" +#include "core/pipeline_ng/pipeline_context.h" +#include "base/log/log.h" +#include "base/utils/utils.h" +#include "core/components_ng/manager/navigation/navigation_manager.h" +#include "core/components_ng/pattern/image/image_pattern.h" + +namespace OHOS::NavPushPathHelper { + +OHOS::sptr HspSilentInstall::GetBundleManager() +{ + auto systemAbilityMgr = OHOS::SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (!systemAbilityMgr) { + TAG_LOGE(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, "get system ability failed"); + return nullptr; + } + auto bundleObj = systemAbilityMgr->GetSystemAbility(OHOS::BUNDLE_MGR_SERVICE_SYS_ABILITY_ID); + if (!bundleObj) { + TAG_LOGE(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, "get bundle service failed"); + return nullptr; + } + return OHOS::iface_cast(bundleObj); +} + +int32_t HspSilentInstall::SilentInstall(const std::string& moduleName, const std::function& callback, + const std::function& silentInstallErrorCallBack) +{ + auto pipeline = OHOS::Ace::NG::PipelineContext::GetCurrentContextSafely(); + CHECK_NULL_RETURN(pipeline, -1); + + auto runtimeContext = OHOS::Ace::Platform::AceContainer::GetRuntimeContext(pipeline->GetInstanceId()); + CHECK_NULL_RETURN(runtimeContext, -1); + + auto bundleName = runtimeContext->GetBundleName(); + if (bundleName.empty()) { + return -1; + } + + auto appInfo = runtimeContext->GetApplicationInfo(); + if (!appInfo) { + return -1; + } + auto bms = GetBundleManager(); + CHECK_NULL_RETURN(bms, -1); + + OHOS::AAFwk::Want want; + want.SetBundle(bundleName); + want.SetModuleName(moduleName); + OHOS::sptr routerCallback = new AtomicServiceStatusCallback(); + routerCallback->SetActionEventHandler(callback); + routerCallback->SetErrorEventHandler(silentInstallErrorCallBack); + if (bms->SilentInstall(want, appInfo->uid / OHOS::AppExecFwk::Constants::BASE_USER_RANGE, routerCallback)) { + TAG_LOGI(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, "Begin to silent install"); + return 0; + } + return -1; +} + +bool HspSilentInstall::IsHspExist(const std::string &moduleName, const std::string &pathName) +{ + auto pipeline = OHOS::Ace::NG::PipelineContext::GetCurrentContextSafely(); + CHECK_NULL_RETURN(pipeline, false); + auto container = OHOS::Ace::Container::CurrentSafely(); + CHECK_NULL_RETURN(container, false); + auto navigationRoute = container->GetNavigationRoute(); + CHECK_NULL_RETURN(navigationRoute, false); + if (navigationRoute->IsNavigationItemExits(pathName)) { + return true; + } + + auto runtimeContext = OHOS::Ace::Platform::AceContainer::GetRuntimeContext(pipeline->GetInstanceId()); + CHECK_NULL_RETURN(runtimeContext, false); + + auto appInfo = runtimeContext->GetApplicationInfo(); + if (!appInfo) { + return false; + } + std::vector moduleList = appInfo->moduleInfos; + auto res = std::any_of(moduleList.begin(), moduleList.end(), [moduleName](const auto &module) { + return module.moduleName == moduleName; + }); + if (res) { + return true; + } + return false; +} + +void HspSilentInstall::UpdateRouteMap() +{ + auto container = OHOS::Ace::Container::CurrentSafely(); + CHECK_NULL_VOID(container); + auto navigationRoute = container->GetNavigationRoute(); + CHECK_NULL_VOID(navigationRoute); + navigationRoute->InitRouteMap(); +} +} // namespace OHOS::NavPushPathHelper \ No newline at end of file diff --git a/navpushpathhelper/src/hsp_silentinstall_napi.cpp b/navpushpathhelper/src/hsp_silentinstall_napi.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fdee451ed8b44f4ac61be37e99aa0807145533dc --- /dev/null +++ b/navpushpathhelper/src/hsp_silentinstall_napi.cpp @@ -0,0 +1,273 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "advanced_ui_component/navpushpathhelper/include/hsp_silentinstall_napi.h" +#include "advanced_ui_component/navpushpathhelper/include/hsp_silentinstall.h" +#include "base/log/log.h" + +using namespace std; + +namespace OHOS::NavPushPathHelper { + +napi_value HspSilentInstallNapi::IsHspExist(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + size_t requireArgc = 2; + napi_value args[2] = { nullptr }; + NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, nullptr, nullptr)); + NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments"); + + // get first parameter:moduleName + napi_valuetype moduleNameType; + NAPI_CALL(env, napi_typeof(env, args[0], &moduleNameType)); + NAPI_ASSERT(env, moduleNameType == napi_string, "Wrong argument type. String expected."); + + size_t maxValueLen = 1024; + char moduleNameValue[maxValueLen]; + size_t moduleNameLength = 0; + napi_get_value_string_utf8(env, args[0], moduleNameValue, maxValueLen, &moduleNameLength); + std::string moduleName = moduleNameValue; + + // get second parameter:pathName + napi_valuetype pathNameType; + NAPI_CALL(env, napi_typeof(env, args[1], &pathNameType)); + NAPI_ASSERT(env, pathNameType == napi_string, "Wrong argument type. String expected."); + + char pathNameValue[maxValueLen]; + size_t pathNameLength = 0; + napi_get_value_string_utf8(env, args[1], pathNameValue, maxValueLen, &pathNameLength); + std::string pathName = pathNameValue; + + bool isHspExits = HspSilentInstall::IsHspExist(moduleName, pathName); + napi_value jsResult; + NAPI_CALL(env, napi_get_boolean(env, isHspExits, &jsResult)); + return jsResult; +} + +napi_value HspSilentInstallNapi::UpdateRouteMap(napi_env env, napi_callback_info info) +{ + HspSilentInstall::UpdateRouteMap(); + return nullptr; +} + +napi_value HspSilentInstallNapi::SilentInstall(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + size_t argc = 3; + size_t requireArgc = 3; + napi_value args[3] = { nullptr }; + NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, nullptr, nullptr)); + NAPI_ASSERT(env, argc >= requireArgc, "Wrong number of arguments"); + + // get first parameter:moduleName + std::string moduleName; + getModuleName(env, args[0], moduleName); + + auto callbackData = new (std::nothrow) CallbackData(); + if (callbackData == nullptr) { + return result; + } + uv_work_t *work = new (std::nothrow) uv_work_t; + if (work == nullptr) { + delete callbackData; + callbackData = nullptr; + return result; + } + int parameterNum = 1; + const int indexTwo = 2; + napi_create_reference(env, args[1], parameterNum, &(callbackData->successCallback)); + napi_create_reference(env, args[indexTwo], parameterNum, &(callbackData->failCallback)); + callbackData->env = env; + + auto successCallback = [callbackData, work]() { + uv_loop_s *loop = nullptr; + napi_get_uv_event_loop(callbackData->env, &loop); + work->data = reinterpret_cast(callbackData); + uv_queue_work(loop, work, [](uv_work_t *work) { (void)work; }, SendSuccessBackWork); + }; + + auto failCallback = [callbackData, work](int32_t errorCode, const std::string& errorMessage) { + callbackData->errCode = errorCode; + callbackData->errorMessage = errorMessage; + + uv_loop_s *loop = nullptr; + napi_get_uv_event_loop(callbackData->env, &loop); + work->data = reinterpret_cast(callbackData); + uv_queue_work(loop, work, [](uv_work_t *work) { (void)work; }, SendFailBackWork); + }; + + HspSilentInstall::SilentInstall(moduleName, successCallback, failCallback); + return result; +} + +napi_value HspSilentInstallNapi::getModuleName(napi_env env, napi_value args, std::string& moduleName) +{ + napi_valuetype moduleNameType; + NAPI_CALL(env, napi_typeof(env, args, &moduleNameType)); + NAPI_ASSERT(env, moduleNameType == napi_string, "Wrong argument type. String expected."); + + napi_status status; + size_t maxValueLen = 1024; + char moduleNameValue[maxValueLen]; + size_t moduleNameLength = 0; + status = napi_get_value_string_utf8(env, args, moduleNameValue, maxValueLen, &moduleNameLength); + NAPI_ASSERT(env, status == napi_ok, "Failed to napi_get_value_string_utf8"); + moduleName = moduleNameValue; + return nullptr; +} + +void HspSilentInstallNapi::SendSuccessBackWork(uv_work_t *work, int statusIn) +{ + if (work == nullptr) { + TAG_LOGE(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, "SendSuccessBackWork -> work is null"); + return; + } + (void)statusIn; + napi_status status; + napi_handle_scope scope = nullptr; + CallbackData *callbackData = reinterpret_cast(work->data); + if (callbackData == nullptr) { + TAG_LOGE(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, "SendSuccessBackWork -> callbackData is null"); + return; + } + + napi_open_handle_scope(callbackData->env, &scope); + if (scope == nullptr) { + TAG_LOGE(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, "SendSuccessBackWork -> scope is null"); + return; + } + + napi_value callback = nullptr; + status = napi_get_reference_value(callbackData->env, callbackData->successCallback, &callback); + if (status != napi_ok) { + TAG_LOGE(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, "SendSuccessBackWork -> napi_get_reference_value error"); + napi_close_handle_scope(callbackData->env, scope); + return; + } + + napi_value result; + status = napi_call_function(callbackData->env, nullptr, callback, 0, nullptr, &result); + if (status != napi_ok) { + TAG_LOGE(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, "SendSuccessBackWork -> napi_call_function error"); + napi_close_handle_scope(callbackData->env, scope); + return; + } + + napi_close_handle_scope(callbackData->env, scope); + + if (callbackData != nullptr) { + delete callbackData; + callbackData = nullptr; + } + + if (work != nullptr) { + delete work; + work = nullptr; + } +} + +void HspSilentInstallNapi::SendFailBackWork(uv_work_t *work, int statusIn) +{ + if (work == nullptr) { + TAG_LOGE(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, "SendSuccessBackWork -> work is null"); + return; + } + (void)statusIn; + napi_status status; + napi_handle_scope scope = nullptr; + CallbackData *callbackData = reinterpret_cast(work->data); + if (callbackData == nullptr) { + TAG_LOGE(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, "SendFailBackWork -> callbackData is null"); + return; + } + + napi_open_handle_scope(callbackData->env, &scope); + if (scope == nullptr) { + TAG_LOGE(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, "SendFailBackWork -> scope is null"); + return; + } + + napi_value callback = nullptr; + status = napi_get_reference_value(callbackData->env, callbackData->failCallback, &callback); + if (status != napi_ok) { + TAG_LOGE(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, "SendFailBackWork -> napi_get_reference_value error"); + napi_close_handle_scope(callbackData->env, scope); + return; + } + + size_t resultLength = 1; + napi_value resultMessage = CreateResultMessage(callbackData); + napi_value result[] = { resultMessage }; + status = napi_call_function(callbackData->env, nullptr, callback, resultLength, result, nullptr); + if (status != napi_ok) { + TAG_LOGE(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, "SendFailBackWork -> napi_call_function error"); + napi_close_handle_scope(callbackData->env, scope); + return; + } + + napi_close_handle_scope(callbackData->env, scope); + + if (callbackData != nullptr) { + delete callbackData; + callbackData = nullptr; + } + + if (work != nullptr) { + delete work; + work = nullptr; + } +} + +napi_value HspSilentInstallNapi::CreateResultMessage(CallbackData *callbackData) +{ + napi_status status; + napi_value result = nullptr; + napi_value code = nullptr; + + status = napi_create_int32(callbackData->env, callbackData->errCode, &code); + if (status != napi_ok) { + TAG_LOGE(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, "CreateResultMessage -> napi_create_int32 error"); + return result; + } + + napi_value message = nullptr; + status = napi_create_string_utf8(callbackData->env, callbackData->errorMessage.c_str(), + NAPI_AUTO_LENGTH, &message); + if (status != napi_ok) { + TAG_LOGE(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, "CreateResultMessage -> napi_create_string_utf8 error"); + return result; + } + + napi_value businessError = nullptr; + status = napi_create_object(callbackData->env, &businessError); + if (status != napi_ok) { + TAG_LOGE(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, "CreateResultMessage -> napi_create_object error"); + return result; + } + + status = napi_set_named_property(callbackData->env, businessError, "code", code); + if (status != napi_ok) { + TAG_LOGE(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, "CreateResultMessage -> napi_set_named_property error"); + return result; + } + + status = napi_set_named_property(callbackData->env, businessError, "message", message); + if (status != napi_ok) { + TAG_LOGE(OHOS::Ace::AceLogTag::ACE_DEFAULT_DOMAIN, "CreateResultMessage -> napi_set_named_property error"); + return result; + } + return businessError; +} +} \ No newline at end of file diff --git a/navpushpathhelper/src/navpushpathhelper.cpp b/navpushpathhelper/src/navpushpathhelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2a562e34f8741c8954e64e801f399d116e534b61 --- /dev/null +++ b/navpushpathhelper/src/navpushpathhelper.cpp @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "native_engine/native_engine.h" + +#include "napi/native_api.h" +#include "napi/native_node_api.h" +#include "advanced_ui_component/navpushpathhelper/include/hsp_silentinstall_napi.h" + +extern const char _binary_navpushpathhelper_abc_start[]; +extern const char _binary_navpushpathhelper_abc_end[]; + +namespace OHOS::NavPushPathHelper { + /* + * function for module exports + */ + static napi_value Init(napi_env env, napi_value exports) + { + /* + * Properties define + */ + napi_property_descriptor desc[] = { + DECLARE_NAPI_FUNCTION("silentInstall", HspSilentInstallNapi::SilentInstall), + DECLARE_NAPI_FUNCTION("isHspExist", HspSilentInstallNapi::IsHspExist), + DECLARE_NAPI_FUNCTION("updateRouteMap", HspSilentInstallNapi::UpdateRouteMap), + }; + NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc)); + return exports; + } + + // Napi get abc code function + extern "C" __attribute__((visibility("default"))) + void NAPI_atomicservice_NavPushPathHelper_GetABCCode(const char **buf, int *buflen) + { + if (buf != nullptr) { + *buf = _binary_navpushpathhelper_abc_start; + } + if (buflen != nullptr) { + *buflen = _binary_navpushpathhelper_abc_end - _binary_navpushpathhelper_abc_start; + } + } + + /* + * Module define + */ + static napi_module NavPushPathHelperModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "atomicservice.NavPushPathHelper", + .nm_priv = ((void*)0), + .reserved = { 0 }, + }; + + /* + * Module registerfunction + */ + extern "C" __attribute__((constructor)) void NavPushPathHelperRegisterModule(void) + { + napi_module_register(&NavPushPathHelperModule); + } +} \ No newline at end of file diff --git a/source/ArkDialog/ArkDialog.ets b/source/ArkDialog/ArkDialog.ets deleted file mode 100644 index 37c4f0b2c008773d37bdea6f445333d6f80cd31d..0000000000000000000000000000000000000000 --- a/source/ArkDialog/ArkDialog.ets +++ /dev/null @@ -1,417 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const CHECKBOX_CONTAINER_HEIGHT: number = 48 -const CONTENT_MAX_LINES: number = 2 -const DIVIDER_CONTAINER_WIDTH: number = 16 -const DIVIDER_HEIGHT: number = 24 -const DIVIDER_WIDTH: number = 2 -const LOADING_PROGRESS_WIDTH: number = 40 -const LOADING_PROGRESS_HEIGHT: number = 48 -const ITEM_TEXT_SIZE: number = 14 -export declare type ButtonOptions = { - value: ResourceStr; - action?: () => void; - background?: ResourceColor; - fontColor?: ResourceColor; -} - -@CustomDialog -export struct TipsDialog{ - controller: CustomDialogController - imageRes: Resource - imageSize: SizeOptions = {width: '100%', height: 180} - title: ResourceStr = '' - content?: ResourceStr = '' - checkTips?: ResourceStr = '' - @State isChecked?: boolean = false - primaryButton?: ButtonOptions = {value: ""} - secondaryButton?: ButtonOptions = {value: ""} - - build() { - Column() { - Row() { - Column() { - Image(this.imageRes) - .size(this.imageSize) - .objectFit(ImageFit.Fill) - }.layoutWeight(1) - .clip(true) - }.width('100%') - .padding({ left: 24, right: 24}) - .margin({top: 24}) - Row() { - Text(this.title) - .fontSize($r('sys.float.ohos_id_text_size_headline8')) - .fontWeight(FontWeight.Medium) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .textAlign(TextAlign.Center) - }.padding({ left: 24, right: 24 }) - .margin({top: 16}) - if (this.content) { - Row() { - Text(this.content) - .fontSize($r('sys.float.ohos_id_text_size_body2')) - .fontWeight(FontWeight.Medium) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .textAlign(TextAlign.Center) - .minFontSize($r('sys.float.ohos_id_text_size_body3')) - }.padding({ left: 24, right: 24, top: 8, bottom: 8 }) - .width('100%') - } - Row() { - Checkbox({ name: 'checkbox', group: 'checkboxGroup' }).select(this.isChecked) - .onChange((checked: boolean) => { - this.isChecked = checked - }) - .margin({ left: 0, right: 8}) - Text(this.checkTips).fontSize($r('sys.float.ohos_id_text_size_body2')) - .fontWeight(FontWeight.Medium) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(CONTENT_MAX_LINES) - .layoutWeight(1) - .focusOnTouch(true) - .onClick(() => { - this.isChecked = !this.isChecked - }) - }.height(CHECKBOX_CONTAINER_HEIGHT).width('100%').padding({ left: 24, right: 24 , top: 8, bottom: 8 }) - - Row() { - if (this.primaryButton.value) { - Button(this.primaryButton.value) - .fontSize($r('sys.float.ohos_id_text_size_button1')) - .fontWeight(FontWeight.Medium) - .layoutWeight(1) - .backgroundColor(this.primaryButton.background? this.primaryButton.background: $r('sys.color.ohos_id_color_background_transparent')) - .fontColor(this.primaryButton.fontColor ? this.primaryButton.fontColor: $r('sys.color.ohos_id_color_text_primary_activated')) - .onClick(() => { - if (this.primaryButton.action) this.primaryButton.action() - this.controller.close() - }) - } - if (this.secondaryButton.value && this.primaryButton.value) { - Column() { - if (!this.secondaryButton.background) { - Divider().width(DIVIDER_WIDTH).height(DIVIDER_HEIGHT).color($r('sys.color.ohos_id_color_list_separator')).vertical(true) - } - }.width(DIVIDER_CONTAINER_WIDTH).alignItems(HorizontalAlign.Center) - } - if (this.secondaryButton.value) { - Button(this.secondaryButton.value) - .fontSize($r('sys.float.ohos_id_text_size_button1')) - .fontWeight(FontWeight.Medium) - .layoutWeight(1) - .backgroundColor(this.secondaryButton.background? this.secondaryButton.background: $r('sys.color.ohos_id_color_background_transparent')) - .fontColor(this.secondaryButton.fontColor ? this.secondaryButton.fontColor: $r('sys.color.ohos_id_color_text_primary_activated')) - .onClick(() => { - if (this.secondaryButton.action) this.secondaryButton.action() - this.controller.close() - }) - } - }.width('100%').padding({ left: 16, right: 16, top: 16, bottom: 16 }) - } - .backgroundBlurStyle(BlurStyle.Thick) - .borderRadius($r('sys.float.ohos_id_corner_radius_dialog')) - .margin({ - left: $r('sys.float.ohos_id_dialog_margin_start'), - right: $r('sys.float.ohos_id_dialog_margin_end'), - bottom: $r('sys.float.ohos_id_dialog_margin_bottom') - }) - // 1.backgroundcolor use in blur enable mod mast set this color: colorDialogBgBlur. but now it is not found - .backgroundColor($r('sys.color.ohos_id_color_dialog_bg')) - } -} - -@CustomDialog -export struct SelectDialog{ - controller: CustomDialogController - title: ResourceStr = '' - content?: ResourceStr = '' - selectedIndex?: number = -1 - confirm?: ButtonOptions = {value: ""} - radioContent: Array = [] - - build() { - Column() { - Row() { - Text(this.title) - .fontSize($r('sys.float.ohos_id_text_size_dialog_tittle')) - .fontWeight(FontWeight.Medium) - .maxLines(CONTENT_MAX_LINES) - .minFontSize($r('sys.float.ohos_id_text_size_sub_title1')) - .textOverflow({ overflow: TextOverflow.Ellipsis}) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .textAlign(TextAlign.Start) - .width('100%') - }.padding({ left: 24, right: 24, top: 24 }) - .constraintSize({minHeight: 56}) - if (this.content) { - Row() { - Text(this.content) - .fontSize($r('sys.float.ohos_id_text_size_body2')) - .fontWeight(FontWeight.Medium) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(CONTENT_MAX_LINES) - .textOverflow({ overflow: TextOverflow.Ellipsis}) - .minFontSize($r('sys.float.ohos_id_text_size_body3')) - }.padding({ left: 24, right: 24, top: 8, bottom: 8 }) - .width('100%') - } - List({space: 1}) { - ForEach(this.radioContent, (item: SheetInfo, index?: number) => { - ListItem() { - Column() { - Row() { - Text(item.title) - .fontSize(ITEM_TEXT_SIZE) - .fontWeight(FontWeight.Regular) - .maxLines(CONTENT_MAX_LINES) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .layoutWeight(1) - Radio({ value: 'item.title', group: 'radioGroup'}).checked(this.selectedIndex == index) - .onChange(() => { - item.action && item.action() - this.controller.close() - }) - .onClick(() => { - item.action && item.action() - this.controller.close() - }) - }.constraintSize({minHeight: 48}).clip(false) - .onClick(() => { - item.action && item.action() - this.controller.close() - }) - if (index < this.radioContent.length - 1) { - Divider().color($r('sys.color.ohos_id_color_list_separator')) - } - } - } - }) - }.width('100%').padding({ left: 24, right: 24, top: 8, bottom: 8 }).clip(false) - Row() { - if (this.confirm.value) { - Button(this.confirm.value) - .fontSize($r('sys.float.ohos_id_text_size_button1')) - .fontWeight(FontWeight.Medium) - .layoutWeight(1) - .backgroundColor(this.confirm.background? this.confirm.background: $r('sys.color.ohos_id_color_background_transparent')) - .fontColor(this.confirm.fontColor ? this.confirm.fontColor: $r('sys.color.ohos_id_color_text_primary_activated')) - .onClick(() => { - this.confirm.action && this.confirm.action() - this.controller.close() - }) - } - }.width('100%').padding({ left: 16, right: 16, top: 16, bottom: 16 }) - } - .backgroundBlurStyle(BlurStyle.Thick) - .borderRadius($r('sys.float.ohos_id_corner_radius_dialog')) - .margin({ - left: $r('sys.float.ohos_id_dialog_margin_start'), - right: $r('sys.float.ohos_id_dialog_margin_end'), - bottom: $r('sys.float.ohos_id_dialog_margin_bottom') - }) - // 1.backgroundcolor use in blur enable mod mast set this color: colorDialogBgBlur. but now it is not found - .backgroundColor($r('sys.color.ohos_id_color_dialog_bg')) - } -} - -@CustomDialog -export struct ConfirmDialog{ - controller: CustomDialogController - title: ResourceStr = '' - content?: ResourceStr = '' - checkTips?: ResourceStr = '' - @State isChecked?: boolean = false - primaryButton?: ButtonOptions = {value: ""} - secondaryButton?: ButtonOptions = {value: ""} - - build() { - Column() { - Row() { - Text(this.title) - .fontSize($r('sys.float.ohos_id_text_size_dialog_tittle')) - .fontWeight(FontWeight.Medium) - .maxLines(CONTENT_MAX_LINES) - .minFontSize($r('sys.float.ohos_id_text_size_sub_title1')) - .textOverflow({ overflow: TextOverflow.Ellipsis}) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .textAlign(TextAlign.Start) - .width('100%') - }.padding({ left: 24, right: 24, top: 24 }) - .constraintSize({minHeight: 56}) - if (this.content) { - Row() { - Text(this.content) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontWeight(FontWeight.Medium) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(CONTENT_MAX_LINES) - .textOverflow({ overflow: TextOverflow.Ellipsis}) - .minFontSize($r('sys.float.ohos_id_text_size_body3')) - }.padding({ left: 24, right: 24, top: 8, bottom: 8 }) - .width('100%') - .constraintSize({minHeight: 36}) - } - Row() { - Checkbox({ name: 'checkbox', group: 'checkboxGroup' }).select(this.isChecked) - .onChange((checked: boolean) => { - this.isChecked = checked - }) - .margin({ left: 0, right: 8}) - Text(this.checkTips).fontSize($r('sys.float.ohos_id_text_size_body2')) - .fontWeight(FontWeight.Medium) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(CONTENT_MAX_LINES) - .layoutWeight(1) - .focusOnTouch(true) - .onClick(() => { - this.isChecked = !this.isChecked - }) - }.height(CHECKBOX_CONTAINER_HEIGHT).width('100%').padding({ left: 24, right: 24 , top: 8, bottom: 8 }) - - Row() { - if (this.primaryButton.value) { - Button(this.primaryButton.value) - .fontSize($r('sys.float.ohos_id_text_size_button1')) - .fontWeight(FontWeight.Medium) - .layoutWeight(1) - .backgroundColor(this.primaryButton.background? this.primaryButton.background: $r('sys.color.ohos_id_color_background_transparent')) - .fontColor(this.primaryButton.fontColor ? this.primaryButton.fontColor: $r('sys.color.ohos_id_color_text_primary_activated')) - .onClick(() => { - if (this.primaryButton.action) this.primaryButton.action() - this.controller.close() - }) - } - if (this.secondaryButton.value && this.primaryButton.value) { - Column() { - if (!this.secondaryButton.background) { - Divider().width(DIVIDER_WIDTH).height(DIVIDER_HEIGHT).color($r('sys.color.ohos_id_color_list_separator')).vertical(true) - } - }.width(DIVIDER_CONTAINER_WIDTH).alignItems(HorizontalAlign.Center) - } - if (this.secondaryButton.value) { - Button(this.secondaryButton.value) - .fontSize($r('sys.float.ohos_id_text_size_button1')) - .fontWeight(FontWeight.Medium) - .layoutWeight(1) - .backgroundColor(this.secondaryButton.background? this.secondaryButton.background: $r('sys.color.ohos_id_color_background_transparent')) - .fontColor(this.secondaryButton.fontColor ? this.secondaryButton.fontColor: $r('sys.color.ohos_id_color_text_primary_activated')) - .onClick(() => { - if (this.secondaryButton.action) this.secondaryButton.action() - this.controller.close() - }) - } - }.width('100%').padding({ left: 16, right: 16, top: 16, bottom: 16 }) - } - .backgroundBlurStyle(BlurStyle.Thick) - .borderRadius($r('sys.float.ohos_id_corner_radius_dialog')) - .margin({ - left: $r('sys.float.ohos_id_dialog_margin_start'), - right: $r('sys.float.ohos_id_dialog_margin_end'), - bottom: $r('sys.float.ohos_id_dialog_margin_bottom') - }) - // 1.backgroundcolor use in blur enable mod mast set this color: colorDialogBgBlur. but now it is not found - .backgroundColor($r('sys.color.ohos_id_color_dialog_bg')) - } -} - -@CustomDialog -export struct AlertDialog{ - controller: CustomDialogController - content: ResourceStr = '' - primaryButton?: ButtonOptions = {value: ""} - secondaryButton?: ButtonOptions = {value: ""} - build() { - Column() { - Row() { - Text(this.content) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontWeight(FontWeight.Medium) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - }.padding({ left: 24, right: 24, top: 24 }) - Row() { - if (this.primaryButton.value) { - Button(this.primaryButton.value) - .fontSize($r('sys.float.ohos_id_text_size_button1')) - .fontWeight(FontWeight.Medium) - .layoutWeight(1) - .backgroundColor(this.primaryButton.background? this.primaryButton.background: $r('sys.color.ohos_id_color_background_transparent')) - .fontColor(this.primaryButton.fontColor ? this.primaryButton.fontColor: $r('sys.color.ohos_id_color_text_primary_activated')) - .onClick(() => { - if (this.primaryButton.action) this.primaryButton.action() - this.controller.close() - }) - } - if (this.secondaryButton.value && this.primaryButton.value) { - Column() { - if (!this.secondaryButton.background) { - Divider().width(DIVIDER_WIDTH).height(DIVIDER_HEIGHT).color($r('sys.color.ohos_id_color_list_separator')).vertical(true) - } - }.width(DIVIDER_CONTAINER_WIDTH).alignItems(HorizontalAlign.Center) - } - if (this.secondaryButton.value) { - Button(this.secondaryButton.value) - .fontSize($r('sys.float.ohos_id_text_size_button1')) - .fontWeight(FontWeight.Medium) - .layoutWeight(1) - .backgroundColor(this.secondaryButton.background? this.secondaryButton.background: $r('sys.color.ohos_id_color_background_transparent')) - .fontColor(this.secondaryButton.fontColor ? this.secondaryButton.fontColor: $r('sys.color.ohos_id_color_text_primary_activated')) - .onClick(() => { - if (this.secondaryButton.action) this.secondaryButton.action() - this.controller.close() - }) - } - }.width('100%').padding({ left: 16, right: 16, top: 16, bottom: 16 }) - } - .backgroundBlurStyle(BlurStyle.Thick) - .borderRadius($r('sys.float.ohos_id_corner_radius_dialog')) - .margin({ - left: $r('sys.float.ohos_id_dialog_margin_start'), - right: $r('sys.float.ohos_id_dialog_margin_end'), - bottom: $r('sys.float.ohos_id_dialog_margin_bottom') - }) - // 1.backgroundcolor use in blur enable mod mast set this color: colorDialogBgBlur. but now it is not found - .backgroundColor($r('sys.color.ohos_id_color_dialog_bg')) - } -} - -@CustomDialog -export struct LoadingDialog{ - controller: CustomDialogController - content?: ResourceStr = '' - build() { - Column() { - Row() { - Text(this.content) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontWeight(FontWeight.Medium) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .layoutWeight(1) - LoadingProgress().width(LOADING_PROGRESS_WIDTH).height(LOADING_PROGRESS_HEIGHT).margin({ left: 16 }) - }.margin({ left: 24, right: 24, top: 24, bottom: 24 }) - .constraintSize({minHeight: 48}) - } - .backgroundBlurStyle(BlurStyle.Thick) - .borderRadius($r('sys.float.ohos_id_corner_radius_dialog')) - .margin({ - left: $r('sys.float.ohos_id_dialog_margin_start'), - right: $r('sys.float.ohos_id_dialog_margin_end'), - bottom: $r('sys.float.ohos_id_dialog_margin_bottom') - }) - // 1.backgroundcolor use in blur enable mod mast set this color: colorDialogBgBlur. but now it is not found - .backgroundColor($r('sys.color.ohos_id_color_dialog_bg')) - } -} \ No newline at end of file diff --git a/source/ComposeListItem/ComposeListItem.ets b/source/ComposeListItem/ComposeListItem.ets deleted file mode 100644 index 0c6bb53403854c05ca4426462f5528e24de52659..0000000000000000000000000000000000000000 --- a/source/ComposeListItem/ComposeListItem.ets +++ /dev/null @@ -1,488 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export enum IconType { - BADGE = 1, - NORMAL_ICON, - SYSTEM_ICON, - HEAD_SCULPTURE, - APP_ICON, - PREVIEW, - LONGITUDINAL, - VERTICAL -} - -enum ItemHeight { - FIRST_HEIGHT = 48, - SECOND_HEIGHT = 56, - THIRD_HEIGHT = 64, - FOURTH_HEIGHT = 72, - FIFTH_HEIGHT = 96 -} - -export type OperateItem = { - icon?: OperateIcon, - subIcon ?: OperateIcon, - button?: OperateButton; - switch?: OperateCheck; - checkbox?: OperateCheck; - radio?: OperateCheck; - image?: ResourceStr; - text?: ResourceStr; - arrow?: OperateIcon; -} - -export type ContentItem = { - iconStyle?: IconType; - icon?: ResourceStr; - primaryText?: ResourceStr; - secondaryText?: ResourceStr; - description?: ResourceStr; -} - -const LISTITEMCARD_BORDER_HIDDEN = 0; -const TEXT_MAX_LINE = 1; -const LISTITEMCARD_BORDER_SHOWN = 2; -const TEXT_COLUMN_SPACE = 2; -const TEXT_SAFE_MARGIN = 8; -const BADGE_SIZE = 8; -const SMALL_ICON_SIZE = 16; -const SYSTEM_ICON_SIZE = 24; -const SAFE_LIST_PADDING = 32; -const HEADSCULPTURE_SIZE = 40; -const BUTTON_SIZE = 28; -const APP_ICON_SIZE = 64; -const PREVIEW_SIZE = 96; -const LONGITUDINAL_SIZE = 96; -const VERTICAL_SIZE = 96; -const NORMAL_ITEM_ROW_SPACE = 16; -const SPECIAL_ITEM_ROW_SPACE = 0; -const SPECIAL_ICON_SIZE = 0; -const DEFAULT_ROW_SPACE = 0; -const SPECICAL_ROW_SPACE = 4; -const OPERATEITEM_ICONLIKE_SIZE = 24; -const OPERATEITEM_ARROW_WIDTH = 12 -const OPERATEITEM_ICON_CLICKABLE_SIZE = 48; -const OPERATEITEM_IMAGE_SIZE = 48; -const HOVERING_COLOR = '#0d000000'; -const TOUCH_DOWN_COLOR = '#1a000000'; -const ACTIVED_COLOR = '#1a0a59f7'; - -@Component -struct ContentItemStruct { - iconStyle: IconType = null - icon: Resource = null - title: string = null - subtitle: string = null - description: string = null - private iconSizeMap: Map = new Map([ - [IconType.BADGE, BADGE_SIZE], - [IconType.NORMAL_ICON, SMALL_ICON_SIZE], - [IconType.SYSTEM_ICON, SYSTEM_ICON_SIZE], - [IconType.HEAD_SCULPTURE, HEADSCULPTURE_SIZE], - [IconType.APP_ICON, APP_ICON_SIZE], - [IconType.PREVIEW, PREVIEW_SIZE], - [IconType.LONGITUDINAL, LONGITUDINAL_SIZE], - [IconType.VERTICAL, VERTICAL_SIZE] - ]) - private itemHeight: number = ItemHeight.FIRST_HEIGHT - private itemRowSpace: number = NORMAL_ITEM_ROW_SPACE - - aboutToAppear() { - if (this.subtitle == null && this.description == null) { - if (this.icon == null) { - this.itemHeight = ItemHeight.FIRST_HEIGHT - } - else { - this.itemHeight = this.iconStyle <= IconType.HEAD_SCULPTURE ? ItemHeight.SECOND_HEIGHT : ItemHeight.THIRD_HEIGHT - } - } - else if (this.description == null) { - if (this.icon == null || (this.icon != null && this.iconStyle <= IconType.SYSTEM_ICON)) { - this.itemHeight = ItemHeight.THIRD_HEIGHT - } - else { - this.itemHeight = ItemHeight.FOURTH_HEIGHT - } - } - else { - this.itemHeight = ItemHeight.FIFTH_HEIGHT - } - - if (this.icon == null && this.iconStyle == null) { - this.itemRowSpace = SPECIAL_ITEM_ROW_SPACE - } - - if (this.iconSizeMap.get(this.iconStyle) >= this.itemHeight) { - this.itemHeight = this.iconSizeMap.get(this.iconStyle) + SAFE_LIST_PADDING; - } - } - - @Builder - createIcon() { - if (this.icon != null && this.iconStyle != null) { - if (this.iconStyle <= IconType.PREVIEW) { - Image(this.icon) - .objectFit(ImageFit.Contain) - .width(this.iconSizeMap.get(this.iconStyle)) - .height(this.iconSizeMap.get(this.iconStyle)) - .borderRadius($r('sys.float.ohos_id_corner_radius_default_m')) - .focusable(true) - } - else { - Image(this.icon) - .objectFit(ImageFit.Contain) - .constraintSize({ - minWidth: SPECIAL_ICON_SIZE, - maxWidth: this.iconSizeMap.get(this.iconStyle), - minHeight: SPECIAL_ICON_SIZE, - maxHeight: this.iconSizeMap.get(this.iconStyle) - }) - .borderRadius($r('sys.float.ohos_id_corner_radius_default_m')) - .focusable(true) - } - } - } - - @Builder - createText() { - Column({ space: TEXT_COLUMN_SPACE }) { - Text(this.title) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .maxLines(TEXT_MAX_LINE) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .focusable(true) - if (this.subtitle != null) { - Text(this.subtitle) - .fontSize($r('sys.float.ohos_id_text_size_body2')) - .fontColor($r('sys.color.ohos_id_color_text_secondary')) - .maxLines(TEXT_MAX_LINE) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .focusable(true) - } - if (this.description != null) { - Text(this.description) - .fontSize($r('sys.float.ohos_id_text_size_body2')) - .fontColor($r('sys.color.ohos_id_color_text_secondary')) - .maxLines(TEXT_MAX_LINE) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .focusable(true) - } - } - .margin({ - top: TEXT_SAFE_MARGIN, - bottom: TEXT_SAFE_MARGIN - }) - .alignItems(HorizontalAlign.Start) - } - - build() { - Row({ space: this.itemRowSpace }) { - this.createIcon() - this.createText() - } - .height(this.itemHeight) - } -} - -@Component -struct OperateItemStruct { - arrow: OperateIcon = null - icon: OperateIcon = null - subIcon: OperateIcon = null - button: OperateButton = null - switch: OperateCheck = null - checkBox: OperateCheck = null - radio: OperateCheck = null - image: Resource = null - text: string = null - @State switchState: boolean = false - @State radioState: boolean = false - @State checkBoxState: boolean = false - private rowSpace: number = DEFAULT_ROW_SPACE - - aboutToAppear() { - if (this.switch != null) { - this.switchState = this.switch.isCheck - } - if (this.radio != null) { - this.radioState = this.radio.isCheck - } - if (this.checkBox != null) { - this.checkBoxState = this.checkBox.isCheck - } - - if ((this.button == null && this.image == null && this.icon != null && this.text != null) || - (this.button == null && this.image == null && this.icon == null && this.arrow != null && this.text != null)) { - this.rowSpace = SPECICAL_ROW_SPACE - } - } - - @Builder - createButton(text: string) { - Button(text) - .fontSize($r('sys.float.ohos_id_text_size_button3')) - .fontColor($r('sys.color.ohos_id_color_text_primary_activated_transparent')) - .height(BUTTON_SIZE) - .backgroundColor($r('sys.color.ohos_id_color_button_normal')) - .labelStyle({ - maxLines: TEXT_MAX_LINE - }) - } - - @Builder - createIcon(icon: OperateIcon) { - Row() { - Image(icon.value) - .height(OPERATEITEM_ICONLIKE_SIZE) - .width(OPERATEITEM_ICONLIKE_SIZE) - .focusable(true) - .fillColor($r('sys.color.ohos_id_color_primary')) - } - .height(OPERATEITEM_ICON_CLICKABLE_SIZE) - .width(OPERATEITEM_ICON_CLICKABLE_SIZE) - .justifyContent(FlexAlign.Center) - .onClick(icon.action) - } - - @Builder - createImage(image: Resource) { - Image(image) - .height(OPERATEITEM_IMAGE_SIZE) - .width(OPERATEITEM_IMAGE_SIZE) - } - - @Builder - createText(text: string) { - Text(text) - .fontSize($r('sys.float.ohos_id_text_size_body2')) - .fontColor($r('sys.color.ohos_id_color_text_secondary')) - .focusable(true) - } - - @Builder - createArrow(icon: OperateIcon) { - Image(icon.value) - .height(OPERATEITEM_ICONLIKE_SIZE) - .width(OPERATEITEM_ARROW_WIDTH) - .focusable(true) - .fillColor($r('sys.color.ohos_id_color_fourth')) - .onClick(icon.action) - } - - @Builder - createRadio(radio: OperateCheck) { - Radio({ value: null, group: null }) - .checked(this.radioState) - .onChange(radio.onChange) - .height(OPERATEITEM_ICONLIKE_SIZE) - .width(OPERATEITEM_ICONLIKE_SIZE) - } - - @Builder - createCheckBox(checkBox: OperateCheck) { - Checkbox() - .select(this.checkBoxState) - .onChange(checkBox.onChange) - .height(OPERATEITEM_ICONLIKE_SIZE) - .height(OPERATEITEM_ICONLIKE_SIZE) - } - - @Builder - createSwitch(toggleParams: OperateCheck) { - Row() { - Toggle({ type: ToggleType.Switch, isOn: this.switchState }) - .onChange(toggleParams.onChange) - .onClick(() => { - this.switchState = !this.switchState - }) - } - .height(OPERATEITEM_ICON_CLICKABLE_SIZE) - .width(OPERATEITEM_ICON_CLICKABLE_SIZE) - .justifyContent(FlexAlign.Center) - } - - build() { - Row({ - space: this.rowSpace - }) { - if (this.button != null) { - this.createButton(this.button.text) - } - - else if (this.image != null) { - this.createImage(this.image) - } - else if (this.icon != null && this.text != null) { - this.createText(this.text) - this.createIcon(this.icon) - } - else if (this.arrow != null && this.text == null) { - this.createArrow(this.arrow) - } - else if (this.arrow != null && this.text != null) { - this.createText(this.text) - this.createArrow(this.arrow) - } - else if (this.text != null) { - this.createText(this.text) - } - else if (this.radio != null) { - this.createRadio(this.radio) - } - else if (this.checkBox != null) { - this.createCheckBox(this.checkBox) - } - else if (this.switch != null) { - this.createSwitch(this.switch) - } - else if (this.icon != null) { - this.createIcon(this.icon) - if (this.subIcon != null) { - this.createIcon(this.subIcon) - } - } - } - } -} - -/** - * Declare type OperateIcon - * @typedef OperationOption - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -export declare type OperateIcon = { - /** - * The content of text or the address of icon. - * @type { ResourceStr }. - * @since 10 - */ - value: ResourceStr, - - /** - * Callback function when operate the icon. - * @type { () => void }. - * @since 10 - */ - action?: () => void -} - -export type OperateButton = { - /** - * The text on the button. - * @type { ResourceStr }. - * @since 10 - */ - text?: string -} - -/** - * Declare type OperateCheck - * @typedef OperationOption - * @syscap SystemCapability.ArkUI.ArkUI.Full - * @since 10 - */ -export declare type OperateCheck = { - /** - * Whether is checked on default. - * @type { ResourceStr }. - * @since 10 - */ - isCheck?: boolean, - - /** - * Callback function when operate the checkbox/switch/radio. - * @type { () => void }. - * @since 10 - */ - onChange?: (value: boolean) => void -} - -@Component -export struct ComposeListItem { - @Prop contentItem: ContentItem = null; - @Prop operateItem: OperateItem = null; - @State frontColor: string = Color.Transparent.toString() - @State borderSize: number = 0; - private isActive: boolean = false - - build() { - Column() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { - if (this.contentItem == null) { - ContentItemStruct({ - title: null - }) - } - if (this.contentItem != null) { - ContentItemStruct({ - icon: typeof this.contentItem.icon === 'string' ? null : this.contentItem.icon, - iconStyle: this.contentItem.iconStyle, - title: typeof this.contentItem.primaryText === 'string' ? this.contentItem.primaryText : null, - subtitle: typeof this.contentItem.secondaryText === 'string' ? this.contentItem.secondaryText : null, - description: typeof this.contentItem.description === 'string' ? this.contentItem.description : null - }) - } - if (this.operateItem != null) { - OperateItemStruct({ - icon: this.operateItem.icon, - subIcon: this.operateItem.subIcon, - button: this.operateItem.button, - switch: this.operateItem.switch, - checkBox: this.operateItem.checkbox, - radio: this.operateItem.radio, - image: typeof this.operateItem.image === 'string' ? null : this.operateItem.image, - text: typeof this.operateItem.text === 'string' ? this.operateItem.text : null, - arrow: typeof this.operateItem.arrow === 'string' ? null : this.operateItem.arrow - }) - } - } - .focusable(true) - .border({ - width: this.borderSize, - color: $r('sys.color.ohos_id_color_focused_outline') - }) - .borderRadius($r('sys.float.ohos_id_corner_radius_default_m')) - .backgroundColor(this.frontColor) - .onFocus(() => { - this.borderSize = LISTITEMCARD_BORDER_SHOWN - }) - .onBlur(() => { - this.borderSize = LISTITEMCARD_BORDER_HIDDEN - }) - .onHover((isHover: boolean) => { - this.frontColor = isHover ? HOVERING_COLOR : (this.isActive ? ACTIVED_COLOR : Color.Transparent.toString()) - }) - .onTouch((event: TouchEvent) => { - if (event.type == TouchType.Down) { - this.frontColor = TOUCH_DOWN_COLOR - } - if (event.type == TouchType.Up) { - this.frontColor = this.isActive ? ACTIVED_COLOR : Color.Transparent.toString() - } - }) - .onClick(() => { - this.isActive = !this.isActive - this.frontColor = this.isActive ? ACTIVED_COLOR : Color.Transparent.toString() - }) - } - .padding({ - left: $r('sys.float.ohos_id_default_padding_start'), - right: $r('sys.float.ohos_id_default_padding_end') - }) - } -} \ No newline at end of file diff --git a/source/ComposeTitleBar/ComposeTitleBar.ets b/source/ComposeTitleBar/ComposeTitleBar.ets deleted file mode 100755 index 4e265927705ea090ce7799f90f88fde6f048ac84..0000000000000000000000000000000000000000 --- a/source/ComposeTitleBar/ComposeTitleBar.ets +++ /dev/null @@ -1,369 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { KeyCode } from '@ohos.multimodalInput.keyCode' - -export declare type ComposeTitleBarMenuItem = { - value: ResourceStr - isEnabled: boolean - action?: () => void -} - -const PUBLIC_MORE = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAY' + - 'AAABS3GwHAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAEZ0FNQQAAsY58+1GTAAA' + - 'AAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOxAAADsQBlSsOGwAABEZJREFUeNrt3D1rFFEUBuA' + - 'xhmAhFlYpUohYiYWFRcAmKAhWK2pjo1iKf8BCMIKFf8BarCyMhVj4VZhGSKEg2FqJyCKWIhYWnstMINgYsh+cmfs88BI' + - 'Cydxw7jmzu2HvNg0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADBN+3r6dx+LXIqsRpa7FF8j48hm5Fn3Peo9mAEYRdY' + - 'jJ3f582Vj7nZfUe/eDsCRyMPI2h5/fyNyI/JDT6v3Tvt7sBllE15ETkxwjeORi5G3ke/6W737MgBnI68jh6ZwrcORq5H' + - 'nhkC9+zAA5YXXy8jBKV5zKXIu8jjyS7+rd+YBeNVtyrSVO9PRyBM9r94LSTfjWuTUDK9/eYIXeENUbb0zDsBi5PYc1rm' + - 'j79U74wCszuih+F/ljrSi/+uud8YBGA10rayqrnfGAVgb6FpZVV3vjAOwPNC1sqq63hkHYGWga2VVdb0XKt/8Rf1fd70' + - 'zDsB4jmt5u3Tl9a59AMb6v+56ZxyArYGulVXV9c44ABtzXOup/q+73hkH4N2cHio/Rj7r/7rrnXEAfkfuz2Gddb2v3ln' + - '/DfpgxneLzaY9xE3l9c46AH8iVyI/Z3Dt8nB/Xc+rd5H5QMy3yJemPVs6zY0edc9HUe/0Z4I/dQ/N5Vjd0oTXKp9QcKF' + - 'pD2qj3r0YgO1NeRM507TH6/bifeR85IMeV++d+vTBWOV9JDcjt5rdv6uw3M3uRR7pa/Xu+wBsOxA53bTnTP/3UX1b3fN' + - 'Q1BsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKqyr6d/97HIpchqZLlL8TUyjmxGnnX' + - 'fo96DGYBRZD1ycpc/XzbmbvcV9e7tAByJPIys7fH3NyI3Ij/0tHrvtL8Hm1E24UXkxATXOB65GHkb+a6/1bsvA3A28jp' + - 'yaArXOhy5GnluCNS7DwNQXni9jByc4jWXIucijyO/9Lt6Zx6AV92mTFu5Mx2NPNHz6r2QdDOuRU7N8PqXJ3iBN0TV1jv' + - 'jACxGbs9hnTv6Xr0zDsDqjB6K/1XuSCv6v+56ZxyA0UDXyqrqemccgLWBrpVV1fXOOADLA10rq6rrnXEAVga6VlZV13u' + - 'h8s1f1P911zvjAIznuJa3S1de79oHYKz/6653xgHYGuhaWVVd74wDsDHHtZ7q/7rrnXEA3s3pofJj5LP+r7veGQfgd+T' + - '+HNZZ1/vqnfXfoA9mfLfYbNpD3FRe76wD8CdyJfJzBtcuD/fX9bx6F5kPxHyLfGnas6XT3OhR93wU9U5/JvhT99BcjtU' + - 'tTXit8gkFF5r2oDbq3YsB2N6UN5EzTXu8bi/eR85HPuhx9d6pTx+MVd5HcjNyq9n9uwrL3exe5JG+Vu++D8C2A5HTTXv' + - 'O9H8f1bfVPQ9FvQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgCn7C9HjBtwWfXpKAAAAAElFTkSuQmCC' - -const PUBLIC_BACK = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAY' + - 'AAABS3GwHAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAEZ0FNQQAAsY58+1GTAAAAA' + - 'XNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAA8VJREFUeNrt3LFLlHEYwPFXz0G' + - 'iIZpEoikkwsFRIiK3gqCigxIC/4Kmhv6OoChouaGoqKCgCKducGh0cDAIamhwiCaHCIeelztpUszee/vl8/nAM3Vd8nufr' + - '+fddVYVAAAAAAAAAAAAAAAAAAAAAABQijFH0KhrMd2Y2ZitmNWYRzHLjkYAB9lUzMOYizv8eS/mZsymoypLxxE0svzvY07' + - 'vcpu5mOmY145LAAdx+U/u4bZzwx+JPjq2cow7glaWf1vXsQkg6/JvPwoggJTLjwDSL/8nRyiAzN/5nzpGAWRd/n7MM0cpg' + - 'IzLvx6z6CjL453gdpZ/IWbDcQrA8iMAy48ALD8CsPwIwPIjAMuPACw/ArD8CMDyIwDLjwAsPwKw/AjA8iMAy48ALD8CsPw' + - 'IwPIjAMuPACw/ArD85A3A8pM2AMtP2gAsP2kDsPykDcDykzYAy0/aACw/aQOw/KQNwPKTNgDLT9oALD9pA7D8pA3A8pM2A' + - 'MtP2gAsP2kDsPykDcDykzYAy0/aACw/aQOw/KQNwPKTNgDLT9oALD9pA7D8pA3A8pM2AMtP2gAsP2kDsPykDcDykzYAy0/' + - 'aACw/aQOw/KQNwPLz3xlv6H4mYp5YfrI+AizF9BwnI/AlZi3mbsxy03feaeh+HsQcc60YgSMxMzE3YmZj3sX8LOlHoPoLn' + - 'HedaEE35n5pzwF856dN9SPBpZICmHRNaNnlkgL46nrQsvmSAqhftlx1TWjR4ZICqPVcE1q0XloA96rBa7XQhl5pAWzFXKm' + - '8i8vo9WMeN3VnnQa/sO8xL2POxEy7Toxo+RdjNpu6w1F9HuBqNXi99lw1eKMM9utHzIeYV8MftbccCQAAAAAAsBdt/XLc+s' + - 'Py9W+MmPqL+1iJuVA1+C4gdFr6d77FvK0GH2nb739lPR5zNuZ51eBnQhFAJQIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIE' + - 'IAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAI' + - 'EIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIE8M8jmBlGgABSRnAqZiXms+MUQNYIDnkUKMu4I/gj6z' + - 'ELMRv7/PsnHKEAMkcw6fgEkDmCNUcngMwRvHFsngRnfWJcL/9tRyaAgxrB+ZijO9ymH7MUs+m4yjLmCBozEXMr5nr1+9We1' + - 'ZgXMXccDwAAAAAAAAAAAAAAAAAAAAAAwO5+AfVgtqHKRnawAAAAAElFTkSuQmCC' - -@Component -export struct ComposeTitleBar { - item: ComposeTitleBarMenuItem - title: ResourceStr - subtitle: ResourceStr - menuItems: Array - - @State titleMaxWidth: number = 0 - @State isItemOnFocus: boolean = false - - private static readonly totalHeight = 56 - private static readonly leftPadding = 12 - private static readonly rightPadding = 12 - private static readonly portraitImageSize = 40 - private static readonly portraitImageLeftPadding = 4 - private static readonly portraitImageRightPadding = 16 - - build() { - Flex({ - justifyContent: FlexAlign.SpaceBetween, - alignItems: ItemAlign.Stretch - }) { - Row() { - Navigator() { - ImageMenuItem({ item: { - value: PUBLIC_BACK, - isEnabled: true - } }) - } - if (this.item !== undefined) { - Image(this.item.value) - .width(ComposeTitleBar.portraitImageSize) - .height(ComposeTitleBar.portraitImageSize) - .margin({ - left: $r('sys.float.ohos_id_text_paragraph_margin_xs'), - right: $r('sys.float.ohos_id_text_paragraph_margin_m') - }) - .focusable(this.item.isEnabled) - .borderRadius(ImageMenuItem.buttonBorderRadius) - .onFocus(() => this.isItemOnFocus = true) - .onBlur(() => this.isItemOnFocus = false) - .border(this.isItemOnFocus ? - { width: ImageMenuItem.focusBorderWidth, - color: $r('sys.color.ohos_id_color_emphasize'), - style: BorderStyle.Solid - } : { width: 0 }) - .onClick(() => this.item.isEnabled && this.item.action && this.item.action()) - } - Column() { - if (this.title !== undefined) { - Row() { - Text(this.title) - .fontWeight(FontWeight.Medium) - .fontSize($r('sys.float.ohos_id_text_size_headline8')) - .fontColor($r('sys.color.ohos_id_color_titlebar_text')) - .maxLines(this.subtitle !== undefined ? 1 : 2) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .constraintSize({ maxWidth: this.titleMaxWidth }) - } - .justifyContent(FlexAlign.Start) - } - if (this.subtitle !== undefined) { - Row() { - Text(this.subtitle) - .fontSize($r('sys.float.ohos_id_text_size_over_line')) - .fontColor($r('sys.color.ohos_id_color_titlebar_subtitle_text')) - .maxLines(1) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .constraintSize({ maxWidth: this.titleMaxWidth }) - } - .justifyContent(FlexAlign.Start) - } - } - .justifyContent(FlexAlign.Start) - .alignItems(HorizontalAlign.Start) - .constraintSize({ maxWidth: this.titleMaxWidth }) - } - .margin({ left: $r('sys.float.ohos_id_default_padding_start') }) - if (this.menuItems !== undefined && this.menuItems.length > 0) { - CollapsibleMenuSection({ menuItems: this.menuItems }) - } - } - .width('100%') - .height(ComposeTitleBar.totalHeight) - .backgroundColor($r('sys.color.ohos_id_color_background')) - .onAreaChange((_oldValue: Area, newValue: Area) => { - let newWidth = Number(newValue.width) - if (this.menuItems !== undefined) { - let menusLength = this.menuItems.length - if (menusLength >= CollapsibleMenuSection.maxCountOfVisibleItems) { - newWidth = newWidth - ImageMenuItem.imageHotZoneWidth * CollapsibleMenuSection.maxCountOfVisibleItems - } else if (menusLength > 0) { - newWidth = newWidth - ImageMenuItem.imageHotZoneWidth * menusLength - } - } - this.titleMaxWidth = newWidth - this.titleMaxWidth -= ComposeTitleBar.leftPadding - this.titleMaxWidth -= ImageMenuItem.imageHotZoneWidth - if (this.item !== undefined) { - this.titleMaxWidth -= ComposeTitleBar.portraitImageLeftPadding - + ComposeTitleBar.portraitImageSize - + ComposeTitleBar.portraitImageRightPadding - } - this.titleMaxWidth -= ComposeTitleBar.rightPadding - }) - } -} - -@Component -struct CollapsibleMenuSection { - menuItems: Array - - static readonly maxCountOfVisibleItems = 3 - private static readonly focusPadding = 4 - private static readonly marginsNum = 2 - - @State isPopupShown: boolean = false - - @State isMoreIconOnFocus: boolean = false - @State isMoreIconOnHover: boolean = false - @State isMoreIconOnClick: boolean = false - - getMoreIconFgColor() { - return this.isMoreIconOnClick - ? $r('sys.color.ohos_id_color_titlebar_icon_pressed') - : $r('sys.color.ohos_id_color_titlebar_icon') - } - - getMoreIconBgColor() { - if (this.isMoreIconOnClick) { - return $r('sys.color.ohos_id_color_click_effect') - } else if (this.isMoreIconOnHover) { - return $r('sys.color.ohos_id_color_hover') - } else { - return Color.Transparent - } - } - - build() { - Column() { - Row() { - if (this.menuItems.length <= CollapsibleMenuSection.maxCountOfVisibleItems) { - ForEach(this.menuItems, (item) => { - ImageMenuItem({ item: item }) - }) - } else { - ForEach(this.menuItems.slice(0, CollapsibleMenuSection.maxCountOfVisibleItems - 1), (item) => { - ImageMenuItem({ item: item }) - }) - - Row() { - Image(PUBLIC_MORE) - .width(ImageMenuItem.imageSize) - .height(ImageMenuItem.imageSize) - .focusable(true) - } - .width(ImageMenuItem.imageHotZoneWidth) - .height(ImageMenuItem.imageHotZoneWidth) - .borderRadius(ImageMenuItem.buttonBorderRadius) - .foregroundColor(this.getMoreIconFgColor()) - .backgroundColor(this.getMoreIconBgColor()) - .justifyContent(FlexAlign.Center) - .border(this.isMoreIconOnFocus ? - { width: ImageMenuItem.focusBorderWidth, - color: $r('sys.color.ohos_id_color_emphasize'), - style: BorderStyle.Solid - } : { width: 0 }) - .onFocus(() => this.isMoreIconOnFocus = true) - .onBlur(() => this.isMoreIconOnFocus = false) - .onHover((isOn) => this.isMoreIconOnHover = isOn) - .onKeyEvent((event) => { - if (event.keyCode !== KeyCode.KEYCODE_ENTER && event.keyCode !== KeyCode.KEYCODE_SPACE) { - return - } - if (event.type === KeyType.Down) { - this.isMoreIconOnClick = true - } - if (event.type === KeyType.Up) { - this.isMoreIconOnClick = false - } - }) - .onTouch((event) => { - if (event.type === TouchType.Down) { - this.isMoreIconOnClick = true - } - if (event.type === TouchType.Up) { - this.isMoreIconOnClick = false - } - }) - .onClick(() => this.isPopupShown = true) - .bindPopup(this.isPopupShown, { - builder: this.popupBuilder, - placement: Placement.Bottom, - popupColor: Color.White, - enableArrow: false, - onStateChange: (e) => this.isPopupShown = e.isVisible - }) - } - } - } - .height('100%') - .margin({ right: $r('sys.float.ohos_id_default_padding_end') }) - .justifyContent(FlexAlign.Center) - } - - @Builder popupBuilder() { - Column() { - ForEach(this.menuItems.slice(CollapsibleMenuSection.maxCountOfVisibleItems - 1, this.menuItems.length), (item, _index?) => { - ImageMenuItem({ item: item }) - }) - } - .width(ImageMenuItem.imageHotZoneWidth + CollapsibleMenuSection.focusPadding * CollapsibleMenuSection.marginsNum) - .margin({ top: CollapsibleMenuSection.focusPadding, bottom: CollapsibleMenuSection.focusPadding }) - } -} - -@Component -struct ImageMenuItem { - item: ComposeTitleBarMenuItem - - static readonly imageSize = 24 - static readonly imageHotZoneWidth = 48 - static readonly buttonBorderRadius = 8 - static readonly focusBorderWidth = 2 - static readonly disabledImageOpacity = 0.4 - - @State isOnFocus: boolean = false - @State isOnHover: boolean = false - @State isOnClick: boolean = false - - getFgColor() { - return this.isOnClick - ? $r('sys.color.ohos_id_color_titlebar_icon_pressed') - : $r('sys.color.ohos_id_color_titlebar_icon') - } - - getBgColor() { - if (this.isOnClick) { - return $r('sys.color.ohos_id_color_click_effect') - } else if (this.isOnHover) { - return $r('sys.color.ohos_id_color_hover') - } else { - return Color.Transparent - } - } - - build() { - Row() { - Image(this.item.value) - .width(ImageMenuItem.imageSize) - .height(ImageMenuItem.imageSize) - .focusable(this.item.isEnabled) - } - .width(ImageMenuItem.imageHotZoneWidth) - .height(ImageMenuItem.imageHotZoneWidth) - .borderRadius(ImageMenuItem.buttonBorderRadius) - .foregroundColor(this.getFgColor()) - .backgroundColor(this.getBgColor()) - .justifyContent(FlexAlign.Center) - .opacity(this.item.isEnabled ? 1 : ImageMenuItem.disabledImageOpacity) - .border(this.isOnFocus ? - { width: ImageMenuItem.focusBorderWidth, - color: $r('sys.color.ohos_id_color_emphasize'), - style: BorderStyle.Solid - } : { width: 0 }) - .onFocus(() => { - if (!this.item.isEnabled) { - return - } - this.isOnFocus = true - }) - .onBlur(() => this.isOnFocus = false) - .onHover((isOn) => { - if (!this.item.isEnabled) { - return - } - this.isOnHover = isOn - }) - .onKeyEvent((event) => { - if (!this.item.isEnabled) { - return - } - if (event.keyCode !== KeyCode.KEYCODE_ENTER && event.keyCode !== KeyCode.KEYCODE_SPACE) { - return - } - if (event.type === KeyType.Down) { - this.isOnClick = true - } - if (event.type === KeyType.Up) { - this.isOnClick = false - } - }) - .onTouch((event) => { - if (!this.item.isEnabled) { - return - } - if (event.type === TouchType.Down) { - this.isOnClick = true - } - if (event.type === TouchType.Up) { - this.isOnClick = false - } - }) - .onClick(() => this.item.isEnabled && this.item.action && this.item.action()) - } -} - -export default {ComposeTitleBar} \ No newline at end of file diff --git a/source/EditableTitleBar/EditableTitleBar.ets b/source/EditableTitleBar/EditableTitleBar.ets deleted file mode 100755 index fffa70e148c6e15cd3b6e151ca8db4747f96871e..0000000000000000000000000000000000000000 --- a/source/EditableTitleBar/EditableTitleBar.ets +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { KeyCode } from '@ohos.multimodalInput.keyCode' - -export enum EditableLeftIconType { - Back, - Cancel -} - -export declare type EditableTitleBarMenuItem = { - value: ResourceStr - isEnabled: boolean - action?: () => void -} - -const PUBLIC_CANCEL = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAABS3Gw' + - 'HAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAEZ0FNQQAAsY58+1GTAAAAAXNSR0IA' + - 'rs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOxAAADsQBlSsOGwAABKpJREFUeNrt3bFrlHccx/Ff4o2dgkOQ4' + - 'JzR4SYJgksnbYcGOrTQsUPtpE4d/RNcFBeFlg7NUlTSTrXQQgsKGV0KHTs4ODiJSL8PdxaUGJK7pPc893m94TvleZLnnt' + - '/7fcc9z5FrDQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAnDQrPTuej2u2a87VvKp5XLNT87OlGiSf1lx' + - '6Zz2/q3kkgLdZr7k5lX8/7tZ8XfOCU4OgW887U/n341bN9T6s56menLAfaj464OfdM8iF6XYv+dV7+X+pOX/ANuOatZqH' + - 'Amjti5prh9jurAgGI//mIbbtIvi15u9FHvBqD07a50fYdqtmt+YDrg1a/jd8tuiD7kMA4yNuL4LlkH+WtV/KAEYz7COC4' + - 'cs/69ovXQB7M+4ngmHLP8/aL1UAD+bYVwTDlX/etT8W+nAV6M82uQS6PuP+rg4NV/5vBNDa6za5HLY9xzO5CIYl/9OaT5' + - 'obYf/xrE1uioggQ/6LNf/04QGd6tHJFQH5owMQAfnjAxAB+eMDEAH54wMQAfnjAxAB+eMDEAH54wMQAfnjAxAB+eMDEAH' + - '54wMQAfnjAxAB+eMDEAH54wMQAfnjAxAB+eMDEAH54wMQAfnjAxAB+eMDEAH54wMQAfnjAxAB+eMDSI6A/AKIjYD8AoiN' + - 'gPwCiI2A/AKIjYD8AoiNgPwCiI2A/AKIjYD8AoiNgPwCiI2A/AKIjYD8AoiNgPwCiI2A/AKIjYD8AoiNgPwCiI2A/AKIj' + - 'YD8AoiNgPwCiI2A/AKIjYD8AoiNgPwCiI1gjfyLY8UpmJnNqbjrc/yO32pOk98rQPIrwWnyCyA5AvILQATkF4AIyC8AEZ' + - 'BfACIgvwBEQH4BiID8J8qqU3BiPJ8O+XuMO8Eng8/2CID85BcA+ckvAPKT35tg8h+n/KP2/3/2SADojfzf1+yKYH7cBxi' + - 'm/N39hWX8RnsBkP9Q8r9BBAKIlV8EAoiXXwQCiJdfBAKIl18EAoiXXwQz4D5A/+Tv2KjZmuPvdfu6T+AVYJDyd3Qfo17G' + - 'b7QXAPkPzTMRCCBVfhEIIF5+EQggXn4RCCBefhEIIF5+EQggXn4RCCBefhEIIF5+EQggXn4RCCBefhEIIF5+EQggXn4RC' + - 'CBefhEIIF5+EQggXn4RCCBefhEIwD+qFUFuAOQXQWwA5BdBbADkF0FsAOQXQWwA5BdBbADkF0FsAOQXQWwA5BdBbADkF0' + - 'FsAOQXQWwA5BdBbADkF0FsAOQXQWwA5BdBbADkF0FsAOQXQWwA5BdBbADkF0FsAOQXQWwA5BdBdAD3a8bkj4rgTM2PAmj' + - 'ty5or5I+L4FzNHzV/LfKB9OGb4rfJP0iO49xvL/pB9CGAMfljIxgLoLUR+WMjGAmgtT3yx0awJ4DWdsgfG8HOog+6D1eB' + - 'ntR8WLNB/sFzlKtDnfw3BNDa65rfp2+I3hfBo5rL5B9UBFttcoNzP35qk8vfLxZ9sCs9OnHdG6Kvps8e3TXiVzWPp88Ut' + - '3k1OLr1vFpz6Z31/LbmntMDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAO/wLvsR65mx80NAAAAABJRU' + - '5ErkJggg==' - -const PUBLIC_OK = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAABS3' + - 'GwHAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAEZ0FNQQAAsY58+1GTAAAAAXNSR0IArs4c6QAAAAZ' + - 'iS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAA+lJREFUeNrt3bFrFgccx+GLlSDi4JDBITiJZHBwEBGRIoqKoIu6iVMd3' + - 'OosCg6W0sm/wEFUDDgpCDoIDoqOKqIoHUrp4CDFoUMRB39HLotoeXMpMXff54EfFE0ivv1+kpQGrmkAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + - 'AAAAAAAAAAAAAAIBJTHkJGIhddT/V7ajbUPey7l7dlbpPAmCs1tb9Wne2++cvPa07Vfd7nw/+g9eXVT7+m3Wn69Z8421m6w7WXa37KADGN' + - 'v4TE7ztTN36uvtL/UPWeJ0Z+PgXnejzBwmAMYx/8VuhTQIgcfy9CYCxjP9D3TsBkPqZf95XAFLH3372vyAAEsf/T93Ruvd93tn/CWbo4z9' + - 'c96jvBxAAseMXANHjFwDR4xcA0eMXANHjFwDR4xcA0eMXANHjFwDR4xcA0eMXANHjFwDR4xcA0eMXANHjFwDR4xcA0eMXANHjFwDR4xcA0' + - 'eMXANHjFwDR4xcA0eMXANHjFwDR4xcA0eMXANHjFwDR4xcA0eP/HgG0z3f9uVl45uu2ZuGBBu3zXn9rej7mEuMfSgDtA46v1c195ff+rbt' + - 'U94stGv9KWqnHpLaPsXxSt/k//iXsq9vY9HjUJca/2gNoH2e/c4K32yUC4x9bAOvqrjeTP41GBMY/qgC2151Z4vuIwPhXxEo8I2xdz/c7W' + - '3fZXo1/6F8B/q471/N9fSUw/sEH8LEb8hYRGH9iAK3HdafrpkVg/IkBtA8yflt3bBn/3SEC4x9sAK3Xda9EYPypAYjA+OMDEIHxxwcgAuO' + - 'PD0AExh8fgAiMPz4AERh/fAAiMP74AERg/PEBiMD44wMQgfHHByAC448PQATGHx+ACIw/PgARGH98AMkRGL8AYiMwfgHERmD8AoiNwPgFE' + - 'BuB8QsgNgLjF0BsBMYvgNgIjF8AsREYvwBiIzB+AcRGYPwCiI3A+AUQG4HxCyA2AuMXQGwExi+A2AiMXwCxERi/AGIjMH4BjDaCTXUP6j5' + - '9423aJ2PeMH4BjDWCHd24n9f9+cXvHa+7U7fb+Fe/qeC/ezvU+e5bleX40A11pm6u+xapMX5fARK+Eix+u7O1brbp/1Bw4xfAoCP4Pxi/A' + - 'GIjMH4BxEZg/AKIjcD4BRAbgfELIDYC4xdAbATGL4DYCIxfAIOL4EXdkbrpZX6sd3WH6p56WQUwJG/qbtX92Cz8EFwfD+sO1L31cq4uU16' + - 'CibU/M3Sy7nzdlgnf51ndxbrbXj4BjCmEPXX76/Y2Cz8DNNP9+l91f3Sf8e92AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + - 'AAAAAzKZwK1uX4kZ6mnAAAAAElFTkSuQmCC' - -const PUBLIC_BACK = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAY' + - 'AAABS3GwHAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAEZ0FNQQAAsY58+1GTAAAAA' + - 'XNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAA8VJREFUeNrt3LFLlHEYwPFXz0G' + - 'iIZpEoikkwsFRIiK3gqCigxIC/4Kmhv6OoChouaGoqKCgCKducGh0cDAIamhwiCaHCIeelztpUszee/vl8/nAM3Vd8nufr' + - '+fddVYVAAAAAAAAAAAAAAAAAAAAAABQijFH0KhrMd2Y2ZitmNWYRzHLjkYAB9lUzMOYizv8eS/mZsymoypLxxE0svzvY07' + - 'vcpu5mOmY145LAAdx+U/u4bZzwx+JPjq2cow7glaWf1vXsQkg6/JvPwoggJTLjwDSL/8nRyiAzN/5nzpGAWRd/n7MM0cpg' + - 'IzLvx6z6CjL453gdpZ/IWbDcQrA8iMAy48ALD8CsPwIwPIjAMuPACw/ArD8CMDyIwDLjwAsPwKw/AjA8iMAy48ALD8CsPw' + - 'IwPIjAMuPACw/ArD85A3A8pM2AMtP2gAsP2kDsPykDcDykzYAy0/aACw/aQOw/KQNwPKTNgDLT9oALD9pA7D8pA3A8pM2A' + - 'MtP2gAsP2kDsPykDcDykzYAy0/aACw/aQOw/KQNwPKTNgDLT9oALD9pA7D8pA3A8pM2AMtP2gAsP2kDsPykDcDykzYAy0/' + - 'aACw/aQOw/KQNwPLz3xlv6H4mYp5YfrI+AizF9BwnI/AlZi3mbsxy03feaeh+HsQcc60YgSMxMzE3YmZj3sX8LOlHoPoLn' + - 'HedaEE35n5pzwF856dN9SPBpZICmHRNaNnlkgL46nrQsvmSAqhftlx1TWjR4ZICqPVcE1q0XloA96rBa7XQhl5pAWzFXKm' + - '8i8vo9WMeN3VnnQa/sO8xL2POxEy7Toxo+RdjNpu6w1F9HuBqNXi99lw1eKMM9utHzIeYV8MftbccCQAAAAAAsBdt/XLc+s' + - 'Py9W+MmPqL+1iJuVA1+C4gdFr6d77FvK0GH2nb739lPR5zNuZ51eBnQhFAJQIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIE' + - 'IAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAI' + - 'EIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIE8M8jmBlGgABSRnAqZiXms+MUQNYIDnkUKMu4I/gj6z' + - 'ELMRv7/PsnHKEAMkcw6fgEkDmCNUcngMwRvHFsngRnfWJcL/9tRyaAgxrB+ZijO9ymH7MUs+m4yjLmCBozEXMr5nr1+9We1' + - 'ZgXMXccDwAAAAAAAAAAAAAAAAAAAAAAwO5+AfVgtqHKRnawAAAAAElFTkSuQmCC' - -@Component -export struct EditableTitleBar { - leftIconStyle: EditableLeftIconType - title: ResourceStr - menuItems: Array - onSave?: () => void - onCancel?: () => void - - @State titleMaxWidth: number = 0 - - static readonly maxCountOfExtraItems = 2 - private static readonly totalHeight = 56 - private static readonly leftPadding = 12 - private static readonly rightPadding = 12 - private static readonly titlePadding = 16 - - build() { - Flex({ - justifyContent: FlexAlign.SpaceBetween, - alignItems: ItemAlign.Stretch - }) { - Row() { - if (this.leftIconStyle == EditableLeftIconType.Back) { - Navigator() { - ImageMenuItem({ item: { - value: PUBLIC_BACK, - isEnabled: true - } }) - } - } else { - ImageMenuItem({ item: { - value: PUBLIC_CANCEL, - isEnabled: true, - action: () => this.onCancel && this.onCancel() - } }) - } - - Column() { - Text(this.title) - .fontWeight(FontWeight.Medium) - .fontSize($r('sys.float.ohos_id_text_size_headline8')) - .fontColor($r('sys.color.ohos_id_color_titlebar_text')) - .maxLines(1) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .constraintSize({ maxWidth: this.titleMaxWidth }) - } - .justifyContent(FlexAlign.Start) - .alignItems(HorizontalAlign.Start) - .constraintSize({ maxWidth: this.titleMaxWidth }) - } - .margin({ left: $r('sys.float.ohos_id_default_padding_start') }) - - EditableTitleBarMenuSection({ - menuItems: this.menuItems, - onSave: this.onSave - }) - } - .width('100%') - .height(EditableTitleBar.totalHeight) - .backgroundColor($r('sys.color.ohos_id_color_background')) - .onAreaChange((_oldValue: Area, newValue: Area) => { - let nValue = Number(newValue.width) - nValue = nValue - EditableTitleBar.leftPadding - EditableTitleBar.rightPadding - EditableTitleBar.titlePadding - nValue = nValue - ImageMenuItem.imageHotZoneWidth - ImageMenuItem.imageHotZoneWidth - if (this.menuItems === undefined) { - this.titleMaxWidth = nValue - return - } - if (this.menuItems.length > EditableTitleBar.maxCountOfExtraItems) { - this.titleMaxWidth = nValue - ImageMenuItem.imageHotZoneWidth * EditableTitleBar.maxCountOfExtraItems - } else { - this.titleMaxWidth = nValue - ImageMenuItem.imageHotZoneWidth * this.menuItems.length - } - }) - } -} - -@Component -struct EditableTitleBarMenuSection { - menuItems: Array - onSave?: () => void - - build() { - Column() { - Row() { - if (this.menuItems !== undefined && this.menuItems.length > 0) { - ForEach(this.menuItems.slice(0, EditableTitleBar.maxCountOfExtraItems), (item: EditableTitleBarMenuItem) => { - ImageMenuItem({ item: item }) - }) - } - ImageMenuItem({ item: { - value: PUBLIC_OK, - isEnabled: true, - action: () => this.onSave && this.onSave() - } }) - } - } - .margin({ - left: $r('sys.float.ohos_id_elements_margin_vertical_l'), - right: $r('sys.float.ohos_id_default_padding_end') - }) - .justifyContent(FlexAlign.Center) - } -} - -@Component -struct ImageMenuItem { - item: EditableTitleBarMenuItem - - static readonly imageSize = 24 - static readonly imageHotZoneWidth = 48 - static readonly buttonBorderRadius = 8 - static readonly focusBorderWidth = 2 - static readonly disabledImageOpacity = 0.4 - - @State isOnFocus: boolean = false - @State isOnHover: boolean = false - @State isOnClick: boolean = false - - getFgColor() { - return this.isOnClick - ? $r('sys.color.ohos_id_color_titlebar_icon_pressed') - : $r('sys.color.ohos_id_color_titlebar_icon') - } - - getBgColor() { - if (this.isOnClick) { - return $r('sys.color.ohos_id_color_click_effect') - } else if (this.isOnHover) { - return $r('sys.color.ohos_id_color_hover') - } else { - return Color.Transparent - } - } - - build() { - Row() { - Image(this.item.value) - .width(ImageMenuItem.imageSize) - .height(ImageMenuItem.imageSize) - .focusable(this.item.isEnabled) - } - .width(ImageMenuItem.imageHotZoneWidth) - .height(ImageMenuItem.imageHotZoneWidth) - .borderRadius(ImageMenuItem.buttonBorderRadius) - .foregroundColor(this.getFgColor()) - .backgroundColor(this.getBgColor()) - .justifyContent(FlexAlign.Center) - .opacity(this.item.isEnabled ? 1 : ImageMenuItem.disabledImageOpacity) - .border(this.isOnFocus ? - { width: ImageMenuItem.focusBorderWidth, - color: $r('sys.color.ohos_id_color_emphasize'), - style: BorderStyle.Solid - } : { width: 0 }) - .onFocus(() => { - if (!this.item.isEnabled) { - return - } - this.isOnFocus = true - }) - .onBlur(() => this.isOnFocus = false) - .onHover((isOn) => { - if (!this.item.isEnabled) { - return - } - this.isOnHover = isOn - }) - .onKeyEvent((event) => { - if (!this.item.isEnabled) { - return - } - if (event.keyCode !== KeyCode.KEYCODE_ENTER && event.keyCode !== KeyCode.KEYCODE_SPACE) { - return - } - if (event.type === KeyType.Down) { - this.isOnClick = true - } - if (event.type === KeyType.Up) { - this.isOnClick = false - } - }) - .onTouch((event) => { - if (!this.item.isEnabled) { - return - } - if (event.type === TouchType.Down) { - this.isOnClick = true - } - if (event.type === TouchType.Up) { - this.isOnClick = false - } - }) - .onClick(() => this.item.isEnabled && this.item.action && this.item.action()) - } -} - -export default { EditableLeftIconType, EditableTitleBar } \ No newline at end of file diff --git a/source/Filter/Filter.ets b/source/Filter/Filter.ets deleted file mode 100644 index eaddb3b2b8325947a362e74b373fadd4fe68f8d8..0000000000000000000000000000000000000000 --- a/source/Filter/Filter.ets +++ /dev/null @@ -1,1025 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import measure from '@ohos.measure' -import curves from '@ohos.curves' - -const TEXT_HOT_AREA_WIDTH: number = 8 -const LIST_ROW_HEIGHT: number = 40 -const ARROW_IMG_SIZE: number = 24 -const MULTI_LINE_PADDING: number = 24 -const BAR_ANIMATION_DURATION: number = 150 -const ARROW_ANIMATION_DURATION: number = 200 -const ANIMATION_DURATION_250: number = 250 -const ANIMATION_DURATION_100: number = 100 -const FILTER_TOP_PADDING: number = 8 -const SEPARATOR_HEIGHT: number = 16 -const SEPARATOR_WIDTH: number = 1 -const FLOAT_OPACITY: number = 0.95 -const FILTER_FONT_SIZE = 12 -const FOCUS_BORDER_WIDTH = 2 -const ARROW_SHOW_DELAY = 300 -const PERCENT_100: Length = '100%' -const SHARP_CUBIC_BEZIER = curves.cubicBezierCurve(0.33, 0, 0.67, 1) -const INTER_POLATING_SPRING = curves.interpolatingSpring(0, 1, 328, 34) -const FRICTION_CUBIC_BEZIER = curves.cubicBezierCurve(0.2, 0, 0.2, 1) -const TRANS_COLOR: string = '#00FFFFFF' - -export enum FilterType { - MULTI_LINE_FILTER, - LIST_FILTER -} - -export declare type FilterParams = { - name: ResourceStr, - options: Array -} - -export declare type FilterResult = { - name: ResourceStr, - index: number, - value: ResourceStr -} - -@Observed -class FontWeightArray extends Array { -} - -@Observed -class ResourceArray extends Array { -} - -@Observed -class BooleanArray extends Array { -} - -@Observed -export class ObservedBoolean { - public value: boolean - - constructor(value: boolean) { - this.value = value - } -} - -@Observed -class ObservedNumber { - public value: number - - constructor(value: number) { - this.value = value - } -} - -@Component -struct ListFilterRow { - @ObjectLink colorRow: ResourceArray - @ObjectLink fontWeightRow: FontWeightArray - @ObjectLink backgroundColorRow: ResourceArray - @ObjectLink isBackgroundHoverRow: BooleanArray - filterRow: FilterParams - onItemClick: (colIndex: number) => void - - build() { - List() { - ForEach(this.filterRow.options, (option, colIndex?: number) => { - ListItem() { - Text(option.toString()) - .fontSize($r('sys.float.ohos_id_text_size_body3')) - .fontColor(this.colorRow[colIndex]) - .fontWeight(this.fontWeightRow[colIndex]) - .focusable(true) - } - .height(PERCENT_100) - .onClick(() => { - this.onItemClick(colIndex) - }) - .focusable(true) - .stateStyles({ - focused: { - .border({ - radius: $r('sys.float.ohos_id_corner_radius_clicked'), - width: FOCUS_BORDER_WIDTH, - color: $r('sys.color.ohos_id_color_focused_outline'), - style: BorderStyle.Solid - }) - .padding({ - left: TEXT_HOT_AREA_WIDTH - FOCUS_BORDER_WIDTH, - right: TEXT_HOT_AREA_WIDTH - FOCUS_BORDER_WIDTH - }) - }, - normal: { - .border({ - radius: $r('sys.float.ohos_id_corner_radius_clicked'), - width: 0 }) - .padding({ left: TEXT_HOT_AREA_WIDTH, right: TEXT_HOT_AREA_WIDTH }) - } - }) - .backgroundColor(this.isBackgroundHoverRow[colIndex] ? this.backgroundColorRow[colIndex] : TRANS_COLOR) - .onHover((isHover: boolean) => { - animateTo({ - curve: FRICTION_CUBIC_BEZIER, - duration: ANIMATION_DURATION_250 - }, () => { - if (isHover) { - this.backgroundColorRow[colIndex] = $r('sys.color.ohos_id_color_hover') - this.isBackgroundHoverRow[colIndex] = true - } else { - this.isBackgroundHoverRow[colIndex] = false - } - }) - }) - .onTouch((event) => { - if (event.type === TouchType.Down) { - animateTo({ - curve: SHARP_CUBIC_BEZIER, - duration: ANIMATION_DURATION_100 - }, () => { - this.backgroundColorRow[colIndex] = $r('sys.color.ohos_id_color_click_effect') - this.isBackgroundHoverRow[colIndex] = true - }) - } else if (event.type === TouchType.Up) { - animateTo({ - curve: SHARP_CUBIC_BEZIER, - duration: ANIMATION_DURATION_100 - }, () => { - this.isBackgroundHoverRow[colIndex] = false - }) - } - }) - }) - } - .listDirection(Axis.Horizontal) - .margin({ left: -TEXT_HOT_AREA_WIDTH * 2 }) - .scrollBar(BarState.Off) - .width(PERCENT_100) - .height(LIST_ROW_HEIGHT) - .align(Alignment.Start) - } -} - -@Component -struct MultiFilterRow { - @ObjectLink colorRow: ResourceArray - @ObjectLink fontWeightRow: FontWeightArray - @ObjectLink backgroundColorRow: ResourceArray - @ObjectLink isBackgroundHoverRow: BooleanArray - @ObjectLink twoLineModeItemNumRow: ObservedNumber - @ObjectLink twoLineModeItemNumRecordRow: ObservedNumber - @ObjectLink arrowShowStateRow: ObservedBoolean - @ObjectLink isArrowIconDown: ObservedBoolean - filterRow: FilterParams = null - onItemClick: (colIndex: number) => void - @State arrowBgColorRow: Resource = $r('sys.color.ohos_id_color_hover') - @State isArrowBgHoverRow: boolean = false - private filterColumnWidth: number = 0 - - private calcMultiFilterRowItemNum() { - var curLineRetainWidth = this.filterColumnWidth - vp2px(MULTI_LINE_PADDING) - var curLineSum = 0 - var curLine = 1 - for (var i = 0; i < this.filterRow.options.length; i++) { - let option = this.filterRow.options[i] - let itemWidth = measure.measureText({ - textContent: option, - fontSize: FILTER_FONT_SIZE - }) - if (i === 0) { - continue - } else { - itemWidth += vp2px(TEXT_HOT_AREA_WIDTH * 2) - } - if (curLineRetainWidth - itemWidth > 0) { - curLineRetainWidth -= itemWidth - curLineSum += 1 - } else { - if (curLineSum === 0) { - curLineSum++ - curLineRetainWidth = 0 - } - if (curLine === 1) { - curLine += 1 - curLineRetainWidth = this.filterColumnWidth - vp2px(ARROW_IMG_SIZE) - vp2px(MULTI_LINE_PADDING) - i-- - } else { - break - } - } - } - return curLineSum - } - - @Builder DownAndUpArrow() { - Row() { - Image(this.isArrowIconDown.value ? $r('sys.media.ohos_ic_public_arrow_down') : $r('sys.media.ohos_ic_public_arrow_up')) - .width(ARROW_IMG_SIZE) - .height(LIST_ROW_HEIGHT) - .fillColor($r('sys.color.ohos_id_color_tertiary')) - .focusable(true) - .stateStyles({ - focused: { - .border({ - radius: $r('sys.float.ohos_id_corner_radius_clicked'), - width: FOCUS_BORDER_WIDTH, - color: $r('sys.color.ohos_id_color_focused_outline'), - style: BorderStyle.Solid - }) - .width(ARROW_IMG_SIZE + FOCUS_BORDER_WIDTH * 2) - .offset({ x: -FOCUS_BORDER_WIDTH }) - }, - normal: { - .border({ - radius: $r('sys.float.ohos_id_corner_radius_clicked'), - width: 0 }) - .width(ARROW_IMG_SIZE) - .offset({ x: 0 }) - } - }) - } - .border({ - radius: $r('sys.float.ohos_id_corner_radius_clicked') - }) - .height(LIST_ROW_HEIGHT) - .width(ARROW_IMG_SIZE) - .backgroundColor(this.isArrowBgHoverRow ? this.arrowBgColorRow : TRANS_COLOR) - .focusable(true) - .visibility(this.arrowShowStateRow.value ? Visibility.Visible : Visibility.Hidden) - .onHover((isHover: boolean) => { - animateTo({ - curve: FRICTION_CUBIC_BEZIER, - duration: ANIMATION_DURATION_250 - }, () => { - if (isHover) { - this.arrowBgColorRow = $r('sys.color.ohos_id_color_hover') - this.isArrowBgHoverRow = true - } else { - this.isArrowBgHoverRow = false - } - }) - }) - .onTouch((event) => { - if (event.type === TouchType.Down) { - animateTo({ - curve: SHARP_CUBIC_BEZIER, - duration: ANIMATION_DURATION_100 - }, () => { - this.arrowBgColorRow = $r('sys.color.ohos_id_color_click_effect') - this.isArrowBgHoverRow = true - }) - } else if (event.type === TouchType.Up) { - animateTo({ - curve: SHARP_CUBIC_BEZIER, - duration: ANIMATION_DURATION_100 - }, () => { - this.isArrowBgHoverRow = false - }) - } - }) - .onClick(() => { - if (this.isArrowIconDown.value) { - this.isArrowIconDown.value = false - this.arrowShowStateRow.value = false - animateTo({ - curve: INTER_POLATING_SPRING, - }, () => { - this.twoLineModeItemNumRow.value = this.filterRow.options.length - }) - - animateTo({ - delay: 300, - duration: ARROW_ANIMATION_DURATION, - curve: SHARP_CUBIC_BEZIER - }, () => { - this.arrowShowStateRow.value = true - }) - } else { - this.isArrowIconDown.value = true - this.arrowShowStateRow.value = false - - animateTo({ - curve: INTER_POLATING_SPRING, - }, () => { - this.twoLineModeItemNumRow.value = this.twoLineModeItemNumRecordRow.value - }) - animateTo({ - delay: ARROW_SHOW_DELAY, - duration: ARROW_ANIMATION_DURATION, - curve: SHARP_CUBIC_BEZIER - }, () => { - this.arrowShowStateRow.value = true - }) - } - - }) - - } - - build() { - Row() { - if (this.filterRow.options && this.filterRow.options.length > 0) { - Text(this.filterRow.options[0].toString()) - .height(LIST_ROW_HEIGHT) - .width(px2vp(measure.measureText({ - textContent: this.filterRow.options[0].toString(), - fontSize: FILTER_FONT_SIZE - })) + (TEXT_HOT_AREA_WIDTH * 2)) - .margin({ left: -TEXT_HOT_AREA_WIDTH }) - .fontSize($r('sys.float.ohos_id_text_size_body3')) - .fontColor(this.colorRow[0]) - .fontWeight(this.fontWeightRow[0]) - .backgroundColor(this.isBackgroundHoverRow[0] ? this.backgroundColorRow[0] : TRANS_COLOR) - .onClick(() => { - this.onItemClick(0) - }) - .focusable(true) - .onHover((isHover: boolean) => { - animateTo({ - curve: FRICTION_CUBIC_BEZIER, - duration: ANIMATION_DURATION_250 - }, () => { - if (isHover) { - this.backgroundColorRow[0] = $r('sys.color.ohos_id_color_hover') - this.isBackgroundHoverRow[0] = true - } else { - this.isBackgroundHoverRow[0] = false - } - }) - }) - .onTouch((event) => { - if (event.type === TouchType.Down) { - animateTo({ - curve: SHARP_CUBIC_BEZIER, - duration: ANIMATION_DURATION_100 - }, () => { - this.backgroundColorRow[0] = $r('sys.color.ohos_id_color_click_effect') - this.isBackgroundHoverRow[0] = true - }) - } else if (event.type === TouchType.Up) { - animateTo({ - curve: SHARP_CUBIC_BEZIER, - duration: ANIMATION_DURATION_100 - }, () => { - this.isBackgroundHoverRow[0] = false - }) - } - }) - .stateStyles({ - focused: { - .border({ - radius: $r('sys.float.ohos_id_corner_radius_clicked'), - width: FOCUS_BORDER_WIDTH, - color: $r('sys.color.ohos_id_color_focused_outline'), - style: BorderStyle.Solid - }) - .padding({ - left: TEXT_HOT_AREA_WIDTH - FOCUS_BORDER_WIDTH, - right: TEXT_HOT_AREA_WIDTH - FOCUS_BORDER_WIDTH - }) - }, - normal: { - .border({ - radius: $r('sys.float.ohos_id_corner_radius_clicked'), - width: 0 }) - .padding({ left: TEXT_HOT_AREA_WIDTH, right: TEXT_HOT_AREA_WIDTH }) - } - }) - } - Row() { - Flex({ direction: FlexDirection.Row, wrap: FlexWrap.Wrap }) { - ForEach(this.filterRow.options.slice(0, this.twoLineModeItemNumRow.value + 1), (option, colIndex?: number) => { - if (colIndex > 0) { - Text(option.toString()) - .transition(TransitionEffect.OPACITY) - .fontSize($r('sys.float.ohos_id_text_size_body3')) - .height(LIST_ROW_HEIGHT) - .fontColor(this.colorRow[colIndex]) - .fontWeight(this.fontWeightRow[colIndex]) - .backgroundColor(this.isBackgroundHoverRow[colIndex] ? this.backgroundColorRow[colIndex] : TRANS_COLOR) - .onClick(() => { - this.onItemClick(colIndex) - }) - .onHover((isHover: boolean) => { - animateTo({ - curve: FRICTION_CUBIC_BEZIER, - duration: ANIMATION_DURATION_250 - }, () => { - if (isHover) { - this.backgroundColorRow[colIndex] = $r('sys.color.ohos_id_color_hover') - this.isBackgroundHoverRow[colIndex] = true - } else { - this.isBackgroundHoverRow[colIndex] = false - } - }) - }) - .onTouch((event) => { - if (event.type === TouchType.Down) { - animateTo({ - curve: SHARP_CUBIC_BEZIER, - duration: ANIMATION_DURATION_100 - }, () => { - this.backgroundColorRow[colIndex] = $r('sys.color.ohos_id_color_click_effect') - this.isBackgroundHoverRow[colIndex] = true - }) - } else if (event.type === TouchType.Up) { - animateTo({ - curve: SHARP_CUBIC_BEZIER, - duration: ANIMATION_DURATION_100 - }, () => { - this.isBackgroundHoverRow[colIndex] = false - }) - } - }) - .focusable(true) - .stateStyles({ - focused: { - .border({ - radius: $r('sys.float.ohos_id_corner_radius_clicked'), - width: FOCUS_BORDER_WIDTH, - color: $r('sys.color.ohos_id_color_focused_outline'), - style: BorderStyle.Solid - }) - .padding({ - left: TEXT_HOT_AREA_WIDTH - FOCUS_BORDER_WIDTH, - right: TEXT_HOT_AREA_WIDTH - FOCUS_BORDER_WIDTH - }) - }, - normal: { - .border({ - radius: $r('sys.float.ohos_id_corner_radius_clicked'), - width: 0 }) - .padding({ left: TEXT_HOT_AREA_WIDTH, right: TEXT_HOT_AREA_WIDTH }) - } - }) - } - }) - this.DownAndUpArrow() - }.alignSelf(ItemAlign.Stretch) - }.width(PERCENT_100) - .padding({ right: $r('sys.float.ohos_id_max_padding_end') }) - .onAreaChange((_oldValue: Area, newValue: Area) => { - this.filterColumnWidth = vp2px(parseInt(newValue.width.toString(), 0)) - if (this.twoLineModeItemNumRow.value === 0) { - var curLineSum = this.calcMultiFilterRowItemNum() - this.twoLineModeItemNumRow.value = curLineSum - this.twoLineModeItemNumRecordRow.value = curLineSum - if (curLineSum < this.filterRow.options.length - 1) { - this.arrowShowStateRow.value = true - } else { - this.arrowShowStateRow.value = false - } - } - }) - - }.width(PERCENT_100) - .alignItems(VerticalAlign.Top) - .padding({ left: $r('sys.float.ohos_id_max_padding_start'), right: $r('sys.float.ohos_id_max_padding_end') }) - } -} - - -@Component -export struct Filter { - @BuilderParam container: () => void - @Prop multiFilters: Array = [] - @Prop additionFilters: FilterParams = null - onFilterChanged: (filterResults: Array) => void = null - @Prop filterType: FilterType = FilterType.LIST_FILTER - private selectedFilters: Array = null - @State private colorArr: Array = null - @State private fontWeightArr: Array = null - @State private backgroundColorArr: Array = null - @State private isBackgroundHover: Array = null - @State private floatArrowBgColor: Resource = null - @State private isFloatArrowBgHover: boolean = false - @State private isArrowIconDownArr: Array = null - @State private additionColorArr: Array = null - @State private additionFontWeightArr: Array = null - @State private additionBackgroundColorArr: Array = null - @State private isAdditionBackgroundHover: Array = null - @State colorRefresh: boolean = false - @State isFloatBarShow: boolean = false - isFloatBarShowWithoutAnimation: boolean = false - @State isFloatShowAllFilter: boolean = false - isFloatShowAllFilterWithoutAnimation: boolean = false - @State floatFilterPosition: number = 0 - @State floatFilterBarHeight: number = 0 - @State floatFilterBarPosition: number = 0 - filterDynamicHeight: number = 0 - @State twoLineModeItemNum: Array = null - @State twoLineModeItemNumRecord: Array = null - @State downArrowShowState: Array = null - - textColor(rowIndex: number, colIndex: number) { - if (this.selectedFilters.length > rowIndex && this.selectedFilters[rowIndex].index === colIndex) { - return $r('sys.color.ohos_id_color_text_primary_activated') - } - return $r('sys.color.ohos_id_color_text_primary') - } - - aboutToAppear() { - this.initParams() - } - - private filterItemClick(rowIndex: number, colIndex: number) { - let selectedFilterValue = this.multiFilters[rowIndex].options[colIndex] - if (colIndex != this.selectedFilters[rowIndex].index) { - this.colorArr[rowIndex][colIndex] = $r('sys.color.ohos_id_color_text_primary_activated') - this.colorArr[rowIndex][this.selectedFilters[rowIndex].index] = $r('sys.color.ohos_id_color_text_primary') - this.fontWeightArr[rowIndex][colIndex] = FontWeight.Medium - this.fontWeightArr[rowIndex][this.selectedFilters[rowIndex].index] = FontWeight.Regular - this.colorRefresh = !this.colorRefresh - this.selectedFilters[rowIndex].value = selectedFilterValue - this.selectedFilters[rowIndex].index = colIndex - this.onFilterChanged && this.onFilterChanged(this.selectedFilters); - } - } - - private initParams() { - if (!this.selectedFilters) { - this.selectedFilters = [] - for (let filter of this.multiFilters) { - var result: FilterResult = { name: filter.name, index: -1, value: null } - if (filter.options.length > 0) { - result.index = 0 - result.value = filter.options[0] - } - this.selectedFilters.push(result) - } - if (this.additionFilters && this.additionFilters.name) { - var result: FilterResult = { name: this.additionFilters.name, index: -1, value: null } - this.selectedFilters.push(result) - } - } - if (!this.colorArr) { - this.colorArr = [] - this.backgroundColorArr = [] - this.isBackgroundHover = [] - this.fontWeightArr = [] - this.isArrowIconDownArr = [] - this.floatArrowBgColor = $r('sys.color.ohos_id_color_hover') - for (let filter of this.multiFilters) { - var colorRow = new ResourceArray() - var fontWeightRow = new FontWeightArray() - var backgroundColorRow = new ResourceArray() - var isBackgroundHoverRow = new BooleanArray() - for (let index of filter.options.keys()) { - if (index === 0) { - colorRow.push($r('sys.color.ohos_id_color_text_primary_activated')) - fontWeightRow.push(FontWeight.Medium) - } else { - colorRow.push($r('sys.color.ohos_id_color_text_primary')) - fontWeightRow.push(FontWeight.Regular) - } - backgroundColorRow.push($r('sys.color.ohos_id_color_hover')) - } - this.colorArr.push(colorRow) - this.fontWeightArr.push(fontWeightRow) - this.backgroundColorArr.push(backgroundColorRow) - this.isBackgroundHover.push(isBackgroundHoverRow) - this.isArrowIconDownArr.push(new ObservedBoolean(true)) - } - } - if (this.additionFilters && this.additionFilters.options) { - this.additionColorArr = [] - this.additionFontWeightArr = [] - this.additionBackgroundColorArr = [] - this.isAdditionBackgroundHover = [] - for (let i = 0; i < this.additionFilters.options.length; i++) { - this.additionColorArr.push($r('sys.color.ohos_id_color_text_primary')) - this.additionFontWeightArr.push(FontWeight.Regular) - this.additionBackgroundColorArr.push($r('sys.color.ohos_id_color_hover')) - this.isAdditionBackgroundHover.push(false) - } - } - if (!this.twoLineModeItemNum) { - this.twoLineModeItemNum = [] - this.twoLineModeItemNumRecord = [] - this.downArrowShowState = [] - for (let i = 0; i < this.multiFilters.length; i++) { - this.twoLineModeItemNum.push(new ObservedNumber(0)) - this.twoLineModeItemNumRecord.push(new ObservedNumber(0)) - this.downArrowShowState.push(new ObservedBoolean(false)) - } - } - } - - @Builder ListFilter() { - Column() { - ForEach(this.multiFilters, (filter: FilterParams, rowIndex?: number) => { - ListFilterRow({ - colorRow: this.colorArr[rowIndex], - fontWeightRow: this.fontWeightArr[rowIndex], - backgroundColorRow: this.backgroundColorArr[rowIndex], - isBackgroundHoverRow: this.isBackgroundHover[rowIndex], - filterRow: filter, - onItemClick: (colIndex: number) => { - this.filterItemClick(rowIndex, colIndex); - } - }) - }) - }.width(PERCENT_100) - .align(Alignment.Start) - .padding({ left: $r('sys.float.ohos_id_max_padding_start') }) - .onAreaChange((_oldValue: Area, newValue: Area) => { - if (!this.isFloatShowAllFilterWithoutAnimation && !this.isFloatBarShowWithoutAnimation) { - if (this.additionFilters != null) { - this.filterDynamicHeight = parseInt(newValue.height.toString(), 0) + LIST_ROW_HEIGHT + FILTER_TOP_PADDING - } else { - this.filterDynamicHeight = parseInt(newValue.height.toString(), 0) + FILTER_TOP_PADDING - } - this.floatFilterPosition = -this.filterDynamicHeight - } - }) - } - - @Builder MultiLineFilter() { - Column() { - ForEach(this.multiFilters, (filterItem: FilterParams, rowIndex?: number) => { - MultiFilterRow({ - colorRow: this.colorArr[rowIndex], - fontWeightRow: this.fontWeightArr[rowIndex], - backgroundColorRow: this.backgroundColorArr[rowIndex], - isBackgroundHoverRow: this.isBackgroundHover[rowIndex], - arrowShowStateRow: this.downArrowShowState[rowIndex], - twoLineModeItemNumRow: this.twoLineModeItemNum[rowIndex], - twoLineModeItemNumRecordRow: this.twoLineModeItemNumRecord[rowIndex], - isArrowIconDown: this.isArrowIconDownArr[rowIndex], - filterRow: filterItem, - onItemClick: (colIndex: number) => { - this.filterItemClick(rowIndex, colIndex); - } - }) - }) - }.width(PERCENT_100) - .onAreaChange((_oldValue: Area, newValue: Area) => { - if (this.additionFilters != null) { - this.filterDynamicHeight = parseInt(newValue.height.toString(), 0) + LIST_ROW_HEIGHT + FILTER_TOP_PADDING - } else { - this.filterDynamicHeight = parseInt(newValue.height.toString(), 0) + FILTER_TOP_PADDING - } - if (!this.isFloatBarShowWithoutAnimation && !this.isFloatShowAllFilterWithoutAnimation) { - this.floatFilterPosition = -this.filterDynamicHeight - } - }) - } - - private additionItemClick(index: number) { - let additionRowIndex = this.multiFilters.length - if (this.selectedFilters[additionRowIndex].index != index) { - if (this.selectedFilters[additionRowIndex].index === -1) { - this.additionColorArr[index] = $r('sys.color.ohos_id_color_text_primary_activated') - this.additionFontWeightArr[index] = FontWeight.Medium - this.selectedFilters[additionRowIndex].value = this.additionFilters.options[index] - this.selectedFilters[additionRowIndex].index = index - } else { - let lastIndex = this.selectedFilters[additionRowIndex].index - this.additionColorArr[lastIndex] = $r('sys.color.ohos_id_color_text_primary') - this.additionColorArr[index] = $r('sys.color.ohos_id_color_text_primary_activated') - this.additionFontWeightArr[lastIndex] = FontWeight.Regular - this.additionFontWeightArr[index] = FontWeight.Medium - this.selectedFilters[additionRowIndex].value = this.additionFilters.options[index] - this.selectedFilters[additionRowIndex].index = index - } - } else { - this.additionColorArr[index] = $r('sys.color.ohos_id_color_text_primary') - this.additionFontWeightArr[index] = FontWeight.Regular - this.selectedFilters[additionRowIndex].value = null - this.selectedFilters[additionRowIndex].index = -1 - } - this.onFilterChanged && this.onFilterChanged(this.selectedFilters) - this.colorRefresh = !this.colorRefresh - } - - @Builder AdditionFilterList() { - if (this.additionFilters && this.additionFilters.name && this.additionFilters.options && this.additionFilters.options.length != 0) { - List() { - ListItem() { - Row() { - Text(this.additionFilters.name.toString()) - .fontSize($r('sys.float.ohos_id_text_size_body3')) - .fontColor($r('sys.color.ohos_id_color_text_secondary')) - .margin({ left: TEXT_HOT_AREA_WIDTH, right: TEXT_HOT_AREA_WIDTH }) - Row() - .width(SEPARATOR_WIDTH) - .height(SEPARATOR_HEIGHT) - .backgroundColor($r('sys.color.ohos_id_color_list_separator')) - } - }.height(PERCENT_100) - - ForEach(this.additionFilters.options, (option, index?: number) => { - ListItem() { - Text(option.toString()) - .fontSize($r('sys.float.ohos_id_text_size_body3')) - .fontColor(this.additionColorArr[index]) - .fontWeight(this.additionFontWeightArr[index]) - .focusable(true) - } - .height(PERCENT_100) - .backgroundColor(this.isAdditionBackgroundHover[index] ? this.additionBackgroundColorArr[index] : TRANS_COLOR) - .onHover((isHover: boolean) => { - animateTo({ - curve: FRICTION_CUBIC_BEZIER, - duration: ANIMATION_DURATION_250 - }, () => { - if (isHover) { - this.additionBackgroundColorArr[index] = $r('sys.color.ohos_id_color_hover') - this.isAdditionBackgroundHover[index] = true - } else { - this.isAdditionBackgroundHover[index] = false - } - }) - }) - .onTouch((event) => { - if (event.type === TouchType.Down) { - animateTo({ - curve: SHARP_CUBIC_BEZIER, - duration: ANIMATION_DURATION_100 - }, () => { - this.additionBackgroundColorArr[index] = $r('sys.color.ohos_id_color_click_effect') - this.isAdditionBackgroundHover[index] = true - }) - } else if (event.type === TouchType.Up) { - animateTo({ - curve: SHARP_CUBIC_BEZIER, - duration: ANIMATION_DURATION_100 - }, () => { - this.isAdditionBackgroundHover[index] = false - }) - } - }) - .focusable(true) - .stateStyles({ - focused: { - .border({ - radius: $r('sys.float.ohos_id_corner_radius_clicked'), - width: FOCUS_BORDER_WIDTH, - color: $r('sys.color.ohos_id_color_focused_outline'), - style: BorderStyle.Solid - }) - .padding({ - left: TEXT_HOT_AREA_WIDTH - FOCUS_BORDER_WIDTH, - right: TEXT_HOT_AREA_WIDTH - FOCUS_BORDER_WIDTH - }) - }, - normal: { - .border({ - radius: $r('sys.float.ohos_id_corner_radius_clicked'), - width: 0 }) - .padding({ left: TEXT_HOT_AREA_WIDTH, right: TEXT_HOT_AREA_WIDTH }) - } - }) - .onClick(() => { - this.additionItemClick(index) - }) - }) - } - .listDirection(Axis.Horizontal) - .scrollBar(BarState.Off) - .padding({ left: $r('sys.float.ohos_id_max_padding_start') }) - .margin({ left: -TEXT_HOT_AREA_WIDTH * 2 }) - .width(PERCENT_100) - .height(LIST_ROW_HEIGHT) - } - - } - - @Builder FilterHeader() { - Column() { - if (this.filterType === FilterType.LIST_FILTER) { - this.ListFilter() - } else { - this.MultiLineFilter() - } - this.AdditionFilterList() - }.padding({ top: FILTER_TOP_PADDING }) - .onVisibleAreaChange([0.0, 1.0], (_isVisible: boolean, currentRatio: number) => { - if (currentRatio > 0) { - this.isFloatShowAllFilter = false - this.isFloatShowAllFilterWithoutAnimation = false - this.isFloatBarShowWithoutAnimation = false - animateTo({ - curve: INTER_POLATING_SPRING, - onFinish: () => { - if (!this.isFloatBarShowWithoutAnimation) { - this.isFloatBarShow = false - } - } - }, () => { - this.floatFilterBarHeight = 0 - }) - } else { - this.isFloatBarShow = true - this.isFloatBarShowWithoutAnimation = true - animateTo({ - curve: INTER_POLATING_SPRING - }, () => { - this.floatFilterBarHeight = LIST_ROW_HEIGHT + FILTER_TOP_PADDING - }) - } - }) - } - - @Builder FloatFilterHeader() { - Column() { - if (this.filterType === FilterType.LIST_FILTER) { - this.ListFilter() - } else { - this.MultiLineFilter() - } - this.AdditionFilterList() - } - .padding({ top: FILTER_TOP_PADDING }) - .width(PERCENT_100) - .clip(true) - .backgroundColor($r('sys.color.ohos_id_color_background')) - .opacity(FLOAT_OPACITY) - .backgroundBlurStyle(BlurStyle.Thin) - .visibility(this.isFloatShowAllFilter ? Visibility.Visible : Visibility.Hidden) - .position({ x: 0, y: this.floatFilterPosition }) - .zIndex(2) - } - - @Builder FloatFilterBar() { - Row() { - Column() { - Row() { - ForEach(this.selectedFilters.slice(0, this.colorRefresh ? this.selectedFilters.length : this.selectedFilters.length), (selected, index?: number) => { - if (index != 0 && selected.value != null) { - Text('/') - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .fontSize($r('sys.float.ohos_id_text_size_body3')) - } - Text(selected.value) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .fontSize($r('sys.float.ohos_id_text_size_body3')) - }) - }.height(PERCENT_100) - .alignItems(VerticalAlign.Center) - } - .alignItems(HorizontalAlign.Center) - .width(PERCENT_100) - .height(LIST_ROW_HEIGHT) - - Row() { - Image($r('sys.media.ohos_ic_public_arrow_down')) - .width(ARROW_IMG_SIZE) - .height(ARROW_IMG_SIZE) - .fillColor($r('sys.color.ohos_id_color_tertiary')) - .focusable(true) - } - .height(LIST_ROW_HEIGHT) - .margin({ left: -ARROW_IMG_SIZE }) - .backgroundColor(this.isFloatArrowBgHover ? this.floatArrowBgColor : TRANS_COLOR) - .focusable(true) - .stateStyles({ - focused: { - .border({ - radius: $r('sys.float.ohos_id_corner_radius_clicked'), - width: FOCUS_BORDER_WIDTH, - color: $r('sys.color.ohos_id_color_focused_outline'), - style: BorderStyle.Solid - }) - .width(ARROW_IMG_SIZE + FOCUS_BORDER_WIDTH * 2) - .offset({ x: -FOCUS_BORDER_WIDTH }) - }, - normal: { - .border({ - radius: $r('sys.float.ohos_id_corner_radius_clicked'), - width: 0 }) - .width(ARROW_IMG_SIZE) - .offset({ x: 0 }) - } - }) - .onHover((isHover: boolean) => { - if (isHover) { - animateTo({ - curve: FRICTION_CUBIC_BEZIER, - duration: ANIMATION_DURATION_250 - }, () => { - this.floatArrowBgColor = $r('sys.color.ohos_id_color_hover') - this.isFloatArrowBgHover = true - }) - } else { - animateTo({ - curve: FRICTION_CUBIC_BEZIER, - duration: ANIMATION_DURATION_250 - }, () => { - this.isFloatArrowBgHover = false - }) - } - }) - .onTouch((event) => { - if (event.type === TouchType.Down) { - animateTo({ - curve: SHARP_CUBIC_BEZIER, - duration: ANIMATION_DURATION_100 - }, () => { - this.floatArrowBgColor = $r('sys.color.ohos_id_color_click_effect') - this.isFloatArrowBgHover = true - }) - } else if (event.type === TouchType.Up) { - animateTo({ - curve: SHARP_CUBIC_BEZIER, - duration: ANIMATION_DURATION_100 - }, () => { - this.isFloatArrowBgHover = false - }) - } - }) - .onClick(() => { - animateTo({ - duration: BAR_ANIMATION_DURATION, - curve: SHARP_CUBIC_BEZIER - }, () => { - this.isFloatBarShow = false - this.isFloatBarShowWithoutAnimation = false - }) - this.isFloatShowAllFilter = true - this.isFloatShowAllFilterWithoutAnimation = true - animateTo({ - curve: INTER_POLATING_SPRING - }, () => { - this.floatFilterPosition = 0 - this.floatFilterBarPosition = this.filterDynamicHeight - }) - }) - } - .width(PERCENT_100) - .padding({ right: $r('sys.float.ohos_id_max_padding_end') }) - .height(this.floatFilterBarHeight) - .backgroundColor($r('sys.color.ohos_id_color_background')) - .opacity(FLOAT_OPACITY) - .clip(true) - .backgroundBlurStyle(BlurStyle.Thin) - .visibility(this.isFloatBarShow ? Visibility.Visible : Visibility.Hidden) - .alignItems(VerticalAlign.Bottom) - .position({ x: 0, y: this.floatFilterBarPosition }) - .zIndex(1) - } - - private listScroller: Scroller = new Scroller() - - build() { - Stack({ alignContent: Alignment.Top }) { - this.FloatFilterBar(); - this.FloatFilterHeader(); - Column() { - List({ initialIndex: 0, scroller: this.listScroller }) { - ListItem() { - this.FilterHeader() - }.focusable(true) - .onFocus(() => { - this.listScroller.scrollToIndex(0, true) - }) - - ListItem() { - this.container() - }.focusable(true) - .onFocus(() => { - this.listScroller.scrollToIndex(1, true) - }) - } - .listDirection(Axis.Vertical) - .width(PERCENT_100) - .height(PERCENT_100) - .edgeEffect(EdgeEffect.Spring) - .onScroll((_scrollOffset: number, scrollState: ScrollState) => { - if (this.isFloatShowAllFilterWithoutAnimation && scrollState == ScrollState.Scroll) { - this.isFloatBarShowWithoutAnimation = true - this.isFloatShowAllFilterWithoutAnimation = false - animateTo({ - duration: BAR_ANIMATION_DURATION, - curve: SHARP_CUBIC_BEZIER - }, () => { - this.isFloatBarShow = true - }) - - animateTo({ - curve: INTER_POLATING_SPRING, - onFinish: () => { - if (!this.isFloatShowAllFilterWithoutAnimation) { - this.isFloatShowAllFilter = false - } - } - }, () => { - this.floatFilterPosition = -this.filterDynamicHeight - this.floatFilterBarPosition = 0 - }) - } - }) - }.zIndex(0) - }.clip(true) - } -} \ No newline at end of file diff --git a/source/ProgressButton/ProgressButton.ets b/source/ProgressButton/ProgressButton.ets deleted file mode 100644 index 82f0d43c5b750c31f1034494de2c1625a0acb713..0000000000000000000000000000000000000000 --- a/source/ProgressButton/ProgressButton.ets +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const EMPTY_STRING: string = '' -const MAX_PROGRESS: number = 100 -const MAX_PERCENTAGE: string = '100%' -const MIN_PERCENTAGE: string = '0%' - -@Component -export struct ProgressButton { - @Prop @Watch('getProgressContext') progress: number - @State textProgress: string = EMPTY_STRING - @Prop content: string = EMPTY_STRING - @State isLoading: boolean = false - progressButtonWidth?: Length = 44 - clickCallback: () => void = null - @Prop enable: boolean = true - - private getButtonProgress(): number { - if (this.progress < 0) { - return 0 - } else if (this.progress > MAX_PROGRESS) { - return MAX_PROGRESS - } - return this.progress - } - - private getProgressContext() { - if (this.progress < 0) { - this.isLoading = false - this.textProgress = MIN_PERCENTAGE - } else if (this.progress >= MAX_PROGRESS) { - this.isLoading = false - this.textProgress = MAX_PERCENTAGE - } else { - this.textProgress = Math.floor(this.progress / MAX_PROGRESS * MAX_PROGRESS).toString() + "%" - } - } - - build() { - Button() { - Stack(){ - Progress({ value: this.getButtonProgress(), total: MAX_PROGRESS, - style: ProgressStyle.Capsule }) - .height(28) - .borderRadius(14) - .width('100%') - .hoverEffect(HoverEffect.None) - .clip(false) - .enabled(this.enable) - Row() { - Text(this.isLoading? this.textProgress: this.content) - .fontSize($r('sys.float.ohos_id_text_size_button3')) - .fontWeight(FontWeight.Medium) - .fontColor(this.isLoading? $r('sys.color.ohos_id_color_text_primary') - :$r('sys.color.ohos_id_color_emphasize')) - .maxLines(1) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .padding({left: 8, right: 8}) - .opacity(this.enable? 1.0: 0.4) - } - } - } - .borderRadius(14) - .clip(false) - .hoverEffect(HoverEffect.None) - .backgroundColor($r("sys.color.ohos_id_color_foreground_contrary")) - .border({ width: 0.5, color: this.enable ? $r("sys.color.ohos_id_color_toolbar_text_actived") - : $r('sys.color.ohos_id_color_foreground_contrary_disable') }) - .constraintSize({minWidth: 44}) - .width(this.progressButtonWidth < 44? 44: this.progressButtonWidth) - .stateEffect(this.enable) - .onClick(() => { - if(!this.enable){ - return - } - if (this.progress < MAX_PROGRESS) { - this.isLoading = !this.isLoading - } - this.clickCallback && this.clickCallback() - }) - } -} \ No newline at end of file diff --git a/source/SelectTitleBar/SelectTitleBar.ets b/source/SelectTitleBar/SelectTitleBar.ets deleted file mode 100755 index 15d82bbfe0528e508f4d19d76a8e364474c5edff..0000000000000000000000000000000000000000 --- a/source/SelectTitleBar/SelectTitleBar.ets +++ /dev/null @@ -1,383 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { KeyCode } from '@ohos.multimodalInput.keyCode' - -export declare type SelectTitleBarMenuItem = { - value: ResourceStr - isEnabled: boolean - action?: () => void -} - -const PUBLIC_MORE = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAY' + - 'AAABS3GwHAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAEZ0FNQQAAsY58+1GTAAA' + - 'AAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOxAAADsQBlSsOGwAABEZJREFUeNrt3D1rFFEUBuA' + - 'xhmAhFlYpUohYiYWFRcAmKAhWK2pjo1iKf8BCMIKFf8BarCyMhVj4VZhGSKEg2FqJyCKWIhYWnstMINgYsh+cmfs88BI' + - 'Cydxw7jmzu2HvNg0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADBN+3r6dx+LXIqsRpa7FF8j48hm5Fn3Peo9mAEYRdY' + - 'jJ3f582Vj7nZfUe/eDsCRyMPI2h5/fyNyI/JDT6v3Tvt7sBllE15ETkxwjeORi5G3ke/6W737MgBnI68jh6ZwrcORq5H' + - 'nhkC9+zAA5YXXy8jBKV5zKXIu8jjyS7+rd+YBeNVtyrSVO9PRyBM9r94LSTfjWuTUDK9/eYIXeENUbb0zDsBi5PYc1rm' + - 'j79U74wCszuih+F/ljrSi/+uud8YBGA10rayqrnfGAVgb6FpZVV3vjAOwPNC1sqq63hkHYGWga2VVdb0XKt/8Rf1fd70' + - 'zDsB4jmt5u3Tl9a59AMb6v+56ZxyArYGulVXV9c44ABtzXOup/q+73hkH4N2cHio/Rj7r/7rrnXEAfkfuz2Gddb2v3ln' + - '/DfpgxneLzaY9xE3l9c46AH8iVyI/Z3Dt8nB/Xc+rd5H5QMy3yJemPVs6zY0edc9HUe/0Z4I/dQ/N5Vjd0oTXKp9QcKF' + - 'pD2qj3r0YgO1NeRM507TH6/bifeR85IMeV++d+vTBWOV9JDcjt5rdv6uw3M3uRR7pa/Xu+wBsOxA53bTnTP/3UX1b3fN' + - 'Q1BsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKqyr6d/97HIpchqZLlL8TUyjmxGnnX' + - 'fo96DGYBRZD1ycpc/XzbmbvcV9e7tAByJPIys7fH3NyI3Ij/0tHrvtL8Hm1E24UXkxATXOB65GHkb+a6/1bsvA3A28jp' + - 'yaArXOhy5GnluCNS7DwNQXni9jByc4jWXIucijyO/9Lt6Zx6AV92mTFu5Mx2NPNHz6r2QdDOuRU7N8PqXJ3iBN0TV1jv' + - 'jACxGbs9hnTv6Xr0zDsDqjB6K/1XuSCv6v+56ZxyA0UDXyqrqemccgLWBrpVV1fXOOADLA10rq6rrnXEAVga6VlZV13u' + - 'h8s1f1P911zvjAIznuJa3S1de79oHYKz/6653xgHYGuhaWVVd74wDsDHHtZ7q/7rrnXEA3s3pofJj5LP+r7veGQfgd+T' + - '+HNZZ1/vqnfXfoA9mfLfYbNpD3FRe76wD8CdyJfJzBtcuD/fX9bx6F5kPxHyLfGnas6XT3OhR93wU9U5/JvhT99BcjtU' + - 'tTXit8gkFF5r2oDbq3YsB2N6UN5EzTXu8bi/eR85HPuhx9d6pTx+MVd5HcjNyq9n9uwrL3exe5JG+Vu++D8C2A5HTTXv' + - 'O9H8f1bfVPQ9FvQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgCn7C9HjBtwWfXpKAAAAAElFTkSuQmCC' - -const PUBLIC_BACK = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAY' + - 'AAABS3GwHAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAEZ0FNQQAAsY58+1GTAAAAA' + - 'XNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAA8VJREFUeNrt3LFLlHEYwPFXz0G' + - 'iIZpEoikkwsFRIiK3gqCigxIC/4Kmhv6OoChouaGoqKCgCKducGh0cDAIamhwiCaHCIeelztpUszee/vl8/nAM3Vd8nufr' + - '+fddVYVAAAAAAAAAAAAAAAAAAAAAABQijFH0KhrMd2Y2ZitmNWYRzHLjkYAB9lUzMOYizv8eS/mZsymoypLxxE0svzvY07' + - 'vcpu5mOmY145LAAdx+U/u4bZzwx+JPjq2cow7glaWf1vXsQkg6/JvPwoggJTLjwDSL/8nRyiAzN/5nzpGAWRd/n7MM0cpg' + - 'IzLvx6z6CjL453gdpZ/IWbDcQrA8iMAy48ALD8CsPwIwPIjAMuPACw/ArD8CMDyIwDLjwAsPwKw/AjA8iMAy48ALD8CsPw' + - 'IwPIjAMuPACw/ArD85A3A8pM2AMtP2gAsP2kDsPykDcDykzYAy0/aACw/aQOw/KQNwPKTNgDLT9oALD9pA7D8pA3A8pM2A' + - 'MtP2gAsP2kDsPykDcDykzYAy0/aACw/aQOw/KQNwPKTNgDLT9oALD9pA7D8pA3A8pM2AMtP2gAsP2kDsPykDcDykzYAy0/' + - 'aACw/aQOw/KQNwPLz3xlv6H4mYp5YfrI+AizF9BwnI/AlZi3mbsxy03feaeh+HsQcc60YgSMxMzE3YmZj3sX8LOlHoPoLn' + - 'HedaEE35n5pzwF856dN9SPBpZICmHRNaNnlkgL46nrQsvmSAqhftlx1TWjR4ZICqPVcE1q0XloA96rBa7XQhl5pAWzFXKm' + - '8i8vo9WMeN3VnnQa/sO8xL2POxEy7Toxo+RdjNpu6w1F9HuBqNXi99lw1eKMM9utHzIeYV8MftbccCQAAAAAAsBdt/XLc+s' + - 'Py9W+MmPqL+1iJuVA1+C4gdFr6d77FvK0GH2nb739lPR5zNuZ51eBnQhFAJQIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIE' + - 'IAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAI' + - 'EIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIEIAIE8M8jmBlGgABSRnAqZiXms+MUQNYIDnkUKMu4I/gj6z' + - 'ELMRv7/PsnHKEAMkcw6fgEkDmCNUcngMwRvHFsngRnfWJcL/9tRyaAgxrB+ZijO9ymH7MUs+m4yjLmCBozEXMr5nr1+9We1' + - 'ZgXMXccDwAAAAAAAAAAAAAAAAAAAAAAwO5+AfVgtqHKRnawAAAAAElFTkSuQmCC' - -@Component -export struct SelectTitleBar { - @State selected: number = 0 - - options: Array - menuItems: Array - - subtitle: ResourceStr - badgeValue: number - hidesBackButton: boolean - - onSelected: ((index: number) => void) - - private static readonly badgeSize = 16 - private static readonly totalHeight = 56 - private static readonly leftPadding = 24 - private static readonly leftPaddingWithBack = 12 - private static readonly rightPadding = 24 - private static readonly badgePadding = 16 - private static readonly subtitleLeftPadding = 8 - - @State selectMaxWidth: number = 0 - - build() { - Flex({ - justifyContent: FlexAlign.SpaceBetween, - alignItems: ItemAlign.Stretch - }) { - Row() { - if (!this.hidesBackButton) { - Navigator() { - ImageMenuItem({ item: { - value: PUBLIC_BACK, - isEnabled: true - } }) - } - } - Column() { - if (this.badgeValue !== undefined) { - Badge({ - count: this.badgeValue, - position: BadgePosition.Right, - style: { - badgeSize: SelectTitleBar.badgeSize, - badgeColor: $r('sys.color.ohos_id_color_emphasize'), - borderColor: $r('sys.color.ohos_id_color_emphasize'), - borderWidth: 0 - } - }) { - Row() { - Select(this.options) - .selected(this.selected) - .value(this.selected < this.options.length ? this.options[this.selected].value.toString() : "") - .font({ size: $r('sys.float.ohos_id_text_size_headline8') }) - .fontColor($r('sys.color.ohos_id_color_titlebar_text')) - .onSelect(this.onSelected) - .constraintSize({ maxWidth: this.selectMaxWidth }) - } - .justifyContent(FlexAlign.Start) - .margin({ right: $r('sys.float.ohos_id_elements_margin_horizontal_l') }) - } - } else { - Row() { - Select(this.options) - .selected(this.selected) - .value(this.selected < this.options.length ? this.options[this.selected].value.toString() : "") - .font({ size: $r('sys.float.ohos_id_text_size_headline8') }) - .fontColor($r('sys.color.ohos_id_color_titlebar_text')) - .onSelect(this.onSelected) - .constraintSize({ maxWidth: this.selectMaxWidth }) - } - .justifyContent(FlexAlign.Start) - } - if (this.subtitle !== undefined) { - Row() { - Text(this.subtitle) - .fontSize($r('sys.float.ohos_id_text_size_over_line')) - .fontColor($r('sys.color.ohos_id_color_titlebar_subtitle_text')) - .maxLines(1) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .constraintSize({ maxWidth: this.selectMaxWidth }) - } - .justifyContent(FlexAlign.Start) - .margin({ left: SelectTitleBar.subtitleLeftPadding }) - } - } - .justifyContent(FlexAlign.Start) - .alignItems(HorizontalAlign.Start) - .constraintSize({ maxWidth: this.selectMaxWidth }) - } - .margin({ left: this.hidesBackButton ? $r('sys.float.ohos_id_max_padding_start') : $r('sys.float.ohos_id_default_padding_start') }) - if (this.menuItems !== undefined && this.menuItems.length > 0) { - CollapsibleMenuSection({ menuItems: this.menuItems }) - } - } - .width('100%') - .height(SelectTitleBar.totalHeight) - .backgroundColor($r('sys.color.ohos_id_color_background')) - .onAreaChange((_oldValue: Area, newValue: Area) => { - let newWidth = Number(newValue.width) - if (!this.hidesBackButton) { - newWidth -= ImageMenuItem.imageHotZoneWidth - newWidth += SelectTitleBar.leftPadding - newWidth -= SelectTitleBar.leftPaddingWithBack - } - if (this.menuItems !== undefined) { - let menusLength = this.menuItems.length - if (menusLength >= CollapsibleMenuSection.maxCountOfVisibleItems) { - newWidth -= ImageMenuItem.imageHotZoneWidth * CollapsibleMenuSection.maxCountOfVisibleItems - } else if (menusLength > 0) { - newWidth -= ImageMenuItem.imageHotZoneWidth * menusLength - } - } - if (this.badgeValue !== undefined) { - this.selectMaxWidth = newWidth - SelectTitleBar.badgeSize - SelectTitleBar.leftPadding - SelectTitleBar.rightPadding - SelectTitleBar.badgePadding - } else { - this.selectMaxWidth = newWidth - SelectTitleBar.leftPadding - SelectTitleBar.rightPadding - } - }) - } -} - -@Component -struct CollapsibleMenuSection { - menuItems: Array - - static readonly maxCountOfVisibleItems = 3 - private static readonly focusPadding = 4 - private static readonly marginsNum = 2 - - @State isPopupShown: boolean = false - - @State isMoreIconOnFocus: boolean = false - @State isMoreIconOnHover: boolean = false - @State isMoreIconOnClick: boolean = false - - getMoreIconFgColor() { - return this.isMoreIconOnClick - ? $r('sys.color.ohos_id_color_titlebar_icon_pressed') - : $r('sys.color.ohos_id_color_titlebar_icon') - } - - getMoreIconBgColor() { - if (this.isMoreIconOnClick) { - return $r('sys.color.ohos_id_color_click_effect') - } else if (this.isMoreIconOnHover) { - return $r('sys.color.ohos_id_color_hover') - } else { - return Color.Transparent - } - } - - build() { - Column() { - Row() { - if (this.menuItems.length <= CollapsibleMenuSection.maxCountOfVisibleItems) { - ForEach(this.menuItems, (item) => { - ImageMenuItem({ item: item }) - }) - } else { - ForEach(this.menuItems.slice(0, CollapsibleMenuSection.maxCountOfVisibleItems - 1), (item) => { - ImageMenuItem({ item: item }) - }) - - Row() { - Image(PUBLIC_MORE) - .width(ImageMenuItem.imageSize) - .height(ImageMenuItem.imageSize) - .focusable(true) - } - .width(ImageMenuItem.imageHotZoneWidth) - .height(ImageMenuItem.imageHotZoneWidth) - .borderRadius(ImageMenuItem.buttonBorderRadius) - .foregroundColor(this.getMoreIconFgColor()) - .backgroundColor(this.getMoreIconBgColor()) - .justifyContent(FlexAlign.Center) - .border(this.isMoreIconOnFocus ? - { width: ImageMenuItem.focusBorderWidth, - color: $r('sys.color.ohos_id_color_emphasize'), - style: BorderStyle.Solid - } : { width: 0 }) - .onFocus(() => this.isMoreIconOnFocus = true) - .onBlur(() => this.isMoreIconOnFocus = false) - .onHover((isOn) => this.isMoreIconOnHover = isOn) - .onKeyEvent((event) => { - if (event.keyCode !== KeyCode.KEYCODE_ENTER && event.keyCode !== KeyCode.KEYCODE_SPACE) { - return - } - if (event.type === KeyType.Down) { - this.isMoreIconOnClick = true - } - if (event.type === KeyType.Up) { - this.isMoreIconOnClick = false - } - }) - .onTouch((event) => { - if (event.type === TouchType.Down) { - this.isMoreIconOnClick = true - } - if (event.type === TouchType.Up) { - this.isMoreIconOnClick = false - } - }) - .onClick(() => this.isPopupShown = true) - .bindPopup(this.isPopupShown, { - builder: this.popupBuilder, - placement: Placement.Bottom, - popupColor: Color.White, - enableArrow: false, - onStateChange: (e) => this.isPopupShown = e.isVisible - }) - } - } - } - .height('100%') - .margin({ right: $r('sys.float.ohos_id_default_padding_end') }) - .justifyContent(FlexAlign.Center) - } - - @Builder popupBuilder() { - Column() { - ForEach(this.menuItems.slice(CollapsibleMenuSection.maxCountOfVisibleItems - 1, this.menuItems.length), (item, _index?) => { - ImageMenuItem({ item: item }) - }) - } - .width(ImageMenuItem.imageHotZoneWidth + CollapsibleMenuSection.focusPadding * CollapsibleMenuSection.marginsNum) - .margin({ top: CollapsibleMenuSection.focusPadding, bottom: CollapsibleMenuSection.focusPadding }) - } -} - -@Component -struct ImageMenuItem { - item: SelectTitleBarMenuItem - - static readonly imageSize = 24 - static readonly imageHotZoneWidth = 48 - static readonly buttonBorderRadius = 8 - static readonly focusBorderWidth = 2 - static readonly disabledImageOpacity = 0.4 - - @State isOnFocus: boolean = false - @State isOnHover: boolean = false - @State isOnClick: boolean = false - - getFgColor() { - return this.isOnClick - ? $r('sys.color.ohos_id_color_titlebar_icon_pressed') - : $r('sys.color.ohos_id_color_titlebar_icon') - } - - getBgColor() { - if (this.isOnClick) { - return $r('sys.color.ohos_id_color_click_effect') - } else if (this.isOnHover) { - return $r('sys.color.ohos_id_color_hover') - } else { - return Color.Transparent - } - } - - build() { - Row() { - Image(this.item.value) - .width(ImageMenuItem.imageSize) - .height(ImageMenuItem.imageSize) - .focusable(this.item.isEnabled) - } - .width(ImageMenuItem.imageHotZoneWidth) - .height(ImageMenuItem.imageHotZoneWidth) - .borderRadius(ImageMenuItem.buttonBorderRadius) - .foregroundColor(this.getFgColor()) - .backgroundColor(this.getBgColor()) - .justifyContent(FlexAlign.Center) - .opacity(this.item.isEnabled ? 1 : ImageMenuItem.disabledImageOpacity) - .border(this.isOnFocus ? - { width: ImageMenuItem.focusBorderWidth, - color: $r('sys.color.ohos_id_color_emphasize'), - style: BorderStyle.Solid - } : { width: 0 }) - .onFocus(() => { - if (!this.item.isEnabled) { - return - } - this.isOnFocus = true - }) - .onBlur(() => this.isOnFocus = false) - .onHover((isOn) => { - if (!this.item.isEnabled) { - return - } - this.isOnHover = isOn - }) - .onKeyEvent((event) => { - if (!this.item.isEnabled) { - return - } - if (event.keyCode !== KeyCode.KEYCODE_ENTER && event.keyCode !== KeyCode.KEYCODE_SPACE) { - return - } - if (event.type === KeyType.Down) { - this.isOnClick = true - } - if (event.type === KeyType.Up) { - this.isOnClick = false - } - }) - .onTouch((event) => { - if (!this.item.isEnabled) { - return - } - if (event.type === TouchType.Down) { - this.isOnClick = true - } - if (event.type === TouchType.Up) { - this.isOnClick = false - } - }) - .onClick(() => this.item.isEnabled && this.item.action && this.item.action()) - } -} - -export default { SelectTitleBar } \ No newline at end of file diff --git a/source/SplitLayout/SplitLayout.ets b/source/SplitLayout/SplitLayout.ets deleted file mode 100644 index 9fb74a26696b93ddb485dc41abbfe51772572913..0000000000000000000000000000000000000000 --- a/source/SplitLayout/SplitLayout.ets +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@Component -export struct splitlayout { - @BuilderParam container: () => void - @State sizeValue: string = '' - @State areaWidth: number = 0 - @State imageBackgroundColor: string = "#19000000" - @Prop mainImage: Resource = $r("app.media.music") - @Prop primaryText: string = "新歌推荐" - secondaryText?: string = "私人订制新歌精选站,为你推荐专属优质新歌;为你推荐专属优质新歌" - tertiaryText?: string = "每日更新" - - build() { - Column() { - if (this.areaWidth < 600) { - GridRow({ - columns: 4, - breakpoints: { - reference: BreakpointsReference.WindowSize }, - direction: GridRowDirection.Row - }) { - GridCol({ span: { xs: 4, sm: 4, md: 4, lg: 4 } }) { - Column() { - Stack({ alignContent: Alignment.Bottom }) { - Image(this.mainImage) - - Column() { - Text(this.primaryText) - .textAlign(TextAlign.Center) - .fontSize($r('sys.float.ohos_id_text_size_headline7')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - Text(this.secondaryText) - .textAlign(TextAlign.Center) - .fontSize($r('sys.float.ohos_id_text_size_body2')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .margin({ top: 4, bottom: 8 }) - Text(this.tertiaryText) - .textAlign(TextAlign.Center) - .fontSize($r('sys.float.ohos_id_text_size_caption')) - .fontColor($r('sys.color.ohos_id_color_text_secondary')) - .margin({ bottom: 24 }) - } - .alignItems(HorizontalAlign.Center) - .margin({ - left: $r('sys.float.ohos_id_max_padding_start'), - right: $r('sys.float.ohos_id_max_padding_end'), }) - } - .height('34%') - .width('100%') - - Column() { - this.container() - } - .height('66%') - .width('100%') - } - } - } - } else if (600 < this.areaWidth && this.areaWidth < 840) { - // 形态二 - GridRow({ - columns: 8, - breakpoints: { - reference: BreakpointsReference.WindowSize }, - direction: GridRowDirection.Row - }) { - GridCol({ span: { xs: 8, sm: 8, md: 8, lg: 8 } }) { - Column() { - Row() { - Image(this.mainImage) - .margin({ left: 96, right: 36 }) - .height('60%') - .width('20%') - Column() { - Text(this.primaryText) - .fontSize($r('sys.float.ohos_id_text_size_headline7')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - Text(this.secondaryText) - .fontSize($r('sys.float.ohos_id_text_size_body2')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .margin({ top: 4, bottom: 8 }) - Text(this.tertiaryText) - .fontSize($r('sys.float.ohos_id_text_size_caption')) - .fontColor($r('sys.color.ohos_id_color_text_secondary')) - } - .alignItems(HorizontalAlign.Start) - .margin({ right: 96 }) - } - .backgroundColor(this.imageBackgroundColor) - .height('34%') - - Column() { - this.container() - } - .height('66%') - } - - } - } - - } else if (this.areaWidth > 840) { - GridRow({ - columns: 12, - breakpoints: { - reference: BreakpointsReference.WindowSize }, - direction: GridRowDirection.Row - }) { - GridCol({ span: { xs: 4, sm: 4, md: 4, lg: 4 } }) { - Column() { - Image(this.mainImage) - .height('17%') - .width('34%') - .margin({ bottom: 36 }) - Text(this.primaryText) - .textAlign(TextAlign.Center) - .fontSize($r('sys.float.ohos_id_text_size_headline7')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .margin({ left: 48, right: 48 }) - Text(this.secondaryText) - .textAlign(TextAlign.Center) - .fontSize($r('sys.float.ohos_id_text_size_body1')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .margin({ top: 4, bottom: 8, left: 48, right: 48 }) - Text(this.tertiaryText) - .textAlign(TextAlign.Center) - .fontSize($r('sys.float.ohos_id_text_size_body2')) - .fontColor($r('sys.color.ohos_id_color_text_secondary')) - .margin({ bottom: 24, left: 48, right: 48 }) - } - .height('100%') - .backgroundColor(this.imageBackgroundColor) - .justifyContent(FlexAlign.Center) - .alignItems(HorizontalAlign.Center) - } - .height('100%') - - GridCol({ span: { xs: 8, sm: 8, md: 8, lg: 8 } }) { - this.container() - } - - } - } - } - - .onAreaChange((oldValue: Area, newValue: Area) => { - console.info(`Ace: on area change, oldValue is ${JSON.stringify(oldValue)} value is ${JSON.stringify(newValue)}`) - this.sizeValue = JSON.stringify(newValue) - this.areaWidth = parseInt(newValue.width.toString(), 0); - console.info(`pingAce: on area change, oldValue is` + this.areaWidth) - console.info(`pingAce: on area change, oldValue is` + parseInt(newValue.height.toString(), 0)) - }) - } -} diff --git a/source/SubHeader/SubHeader.ets b/source/SubHeader/SubHeader.ets deleted file mode 100644 index da40ac5906fc9c90a13d0852590feb85d9d63322..0000000000000000000000000000000000000000 --- a/source/SubHeader/SubHeader.ets +++ /dev/null @@ -1,399 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const SPACE_MARGIN: number = 8 -const MARGIN_NUM: number = 4 -const IMAGE_WIDTH_NUM: number = 16 -const IMAGE_HEIGHT_NUM: number = 24 -const BUTTON_SIZE: number = 32 -const SINGLE_LINE_HEIGHT: number = 48 -const DOUBLE_LINE_HEIGHT: number = 64 -const BUTTON_HEIGHT: number = 28 -const IMAGE_WIDTH: number = 12 -const BORDER_WIDTH = 2 -const DIVIDEND_WIDTH = 3 -const SINGLE_LINE_NUM: number = 1 -const DOUBLE_LINE_NUM: number = 2 -const MIN_FONT_SIZE: number = 14 -const MAIN_TEXT_SIZE: number = 10 -const CONSTRAINT_WIDTH: number = 40 -const CONSTRAINT_NUM: number = 44 - -export enum OperationType { - TEXT_ARROW = 0, - BUTTON = 1, - ICON_GROUP = 2, - LOADING = 3, -} - -export declare type OperationOption = { - value: ResourceStr; - action?: () => void; -} - -export declare type SelectOptions = { - options: Array; - selected?: number; - value?: string; - onSelect?: (index: number, value?: string) => void; -} - -@Component -struct IconGroup { - @State bgColor: Resource = $r('sys.color.ohos_id_color_background') - @State isFocus: boolean = false - item: OperationOption - focusBorderWidth = BORDER_WIDTH - - build() { - Row() { - Image(this.item.value) - .fillColor($r('sys.color.ohos_id_color_primary')) - .width(IMAGE_HEIGHT_NUM) - .height(IMAGE_HEIGHT_NUM) - .focusable(true) - } - .focusable(true) - .width(BUTTON_SIZE) - .height(BUTTON_SIZE) - .margin({ right: SPACE_MARGIN, bottom: MARGIN_NUM }) - .justifyContent(FlexAlign.Center) - .borderRadius($r('sys.float.ohos_id_corner_radius_clicked')) - .backgroundColor(this.bgColor) - .onTouch((event) => { - if (event.type === TouchType.Down) { - this.item.action && this.item.action() - this.bgColor = $r('sys.color.ohos_id_color_click_effect') - } - if (event.type === TouchType.Up) { - this.bgColor = $r('sys.color.ohos_id_color_background') - } - }) - .onHover((isHover: boolean) => { - if (isHover) { - this.bgColor = $r('sys.color.ohos_id_color_hover') - } else { - this.bgColor = $r('sys.color.ohos_id_color_background') - } - }) - .border(this.isFocus ? - { width: this.focusBorderWidth, - color: $r('sys.color.ohos_id_color_emphasize'), - style: BorderStyle.Solid - } : { width: 0 }) - .onFocus(() => { - this.isFocus = true; - }) - .onBlur(() => { - this.isFocus = false; - }) - .onKeyEvent((event) => { - if (event.keyCode === 2054 || event.keyCode === 2050) { - this.item.action && this.item.action() - } - }) - } -} - -@Component -export struct SubHeader1 { - @Prop icon: Resource - @Prop primaryTitle: string - @Prop secondaryTitle: string - @Prop select: SelectOptions - @Prop operationType: OperationType = OperationType.BUTTON - operationItem: Array - @State isDuplicateLine: boolean = false - @State textArrowBgColor: Resource = $r('sys.color.ohos_id_color_background') - @State buttonBgColor: Resource = $r('sys.color.ohos_id_color_background') - @State iconBgColor: Resource = $r('sys.color.ohos_id_color_background') - @State firstIconBgColor: Resource = $r('sys.color.ohos_id_color_background') - @State SecondaryIconBgColor: Resource = $r('sys.color.ohos_id_color_background') - @State thirdIconBgColor: Resource = $r('sys.color.ohos_id_color_background') - @State flag: boolean = false - @State isTextArrowFocus: boolean = false - @State flexWidth: number = 0 - @State titleWidth: number = 0 - @State titleWidth1: number = 0 - @State isButtonFocus: boolean = false - focusBorderWidth = BORDER_WIDTH - - @Builder ListTextStyle($$: { content: ResourceStr }) { - Text($$.content) - .fontColor($r('sys.color.ohos_id_color_text_secondary')) - .fontSize($r('sys.float.ohos_id_text_size_sub_title3')) - .fontWeight(FontWeight.Medium) - .maxLines(DOUBLE_LINE_NUM) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .constraintSize({ minWidth: this.titleWidth }) - .margin({ left: $r('sys.float.ohos_id_max_padding_end'), bottom: SPACE_MARGIN, right: MARGIN_NUM }).borderWidth(1) - } - - @Builder ListIconStyle($$: { content: ResourceStr }, icon: ResourceStr) { - Row() { - Image(icon) - .width(IMAGE_WIDTH_NUM) - .height(IMAGE_WIDTH_NUM) - .margin({ right: SPACE_MARGIN }) - Text($$.content) - .fontColor($r('sys.color.ohos_id_color_text_secondary')) - .fontSize($r('sys.float.ohos_id_text_size_sub_title3')) - .fontWeight(FontWeight.Medium) - .maxLines(DOUBLE_LINE_NUM) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .constraintSize({ minWidth: this.titleWidth - CONSTRAINT_WIDTH }) - } - .margin({ left: $r('sys.float.ohos_id_max_padding_end'), bottom: SPACE_MARGIN, right: MARGIN_NUM }) - } - - @Builder ContentTextStyle($$: { content: ResourceStr }) { - Text($$.content) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .fontSize($r('sys.float.ohos_id_text_size_sub_title2')) - .fontWeight(FontWeight.Medium) - .maxLines(DOUBLE_LINE_NUM) - .maxFontSize($r('sys.float.ohos_id_text_size_sub_title2')) - .minFontSize(MIN_FONT_SIZE) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .constraintSize({ maxWidth: this.titleWidth }) - .margin({ left: $r('sys.float.ohos_id_max_padding_start'), - right: MARGIN_NUM, bottom: SPACE_MARGIN }) - } - - @Builder SubTextStyle($$: { content: ResourceStr, subContent: ResourceStr }) { - Column() { - Text($$.content) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .fontSize($r('sys.float.ohos_id_text_size_sub_title2')) - .fontWeight(FontWeight.Medium) - .maxLines(SINGLE_LINE_NUM) - .maxFontSize($r('sys.float.ohos_id_text_size_sub_title2')) - .minFontSize(MIN_FONT_SIZE) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - Text($$.subContent) - .fontColor($r('sys.color.ohos_id_color_text_secondary')) - .fontSize($r('sys.float.ohos_id_text_size_sub_title3')) - .fontWeight(FontWeight.Medium) - .maxLines(SINGLE_LINE_NUM) - .maxFontSize($r('sys.float.ohos_id_text_size_sub_title3')) - .minFontSize(MAIN_TEXT_SIZE) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - } - .constraintSize({ maxWidth: this.titleWidth }) - .alignItems(HorizontalAlign.Start) - .onAppear(() => { - this.isDuplicateLine = true - }) - .margin({ left: $r('sys.float.ohos_id_max_padding_start'), - right: MARGIN_NUM, bottom: SPACE_MARGIN }) - } - - @Builder SelectStyle(selectParam: SelectOptions) { - Select(selectParam.options) - .selected(selectParam.selected) - .value(selectParam.value) - .onSelect((index: number, value?: string) => { - if (selectParam.onSelect) { - selectParam.onSelect(index, value) - } - }) - .constraintSize({ maxWidth: this.titleWidth }) - .margin({ left: $r('sys.float.ohos_id_default_padding_start'), right: MARGIN_NUM}) - } - - @Builder LoadingProcessStyle() { - LoadingProgress() - .width(IMAGE_HEIGHT_NUM) - .height(IMAGE_HEIGHT_NUM) - .focusable(true) - .margin({ right: $r('sys.float.ohos_id_default_padding_end'), bottom: MARGIN_NUM }) - } - - @Builder TextArrowStyle(textArrow: OperationOption) { - Row() { - Row() { - if (textArrow != null) { - Text(textArrow.value) - .fontColor($r('sys.color.ohos_id_color_text_secondary')) - .fontSize($r('sys.float.ohos_id_text_size_body2')) - .margin({ right: MARGIN_NUM }) - .focusable(true) - .maxLines(DOUBLE_LINE_NUM) - } - Image($r('sys.media.ohos_ic_public_arrow_right')) - .fillColor($r('sys.color.ohos_id_color_tertiary')) - .width(IMAGE_WIDTH) - .height(IMAGE_HEIGHT_NUM) - .focusable(true) - }.margin({ left: SPACE_MARGIN, right: SPACE_MARGIN }) - } - .justifyContent(FlexAlign.End) - .focusable(true) - .margin({ left:MARGIN_NUM, right: MARGIN_NUM, bottom: MARGIN_NUM }) - .borderRadius($r('sys.float.ohos_id_corner_radius_subtab')) - .backgroundColor(this.textArrowBgColor) - .onTouch((event) => { - if (event.type === TouchType.Down) { - if (textArrow.action) { - textArrow.action() - } - this.textArrowBgColor = $r('sys.color.ohos_id_color_click_effect') - } - if (event.type === TouchType.Up) { - this.textArrowBgColor = $r('sys.color.ohos_id_color_background') - } - }) - .onHover((isHover: boolean) => { - if (isHover) { - this.textArrowBgColor = $r('sys.color.ohos_id_color_hover') - } else { - this.textArrowBgColor = $r('sys.color.ohos_id_color_background') - } - }) - .border(this.isTextArrowFocus ? - { width: this.focusBorderWidth, - color: $r('sys.color.ohos_id_color_focused_outline'), - style: BorderStyle.Solid - } : { width: 0 }) - .onFocus(() => { - this.isTextArrowFocus = true; - }) - .onBlur(() => { - this.isTextArrowFocus = false; - }) - .onKeyEvent((event) => { - if (event.keyCode === 2054 || event.keyCode === 2050) { - textArrow.action && textArrow.action() - } - }) - } - - @Builder ButtonStyle(button: OperationOption) { - Row() { - if (button != null) { - Text(button.value) - .maxLines(1) - .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) - .fontSize($r('sys.float.ohos_id_text_size_button2')) - .fontWeight(FontWeight.Medium) - .margin({ left: SPACE_MARGIN, right: SPACE_MARGIN }) - .focusable(true) - } - } - .onAreaChange((oldValue: Area, newValue: Area) => { - Number(parseInt(newValue.width.toString(), 0)) - console.log('wy buttonStyle1'+Number(parseInt(newValue.width.toString(), 0))) - }) - .justifyContent(FlexAlign.End) - .alignItems(VerticalAlign.Center) - .constraintSize({ maxWidth: this.flexWidth-this.titleWidth1 + 36 }) - .focusable(true) - .height(BUTTON_HEIGHT) - .margin({ left: SPACE_MARGIN, right: MARGIN_NUM }) - .borderRadius(IMAGE_WIDTH_NUM) - .backgroundColor(this.buttonBgColor) - .onTouch((event) => { - if (event.type === TouchType.Down) { - if (button.action) { - button.action() - } - this.buttonBgColor = $r('sys.color.ohos_id_color_click_effect') - } - if (event.type === TouchType.Up) { - this.buttonBgColor = $r('sys.color.ohos_id_color_background') - } - }) - .onHover((isHover: boolean) => { - if (isHover) { - this.buttonBgColor = $r('sys.color.ohos_id_color_hover') - } else { - this.buttonBgColor = $r('sys.color.ohos_id_color_background') - } - }) - .border(this.isButtonFocus ? - { width: this.focusBorderWidth, - color: $r('sys.color.ohos_id_color_focused_outline'), - style: BorderStyle.Solid - } : { width: 0 }) - .onFocus(() => { - this.isButtonFocus = true; - }) - .onBlur(() => { - this.isButtonFocus = false; - }) - .onKeyEvent((event) => { - if (event.keyCode === 2054 || event.keyCode === 2050) { - button.action && button.action() - } - }) - } - - build() { - Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.End }) { - Row() { - if (this.secondaryTitle != null && this.icon != null) { - this.ListIconStyle({ content: this.secondaryTitle }, this.icon) - } else if (this.secondaryTitle != null && this.primaryTitle != null) { - this.SubTextStyle({ content: this.primaryTitle, subContent: this.secondaryTitle }) - } else if (this.secondaryTitle != null) { - this.ListTextStyle({ content: this.secondaryTitle }) - } else if (this.select != null) { - this.SelectStyle(this.select) - } else if (this.primaryTitle != null) { - this.ContentTextStyle({ content: this.primaryTitle }) - } - } - .onAreaChange((oldValue: Area, newValue: Area) => { - this.titleWidth1 = Number(parseInt(newValue.width.toString(), 0)) - console.log('wy titleWidth1'+this.titleWidth.toString()) - }) - - Row() { - if (this.operationType === OperationType.BUTTON && this.operationItem != null) { - this.ButtonStyle(this.operationItem[0] ) - } - if (this.operationType === OperationType.ICON_GROUP && this.operationItem != null) { - Row() { - ForEach(this.operationItem, (item, index?: number) => { - if (index == 0) { - IconGroup({ item: item }) - } - if (index == 1) { - IconGroup({ item: item }) - } - if (index == 2) { // Image count - IconGroup({ item: item }) - } - }) - } - } - if (this.operationType === OperationType.TEXT_ARROW && this.operationItem != null) { - this.TextArrowStyle(this.operationItem[0]) - } - if (this.operationType === OperationType.LOADING) { - this.LoadingProcessStyle() - } - } - } - .onAreaChange((oldValue: Area, newValue: Area) => { - let flexWidth = Number(parseInt(newValue.width.toString(), 0)) - this.flexWidth = flexWidth - CONSTRAINT_NUM - this.titleWidth = this.flexWidth / DIVIDEND_WIDTH * BORDER_WIDTH - console.log('wy flexWidth'+this.flexWidth.toString()) - }) - .padding({ right: $r('sys.float.ohos_id_default_padding_end') }) - .height(this.isDuplicateLine ? DOUBLE_LINE_HEIGHT : SINGLE_LINE_HEIGHT) - } -} \ No newline at end of file diff --git a/source/TabTitleBar/TabTitleBar.ets b/source/TabTitleBar/TabTitleBar.ets deleted file mode 100755 index ae5217b9e646674754d1b1515011fe6a0d2f57e7..0000000000000000000000000000000000000000 --- a/source/TabTitleBar/TabTitleBar.ets +++ /dev/null @@ -1,478 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { KeyCode } from '@ohos.multimodalInput.keyCode' - -export declare type TabTitleBarMenuItem = { - value: ResourceStr - isEnabled: boolean - action?: () => void -} - -export declare type TabTitleBarTabItem = { - title: ResourceStr - icon?: ResourceStr -} - -const PUBLIC_MORE = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAABS3GwHAAAAIGNIUk0AAHomAACAhAAA+' + - 'gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAEZ0FNQQAAsY58+1GTAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAO' + - 'xAAADsQBlSsOGwAABEZJREFUeNrt3D1rFFEUBuAxhmAhFlYpUohYiYWFRcAmKAhWK2pjo1iKf8BCMIKFf8BarCyMhVj4VZhGSKEg2FqJyCKWIhY' + - 'WnstMINgYsh+cmfs88BICydxw7jmzu2HvNg0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADBN+3r6dx+LXIqsRpa7FF8j48hm5Fn3Peo9mAEYRd' + - 'YjJ3f582Vj7nZfUe/eDsCRyMPI2h5/fyNyI/JDT6v3Tvt7sBllE15ETkxwjeORi5G3ke/6W737MgBnI68jh6ZwrcORq5HnhkC9+zAA5YXXy8jBK' + - 'V5zKXIu8jjyS7+rd+YBeNVtyrSVO9PRyBM9r94LSTfjWuTUDK9/eYIXeENUbb0zDsBi5PYc1rmj79U74wCszuih+F/ljrSi/+uud8YBGA10rayq' + - 'rnfGAVgb6FpZVV3vjAOwPNC1sqq63hkHYGWga2VVdb0XKt/8Rf1fd70zDsB4jmt5u3Tl9a59AMb6v+56ZxyArYGulVXV9c44ABtzXOup/q+73hk' + - 'H4N2cHio/Rj7r/7rrnXEAfkfuz2Gddb2v3ln/DfpgxneLzaY9xE3l9c46AH8iVyI/Z3Dt8nB/Xc+rd5H5QMy3yJemPVs6zY0edc9HUe/0Z4I/dQ' + - '/N5Vjd0oTXKp9QcKFpD2qj3r0YgO1NeRM507TH6/bifeR85IMeV++d+vTBWOV9JDcjt5rdv6uw3M3uRR7pa/Xu+wBsOxA53bTnTP/3UX1b3fNQ1' + - 'BsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKqyr6d/97HIpchqZLlL8TUyjmxGnnXfo96DGYBRZD1ycpc/Xzbm' + - 'bvcV9e7tAByJPIys7fH3NyI3Ij/0tHrvtL8Hm1E24UXkxATXOB65GHkb+a6/1bsvA3A28jpyaArXOhy5GnluCNS7DwNQXni9jByc4jWXIucijyO' + - '/9Lt6Zx6AV92mTFu5Mx2NPNHz6r2QdDOuRU7N8PqXJ3iBN0TV1jvjACxGbs9hnTv6Xr0zDsDqjB6K/1XuSCv6v+56ZxyA0UDXyqrqemccgLWBrp' + - 'VV1fXOOADLA10rq6rrnXEAVga6VlZV13uh8s1f1P911zvjAIznuJa3S1de79oHYKz/6653xgHYGuhaWVVd74wDsDHHtZ7q/7rrnXEA3s3pofJj5' + - 'LP+r7veGQfgd+T+HNZZ1/vqnfXfoA9mfLfYbNpD3FRe76wD8CdyJfJzBtcuD/fX9bx6F5kPxHyLfGnas6XT3OhR93wU9U5/JvhT99BcjtUtTXit' + - '8gkFF5r2oDbq3YsB2N6UN5EzTXu8bi/eR85HPuhx9d6pTx+MVd5HcjNyq9n9uwrL3exe5JG+Vu++D8C2A5HTTXvO9H8f1bfVPQ9FvQEAAAAAAAA' + - 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAgCn7C9HjBtwWfXpKAAAAAElFTkSuQmCC' - -@Component -export struct TabTitleBar { - tabItems: Array - menuItems: Array - @BuilderParam swiperContent: () => void - - @State tabWidth: number = 0 - @State currentIndex: number = 0 - - static readonly totalHeight = 56 - static readonly correctionOffset = -40.0 - static readonly gradientMaskWidth = 24 - private menuSectionWidth = 0 - - private scroller: Scroller = new Scroller() - private swiperController: SwiperController = new SwiperController() - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private leftContext2D: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private rightContext2D: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - @Builder GradientMask(context2D: CanvasRenderingContext2D, x0: number, y0: number, x1: number, y1: number) { - Column() { - Canvas(context2D) - .width(TabTitleBar.gradientMaskWidth) - .height(TabTitleBar.totalHeight) - .onReady(() => { - var grad = context2D.createLinearGradient(x0, y0, x1, y1) - grad.addColorStop(0.0, '#ffffffff') - grad.addColorStop(1, '#00ffffff') - context2D.fillStyle = grad - context2D.fillRect(0, 0, TabTitleBar.gradientMaskWidth, TabTitleBar.totalHeight) - }) - } - .width(TabTitleBar.gradientMaskWidth) - .height(TabTitleBar.totalHeight) - } - - build() { - Column() { - Flex({ - justifyContent: FlexAlign.SpaceBetween, - alignItems: ItemAlign.Stretch - }) { - Stack({ alignContent: Alignment.End }) { - Stack({ alignContent: Alignment.Start }) { - Column() { - List({ initialIndex: 0, scroller: this.scroller, space: 0 }) { - ForEach(this.tabItems, (tabItem, index?: number) => { - ListItem() { - TabContentItem({ - item: tabItem, - index: index, - maxIndex: this.tabItems.length - 1, - currentIndex: this.currentIndex, - onCustomClick: () => this.currentIndex = index - }) - } - }) - } - .width('100%') - .height(TabTitleBar.totalHeight) - .constraintSize({ maxWidth: this.tabWidth }) - .edgeEffect(EdgeEffect.Spring) - .listDirection(Axis.Horizontal) - .scrollBar(BarState.Off) - } - this.GradientMask(this.leftContext2D, 0, TabTitleBar.totalHeight / 2, - TabTitleBar.gradientMaskWidth, TabTitleBar.totalHeight / 2) - } - this.GradientMask(this.rightContext2D, TabTitleBar.gradientMaskWidth, - TabTitleBar.totalHeight / 2, 0, TabTitleBar.totalHeight / 2) - } - - if (this.menuItems !== undefined && this.menuItems.length > 0) { - CollapsibleMenuSection({ menuItems: this.menuItems }) - .height(TabTitleBar.totalHeight) - .onAreaChange((_oldValue: Area, newValue: Area) => { - this.menuSectionWidth = Number(newValue.width) - }) - } - } - .backgroundColor($r('sys.color.ohos_id_color_background')) - .margin({ right: $r('sys.float.ohos_id_max_padding_end') }) - .onAreaChange((_oldValue: Area, newValue: Area) => { - this.tabWidth = Number(newValue.width) - this.menuSectionWidth - }) - - Column() { - Swiper(this.swiperController) { this.swiperContent() } - .index(this.currentIndex) - .itemSpace(0) - .indicator(false) - .width('100%') - .height('100%') - .curve(Curve.Friction) - .onChange((index) => { - this.currentIndex = index - this.scroller.scrollToIndex(this.currentIndex) - this.scroller.scrollBy(TabTitleBar.correctionOffset, 0) - }) - .onAppear(() => { - this.scroller.scrollToIndex(this.currentIndex) - this.scroller.scrollBy(TabTitleBar.correctionOffset, 0) - }) - } - } - } -} - -@Component -struct CollapsibleMenuSection { - menuItems: Array - - static readonly maxCountOfVisibleItems = 1 - private static readonly focusPadding = 4 - private static readonly marginsNum = 2 - - @State isPopupShown: boolean = false - - @State isMoreIconOnFocus: boolean = false - @State isMoreIconOnHover: boolean = false - @State isMoreIconOnClick: boolean = false - - getMoreIconFgColor() { - return this.isMoreIconOnClick - ? $r('sys.color.ohos_id_color_titlebar_icon_pressed') - : $r('sys.color.ohos_id_color_titlebar_icon') - } - - getMoreIconBgColor() { - if (this.isMoreIconOnClick) { - return $r('sys.color.ohos_id_color_click_effect') - } else if (this.isMoreIconOnHover) { - return $r('sys.color.ohos_id_color_hover') - } else { - return Color.Transparent - } - } - - build() { - Column() { - Row() { - if (this.menuItems.length <= CollapsibleMenuSection.maxCountOfVisibleItems) { - ForEach(this.menuItems, (item) => { - ImageMenuItem({ item: item }) - }) - } else { - ForEach(this.menuItems.slice(0, CollapsibleMenuSection.maxCountOfVisibleItems - 1), (item) => { - ImageMenuItem({ item: item }) - }) - - Row() { - Image(PUBLIC_MORE) - .width(ImageMenuItem.imageSize) - .height(ImageMenuItem.imageSize) - .focusable(true) - } - .width(ImageMenuItem.imageHotZoneWidth) - .height(ImageMenuItem.imageHotZoneWidth) - .borderRadius(ImageMenuItem.buttonBorderRadius) - .foregroundColor(this.getMoreIconFgColor()) - .backgroundColor(this.getMoreIconBgColor()) - .justifyContent(FlexAlign.Center) - .border(this.isMoreIconOnFocus ? - { width: ImageMenuItem.focusBorderWidth, - color: $r('sys.color.ohos_id_color_emphasize'), - style: BorderStyle.Solid - } : { width: 0 }) - .onFocus(() => this.isMoreIconOnFocus = true) - .onBlur(() => this.isMoreIconOnFocus = false) - .onHover((isOn) => this.isMoreIconOnHover = isOn) - .onKeyEvent((event) => { - if (event.keyCode !== KeyCode.KEYCODE_ENTER && event.keyCode !== KeyCode.KEYCODE_SPACE) { - return - } - if (event.type === KeyType.Down) { - this.isMoreIconOnClick = true - } - if (event.type === KeyType.Up) { - this.isMoreIconOnClick = false - } - }) - .onTouch((event) => { - if (event.type === TouchType.Down) { - this.isMoreIconOnClick = true - } - if (event.type === TouchType.Up) { - this.isMoreIconOnClick = false - } - }) - .onClick(() => this.isPopupShown = true) - .bindPopup(this.isPopupShown, { - builder: this.popupBuilder, - placement: Placement.Bottom, - popupColor: Color.White, - enableArrow: false, - onStateChange: (e) => this.isPopupShown = e.isVisible - }) - } - } - } - .height('100%') - // .margin({ right: $r('sys.float.ohos_id_default_padding_end') }) - .justifyContent(FlexAlign.Center) - } - - @Builder popupBuilder() { - Column() { - ForEach(this.menuItems.slice(CollapsibleMenuSection.maxCountOfVisibleItems - 1, this.menuItems.length), (item, _index?) => { - ImageMenuItem({ item: item }) - }) - } - .width(ImageMenuItem.imageHotZoneWidth + CollapsibleMenuSection.focusPadding * CollapsibleMenuSection.marginsNum) - .margin({ top: CollapsibleMenuSection.focusPadding, bottom: CollapsibleMenuSection.focusPadding }) - } -} - -@Component -struct TabContentItem { - item: TabTitleBarTabItem - index: number - maxIndex: number - onCustomClick?: () => void - - @Prop currentIndex: number - - @State isOnFocus: boolean = false - @State isOnHover: boolean = false - @State isOnClick: boolean = false - - static readonly imageSize = 24 - static readonly imageHotZoneWidth = 48 - static readonly imageMagnificationFactor = 1.4 - static readonly buttonBorderRadius = 8 - static readonly focusBorderWidth = 2 - - getBgColor() { - if (this.isOnClick) { - return $r('sys.color.ohos_id_color_click_effect') - } else if (this.isOnHover) { - return $r('sys.color.ohos_id_color_hover') - } else { - return Color.Transparent - } - } - - build() { - Row() { - Column() { - if (this.item.icon === undefined) { - Text(this.item.title) - .fontSize(this.index === this.currentIndex - ? $r('sys.float.ohos_id_text_size_headline7') - : $r('sys.float.ohos_id_text_size_headline9')) - .fontColor(this.index === this.currentIndex - ? $r('sys.color.ohos_id_color_titlebar_text') - : $r('sys.color.ohos_id_color_titlebar_text_off')) - .fontWeight(FontWeight.Medium) - .focusable(true) - .padding({ top: this.index === this.currentIndex ? 6 : 10, left: 8, bottom: 2, right: 8 }) - .onFocus(() => this.isOnFocus = true) - .onBlur(() => this.isOnFocus = false) - .onHover((isOn) => this.isOnHover = isOn) - .onKeyEvent((event) => { - if (event.keyCode !== KeyCode.KEYCODE_ENTER && event.keyCode !== KeyCode.KEYCODE_SPACE) { - return - } - if (event.type === KeyType.Down) { - this.isOnClick = true - } - if (event.type === KeyType.Up) { - this.isOnClick = false - } - }) - .onTouch((event) => { - if (event.type === TouchType.Down) { - this.isOnClick = true - } - if (event.type === TouchType.Up) { - this.isOnClick = false - } - }) - .onClick(() => this.onCustomClick && this.onCustomClick()) - } else { - Row() { - Image(this.item.icon) - .alt(this.item.title) - .height(TabContentItem.imageSize) - .focusable(true) - .scale({ - x: this.index === this.currentIndex ? TabContentItem.imageMagnificationFactor : 1, - y: this.index === this.currentIndex ? TabContentItem.imageMagnificationFactor : 1 - }) - } - .width(TabContentItem.imageHotZoneWidth) - .height(TabContentItem.imageHotZoneWidth) - .justifyContent(FlexAlign.Center) - .onFocus(() => this.isOnFocus = true) - .onBlur(() => this.isOnFocus = false) - .onHover((isOn) => this.isOnHover = isOn) - .onKeyEvent((event) => { - if (event.keyCode !== KeyCode.KEYCODE_ENTER && event.keyCode !== KeyCode.KEYCODE_SPACE) { - return - } - if (event.type === KeyType.Down) { - this.isOnClick = true - } - if (event.type === KeyType.Up) { - this.isOnClick = false - } - }) - .onTouch((event) => { - if (event.type === TouchType.Down) { - this.isOnClick = true - } - if (event.type === TouchType.Up) { - this.isOnClick = false - } - }) - .onClick(() => this.onCustomClick && this.onCustomClick()) - } - } - .justifyContent(FlexAlign.Center) - } - .height(TabTitleBar.totalHeight) - .alignItems(VerticalAlign.Center) - .justifyContent(FlexAlign.Center) - .margin({ - left: this.index === 0 ? 16 : 0, - right: this.index === this.maxIndex ? 12 : 0 - }) // sys.float.ohos_id_max_padding_start - 8 - .borderRadius(TabContentItem.buttonBorderRadius) - .backgroundColor(this.getBgColor()) - .border(this.isOnFocus ? - { width: TabContentItem.focusBorderWidth, - color: $r('sys.color.ohos_id_color_emphasize'), - style: BorderStyle.Solid - } : { width: 0 }) - } -} - -@Component -struct ImageMenuItem { - item: TabTitleBarMenuItem - - static readonly imageSize = 24 - static readonly imageHotZoneWidth = 48 - static readonly buttonBorderRadius = 8 - static readonly focusBorderWidth = 2 - static readonly disabledImageOpacity = 0.4 - - @State isOnFocus: boolean = false - @State isOnHover: boolean = false - @State isOnClick: boolean = false - - getFgColor() { - return this.isOnClick - ? $r('sys.color.ohos_id_color_titlebar_icon_pressed') - : $r('sys.color.ohos_id_color_titlebar_icon') - } - - getBgColor() { - if (this.isOnClick) { - return $r('sys.color.ohos_id_color_click_effect') - } else if (this.isOnHover) { - return $r('sys.color.ohos_id_color_hover') - } else { - return Color.Transparent - } - } - - build() { - Row() { - Image(this.item.value) - .width(ImageMenuItem.imageSize) - .height(ImageMenuItem.imageSize) - .focusable(this.item.isEnabled) - } - .width(ImageMenuItem.imageHotZoneWidth) - .height(ImageMenuItem.imageHotZoneWidth) - .borderRadius(ImageMenuItem.buttonBorderRadius) - .foregroundColor(this.getFgColor()) - .backgroundColor(this.getBgColor()) - .justifyContent(FlexAlign.Center) - .opacity(this.item.isEnabled ? 1 : ImageMenuItem.disabledImageOpacity) - .border(this.isOnFocus ? - { width: ImageMenuItem.focusBorderWidth, - color: $r('sys.color.ohos_id_color_emphasize'), - style: BorderStyle.Solid - } : { width: 0 }) - .onFocus(() => { - if (!this.item.isEnabled) { - return - } - this.isOnFocus = true - }) - .onBlur(() => this.isOnFocus = false) - .onHover((isOn) => { - if (!this.item.isEnabled) { - return - } - this.isOnHover = isOn - }) - .onKeyEvent((event) => { - if (!this.item.isEnabled) { - return - } - if (event.keyCode !== KeyCode.KEYCODE_ENTER && event.keyCode !== KeyCode.KEYCODE_SPACE) { - return - } - if (event.type === KeyType.Down) { - this.isOnClick = true - } - if (event.type === KeyType.Up) { - this.isOnClick = false - } - }) - .onTouch((event) => { - if (!this.item.isEnabled) { - return - } - if (event.type === TouchType.Down) { - this.isOnClick = true - } - if (event.type === TouchType.Up) { - this.isOnClick = false - } - }) - .onClick(() => this.item.isEnabled && this.item.action && this.item.action()) - } -} - -export default { TabTitleBar } \ No newline at end of file diff --git a/source/ToolBar/ToolBar.ets b/source/ToolBar/ToolBar.ets deleted file mode 100644 index 06bf3fdeb189e3f147f334ea4766451d648e8f3c..0000000000000000000000000000000000000000 --- a/source/ToolBar/ToolBar.ets +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export enum ItemState { - ENABLE = 1, - DISABLE = 2, - ACTIVATE = 3 -} - -const PUBLIC_MORE = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAAIGNIUk0AAHomAACAhAAA" + - "+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAEZ0FNQQAAsY58+1GTAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzA" + - "AAOxAAADsQBlSsOGwAAAYFJREFUeNrt3CFLQ1EUB/CpCwYRo8G4j2IwCNrUYjH4AfwcfgBBwWZRMNgtFqPdILJgEhGDweAZvDjmJnfv3I" + - "3fD/5l3DfOfWdv23vhdDoAAAAAAAAwzxam9L5rkePIdmSjee05chu5iHxXej5ar3saDdiJXDabGaYfOYg8VHbyU+peKryJvch1ZHnEmtXIY" + - "eQ+8lrJyU+re7HgJtYj52Ou7Uau/thwW1LrLtmAk8jKBOsH37FHFTQgte6SDdht6ZjSUusu2YBeS8eUllr3YvLmuzP6971bYwP6/zjmpYKT" + - "mVp3yQbctXRMaal1l2zAaeRngvUfkbMKGpBad8kbsffIZ2RrzPX7kacKGpBad+k74cfmE7I54ur6au4obyr6UU2re1oP43rNDc6wh1qDS/6t0" + - "n83s1o3AAAAAAAAAAAAAEAysyKS6zYrIrlusyKS6zYrwqyIdGZFJDMrIplZETPIrIh5qdusCLMi0pkVkcysiAqYFVEJsyIAAAAAAAAAKOYXUlF" + - "8EUcdfbsAAAAASUVORK5CYII="; - -@Observed -export class ToolBarOption { - content: string; - action?: () => void; - icon?: Resource; - state?: ItemState = 1; -} - -@Observed -export class ToolBarOptions extends Array { -} - -@Component -export struct ToolBar { - @ObjectLink toolBarList: ToolBarOptions - controller: TabsController - @Prop activateIndex: number = -1 - @State menuContent: { value: string, action: () => void }[] = [] - toolBarItemBackground: Resource[] = [] - @State itemBackground: Resource = $r('sys.color.ohos_id_color_toolbar_bg') - @Builder MoreTabBuilder(index: number) { - Column() { - Image(PUBLIC_MORE) - .width(24) - .height(24) - .fillColor($r('sys.color.ohos_id_color_toolbar_icon')) - .margin({ top: 8, bottom: 2 }) - .objectFit(ImageFit.Contain) - Text($r('app.string.id_string_more')) - .fontColor($r('sys.color.ohos_id_color_toolbar_text')) - .fontSize($r('sys.float.ohos_id_text_size_caption')) - .fontWeight(FontWeight.Medium) - }.width('100%').height('100%').bindMenu(this.menuContent, { offset: { x: 5, y : -10}}) - .padding({left: 4, right: 4}) - .borderRadius($r('sys.float.ohos_id_corner_radius_clicked')) - } - - @Builder TabBuilder(index: number) { - Column() { - Image(this.toolBarList[index].icon) - .width(24) - .height(24) - .fillColor(this.activateIndex === index && !(this.toolBarList[index].state === 2) - ? $r('sys.color.ohos_id_color_text_primary_activated') : $r('sys.color.ohos_id_color_primary')) - .opacity((this.toolBarList[index].state === 2) ? 0.4 : 1) - .margin({ top: 8, bottom: 2 }) - .objectFit(ImageFit.Contain) - Text(this.toolBarList[index].content) - .fontColor(this.activateIndex === index && !(this.toolBarList[index].state === 2) - ? $r('sys.color.ohos_id_color_toolbar_text_actived') : $r('sys.color.ohos_id_color_toolbar_text')) - .fontSize($r('sys.float.ohos_id_text_size_caption')) - .maxFontSize($r('sys.float.ohos_id_text_size_caption')) - .minFontSize(9) - .fontWeight(FontWeight.Medium) - .maxLines(2) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .opacity((this.toolBarList[index].state === 2) ? 0.4 : 1) - } - .width('100%').height('100%') - .focusable(!(this.toolBarList[index].state === 2)) - .focusOnTouch(!(this.toolBarList[index].state === 2)) - .padding({left: 4, right: 4}) - .borderRadius($r('sys.float.ohos_id_corner_radius_clicked')) - .backgroundColor(this.itemBackground) - .onClick(() => { - if (this.toolBarList[index].state === 3) { - if (this.activateIndex === index) - this.activateIndex = -1 - else { - this.activateIndex = index - } - } - if (!(this.toolBarList[index].state === 2)) { - this.toolBarList[index].action && this.toolBarList[index].action() - } - }) - .onHover((isHover: boolean) => { - if (isHover ) { - this.toolBarItemBackground[index] = (this.toolBarList[index].state === 2) - ? $r('sys.color.ohos_id_color_toolbar_bg'): $r('sys.color.ohos_id_color_hover') - } else { - this.toolBarItemBackground[index] = $r('sys.color.ohos_id_color_toolbar_bg') - } - this.itemBackground = this.toolBarItemBackground[index] - }) - .stateStyles({ - pressed: { - .backgroundColor((this.toolBarList[index].state === 2) ? this.toolBarItemBackground[index] : $r('sys.color.ohos_id_color_click_effect')) - }, - normal: { - .backgroundColor(this.toolBarItemBackground[index]) - } - }) - } - - refreshData() { - this.menuContent = [] - for (let i = 0; i < this.toolBarList.length; i++) { - if (i >= 4 && this.toolBarList.length > 5) { - this.menuContent[i - 4] = { - value: this.toolBarList[i].content, - action: this.toolBarList[i].action - } - } else { - this.toolBarItemBackground[i] = $r('sys.color.ohos_id_color_toolbar_bg') - this.menuContent = [] - } - } - return true - } - - aboutToAppear() { - this.refreshData() - } - build() { - Column() { - Divider().width('100%').height(1) - Column() { - Tabs({ barPosition: BarPosition.End, controller: this.controller}) { - ForEach(this.toolBarList, (item: ToolBarOption, index: number) => { - if (this.toolBarList.length <= 5) { - TabContent() { - }.tabBar(this.TabBuilder(index)) - .enabled(!(this.toolBarList[index].state === 2)) - .focusOnTouch(!(this.toolBarList[index].state === 2)) - } else if (index < 4){ - TabContent() { - }.tabBar(this.TabBuilder(index)) - .enabled(!(this.toolBarList[index].state === 2)) - .focusOnTouch(!(this.toolBarList[index].state === 2)) - } - }) - if (this.refreshData() && this.toolBarList.length > 5) { - TabContent() { - }.tabBar(this.MoreTabBuilder(4)) - } - } - .vertical(false) - .constraintSize({ minHeight: 56, maxHeight: 56}) - .barMode(BarMode.Fixed) - .onChange((index: number) => { - }) - .width('100%') - .backgroundColor($r('sys.color.ohos_id_color_toolbar_bg')) - }.width('100%') - } - } -} \ No newline at end of file diff --git a/source/TreeView/TreeView.ets b/source/TreeView/TreeView.ets deleted file mode 100644 index 8f56915dcf91723e10c6c3b8d92c308014928eca..0000000000000000000000000000000000000000 --- a/source/TreeView/TreeView.ets +++ /dev/null @@ -1,3327 +0,0 @@ -/* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export namespace TreeView { - const IMAGE_NODE_HEIGHT: number = 24 - const IMAGE_NODE_WIDTH: number = 24 - const ITEM_WIDTH: number = 0 - const ITEM_HEIGHT: number = 44 - const ITEM_HEIGHT_INPUT: number = 32 - const BORDER_WIDTH_HAS: number = 2 - const BORDER_WIDTH_NONE: number = 0 - const NODE_HEIGHT: number = 44 - const LIST_ITEM_HEIGHT_NONE: number = 0 - const LIST_ITEM_HEIGHT: number = 48 - const SHADOW_OFFSETY: number = 10 - const FLAG_NUMBER: number = 2 - const DRAG_OPACITY: number = 0.4 - const DRAG_OPACITY_NONE: number = 1 - const FLAG_LINE_HEIGHT: string = '1.5vp' - const X_OFF_SET: string = '0vp' - const Y_OFF_SET: string = '2.75vp' - const Y_BOTTOM_OFF_SET: string = '-1.25vp' - const Y_BASE_PLATE_OFF_SET: string = '1.5vp' - const COLOR_SELECT: string = '#1A0A59F7' - const COLOR_IMAGE_ROW: string = '#00000000' - const COLOR_IMAGE_EDIT: string = '#FFFFFF' - const SHADOW_COLOR: string = '#00001E' - const GRAG_POP_UP_HEIGHT: string = '48' - const LEFT_PADDING: string = '8vp' - const RIGHT_PADDING: string = '8vp' - const FLOOR_MIN_WIDTH: string = '128vp' - const FLOOR_MAX_WIDTH: string = '208vp' - const TEXT_MIN_WIDTH: string = '80vp' - const TEXT_MAX_WIDTH: string = '160vp' - const MIN_WIDTH: string = '112vp' - const MAX_WIDTH: string = '192vp' - - export class TreeListener { - _events = [] - - constructor() { - } - - /* - * Event registration and processing. - * - * The event will not be destroyed after being processed. - * - * @param type Registered Events. - * @param callback Event callback. - * @since 10 - */ - public on(type: TreeListenType, callback: (callbackParam: CallbackParam) => void) { - if (Array.isArray(type)) { - for (let i = 0, l = type.length; i < l; i++) { - this.on(type[i], callback) - } - } else { - (this._events[type] || (this._events[type] = [])).push(callback) - } - } - - /* - * Event registration and processing. - * - * After the event is processed once, it will be destroyed. - * - * @param type Registered Events. - * @param callback Event callback. - * @since 10 - */ - public once(type: TreeListenType, callback: (callbackParam: CallbackParam) => void) { - let _self = this; - function handler() { - _self.off(type, handler); - callback.apply(null, [type, callback]); - } - - handler.callback = callback; - this.on(type, handler); - } - - /* - * Destroy event. - * - * @param type Registered Events. - * @param callback Event callback. - * @since 10 - */ - public off(type: TreeListenType, callback: (callbackParam: CallbackParam) => void) { - if (type == null) { - this._events = []; - } - if (Array.isArray(type)) { - for (let i = 0, l = type.length; i < l; i++) { - this.off(type[i], callback) - } - } - const cbs = this._events[type]; - if (!cbs) { - return; - } - if (callback == null) { - this._events[type] = null - } - let cb, i = cbs.length - while (i--) { - cb = cbs[i] - if (cb === callback || cb.callback === callback) { - cbs.splice(i, 1) - break - } - } - } - - /* - * Triggers all callbacks of an event with parameters. - * - * @param event Registered Events. - * @param argument Parameters returned by the callback event. - * @since 10 - */ - public emit(event, argument: any[]) { - let _self = this - if (!this._events[event]) { - return - } - let cbs = [...this._events[event]]; - if (cbs) { - for (let i = 0, l = cbs.length; i < l; i++) { - try { - cbs[i].apply(_self,argument) - } catch (e) { - new Error(e) - } - } - } - } - } - - /* - * TreeListenType listen type. - * - * @since 10 - */ - export enum TreeListenType { - NODE_ADD = "NodeAdd", - NODE_DELETE = "NodeDelete", - NODE_MODIFY = "NodeModify", - NODE_MOVE = "NodeMove", - NODE_CLICK = 'NodeClick', - } - - /* - * TreeListenerManager. - * - * @since 10 - */ - export class TreeListenerManager { - static readonly APP_KEY_EVENT_BUS = "app_key_event_bus"; - private appEventBus: TreeListener; - private constructor() { - this.appEventBus = new TreeListener(); - } - - /* - * Obtains the EventBusManager object. - * - * @since 10 - */ - public static getInstance(): TreeListenerManager { - if (AppStorage.Get(this.APP_KEY_EVENT_BUS) == null) { - AppStorage.SetOrCreate(this.APP_KEY_EVENT_BUS, new TreeListenerManager()) - } - return AppStorage.Get(this.APP_KEY_EVENT_BUS); - } - - /* - * Obtains the EventBus object. - * - * @since 10 - */ - public getTreeListener(): TreeListener { - return this.appEventBus; - } - } - - class BasicDataSource implements IDataSource { - private listeners: DataChangeListener[] = [] - - public totalCount(): number { - return 0 - } - public getData(index: number): any { - return undefined - } - - registerDataChangeListener(listener: DataChangeListener): void { - if (this.listeners.indexOf(listener) < 0) { - this.listeners.push(listener) - } - } - unregisterDataChangeListener(listener: DataChangeListener): void { - const pos = this.listeners.indexOf(listener); - if (pos >= 0) { - this.listeners.splice(pos, 1) - } - } - - notifyDataReload(): void { - this.listeners.forEach(listener => { - listener.onDataReloaded() - }) - } - notifyDataAdd(index: number): void { - this.listeners.forEach(listener => { - listener.onDataAdd(index) - }) - } - notifyDataChange(index: number): void { - this.listeners.forEach(listener => { - listener.onDataChange(index) - }) - } - notifyDataDelete(index: number): void { - this.listeners.forEach(listener => { - listener.onDataDelete(index) - }) - } - notifyDataMove(from: number, to: number): void { - this.listeners.forEach(listener => { - listener.onDataMove(from, to) - }) - } - } - - export enum Event { - TOUCH_DOWN = 0, - TOUCH_UP = 1, - HOVER = 3, - HOVER_OVER = 4, - FOCUS = 5, - BLUR = 6, - MOUSE_BUTTON_RIGHT = 7, - DRAG = 8 - } - - export enum MenuOperation { - ADD_NODE = 0, - REMOVE_NODE = 1, - MODIFY_NODE = 2, - COMMIT_NODE = 3 - } - - export enum PopUpType { - HINTS = 0, - WARNINGS = 1 - } - - export enum InputError { - INVALID_ERROR = 0, - LENGTH_ERROR = 1, - NONE = 2 - } - - export enum Flag { - DOWN_FLAG = 0, - UP_FLAG = 1, - NONE = 2 - } - - export class NodeItem { - private nodeItem: { imageNode?: ImageNode, - mainTitleNode?: MainTitleNode, - imageCollapse?: ImageNode}; - private childNodeInfo: { isHasChildNode: boolean, childNum: number, allChildNum: number }; - menu: () => void; - nodeLevel: number; - parentNodeId: number; - currentNodeId: number; - children: Array; - data: { isFolder?: boolean, - icon?: Resource, - selectedIcon?: Resource, - editIcon?: Resource, - primaryTitle?: string, - menu?: () => void, - objectCount?: number | string } - - constructor(data: { isFolder?: boolean, - icon?: Resource, - selectedIcon?: Resource, - editIcon?: Resource, - primaryTitle?: string, - menu?: () => void, - objectCount?: number | string }) { - this.data = data; - this.nodeLevel = -1; - this.parentNodeId = -1; - this.nodeItem = { imageNode: null, mainTitleNode: null, imageCollapse: null }; - this.childNodeInfo = { isHasChildNode: false, childNum: 0, allChildNum: 0 }; - this.menu = data.menu; - if (data.icon) { - this.nodeItem.imageNode = new ImageNode(data.icon, data.selectedIcon, data.editIcon, - $r('sys.float.ohos_id_alpha_content_fourth'), - IMAGE_NODE_HEIGHT, - IMAGE_NODE_WIDTH); - } - if (data.primaryTitle) { - this.nodeItem.mainTitleNode = new MainTitleNode(data.primaryTitle); - } - this.children = []; - } - - addImageCollapse(isHasChildNode: boolean) { - if (isHasChildNode) { - this.nodeItem.imageCollapse = new ImageNode($r('sys.media.ohos_ic_public_arrow_right'), null, null, - $r('sys.float.ohos_id_alpha_content_tertiary'), - IMAGE_NODE_HEIGHT, - IMAGE_NODE_WIDTH); - this.nodeItem.imageCollapse.itemRightMargin = ($r('sys.float.ohos_id_text_paragraph_margin_xs')); - } else { - this.nodeItem.imageCollapse = null; - } - } - - getNodeItem() { - return this.nodeItem; - } - - getChildNodeInfo() { - return this.childNodeInfo; - } - - getMenu(): () => void { - return this.menu; - } - - getCurrentNodeId() { - return this.currentNodeId; - } - - getIsFolder() { - return this.data.isFolder; - } - } - - class NodeBaseInfo { - public rightMargin: Resource | number; - private width: number; - private height: number; - constructor() { - } - - set itemWidth(width: number) { - this.width = width; - } - - get itemWidth(): number { - return this.width; - } - - set itemHeight(height: number) { - this.height = height; - } - - get itemHeight(): number { - return this.height; - } - - set itemRightMargin(rightMargin: Resource | number) { - this.rightMargin = rightMargin; - } - - get itemRightMargin() { - return this.rightMargin; - } - } - - export enum NodeStatus { - Expand = 0, - Collapse - } - - export enum InteractionStatus { - Normal = 0, - Selected, - Edit, - FinishEdit, - DragInsert, - FinishDragInsert - } - - export class ImageNode extends NodeBaseInfo { - private imageSource: Resource; - private imageNormalSource: Resource; - private imageSelectedSource: Resource; - private imageEditSource: Resource; - private imageOpacity: Resource; - private currentInteractionStatus: InteractionStatus; - private imageCollapseSource: Resource; - private imageCollapseDownSource: Resource; - private isImageCollapse: boolean; - private imageCollapseRightSource: Resource; - constructor(imageSource: Resource, itemSelectedIcon: Resource, itemEditIcon: Resource, - imageOpacity: Resource, itemWidth: number, itemHeight: number) { - super(); - this.rightMargin = $r('sys.float.ohos_id_elements_margin_horizontal_m'); - this.imageSource = imageSource; - this.imageNormalSource = imageSource; - if (itemSelectedIcon != null) { - this.imageSelectedSource = itemSelectedIcon; - } else { - this.imageSelectedSource = this.imageNormalSource; - } - if (itemEditIcon != null) { - this.imageEditSource = itemEditIcon; - } else { - this.imageEditSource = this.imageNormalSource; - } - this.imageOpacity = imageOpacity; - this.itemWidth = itemWidth; - this.itemHeight = itemHeight; - this.imageCollapseSource = imageSource; - this.imageCollapseDownSource = $r('sys.media.ohos_ic_public_arrow_down'); - this.imageCollapseRightSource = $r('sys.media.ohos_ic_public_arrow_right'); - this.isImageCollapse = true; - } - - get source() { - return this.imageSource; - } - - get normalSource() { - return this.imageNormalSource; - } - - get selectedSource() { - return this.imageSelectedSource; - } - - get editSource() { - return this.imageEditSource; - } - - get opacity() { - return this.imageOpacity; - } - - get noOpacity() { - return 1; - } - - get collapseSource() { - return this.imageCollapseSource; - } - - get isCollapse() { - return this.isImageCollapse; - } - - changeImageCollapseSource(nodeStatus: NodeStatus) { - if (nodeStatus == NodeStatus.Expand) { - this.imageCollapseSource = this.imageCollapseDownSource; - } else if (nodeStatus == NodeStatus.Collapse) { - this.imageCollapseSource = this.imageCollapseRightSource; - } - } - - setImageCollapseSource(interactionStatus: InteractionStatus, nodeStatus: NodeStatus) { - if (interactionStatus === InteractionStatus.Edit || interactionStatus === InteractionStatus.DragInsert) { - this.imageCollapseDownSource = $r('sys.media.ohos_ic_public_arrow_down'); - this.imageCollapseRightSource = $r('sys.media.ohos_ic_public_arrow_right'); - this.isImageCollapse = false; - } else if (interactionStatus === InteractionStatus.FinishEdit || - interactionStatus === InteractionStatus.FinishDragInsert) { - this.imageCollapseDownSource = $r('sys.media.ohos_ic_public_arrow_down'); - this.imageCollapseRightSource = $r('sys.media.ohos_ic_public_arrow_right'); - this.isImageCollapse = true; - } - this.imageCollapseSource = (nodeStatus == NodeStatus.Collapse) ? - this.imageCollapseRightSource : this.imageCollapseDownSource; - } - - setImageSource(interactionStatus: InteractionStatus) { - switch (interactionStatus) { - case InteractionStatus.Normal: - this.imageSource = this.imageNormalSource; - this.currentInteractionStatus = interactionStatus; - break; - case InteractionStatus.Selected: - if (this.currentInteractionStatus !== InteractionStatus.Edit) { - this.imageSource = this.imageSelectedSource; - this.currentInteractionStatus = interactionStatus; - } - break; - case InteractionStatus.Edit: - this.imageSource = this.imageEditSource; - this.currentInteractionStatus = interactionStatus; - break; - case InteractionStatus.FinishEdit: - this.imageSource = this.imageSelectedSource; - this.currentInteractionStatus = interactionStatus; - break; - case InteractionStatus.DragInsert: - this.imageSource = this.imageEditSource; - this.currentInteractionStatus = interactionStatus; - break; - case InteractionStatus.FinishDragInsert: - this.imageSource = this.imageNormalSource; - this.currentInteractionStatus = interactionStatus; - break; - default: - break; - } - } - } - - export class MainTitleNode extends NodeBaseInfo { - private mainTitleName: string; - private mainTitleSetting: { fontColor: Resource, fontSize: Resource, fontWeight: FontWeight } - private showPopUpTimeout: number; - constructor(mainTitleName: string) { - super(); - this.mainTitleName = mainTitleName; - this.itemWidth = ITEM_WIDTH; - this.itemHeight = ITEM_HEIGHT; - this.rightMargin = $r('sys.float.ohos_id_text_paragraph_margin_xs'); - this.mainTitleSetting = { fontColor: $r('sys.color.ohos_id_color_primary'), - fontSize: $r('sys.float.ohos_id_text_size_body1'), - fontWeight: FontWeight.Normal }; - this.showPopUpTimeout = 0; - } - setMainTitleSelected(isSelected: boolean): void { - if (isSelected) { - this.mainTitleSetting = { fontColor: $r('sys.color.ohos_id_color_text_primary_activated'), - fontSize: $r('sys.float.ohos_id_text_size_body1'), - fontWeight: FontWeight.Regular }; - } else { - this.mainTitleSetting = { fontColor: $r('sys.color.ohos_id_color_primary'), - fontSize: $r('sys.float.ohos_id_text_size_body1'), - fontWeight: FontWeight.Normal }; - } - } - set title(text: string) { - this.mainTitleName = text; - } - get title(): string { - return this.mainTitleName; - } - - set popUpTimeout(showPopUpTimeout: number) { - this.showPopUpTimeout = showPopUpTimeout; - } - - get popUpTimeout() { - return this.showPopUpTimeout; - } - - get color(): Resource { - return this.mainTitleSetting.fontColor; - } - - - get size(): Resource { - return this.mainTitleSetting.fontSize; - } - - get weight(): FontWeight { - return this.mainTitleSetting.fontWeight; - } - - setMainTitleHighLight(isHighLight: boolean): void { - if (isHighLight) { - this.mainTitleSetting = { fontColor: $r('sys.color.ohos_id_color_primary_contrary'), - fontSize: $r('sys.float.ohos_id_text_size_body1'), - fontWeight: FontWeight.Regular }; - } else { - this.mainTitleSetting = { fontColor: $r('sys.color.ohos_id_color_primary'), - fontSize: $r('sys.float.ohos_id_text_size_body1'), - fontWeight: FontWeight.Normal }; - } - } - - } - - export class InputText extends NodeBaseInfo { - private inputTextSetting: { fontColor: Resource, fontSize: Resource, fontWeight: FontWeight } - private status: { normal: Resource, hover: Resource, press: Resource }; - private statusColor: Resource = $r('sys.color.ohos_id_color_background'); - private editItemColor: Resource = $r('sys.color.ohos_id_color_emphasize'); - private radius: Resource = $r('sys.float.ohos_id_corner_radius_default_xs') - constructor() { - super(); - this.itemWidth = ITEM_WIDTH; - this.itemHeight = ITEM_HEIGHT_INPUT; - this.rightMargin = $r('sys.float.ohos_id_text_paragraph_margin_xs'); - this.inputTextSetting = { - fontColor: $r('sys.color.ohos_id_color_text_primary'), - fontSize: $r('sys.float.ohos_id_text_size_body1'), - fontWeight: FontWeight.Normal }; - } - - get color(): Resource { - return this.inputTextSetting.fontColor; - } - - get size(): Resource { - return this.inputTextSetting.fontSize; - } - - get weight(): FontWeight { - return this.inputTextSetting.fontWeight; - } - - get borderRadius(): Resource { - return this.radius; - } - - get backgroundColor() { - return this.statusColor; - } - - get editColor() { - return this.editItemColor; - } - - get textInputStatusColor() { - return this.status; - } - } - - export class NodeInfo { - private childNodeInfo: { isHasChildNode: boolean, childNum: number, allChildNum: number }; - private parentNodeId: number; - private currentNodeId: number; - private nodeHeight: Resource | number; - private nodeLevel: number; - private nodeItem: { imageNode?: ImageNode, - inputText: InputText, - mainTitleNode?: MainTitleNode, - imageCollapse?: ImageNode }; - private nodeLeftPadding: number; - private nodeColor: Resource | string; - private nodeIsShow: boolean; - private status: { normal: Resource, hover: Resource, press: Resource, selected: string, highLight: Resource }; - private nodeBorder: { borderWidth: Resource | number, borderColor: Resource, borderRadius: Resource }; - private popUpInfo: { popUpIsShow: boolean, - popUpEnableArrow: boolean, - popUpColor: Resource, - popUpText: string | Resource, - popUpTextColor: Resource}; - private listItemHeight: number; - private menu: () => void; - private isShowTitle: boolean; - private isShowInputText: boolean; - private isSelected: boolean; - readonly borderWidth: {has: Resource | number, none: Resource | number } = - {has: BORDER_WIDTH_HAS/* 2vp */, none: BORDER_WIDTH_NONE/* 0vp */} - - /* parameter of the drag event.*/ - private nodeParam: { - isFolder?: boolean, - icon?: Resource, - selectedIcon?: Resource, - editIcon?: Resource, - primaryTitle?: string, - menu?: () => void, - secondaryTitle?: number | string - }; - private node: NodeItem; - private canShowFlagLine: boolean = false; - private isOverBorder: boolean = false; - private canShowBottomFlagLine: boolean = false; - private isHighLight: boolean = false; - private flagLineLeftMargin: number; - private isModify: boolean = false; - - constructor(node: NodeItem) { - this.childNodeInfo = node.getChildNodeInfo(); - this.nodeItem = { imageNode: null, inputText: null, mainTitleNode: null, imageCollapse: null }; - this.popUpInfo = { popUpIsShow: false, - popUpEnableArrow: false, - popUpColor: null, - popUpText: '', - popUpTextColor: null }; - this.nodeItem.imageNode = node.getNodeItem().imageNode; - this.nodeItem.inputText = new InputText(); - this.nodeItem.mainTitleNode = node.getNodeItem().mainTitleNode; - this.nodeItem.imageCollapse = node.getNodeItem().imageCollapse; - this.menu = node.menu; - this.parentNodeId = node.parentNodeId; - this.currentNodeId = node.currentNodeId; - this.nodeHeight = NODE_HEIGHT; - this.nodeLevel = node.nodeLevel; - this.nodeLeftPadding = node.nodeLevel * 12 + 8; // calculate left padding - this.nodeColor = $r('sys.color.ohos_id_color_background'); - this.nodeIsShow = (this.nodeLevel > 0) ? false : true; - this.listItemHeight = (this.nodeLevel > 0) ? LIST_ITEM_HEIGHT_NONE : LIST_ITEM_HEIGHT; - this.isShowTitle = true; - this.isShowInputText = false; - this.isSelected = false; - this.status = { normal: $r('sys.color.ohos_id_color_background_transparent'), - hover: $r('sys.color.ohos_id_color_hover'), - press: $r('sys.color.ohos_id_color_click_effect'), - selected: COLOR_SELECT, - highLight: $r('sys.color.ohos_id_color_activated') - }; - this.nodeBorder = { borderWidth: BORDER_WIDTH_NONE, - borderColor: $r('sys.color.ohos_id_color_focused_outline'), - borderRadius: $r('sys.float.ohos_id_corner_radius_clicked') - }; - this.flagLineLeftMargin = node.nodeLevel * 12 + 8; - this.node = node; - this.nodeParam = node.data; - } - - getPopUpInfo() { - return this.popUpInfo; - } - - setPopUpIsShow(isShow: boolean) { - this.popUpInfo.popUpIsShow = isShow; - } - - setPopUpEnableArrow(popUpEnableArrow: boolean) { - this.popUpInfo.popUpEnableArrow = popUpEnableArrow; - } - - setPopUpColor(color: Resource) { - this.popUpInfo.popUpColor = color; - } - - setPopUpText(text: string | Resource) { - this.popUpInfo.popUpText = text; - } - - setPopUpTextColor(popUpTextColor: Resource) { - this.popUpInfo.popUpTextColor = popUpTextColor; - } - - getIsShowTitle() { - return this.isShowTitle; - } - - getIsShowInputText() { - return this.isShowInputText; - } - - setTitleAndInputTextStatus(isModify: boolean) { - if (isModify) { - this.isShowTitle = false; - this.isShowInputText = true; - } else { - this.isShowTitle = true; - this.isShowInputText = false; - } - } - - handleImageCollapseAfterAddNode(isAddImageCollapse: boolean) { - // listTree this node already has ImageCollapse. - if (isAddImageCollapse) { - this.nodeItem.imageCollapse = new ImageNode($r('sys.media.ohos_ic_public_arrow_down'), null, null, - $r('sys.float.ohos_id_alpha_content_tertiary'), - IMAGE_NODE_HEIGHT, - IMAGE_NODE_WIDTH); - this.nodeItem.imageCollapse.itemRightMargin = ($r('sys.float.ohos_id_text_paragraph_margin_xs')); - } else { - this.nodeItem.imageCollapse = null; - } - } - - setNodeColor(nodeColor: Resource | string): void { - this.nodeColor = nodeColor; - } - - getNodeColor(): Resource | string { - return this.nodeColor; - } - - setListItemHeight(listItemHeight: number): void { - this.listItemHeight = listItemHeight; - } - - getListItemHeight(): number { - return this.listItemHeight; - } - - getNodeCurrentNodeId(): number { - return this.currentNodeId; - } - - getNodeParentNodeId(): number { - return this.parentNodeId; - } - - getNodeLeftPadding(): number { - return this.nodeLeftPadding; - } - - getNodeHeight(): Resource | number { - return this.nodeHeight; - } - - setNodeIsShow(nodeIsShow: boolean): void { - this.nodeIsShow = nodeIsShow; - } - - getNodeIsShow(): boolean { - return this.nodeIsShow; - } - - getNodeItem() { - return this.nodeItem; - } - - getNodeStatus() { - return this.status; - } - - getNodeBorder() { - return this.nodeBorder; - } - - setNodeBorder(isClearFocusStatus: boolean): void { - this.nodeBorder.borderWidth = isClearFocusStatus ? this.borderWidth.has : this.borderWidth.none; - } - - getChildNodeInfo() { - return this.childNodeInfo; - } - - getCurrentNodeId() { - return this.currentNodeId; - } - - getMenu() { - return this.menu; - } - - setIsSelected(isSelected: boolean) { - this.isSelected = isSelected; - } - - getIsSelected() { - return this.isSelected; - } - - /* To gain the information while to alter node. */ - getNodeInfoData() { - return this.nodeParam; - } - - /* To gain the tree Node(NodeItem) while to alter node. */ - public getNodeInfoNode() { - return this.node; - } - - public getIsFolder() { - return this.nodeParam.isFolder; - } - - public setCanShowFlagLine(canShowFlagLine: boolean) { - this.canShowFlagLine = canShowFlagLine; - } - - public getCanShowFlagLine(): boolean { - return this.canShowFlagLine; - } - - public setFlagLineLeftMargin(currentNodeLevel: number) { - this.flagLineLeftMargin = currentNodeLevel * 12 + 8; // calculate - } - - public getFlagLineLeftMargin(): number { - return this.flagLineLeftMargin; - } - - public getNodeLevel(): number { - return this.nodeLevel; - } - - public setIsOverBorder(isOverBorder: boolean) { - this.isOverBorder = isOverBorder; - } - - public getIsOverBorder() { - return this.isOverBorder; - } - - public setCanShowBottomFlagLine(canShowBottomFlagLine: boolean) { - this.canShowBottomFlagLine = canShowBottomFlagLine; - } - - public getCanShowBottomFlagLine() { - return this.canShowBottomFlagLine; - } - - public setIsHighLight(isHighLight: boolean) { - this.isHighLight = isHighLight; - } - - public getIsHighLight(): boolean { - return this.isHighLight; - } - - public setIsModify(isModify: boolean) { - this.isModify = isModify; - } - - public getIsModify(): boolean { - return this.isModify; - } - - } - - - export class ListNodeUtils { - private _root: NodeItem; - public addNewNodeId: number; - private readonly MaxNodeLevel = 50; - private readonly MAX_CN_LENGTH: number = 254; - private readonly MAX_EN_LENGTH: number = 255; - private readonly INITIAL_INVALID_VALUE = -1; - constructor() { - this._root = new NodeItem({}); - this._root.nodeLevel = -1; - this._root.parentNodeId = -1; - this._root.currentNodeId = -1; - } - - getNewNodeId() { - return this.addNewNodeId; - } - - traverseNodeDF(callback, root: NodeItem = this._root) { - let stack = [], found = false; - stack.unshift(root); - let currentNode = stack.shift(); - while(!found && currentNode) { - found = callback(currentNode) === true; - if (!found) { - stack.unshift(...currentNode.children); - currentNode = stack.shift(); - } - } - } - - traverseNodeBF(callback) { - let queue = []; - let found: boolean = false; - queue.push(this._root); - let currentNode: NodeItem = queue.shift(); - while(!found && currentNode) { - try { - found = callback(currentNode); - } catch(err) { - var e = err.name + " == " + err.message; - } - if (!found) { - queue.push(...currentNode.children) - currentNode = queue.shift(); - } - } - } - - private contains(callback, traversal) { - traversal.call(this, callback, true); - } - - private updateParentChildNum(parentNode: NodeItem, isAdd: boolean, count: number) { - let parentNodeId: number = parentNode.parentNodeId; - while(parentNodeId >= 0) { - this.traverseNodeDF((node: NodeItem): boolean => { - if (node.currentNodeId == parentNodeId) { - node.getChildNodeInfo().allChildNum = - isAdd ? node.getChildNodeInfo().allChildNum + count : node.getChildNodeInfo().allChildNum - count; - parentNodeId = node.parentNodeId; - return false; - } - return false; - }) - } - } - - findParentNodeId(currentNodeId: number): number { - let current = null, - callback = function(node): boolean { - if (node.currentNodeId == currentNodeId ) { - current = node; - return true; - } - return false; - }; - this.contains(callback, this.traverseNodeBF); - return current.parentNodeId; - } - - addNode(parentNodeId: number, - currentNodeId: number, - data: { isFolder?: boolean, - icon?: Resource, - selectedIcon?: Resource, - editIcon?: Resource, - primaryTitle?: string, - secondaryTitle?: number | string, - menu?: () => void, - }): ListNodeUtils { - if (this._root === null) { - this._root = new NodeItem({}); - this._root.nodeLevel = -1; - this._root.parentNodeId = -1; - this._root.currentNodeId = -1; - } - - let parent = null, - callback = function(node): boolean { - if (node.currentNodeId == parentNodeId ) { - parent = node; - return true; - } - return false; - }; - this.contains(callback, this.traverseNodeBF); - if (parent) { - let currentNode: NodeItem = new NodeItem(data); - if (parent.nodeLevel > this.MaxNodeLevel) { - throw new Error('ListNodeUtils[addNode]: The level of the tree view cannot exceed 50.'); - } - currentNode.nodeLevel = parent.nodeLevel + 1; // nodeLevel - currentNode.parentNodeId = parentNodeId; - currentNode.currentNodeId = currentNodeId; - parent.children.push(currentNode); - parent.getChildNodeInfo().isHasChildNode = true; - parent.getChildNodeInfo().childNum = parent.children.length; - parent.getChildNodeInfo().allChildNum += 1; // childNum - parent.addImageCollapse(parent.getChildNodeInfo().isHasChildNode); - this.updateParentChildNum(parent, true, 1); - return this; - } else { - throw new Error('ListNodeUtils[addNode]: Parent node not found.'); - } - } - - findNodeIndex(children, currentNodeId: number) { - let index = this.INITIAL_INVALID_VALUE; - for (let i = 0, len = children.length; i < len; i++) { - if (children[i].currentNodeId === currentNodeId) { - index = i; - break; - } - } - return index; - } - - private freeNodeMemory(rootNode: NodeItem, removeNodeIdList: number[]) { - let deleteNode: NodeItem[] = []; - let callback = function(node): boolean { - deleteNode.push(node); - return false; - }; - this.traverseNodeDF(callback, rootNode); - deleteNode.forEach((value)=>{ - removeNodeIdList.push(value.currentNodeId); - value = null; - }) - } - - removeNode(currentNodeId: number, parentNodeId: number, traversal: any) { - let parent = null, - callback = function(node): boolean { - if (node.currentNodeId == parentNodeId) { - parent = node; - return true; - } - return false; - }; - this.contains(callback, traversal); - - if (parent) { - let removeNodeIdList: number[] = []; - let index = this.findNodeIndex(parent.children, currentNodeId); - if (index < 0) { - throw new Error('Node does not exist.'); - } else { - var deleteNodeAllChildNum = parent.children[index].getChildNodeInfo().allChildNum + 1; - this.freeNodeMemory(parent.children[index], removeNodeIdList); - let node = parent.children.splice(index, 1); - node = null; - if (parent.children.length == 0) { - parent.addImageCollapse(false); - } - } - parent.getChildNodeInfo().childNum = parent.children.length; - parent.getChildNodeInfo().allChildNum -= (deleteNodeAllChildNum); - this.updateParentChildNum(parent, false, deleteNodeAllChildNum); - return removeNodeIdList; - } else { - throw new Error('Parent does not exist.'); - } - } - - getNewNodeInfo(nodeId: number) { - let parent = null, - callback = function(node): boolean { - if (node.currentNodeId == nodeId) { - parent = node; - return true; - } - return false; - }; - this.contains(callback, this.traverseNodeBF); - let newNodeInfo: { isFolder: boolean, icon: Resource, selectedIcon: Resource, editIcon: Resource, menu: () => any, secondaryTitle: number | string } = - { isFolder: true, icon: null, selectedIcon: null, editIcon: null, menu: null, secondaryTitle: '' }; - if (parent) { - if (parent.children.length === 0) { - if (parent.getNodeItem().imageNode != null) { - newNodeInfo.icon = parent.getNodeItem().imageNode.normalSource; - newNodeInfo.selectedIcon = parent.getNodeItem().imageNode.selectedSource; - newNodeInfo.editIcon = parent.getNodeItem().imageNode.editSource; - newNodeInfo.menu = parent.getMenu(); - } else { - newNodeInfo.icon = null; - newNodeInfo.selectedIcon = null; - newNodeInfo.editIcon = null; - newNodeInfo.menu = parent.getMenu(); - } - } else if (parent.children.length > 0) { - if (parent.getNodeItem().imageNode != null) { - newNodeInfo.icon = (parent.children[0].getNodeItem().imageNode != null) ? - parent.children[0].getNodeItem().imageNode.normalSource : null; - newNodeInfo.selectedIcon = (parent.children[0].getNodeItem().imageNode != null) ? - parent.children[0].getNodeItem().imageNode.selectedSource : null; - newNodeInfo.editIcon = (parent.children[0].getNodeItem().imageNode != null) ? - parent.children[0].getNodeItem().imageNode.editSource : null; - newNodeInfo.menu = parent.children[0].getMenu(); - } else { - newNodeInfo.icon = null; - newNodeInfo.selectedIcon = null; - newNodeInfo.editIcon = null; - newNodeInfo.menu = parent.children[0].getMenu(); - } - } - } - return newNodeInfo; - } - - getClickChildId(nodeId: number) { - let parent = null, - callback = function(node): boolean { - if (node.currentNodeId == nodeId) { - parent = node; - return true; - } - return false; - }; - this.contains(callback, this.traverseNodeBF); - if (parent) { - if (parent.children.length === 0) { - return []; - } else if (parent.children.length > 0) { - var nodeInfo: { itemId: number, itemIcon: Resource, itemTitle: string } = - { itemId: null, itemIcon: null, itemTitle: null } - var childrenNodeInfo: Array = new Array(parent.children.length); - for (let i = 0; i < childrenNodeInfo.length; i++) { - childrenNodeInfo[i] = 0; - } - for (let i = 0; i < parent.children.length && i < childrenNodeInfo.length; i++) { - childrenNodeInfo[i] = parent.children[i].currentNodeId; - } - return childrenNodeInfo; - } - } - return []; - } - - getClickNodeChildrenInfo(nodeId: number) { - let parent = null, - callback = function(node): boolean { - if (node.currentNodeId == nodeId) { - parent = node; - return true; - } - return false; - }; - this.contains(callback, this.traverseNodeBF); - if (parent) { - if (parent.children.length === 0) { - return []; - } else if (parent.children.length > 0) { - var nodeInfo: { itemId: number, itemIcon: Resource, itemTitle: string } = - { itemId: null, itemIcon: null, itemTitle: null } - var childrenNodeInfo: Array<{ itemId: number, itemIcon: Resource, itemTitle: string, isFolder: boolean }> = new Array(parent.children.length); - for (let i = 0; i < childrenNodeInfo.length; i++) { - childrenNodeInfo[i] = { itemId: null, itemIcon: null, itemTitle: null, isFolder: null }; - } - for (let i = 0; i < parent.children.length && i < childrenNodeInfo.length; i++) { - childrenNodeInfo[i].itemId = parent.children[i].currentNodeId; - if (parent.children[i].getNodeItem().imageNode) { - childrenNodeInfo[i].itemIcon = parent.children[i].getNodeItem().imageNode.source; - } - if (parent.children[i].getNodeItem().mainTitleNode) { - childrenNodeInfo[i].itemTitle = parent.children[i].getNodeItem().mainTitleNode.title; - } - childrenNodeInfo[i].isFolder = parent.children[i].getIsFolder(); - } - return childrenNodeInfo; - } - } - return []; - } - - public checkMainTitleIsValid(title: string) : boolean { - let invalid = /[\\\/:*?"<>|]/; - let invalidLength = /^[\u4e00-\u9fa5]+$/; - if (invalid.test(title)) { - return false; - } - if ((invalidLength.test(title) && title.length > this.MAX_CN_LENGTH) || - (!invalidLength.test(title) && title.length > this.MAX_EN_LENGTH)) { - return false; - } - return true; - } - - /* - * DFS: Depth first traversal in drag event. - * @param callback - */ - dragTraverseNodeDF(callback, root: NodeItem = this._root, listNode) { - let stack = [], found = false; - stack.unshift(root); - let currentNode = stack.shift(); - while(!found && currentNode) { - found = callback(currentNode, listNode) === true; - if (!found) { - stack.unshift(...currentNode.children); - currentNode = stack.shift(); - } - } - } - - /* - * Add the first dragging node in dragging nodes - * 1.the first dragging node needs to distinguish the position to insert - */ - addDragNode(parentNodeId: number, - currentNodeId: number, - insertCurrentNodeId: number, - isAfter: boolean, - data: { isFolder?: boolean, - icon?: Resource, - selectedIcon?: Resource, - editIcon?: Resource, - primaryTitle?: string, - menu?: () => any, - objectCount?: number }): ListNodeUtils { - - if (this._root === null) { - this._root = new NodeItem({}); - this._root.nodeLevel = this.INITIAL_INVALID_VALUE; - this._root.parentNodeId = this.INITIAL_INVALID_VALUE; - this._root.currentNodeId = this.INITIAL_INVALID_VALUE; - } - - let parent = null, - callback = function(node): boolean { - if (node.currentNodeId == parentNodeId ) { - parent = node; - return true; - } - return false; - }; - this.contains(callback, this.traverseNodeBF); - if (parent) { - let currentNode: NodeItem = new NodeItem(data); - if (parent.nodeLevel > this.MaxNodeLevel) { - throw new Error('ListNodeUtils[addNode]: The level of the tree view cannot exceed 50.'); - } - currentNode.nodeLevel = parent.nodeLevel + 1; - currentNode.parentNodeId = parentNodeId; - currentNode.currentNodeId = currentNodeId; - let insertIndex: number = this.INITIAL_INVALID_VALUE; - if (parent.children.length) { - for (let i = 0; i < parent.children.length; i++) { - if ( parent.children[i].getCurrentNodeId() == insertCurrentNodeId) { - insertIndex = i; - break; - } - } - if (isAfter) { - parent.children.splice(insertIndex + 1, 0, currentNode); - } else { - parent.children.splice(insertIndex, 0, currentNode); - } - } else { - parent.children.push(currentNode); - } - parent.getChildNodeInfo().isHasChildNode = true; - parent.getChildNodeInfo().childNum = parent.children.length; - parent.getChildNodeInfo().allChildNum += 1; - parent.addImageCollapse(parent.getChildNodeInfo().isHasChildNode); - this.updateParentChildNum(parent, true, 1); - return this; - } else { - throw new Error('ListNodeUtils[addNode]: Parent node not found.'); - } - } - - } - - - export class ListNodeDataSource extends BasicDataSource { - readonly ROOT_NODE_ID = -1; - private listNodeUtils: ListNodeUtils = new ListNodeUtils(); - private listNode: NodeInfo[] = []; - private readonly INITIAL_INVALID_VALUE = -1; - private lastIndex: number = -1; // record the last focused node. - thisIndex: number = -1; // records clicked nodes in the current period. - private modifyNodeIndex: number = -1; // records the nodes edited in the current period. - modifyNodeId: number = -1 - private currentOperation: MenuOperation; - private expandAndCollapseInfo = new Map(); - private loadedNodeIdAndIndexMap = new Map(); // [currentNodeId, index] - private isTouchDown: boolean = false; - private appEventBus: TreeListener = TreeListenerManager.getInstance().getTreeListener(); - - /* parameter of the drag event. */ - private isInnerDrag: boolean = false; // Judge whether it is an internal drag event. - private isDrag: boolean = false; // It is used to handle events(For example, prevent press events) during global drag. - private draggingCurrentNodeId: number = this.INITIAL_INVALID_VALUE; // Record the current ID of the dragged node. - private draggingParentNodeId: number = this.INITIAL_INVALID_VALUE; // Record the parent ID of the dragged node. - private currentNodeInfo: NodeInfo = null; // To solve the problem of currentIndex missed in onDrop event. - private listItemOpacity : number = 1; // It is used to set the opacity of the node when dragged. - private lastPassIndex: number = this.INITIAL_INVALID_VALUE; // record the last passing node index in drag. - private lastPassId: number = this.INITIAL_INVALID_VALUE; // record the last passing node Id in drag. - private thisPassIndex: number = this.INITIAL_INVALID_VALUE; // record the current passing node in drag. - private lastDelayExpandIndex: number = this.INITIAL_INVALID_VALUE; // record last passing node in delay expand event. - private timeoutExpandId: number = this.INITIAL_INVALID_VALUE; - private lastTimeoutExpandId: number = this.INITIAL_INVALID_VALUE; - private clearTimeoutExpandId: number = this.INITIAL_INVALID_VALUE; - private timeoutHighLightId: number = this.INITIAL_INVALID_VALUE; - private lastTimeoutHighLightId: number = this.INITIAL_INVALID_VALUE; - private clearTimeoutHighLightId: number = this.INITIAL_INVALID_VALUE; - private lastDelayHighLightIndex: number = this.INITIAL_INVALID_VALUE; // record last passing node in HighLight event. - private lastDelayHighLightId: number = this.INITIAL_INVALID_VALUE; //record last passing node Id in HighLight event. - private nodeIdAndSubtitleMap = new Map(); // [currentNodeId, subtitle] - private flag: Flag = Flag.NONE; - private selectedParentNodeId: number = this.INITIAL_INVALID_VALUE; - private selectedParentNodeSubtitle: any = ''; - private insertNodeSubtitle: any = ''; - private currentFocusNodeId: number = this.INITIAL_INVALID_VALUE; - private lastFocusNodeId: number = this.INITIAL_INVALID_VALUE; - private addFocusNodeId: number = this.INITIAL_INVALID_VALUE; - - readonly FLAG_LINE: { flagLineHeight: string, - flagLineColor: Resource, - xOffset: string, - yTopOffset: string, - yBottomOffset: string, - yBasePlateOffset: string } = { - flagLineHeight: FLAG_LINE_HEIGHT, - flagLineColor: $r('sys.color.ohos_id_color_activated'), - xOffset: X_OFF_SET, - yTopOffset: Y_OFF_SET, - yBottomOffset: Y_BOTTOM_OFF_SET, - yBasePlateOffset: Y_BASE_PLATE_OFF_SET - } - - private readonly DRAG_POPUP: { floorConstraintSize: { minWidth: string, maxWidth: string }, - textConstraintSize: { minWidth1: string, maxWidth1: string, - minWidth2: string, maxWidth2: string }, - padding: { left: string, right: string }, - backgroundColor: ResourceColor, - height: string, - shadow: { radius: Resource, color: ResourceColor, offsetX?: number, offsetY?: number }, - borderRadius : Resource, - fontColor: Resource, - fontSize: Resource, - fontWeight: FontWeight - imageOpacity: Resource } = { - floorConstraintSize: { minWidth: FLOOR_MIN_WIDTH, maxWidth: FLOOR_MAX_WIDTH }, - textConstraintSize: { minWidth1: TEXT_MIN_WIDTH, maxWidth1: TEXT_MAX_WIDTH, minWidth2: MIN_WIDTH, maxWidth2: MAX_WIDTH }, - padding: { left: LEFT_PADDING, right: RIGHT_PADDING }, - backgroundColor: COLOR_IMAGE_EDIT, - height: GRAG_POP_UP_HEIGHT, - shadow: { radius: $r('sys.float.ohos_id_corner_radius_default_m'), color: SHADOW_COLOR, offsetX: 0, offsetY: SHADOW_OFFSETY }, - borderRadius: $r('sys.float.ohos_id_corner_radius_clicked'), - fontColor: $r('sys.color.ohos_id_color_primary'), - fontSize: $r('sys.float.ohos_id_text_size_body1'), - fontWeight: FontWeight.Regular, - imageOpacity: $r('sys.float.ohos_id_alpha_content_fourth') - } - - private readonly subTitle: { normalFontColor: Resource, - highLightFontColor: Resource, - fontSize: Resource, - fontWeight: FontWeight, - margin: { left: string, right: string } } = { - normalFontColor: $r('sys.color.ohos_id_color_secondary'), - highLightFontColor: $r('sys.color.ohos_id_color_primary_contrary'), - fontSize: $r('sys.float.ohos_id_text_size_body2'), - fontWeight: FontWeight.Regular, - margin: { left: '4vp', right: '24' } - } - - private changeNodeColor(index: number, color: Resource | string): void { - this.listNode[index].setNodeColor(color); - } - - private getNodeColor(index) { - return this.listNode[index].getNodeColor(); - } - - private handleFocusEffect(index: number, isClearFocusStatus: boolean) { - if (this.listNode[index].getNodeIsShow()) { - this.listNode[index].setNodeBorder(isClearFocusStatus); - } - } - - private setImageSource(index: number, interactionStatus: InteractionStatus) { - let nodeInfo: NodeInfo = this.listNode[index]; - nodeInfo.setIsSelected(interactionStatus === InteractionStatus.Selected || - interactionStatus === InteractionStatus.Edit || interactionStatus === InteractionStatus.FinishEdit); - if (nodeInfo.getNodeItem().mainTitleNode != null && interactionStatus != InteractionStatus.DragInsert && - interactionStatus != InteractionStatus.FinishDragInsert) { - nodeInfo.getNodeItem().mainTitleNode.setMainTitleSelected(interactionStatus === InteractionStatus.Selected || - interactionStatus === InteractionStatus.FinishEdit); - } - if (nodeInfo.getNodeItem().imageNode != null) { - nodeInfo.getNodeItem().imageNode.setImageSource(interactionStatus); - } - } - - private setImageCollapseSource(index: number, interactionStatus: InteractionStatus) { - let nodeInfo: NodeInfo = this.listNode[index]; - if (nodeInfo.getNodeItem().imageCollapse != null) { - nodeInfo.getNodeItem().imageCollapse.setImageCollapseSource(interactionStatus, - this.expandAndCollapseInfo.get(nodeInfo.getCurrentNodeId())); - } - } - - public clearLastIndexStatus() { - if (this.lastIndex == -1 || this.lastIndex >= this.listNode.length) { - return; - } - this.setImageSource(this.lastIndex, InteractionStatus.Normal); - this.changeNodeColor(this.lastIndex, this.listNode[this.lastIndex].getNodeStatus().normal); - this.handleFocusEffect(this.lastIndex, false); - this.notifyDataChange(this.loadedNodeIdAndIndexMap.get(this.listNode[this.lastIndex].getCurrentNodeId())); - } - - private changeNodeStatus(clickIndex: number): void { - let thisIndex: number = clickIndex; - let tmp: NodeInfo[] = this.ListNode; - let nodeId = tmp[clickIndex].getCurrentNodeId(); - if (this.expandAndCollapseInfo.get(nodeId) == NodeStatus.Expand) { - this.expandAndCollapseInfo.set(nodeId, NodeStatus.Collapse); - tmp[thisIndex].getNodeItem().imageCollapse.changeImageCollapseSource(NodeStatus.Collapse); - } else if (this.expandAndCollapseInfo.get(nodeId) == NodeStatus.Collapse) { - this.expandAndCollapseInfo.set(nodeId, NodeStatus.Expand); - tmp[thisIndex].getNodeItem().imageCollapse.changeImageCollapseSource(NodeStatus.Expand); - } - } - - private handleExpandAndCollapse(clickIndex: number) { - let thisIndex: number = clickIndex; - let tmp: NodeInfo[] = this.ListNode; - let nodeId = tmp[thisIndex].getCurrentNodeId(); - if (!this.expandAndCollapseInfo.has(nodeId)) { - return; - } - - let rootNodeStatus: NodeStatus = this.expandAndCollapseInfo.get(nodeId); - if (tmp[thisIndex].getChildNodeInfo().isHasChildNode && rootNodeStatus == NodeStatus.Collapse) { - for(var i = 0; i < tmp[thisIndex].getChildNodeInfo().allChildNum; i++) { - tmp[thisIndex + 1 + i].setNodeIsShow(false); - tmp[thisIndex + 1 + i].setListItemHeight(LIST_ITEM_HEIGHT_NONE); - } - this.notifyDataReload(); - return; - } - - let childNum: number[] = new Array(tmp[thisIndex].getChildNodeInfo().childNum); - childNum[0] = thisIndex + 1; - let index = 1; - while(index < tmp[thisIndex].getChildNodeInfo().childNum) { - childNum[index] = childNum[index -1] + tmp[childNum[index - 1]].getChildNodeInfo().allChildNum + 1; - index++; - } - if (rootNodeStatus == NodeStatus.Expand) { - for(var i = 0; i < childNum.length; i++) { - tmp[childNum[i]].setNodeIsShow(true); - tmp[childNum[i]].setListItemHeight(LIST_ITEM_HEIGHT); - let nodeId = tmp[childNum[i]].getCurrentNodeId(); - if(this.expandAndCollapseInfo.get(nodeId) == NodeStatus.Expand) { - this.handleExpandAndCollapse(childNum[i]); - } - } - } - childNum = null; - this.notifyDataReload(); - } - - public init(listNodeUtils: ListNodeUtils) { - let index = 0; - this.listNode = []; - this.listNodeUtils = listNodeUtils; - this.loadedNodeIdAndIndexMap.clear(); - this.listNodeUtils.traverseNodeDF((node: NodeItem): boolean => { - if (node.currentNodeId >= 0) { - var nodeInfo: NodeInfo = new NodeInfo(node); - this.listNode.push(nodeInfo); - if (nodeInfo.getChildNodeInfo().isHasChildNode) { - this.expandAndCollapseInfo.set(nodeInfo.getCurrentNodeId(), NodeStatus.Collapse); - } - if (nodeInfo.getNodeIsShow()) { - this.loadedNodeIdAndIndexMap.set(nodeInfo.getCurrentNodeId(), index++); - } - if (nodeInfo.getIsFolder()) { - this.nodeIdAndSubtitleMap.set(nodeInfo.getCurrentNodeId(), - nodeInfo.getNodeInfoData().secondaryTitle || nodeInfo.getNodeInfoData().secondaryTitle == 0 ? - nodeInfo.getNodeInfoData().secondaryTitle : ''); - } - } - return false; - }); - } - - private refreshRemoveNodeData(removeNodeIdList: number[], parentNodeInfo: NodeInfo) { - let deleteIndexList: number[] = []; - for (let i = 0; i < removeNodeIdList.length; i++) { - for (let j = 0; j < this.listNode.length; j++) { - if (this.listNode[j].getNodeCurrentNodeId() == removeNodeIdList[i]) { - let currentNodeId = this.listNode[j].getNodeCurrentNodeId(); - if (this.loadedNodeIdAndIndexMap.has(currentNodeId)) { - // this.listNode index to lazyForEach index. - deleteIndexList.push(this.loadedNodeIdAndIndexMap.get(currentNodeId)); - } - let deleteNode = this.listNode.splice(j, 1); - deleteNode = null; // free memory - if (this.expandAndCollapseInfo.has(removeNodeIdList[i])) { - this.expandAndCollapseInfo.delete(removeNodeIdList[i]); // delete deleteNode expandAndCollapseInfo. - } - break; - } - } - } - deleteIndexList.forEach((value)=>{ - this.notifyDataDelete(value); // notifyDataDelete do not update data. - this.notifyDataChange(value); // call notifyDataChange to update data. - }) - let index: number = 0; - for (let i = 0; i < this.listNode.length; i++) { - if (this.listNode[i].getNodeCurrentNodeId() == parentNodeInfo.getNodeCurrentNodeId()) { - if (parentNodeInfo.getNodeItem().imageCollapse == null) { - this.listNode[i].handleImageCollapseAfterAddNode(false); - // delete deleteNode parentNode expandAndCollapseInfo. - this.expandAndCollapseInfo.delete(parentNodeInfo.getNodeCurrentNodeId()); - this.notifyDataChange(this.loadedNodeIdAndIndexMap.get(this.listNode[i].getNodeCurrentNodeId())); - } - break; - } - } - let callbackParam: CallbackParam = {currentNodeId: parentNodeInfo.getNodeCurrentNodeId(), parentNodeId: parentNodeInfo.getNodeParentNodeId()}; - this.appEventBus.emit(TreeListenType.NODE_DELETE, [callbackParam]); - } - - private refreshAddNodeData(addNodeIdList: number[]) { - var addNodeInfo: NodeInfo; - this.listNodeUtils.traverseNodeDF((node: NodeItem): boolean => { - if (node.currentNodeId === addNodeIdList[0]) { - addNodeInfo = new NodeInfo(node); - return true; - } - return false; - }); - addNodeInfo.setIsModify(true); - - let index: number = 0; - for (let i = 0; i < this.listNode.length; i++) { - if (this.listNode[i].getNodeCurrentNodeId() == addNodeInfo.getNodeParentNodeId()) { - index = i; - if (this.listNode[i].getNodeItem().imageCollapse == null) { - this.listNode[i].handleImageCollapseAfterAddNode(true); - this.notifyDataChange(index); - } else if (this.expandAndCollapseInfo.get(this.listNode[i].getNodeCurrentNodeId()) == NodeStatus.Collapse) { - this.changeNodeStatus(index); - } - this.listNode.splice(i + 1, 0, addNodeInfo); - this.listNode[i + 1].setTitleAndInputTextStatus(true); // false->true: realize inner Interaction. - this.listNode[i + 1].setNodeIsShow(true); - this.listNode[i + 1].setListItemHeight(LIST_ITEM_HEIGHT); - this.setImageSource(i + 1, InteractionStatus.Edit); // Normal->Edit : realize inner Interaction. - this.currentOperation = MenuOperation.ADD_NODE; - this.notifyDataAdd(i + 1); - this.notificationNodeInfo(i+1, this.currentOperation); - break; - } - } - this.modifyNodeIndex = index + 1; - this.expandAndCollapseInfo.set(addNodeInfo.getNodeParentNodeId(), NodeStatus.Expand); - this.handleExpandAndCollapse(index); - } - - public refreshData(listNodeUtils: ListNodeUtils, operation: MenuOperation, - parentNodeId: number, changeNodeIdList: number[]) { - let parentNodeInfo: NodeInfo; - this.listNodeUtils = listNodeUtils; - this.listNodeUtils.traverseNodeDF((node: NodeItem): boolean => { - if (node.currentNodeId == parentNodeId) { - parentNodeInfo = new NodeInfo(node); - return true; - } - return false; - }); - - if (operation === MenuOperation.REMOVE_NODE) { - this.nodeIdAndSubtitleMap.set(parentNodeId, this.selectedParentNodeSubtitle); - this.notifyDataChange(this.loadedNodeIdAndIndexMap.get(parentNodeId)); - this.refreshRemoveNodeData(changeNodeIdList, parentNodeInfo); - } - - if (operation === MenuOperation.ADD_NODE) { - this.addFocusNodeId = changeNodeIdList[0]; - this.nodeIdAndSubtitleMap.set(this.getClickNodeId(), this.selectedParentNodeSubtitle); - this.nodeIdAndSubtitleMap.set(changeNodeIdList[0], this.insertNodeSubtitle); - this.refreshAddNodeData(changeNodeIdList); - } - } - - public setClickIndex(index: number) { - this.thisIndex = index; - } - - public getClickNodeId(): number { - if (this.thisIndex < 0 || this.thisIndex >= this.ListNode.length) { - return -1; - } - return this.ListNode[this.thisIndex].getCurrentNodeId(); - } - - public expandAndCollapseNode(clickIndex: number) { - this.changeNodeStatus(clickIndex); - this.handleExpandAndCollapse(clickIndex) - } - - public getIsTouchDown(): boolean { - return this.isTouchDown; - } - - public getLastIndex(): number { - return this.lastIndex; - } - - public handleEvent(event: Event, index: number) { - /* Return while the event is dragging event. */ - if (this.isDrag) { - return; - } - - if (event === Event.TOUCH_DOWN || event === Event.TOUCH_UP || event === Event.MOUSE_BUTTON_RIGHT) { - if (index != this.lastIndex) { - this.clearLastIndexStatus(); - } - } - let lazyForEachIndex = this.loadedNodeIdAndIndexMap.get(this.listNode[index].getCurrentNodeId()); - switch(event) { - case Event.TOUCH_DOWN: - this.isTouchDown = true; - this.changeNodeColor(index, this.listNode[index].getNodeStatus().press); - break; - case Event.TOUCH_UP: { - if (this.isInnerDrag) { - this.isInnerDrag = false; - } - this.isTouchDown = false; - let nodeInfo: NodeInfo = this.listNode[index]; - this.setImageSource(index, InteractionStatus.Selected); - this.lastIndex = index; - this.changeNodeColor(index, nodeInfo.getNodeStatus().selected); - this.notifyDataChange(lazyForEachIndex); - break; - } - case Event.HOVER: - if (this.getNodeColor(index) != this.listNode[index].getNodeStatus().selected) { - this.changeNodeColor(index, this.listNode[index].getNodeStatus().hover); - this.notifyDataChange(lazyForEachIndex); - } - break; - case Event.HOVER_OVER: - if (this.getNodeColor(index) != this.listNode[index].getNodeStatus().selected) { - this.changeNodeColor(index, this.listNode[index].getNodeStatus().normal); - this.notifyDataChange(lazyForEachIndex); - } - break; - case Event.FOCUS: - this.handleFocusEffect(index, true); - this.notifyDataChange(lazyForEachIndex); - break; - case Event.BLUR: - this.handleFocusEffect(index, false); - this.notifyDataChange(lazyForEachIndex); - break; - case Event.MOUSE_BUTTON_RIGHT: - this.lastIndex = index; - this.finishEditing(); - break; - case Event.DRAG: - this.isTouchDown = false; - let nodeInfo: NodeInfo = this.listNode[index]; - this.setImageSource(index, InteractionStatus.Selected); - this.lastIndex = index; - this.changeNodeColor(index, nodeInfo.getNodeStatus().selected); - this.notifyDataChange(lazyForEachIndex); - break; - default: - break; - } - } - - private notificationNodeInfo(addNodeId: number, operation: MenuOperation) { - if (operation === MenuOperation.MODIFY_NODE) { - let modifyNodeInfo: NodeInfo = this.listNode[this.modifyNodeIndex]; - let backParamModify: CallbackParam = { currentNodeId: modifyNodeInfo.getNodeCurrentNodeId(), - parentNodeId: modifyNodeInfo.getNodeParentNodeId() } - this.appEventBus.emit(TreeListenType.NODE_MODIFY, - [backParamModify]); - } else if (operation === MenuOperation.ADD_NODE) { - let addNodeInfo: NodeInfo = this.listNode[addNodeId]; - let icon: Resource = (addNodeInfo.getNodeItem().imageNode != null) ? - addNodeInfo.getNodeItem().imageNode.source : null; - let selectedIcon: Resource = (addNodeInfo.getNodeItem().imageNode != null) ? - addNodeInfo.getNodeItem().imageNode.selectedSource : null; - let editIcon: Resource = (addNodeInfo.getNodeItem().imageNode != null) ? - addNodeInfo.getNodeItem().imageNode.editSource : null; - let callbackParam: CallbackParam = { currentNodeId: addNodeInfo.getNodeCurrentNodeId(), - parentNodeId: addNodeInfo.getNodeParentNodeId() } - this.appEventBus.emit(TreeListenType.NODE_ADD, - [callbackParam]); - } - } - - public finishEditing() { - if (this.modifyNodeIndex!= -1) { - this.setImageSource(this.modifyNodeIndex, InteractionStatus.FinishEdit); - this.setImageCollapseSource(this.modifyNodeIndex, InteractionStatus.FinishEdit); - this.listNode[this.modifyNodeIndex].setIsModify(false); - this.listNode[this.modifyNodeIndex].setTitleAndInputTextStatus(false); - this.notificationNodeInfo(this.modifyNodeIndex, this.currentOperation); - this.notifyDataChange(this.modifyNodeIndex); - } - } - - public setItemVisibilityOnEdit(nodeId: number, operation: MenuOperation) { - let index: number = -1; - if (nodeId == -1) { - return; - } - if (operation === MenuOperation.MODIFY_NODE) { - for (let i = 0; i < this.listNode.length; i++) { // nodeId to find index - if (this.listNode[i].getCurrentNodeId() == nodeId) { - index = i; - break; - } - } - let nodeInfo: NodeInfo = this.listNode[index]; - nodeInfo.setIsModify(true); - if (nodeInfo.getNodeItem().mainTitleNode === null) { - return; // no title - } - - this.currentOperation = MenuOperation.MODIFY_NODE; - nodeInfo.setTitleAndInputTextStatus(true); - this.setImageSource(index, InteractionStatus.Edit); - this.setImageCollapseSource(index, InteractionStatus.Edit); - this.modifyNodeIndex = index; - if (nodeInfo.getNodeItem().inputText) { - if (nodeInfo.getNodeItem().imageCollapse != null) { - nodeInfo.getNodeItem().inputText.rightMargin = - $r('sys.float.ohos_id_text_paragraph_margin_xs') - } else { - nodeInfo.getNodeItem().inputText.rightMargin = - $r('sys.float.ohos_id_elements_margin_horizontal_m') - } - } - this.notifyDataChange(this.loadedNodeIdAndIndexMap.get(nodeId)); - } - index = nodeId; - if (operation === MenuOperation.COMMIT_NODE) { - let nodeInfo: NodeInfo = this.listNode[index]; - nodeInfo.setTitleAndInputTextStatus(false); - nodeInfo.setIsModify(false); - this.setImageSource(index, InteractionStatus.FinishEdit); - this.setImageCollapseSource(index, InteractionStatus.FinishEdit); - this.notificationNodeInfo(this.modifyNodeIndex, this.currentOperation); - this.notifyDataChange(this.loadedNodeIdAndIndexMap.get(nodeInfo.getCurrentNodeId())); - } - } - - public setPopUpInfo(popUpType: PopUpType, inputError: InputError, isShow: boolean, index: number) { - let nodeInfo: NodeInfo = this.listNode[index]; - nodeInfo.setPopUpIsShow(isShow); - // this.listNode index to lazyForEach index. - let lazyForEachIndex = this.loadedNodeIdAndIndexMap.get(nodeInfo.getCurrentNodeId()); - if (!isShow) { - this.notifyDataChange(lazyForEachIndex); - return; - } - if (popUpType === PopUpType.HINTS) { - if (nodeInfo.getNodeItem().mainTitleNode != null) { - nodeInfo.setPopUpText(nodeInfo.getNodeItem().mainTitleNode.title); - } else { - nodeInfo.setPopUpText(''); - nodeInfo.setPopUpIsShow(false); - } - nodeInfo.setPopUpEnableArrow(false); - nodeInfo.setPopUpColor($r('sys.color.ohos_id_color_background')); - nodeInfo.setPopUpTextColor($r('sys.color.ohos_id_color_text_secondary')); - } else if (popUpType === PopUpType.WARNINGS) { - if (nodeInfo.getNodeItem().inputText != null) { - if (inputError === InputError.INVALID_ERROR) { - nodeInfo.setPopUpText("invalid error"); - } else if (inputError === InputError.LENGTH_ERROR) { - nodeInfo.setPopUpText("length error"); - } - nodeInfo.setPopUpEnableArrow(true); - nodeInfo.setPopUpColor($r('sys.color.ohos_id_color_help_tip_bg')); - nodeInfo.setPopUpTextColor($r('sys.color.ohos_id_color_text_hint_contrary')); - } - } - this.notifyDataChange(lazyForEachIndex); - } - - public setShowPopUpTimeout(timeout: number, index: number) { - if (this.listNode[index].getNodeItem().mainTitleNode != null) { - this.listNode[index].getNodeItem().mainTitleNode.popUpTimeout = timeout; - } - // this.notifyDataChange(index) lazyForEachIndex; - let lazyForEachIndex = this.loadedNodeIdAndIndexMap.get(this.listNode[index].getCurrentNodeId()); - this.notifyDataChange(lazyForEachIndex); - } - - public setMainTitleNameOnEdit(index: number, text: string) { - this.modifyNodeIndex = index; - if (this.listNode[index].getNodeItem().mainTitleNode != null) { - this.listNode[index].getNodeItem().mainTitleNode.title = text; - // this.listNode index to lazyForEach index. - let lazyForEachIndex = this.loadedNodeIdAndIndexMap.get(this.listNode[index].getCurrentNodeId()); - this.notifyDataChange(lazyForEachIndex); - } - } - - public get ListNode(): NodeInfo[] { - return this.listNode; - } - - public totalCount(): number { - let count: number = 0; - let index: number = 0; - this.loadedNodeIdAndIndexMap.clear(); - for (let i =0 ; i < this.listNode.length; i++) { - if (this.listNode[i].getNodeIsShow()) { - this.loadedNodeIdAndIndexMap.set(this.listNode[i].getCurrentNodeId(), index++); - count++; - } - } - return count; - } - - public getData(index: number): any { - let count = 0; - for (let i = 0; i < this.listNode.length; i++) { - if (this.listNode[i].getNodeIsShow()) { - if (index == count) { - return this.listNode[i]; - } - count++; - } - } - return null; - } - - public addData(index: number, data: NodeInfo): void { - this.listNode.splice(index, 0, data) - this.notifyDataAdd(index) - } - - public pushData(data: NodeInfo): void { - this.listNode.push(data) - this.notifyDataAdd(this.listNode.length - 1) - } - - public setIsInnerDrag(isInnerDrag: boolean) { - this.isInnerDrag = isInnerDrag; - } - - public getIsInnerDrag(): boolean { - return this.isInnerDrag; - } - - public setIsDrag(isDrag: boolean) { - this.isDrag = isDrag; - } - - public getIsDrag(): boolean { - return this.isDrag; - } - - public setCurrentNodeInfo(currentNodeInfo: NodeInfo) { - this.currentNodeInfo = currentNodeInfo; - } - - public getCurrentNodeInfo() { - return this.currentNodeInfo; - } - - public setDraggingParentNodeId(draggingParentNodeId: number) { - this.draggingParentNodeId = draggingParentNodeId; - } - - public getDraggingParentNodeId() { - return this.draggingParentNodeId; - } - - public getDraggingCurrentNodeId() { - return this.draggingCurrentNodeId; - } - - public setDraggingCurrentNodeId(draggingCurrentNodeId: number) { - this.draggingCurrentNodeId = draggingCurrentNodeId; - } - - public setListItemOpacity(listItemOpacity: number) { - this.listItemOpacity = listItemOpacity; - } - - public getListItemOpacity(item: NodeInfo) { - return item.getCurrentNodeId() == this.getDraggingCurrentNodeId() ? this.listItemOpacity : 1; - } - - public getDragPopupPara() { - return this.DRAG_POPUP; - } - - public setLastPassIndex(lastPassIndex: number) { - this.lastPassIndex = lastPassIndex; - } - - public getLastPassIndex(): number { - return this.lastPassIndex; - } - - public getIsParentOfInsertNode(insertNodeId: number): boolean { - let selectedNodeItem: NodeItem = this.currentNodeInfo.getNodeInfoNode(); - let isParentNodeOfInsertNode = false, - callback = function(node): boolean { - if (node.currentNodeId == insertNodeId ) { - isParentNodeOfInsertNode = true; - return true; - } - return false; - }; - this.listNodeUtils.traverseNodeDF(callback, selectedNodeItem); - return isParentNodeOfInsertNode; - } - - public setPassIndex(thisPassIndex: number) { - this.thisPassIndex = thisPassIndex; - } - - public getPassIndex(): number { - return this.thisPassIndex; - } - - public clearTimeOutAboutDelayHighLightAndExpand(currentIndex: number) { - if (this.lastPassId != this.INITIAL_INVALID_VALUE && this.loadedNodeIdAndIndexMap.has(this.lastPassId)) { - let index: number = this.loadedNodeIdAndIndexMap.get(this.lastPassId); - let that =this; - this.ListNode.forEach(function(value) { - if (value.getNodeCurrentNodeId() == that.lastPassId) { - value.setCanShowFlagLine(false); - } - }) - this.notifyDataChange(index); - } - - if ((this.lastTimeoutHighLightId != this.INITIAL_INVALID_VALUE && - this.clearTimeoutHighLightId != this.lastTimeoutHighLightId)) { - clearTimeout(this.lastTimeoutHighLightId); - if (this.lastDelayHighLightIndex != this.INITIAL_INVALID_VALUE) { - this.clearHighLight(this.lastDelayHighLightIndex); - let index: number = this.loadedNodeIdAndIndexMap - .get(this.listNode[this.lastDelayHighLightIndex].getCurrentNodeId()); - this.notifyDataChange(index); - } - this.clearTimeoutHighLightId = this.lastTimeoutHighLightId; - } - this.lastTimeoutHighLightId = this.timeoutHighLightId; - this.lastDelayHighLightIndex = currentIndex; - - if ((this.lastTimeoutExpandId != this.INITIAL_INVALID_VALUE && - this.clearTimeoutExpandId != this.lastTimeoutExpandId)) { - clearTimeout(this.lastTimeoutExpandId); - this.clearTimeoutExpandId = this.lastTimeoutExpandId; - } - this.lastTimeoutExpandId = this.timeoutExpandId; - this.lastDelayExpandIndex = this.INITIAL_INVALID_VALUE; - } - - public clearHighLight(currentIndex: number) { - this.changeNodeColor(currentIndex, this.listNode[currentIndex].getNodeStatus().normal); - this.changeNodeHighLightColor(currentIndex, false); - this.setImageSource(currentIndex, InteractionStatus.FinishDragInsert); - this.setImageCollapseSource(currentIndex, InteractionStatus.FinishDragInsert); - this.listNode[currentIndex].setIsHighLight(false); - } - - private changeNodeHighLightColor(index: number, isHighLight: boolean): void { - if (this.listNode[index].getNodeItem().mainTitleNode && this.listNode[index].getIsShowTitle()) { - this.listNode[index].getNodeItem().mainTitleNode.setMainTitleHighLight(isHighLight); - } - } - - public setVisibility(flag: Flag, index: number, isOverBorder: boolean) { - let isChanged: boolean = (this.thisPassIndex != index || this.flag != flag) ? true : false; - this.thisPassIndex = index; - if ((isChanged || isOverBorder) && this.isInnerDrag) { - this.flag = flag; - let currentNodeId: number = this.getData(index).getCurrentNodeId(); - let currentNodeLevel: number = this.expandAndCollapseInfo.get(currentNodeId) == NodeStatus.Expand && - this.flag == Flag.DOWN_FLAG ? this.getData(index).getNodeLevel() + 1 : this.getData(index).getNodeLevel(); - if (this.lastPassId != this.INITIAL_INVALID_VALUE && this.loadedNodeIdAndIndexMap.has(this.lastPassId)) { - let lastIndex: number = this.loadedNodeIdAndIndexMap.get(this.lastPassId); - let that = this; - this.ListNode.forEach(function (value) { - if (value.getNodeCurrentNodeId() == that.lastPassId) { - value.setCanShowFlagLine(false); - } - }) - this.notifyDataChange(lastIndex); - } - if (this.flag == Flag.DOWN_FLAG && index < this.totalCount() - 1) { - this.getData(index).setCanShowFlagLine(false); - this.getData(index+1).setCanShowFlagLine(true); - this.getData(index).setCanShowBottomFlagLine(false); - this.getData(index+1).setFlagLineLeftMargin(currentNodeLevel); - this.notifyDataChange(index); - this.notifyDataChange(index + 1); - this.lastPassId = this.getData(index + 1).getNodeCurrentNodeId(); - } else if (this.flag == Flag.UP_FLAG && index < this.totalCount() - 1) { - this.getData(index).setCanShowFlagLine(true); - this.getData(index+1).setCanShowFlagLine(false); - this.getData(index).setCanShowBottomFlagLine(false); - this.getData(index).setFlagLineLeftMargin(currentNodeLevel); - this.notifyDataChange(index); - this.notifyDataChange(index + 1); - this.lastPassId = this.getData(index).getNodeCurrentNodeId(); - } else if (index >= this.totalCount() - 1) { - if (this.flag == Flag.DOWN_FLAG) { - this.getData(index).setCanShowFlagLine(false); - this.getData(index).setCanShowBottomFlagLine(true); - } else { - this.getData(index).setCanShowFlagLine(true); - this.getData(index).setCanShowBottomFlagLine(false); - } - this.getData(index).setFlagLineLeftMargin(currentNodeLevel); - this.notifyDataChange(index); - this.lastPassId = this.getData(index).getNodeCurrentNodeId(); - } - } - } - - public delayHighLightAndExpandNode(currentIndex: number, currentNodeId: number, showIndex: number) { - let isChangIndex: boolean = currentIndex != this.lastDelayExpandIndex ? true : false; - let isOverBorder: boolean = this.getData(showIndex).getIsOverBorder(); - if (isOverBorder) { - this.lastDelayExpandIndex = this.INITIAL_INVALID_VALUE; - } else { - this.lastDelayExpandIndex = currentIndex; - } - if (isOverBorder || isChangIndex) { - let that = this; - - /* highLight node time-out. */ - let canDelayHighLight: boolean = !isOverBorder && (!this.isInnerDrag || - (this.expandAndCollapseInfo.get(currentNodeId) == NodeStatus.Collapse && this.isInnerDrag) || - (!this.expandAndCollapseInfo.has(currentNodeId) && this.listNode[currentIndex].getIsFolder())); - if (canDelayHighLight) { - /* set hoverState color before highLight. */ - this.changeNodeColor(currentIndex, this.listNode[currentIndex].getNodeStatus().hover); - this.notifyDataChange(showIndex); - - let delayHighLightTime: number = this.isInnerDrag ? 1000 : 0; // ms - this.timeoutHighLightId = setTimeout(function() { - that.delayHighLight(currentIndex); - }, delayHighLightTime) - } - if (isOverBorder || (this.lastTimeoutHighLightId != this.INITIAL_INVALID_VALUE && - this.clearTimeoutHighLightId != this.lastTimeoutHighLightId)) { - clearTimeout(this.lastTimeoutHighLightId); - if (this.lastDelayHighLightIndex != this.INITIAL_INVALID_VALUE) { - this.clearHighLight(this.lastDelayHighLightIndex); - this.notifyDataReload(); - } - this.clearTimeoutHighLightId = this.lastTimeoutHighLightId; - } - this.lastTimeoutHighLightId = this.timeoutHighLightId; - this.lastDelayHighLightIndex = currentIndex; - - /* alter flagLine and expand node time-out. */ - if (!isOverBorder && this.expandAndCollapseInfo.get(currentNodeId) == NodeStatus.Collapse) { - let firstChildNodeId: number = this.getData(showIndex).getNodeInfoNode().children[0].currentNodeId; - let delayAlterFlagLineAndExpandNodeTime: number = 2000; // ms - this.timeoutExpandId = setTimeout(function() { - that.clearHighLight(that.lastDelayHighLightIndex); - that.alterFlagLineAndExpandNode(currentIndex, firstChildNodeId); - }, delayAlterFlagLineAndExpandNodeTime) - } - if (isOverBorder || (this.lastTimeoutExpandId != this.INITIAL_INVALID_VALUE && - this.clearTimeoutExpandId != this.lastTimeoutExpandId)) { - clearTimeout(this.lastTimeoutExpandId); - this.clearTimeoutExpandId = this.lastTimeoutExpandId; - } - this.lastTimeoutExpandId = this.timeoutExpandId; - } - } - - public delayHighLight(currentIndex: number) { - let that =this; - this.ListNode.forEach(function (value) { - if (value.getNodeCurrentNodeId() == that.lastPassId) { - value.setCanShowFlagLine(false); - value.setCanShowBottomFlagLine(false); - } - }) - this.changeNodeColor(currentIndex, this.listNode[currentIndex].getNodeStatus().highLight); - this.listNode[currentIndex].setIsHighLight(true); - this.changeNodeHighLightColor(currentIndex, true); - this.setImageSource(currentIndex, InteractionStatus.DragInsert); - this.setImageCollapseSource(currentIndex, InteractionStatus.DragInsert); - this.notifyDataReload(); - } - - public alterFlagLineAndExpandNode(currentIndex: number, firstChildNodeId: number) { - let that =this; - this.ListNode.forEach(function (value) { - if (value.getNodeCurrentNodeId() == that.lastPassId) { - value.setCanShowFlagLine(false); - value.setCanShowBottomFlagLine(false); - } - }) - this.ListNode.forEach(function (value) { - if (that.isInnerDrag && value.getNodeCurrentNodeId() == firstChildNodeId) { - value.setCanShowFlagLine(true); - } - }) - this.changeNodeStatus(currentIndex); - this.handleExpandAndCollapse(currentIndex); - this.lastPassId = firstChildNodeId; - } - - public hideLastLine() { - if (this.lastPassId != this.INITIAL_INVALID_VALUE && this.loadedNodeIdAndIndexMap.has(this.lastPassId)) { - let that = this; - this.ListNode.forEach(function (value) { - if (value.getNodeCurrentNodeId() == that.lastPassId) { - value.setCanShowFlagLine(false); - value.setCanShowBottomFlagLine(false); - } - }) - let index: number = this.loadedNodeIdAndIndexMap.get(this.lastPassId); - this.notifyDataChange(index); - } - } - - public clearLastTimeoutHighLight() { - if (this.lastTimeoutHighLightId != this.INITIAL_INVALID_VALUE && - this.clearTimeoutHighLightId != this.lastTimeoutHighLightId) { - clearTimeout(this.lastTimeoutHighLightId); - if (this.lastDelayHighLightIndex != this.INITIAL_INVALID_VALUE) { - this.clearHighLight(this.lastDelayHighLightIndex); - } - } - } - - public clearLastTimeoutExpand() { - if (this.lastTimeoutExpandId != this.INITIAL_INVALID_VALUE && - this.clearTimeoutExpandId != this.lastTimeoutExpandId) { - clearTimeout(this.lastTimeoutExpandId); - } - } - - public getSubtitle(currentNodeId: number): string { - if (this.nodeIdAndSubtitleMap.has(currentNodeId)) { - if (typeof this.nodeIdAndSubtitleMap.get(currentNodeId) == "number") { - return this.nodeIdAndSubtitleMap.get(currentNodeId).toString(); - } else { - return this.nodeIdAndSubtitleMap.get(currentNodeId) - } - } else { - return ''; - } - } - - public hasSubtitle(currentNodeId: number) { - return this.nodeIdAndSubtitleMap.has(currentNodeId); - } - - public initialParameterAboutDelayHighLightAndExpandIndex() { - this.lastDelayHighLightIndex = this.INITIAL_INVALID_VALUE; - this.lastDelayExpandIndex = this.INITIAL_INVALID_VALUE; - this.lastPassIndex = this.INITIAL_INVALID_VALUE; - this.draggingCurrentNodeId = this.INITIAL_INVALID_VALUE; - this.flag = Flag.NONE; - } - - public refreshSubtitle(insertNodeCurrentNodeId: number) { - this.nodeIdAndSubtitleMap.set(this.selectedParentNodeId, this.selectedParentNodeSubtitle); - this.nodeIdAndSubtitleMap.set(insertNodeCurrentNodeId, this.insertNodeSubtitle); - this.notifyDataChange(this.loadedNodeIdAndIndexMap.get(this.selectedParentNodeId)); - this.notifyDataChange(this.loadedNodeIdAndIndexMap.get(insertNodeCurrentNodeId)); - } - - public setNodeSubtitlePara( - selectedParentNodeId: number, - selectedParentNodeSubtitle: ResourceStr, - insertNodeSubtitle: ResourceStr - ) { - this.selectedParentNodeId = selectedParentNodeId; - this.selectedParentNodeSubtitle = selectedParentNodeSubtitle; - this.insertNodeSubtitle = insertNodeSubtitle; - } - - public getInsertNodeSubtitle() { - return this.insertNodeSubtitle; - } - - public getExpandAndCollapseInfo(currentNodeId: number) { - return this.expandAndCollapseInfo.get(currentNodeId); - } - - public getLastDelayHighLightId() { - return this.lastDelayHighLightId; - } - - public setLastDelayHighLightId() { - this.ListNode.forEach((value, index) => { - if (index == this.lastDelayHighLightIndex) { - this.lastDelayHighLightId = value.getCurrentNodeId(); - } - }) - } - - public setLastPassId(lastPassId: number) { - this.lastPassId = lastPassId; - } - - public setLastDelayHighLightIndex(lastDelayHighLightIndex) { - this.lastDelayHighLightIndex = lastDelayHighLightIndex; - } - - /* - * Alter the current node location to a needful position. - * 1.Create an array named 'dragNodeParam' to store dragging node information. - * 2.Delete the dragging node from the tree. - * 3.Add the dragging node to the tree. - */ - public alterDragNode(rearParentNodeId: number, rearCurrentNodeId: number, insertNodeInfo: NodeInfo, - dragParentNodeId: number, dragCurrentNodeId: number, frontNodeInfoItem: NodeInfo) { - let dragNodeParam: { parentId: number, currentId: number, data: any }[] = []; - let parentNodeId: number = rearParentNodeId; - let currentNodeId: number = dragCurrentNodeId; - let nodeParam = frontNodeInfoItem.getNodeInfoData(); - let nodeInfo: NodeInfo = null; - let nodeInfoNode: NodeItem = frontNodeInfoItem.getNodeInfoNode(); - let isHighLight : boolean = false; - let insertChildIndex: number = this.INITIAL_INVALID_VALUE; - let currentChildIndex: number = this.INITIAL_INVALID_VALUE; - let isDownFlag: boolean = this.flag == Flag.DOWN_FLAG ? true : false; - - currentChildIndex = this.getChildIndex(dragParentNodeId, dragCurrentNodeId); - insertChildIndex = this.getChildIndex(rearParentNodeId, rearCurrentNodeId); - - if (rearParentNodeId != dragParentNodeId) { - insertChildIndex = isDownFlag ? insertChildIndex + 1 : insertChildIndex; - } else { - if (insertChildIndex > currentChildIndex) { - insertChildIndex = isDownFlag ? insertChildIndex : insertChildIndex - 1; - } else { - insertChildIndex = isDownFlag ? insertChildIndex + 1 : insertChildIndex; - } - } - - for (let i = 0; i < this.listNode.length; i++) { - if (this.listNode[i].getCurrentNodeId() == rearCurrentNodeId) { - isHighLight = this.listNode[i].getIsHighLight(); - if (this.flag == Flag.DOWN_FLAG && this.expandAndCollapseInfo.get(rearCurrentNodeId) == NodeStatus.Expand) { - parentNodeId = rearCurrentNodeId; - insertChildIndex = 0; - } else if (this.flag == Flag.UP_FLAG && this.expandAndCollapseInfo.get(rearCurrentNodeId) == NodeStatus.Expand - && this.listNode[i].getCanShowFlagLine() == false) { - parentNodeId = rearCurrentNodeId; - insertChildIndex = 0; - } else if (isHighLight) { - parentNodeId = rearCurrentNodeId; - insertChildIndex = 0; - } - break; - } - } - - let callbackParam: CallbackParam = { currentNodeId: currentNodeId, parentNodeId: parentNodeId, childIndex: insertChildIndex } - - /* export inner drag node Id. */ - this.appEventBus.emit(TreeListenType.NODE_MOVE, [callbackParam]); - - /* To store dragging node information by the array named 'dragNodeParam'. */ - dragNodeParam.push({parentId: parentNodeId, currentId: currentNodeId, data: nodeParam}); - - let oneself = null, - callback = function(node, listNode): boolean { - if (node) { - oneself = node; - parentNodeId = oneself.parentNodeId; - currentNodeId = oneself.currentNodeId; - for (let i = 0; i < listNode.length; i++) { - if (listNode[i].getNodeCurrentNodeId() == currentNodeId) { - nodeInfo = listNode[i]; - break; - } - } - nodeParam = nodeInfo.getNodeInfoData(); - if (parentNodeId != dragParentNodeId) { - dragNodeParam.push({parentId: parentNodeId, currentId: currentNodeId, data: nodeParam}); - } - return false; - } - return false; - } - this.listNodeUtils.dragTraverseNodeDF(callback, nodeInfoNode, this.listNode); - - /* Delete the dragging node from the tree. */ - this.listNodeUtils.removeNode(dragCurrentNodeId, dragParentNodeId, this.listNodeUtils.traverseNodeBF); - - /* - * Add the dragging node to the tree - * 1.The first dragging node is added singly, because it needs to distinguish the position to insert - * - * Add first node. - */ - let insertCurrentNodeId: number = rearCurrentNodeId; - let isAfter: boolean = isDownFlag; - if (this.expandAndCollapseInfo.get(rearCurrentNodeId) == NodeStatus.Expand) { - isAfter = false; - this.listNode.forEach((value) => { - if (value.getCurrentNodeId() == rearCurrentNodeId && value.getCanShowFlagLine() == false) { - if (value.getNodeInfoNode().children.length) { - insertCurrentNodeId = value.getNodeInfoNode().children[0].currentNodeId; - } else { - insertCurrentNodeId = this.INITIAL_INVALID_VALUE; - } - } - }) - } else if (!this.expandAndCollapseInfo.get(rearCurrentNodeId) && isHighLight) { - this.expandAndCollapseInfo.set(rearCurrentNodeId, NodeStatus.Expand); - } - - this.listNodeUtils.addDragNode(dragNodeParam[0].parentId, dragNodeParam[0].currentId, insertCurrentNodeId, - isAfter, dragNodeParam[0].data); - - /* Add remaining node. */ - for (let j = 1; j < dragNodeParam.length; j++) { - this.listNodeUtils.addNode(dragNodeParam[j].parentId, dragNodeParam[j].currentId, dragNodeParam[j].data); - } - - /* Update node data and reload the array named 'listNode'. */ - for (let i = 0; i < this.listNode.length; i++) { - if (this.listNode[i].getCurrentNodeId() == dragParentNodeId) { - if (this.listNode[i].getNodeInfoNode().getNodeItem().imageCollapse == null) { - this.listNode[i].handleImageCollapseAfterAddNode(false); - this.expandAndCollapseInfo.delete(dragParentNodeId); - break; - } - } - } - let tmp: NodeInfo[] = [...this.listNode]; - this.reloadListNode(this.listNodeUtils, tmp); - - } - - /* - * Reload the array named 'listNode' - * @param listNodeUtils - * @param tmp - */ - public reloadListNode(listNodeUtils: ListNodeUtils, tmp: NodeInfo[]) { - let index = 0; - this.listNode = []; - this.listNodeUtils = listNodeUtils; - this.loadedNodeIdAndIndexMap.clear(); - this.listNodeUtils.traverseNodeDF((node: NodeItem): boolean => { - if (node.currentNodeId >= 0) { - var nodeInfo: NodeInfo = new NodeInfo(node); - this.listNode.push(nodeInfo); - - if (this.expandAndCollapseInfo.get(node.currentNodeId) == NodeStatus.Expand) { - nodeInfo.getNodeItem().imageCollapse.changeImageCollapseSource(NodeStatus.Expand); - } else if (this.expandAndCollapseInfo.get(node.currentNodeId) == NodeStatus.Collapse) { - nodeInfo.getNodeItem().imageCollapse.changeImageCollapseSource(NodeStatus.Collapse); - } - - for (let i = 0; i < tmp.length; i++){ - if (tmp[i].getCurrentNodeId() == nodeInfo.getCurrentNodeId()) { - nodeInfo.setNodeIsShow(tmp[i].getNodeIsShow()); - nodeInfo.setListItemHeight(tmp[i].getListItemHeight()); - if (nodeInfo.getNodeItem().mainTitleNode && nodeInfo.getIsShowTitle()) { - nodeInfo.getNodeItem().mainTitleNode.title = tmp[i].getNodeItem().mainTitleNode.title; - } - break; - } - } - if (nodeInfo.getNodeIsShow()) { - this.loadedNodeIdAndIndexMap.set(nodeInfo.getCurrentNodeId(), index++); - } - } - return false; - }); - } - - public getFlagLine() { - return this.FLAG_LINE; - } - - public getVisibility(nodeInfo: NodeInfo): any { - let lastShowIndex: number = this.loadedNodeIdAndIndexMap.get(nodeInfo.getCurrentNodeId()) - 1; - if (lastShowIndex > this.INITIAL_INVALID_VALUE) { - let lastNodeInfo: NodeInfo = this.getData(lastShowIndex); - return (nodeInfo.getCanShowFlagLine() == true && !nodeInfo.getIsHighLight() && !lastNodeInfo.getIsHighLight()) ? - Visibility.Visible : Visibility.Hidden; - } else { - return (nodeInfo.getCanShowFlagLine() == true && !nodeInfo.getIsHighLight()) ? - Visibility.Visible : Visibility.Hidden; - } - } - - public getSubTitlePara() { - return this.subTitle; - } - - public getIsFolder(nodeId: number) { - if (this.loadedNodeIdAndIndexMap.has(nodeId)) { - return this.getData(this.loadedNodeIdAndIndexMap.get(nodeId)).getIsFolder(); - } - return false; - } - - public getSubTitleFontColor(isHighLight: boolean) { - return isHighLight ? this.subTitle.highLightFontColor : this.subTitle.normalFontColor; - } - - private getChildIndex(rearParentNodeId: number, rearCurrentNodeId: number) { - let insertChildIndex: number = this.INITIAL_INVALID_VALUE; - this.listNodeUtils.traverseNodeBF(function(node): boolean { - if (node.getCurrentNodeId() == rearParentNodeId) { - node.children.forEach((value, index) => { - if (value.getCurrentNodeId() == rearCurrentNodeId) { - insertChildIndex = index; - } - }) - return true; - } - return false; - }); - return insertChildIndex; - } - - public setCurrentFocusNodeId(focusNodeId: number) { - this.currentFocusNodeId = focusNodeId; - } - - public getCurrentFocusNodeId(): number { - return this.currentFocusNodeId; - } - - public setLastFocusNodeId(focusNodeId: number) { - this.lastFocusNodeId = focusNodeId; - } - - public getLastFocusNodeId(): number { - return this.lastFocusNodeId; - } - - public getAddFocusNodeId(): number { - return this.addFocusNodeId; - } - - public setFlag(flag: Flag) { - this.flag = flag; - } - } - - /* nodeId to find index */ - function findCurrentNodeIndex(this, currentNodeId: number): number { - let thisIndex: number = 0; - this.listNodeDataSource.ListNode.forEach(function (value, index) { - if (value.getNodeCurrentNodeId() == currentNodeId) { - thisIndex = index; - } - }) - return thisIndex; - } - - /** - * Tree view control, which is created by using the TreeController class. - * - * When you create this component, you must initialize the listNodeDataSource. - * You can run the listTreeViewWidth command to set the width of the component. - * The default width is 200vp. - * - * @since 10 - */ - @Component - export struct TreeView { - listNodeDataSource: ListNodeDataSource; - treeController: TreeController; - @State dropSelectedIndex: number = 0; - @BuilderParam private listTreeViewMenu: () => void = null; - @Prop listTreeViewWidth: string | number; - @Prop listTreeViewHeight: number | string; - private readonly MAX_CN_LENGTH: number = 254; - private readonly MAX_EN_LENGTH: number = 255; - private readonly INITIAL_INVALID_VALUE = -1; - private readonly MAX_TOUCH_DOWN_COUNT = 0; - private isMultiPress: boolean = false; - private touchDownCount: number = this.INITIAL_INVALID_VALUE; - private appEventBus: TreeListener = TreeListenerManager.getInstance().getTreeListener(); - private readonly itemPadding: { left: Resource, right: Resource, top: Resource, bottom: Resource } = - { left: $r('sys.float.ohos_id_card_margin_middle'), - right: $r('sys.float.ohos_id_card_margin_middle'), - top: $r('sys.float.ohos_id_text_margin_vertical'), - bottom: $r('sys.float.ohos_id_text_margin_vertical')}; - /* { left: '12vp', right: '12vp', top: '2vp', bottom: '2vp' } */ - private readonly textInputPadding: { left : string, right: string, top: string, bottom: string } = - { left : '0vp', right: '0vp', top: '0vp', bottom: '0vp'} - aboutToAppear(): void { - this.listTreeViewWidth = (this.listTreeViewWidth === undefined) ? 200 : this.listTreeViewWidth; - this.listNodeDataSource = this.treeController.getListNodeDataSource(); - } - - private checkInvalidPattern(title: string): boolean { - let pattern = /[\\\/:*?"<>|]/; - return pattern.test(title) - } - - private checkIsAllCN(title: string): boolean { - let pattern = /^[\u4e00-\u9fa5]+$/; - return pattern.test(title) - } - - @Builder popupForShowTitle(text: string | Resource, backgroundColor: Resource, fontColor: Resource ) { - Row() { - Text(text).fontSize($r('sys.float.ohos_id_text_size_body2')).fontWeight('regular').fontColor(fontColor) - }.backgroundColor(backgroundColor) - .border({radius: $r('sys.float.ohos_id_elements_margin_horizontal_l')}) - .padding({left: $r('sys.float.ohos_id_elements_margin_horizontal_l'), - right: $r('sys.float.ohos_id_elements_margin_horizontal_l'), - top: $r('sys.float.ohos_id_card_margin_middle'), - bottom: $r('sys.float.ohos_id_card_margin_middle')}) - } - - @Builder builder() { - this.listTreeViewMenu() - } - - /* Set the popup of dragging node. */ - @Builder draggingPopup(item: NodeInfo) { - Row() { - if (item.getNodeItem().imageNode) { - Row() { - Image(item.getNodeItem().imageNode.normalSource) - .objectFit(ImageFit.Contain) - .height(item.getNodeItem().imageNode.itemHeight) - .width(item.getNodeItem().imageNode.itemWidth) - .opacity(this.listNodeDataSource.getDragPopupPara().imageOpacity) - } - .backgroundColor(COLOR_IMAGE_ROW) - .margin({ right: item.getNodeItem().imageNode.itemRightMargin }) - .height(item.getNodeItem().imageNode.itemHeight) - .width(item.getNodeItem().imageNode.itemWidth) - } - Row() { - if (item.getNodeItem().mainTitleNode && item.getIsShowTitle()) { - Text(item.getNodeItem().mainTitleNode.title) - .maxLines(1) - .fontSize(item.getNodeItem().mainTitleNode.size) - .fontColor(this.listNodeDataSource.getDragPopupPara().fontColor) - .fontWeight(this.listNodeDataSource.getDragPopupPara().fontWeight) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - } - } - .constraintSize({ - minWidth: item.getNodeItem().imageNode ? - this.listNodeDataSource.getDragPopupPara().textConstraintSize.minWidth1 : - this.listNodeDataSource.getDragPopupPara().textConstraintSize.minWidth2, - maxWidth: item.getNodeItem().imageNode ? - this.listNodeDataSource.getDragPopupPara().textConstraintSize.maxWidth1 : - this.listNodeDataSource.getDragPopupPara().textConstraintSize.maxWidth2 }) - } - .constraintSize({ minWidth: this.listNodeDataSource.getDragPopupPara().floorConstraintSize.minWidth, - maxWidth: this.listNodeDataSource.getDragPopupPara().floorConstraintSize.maxWidth }) - .height(this.listNodeDataSource.getDragPopupPara().height) - .backgroundColor(this.listNodeDataSource.getDragPopupPara().backgroundColor) - .padding({ left: this.listNodeDataSource.getDragPopupPara().padding.left, - right: this.listNodeDataSource.getDragPopupPara().padding.right }) - .shadow({ radius: this.listNodeDataSource.getDragPopupPara().shadow.radius, - color: this.listNodeDataSource.getDragPopupPara().shadow.color, - offsetY: this.listNodeDataSource.getDragPopupPara().shadow.offsetY }) - .borderRadius(this.listNodeDataSource.getDragPopupPara().borderRadius) // need to doubleCheck. - } - - build() { - List({ }) { - LazyForEach(this.listNodeDataSource, (item: NodeInfo) => { - ListItem() { - if (item.getNodeIsShow()) { - Column() { - Divider() - .height(this.listNodeDataSource.getFlagLine().flagLineHeight) - .color(this.listNodeDataSource.getFlagLine().flagLineColor) - .visibility(this.listNodeDataSource.getVisibility(item)) - .lineCap(LineCapStyle.Round) - .margin({ left: item.getFlagLineLeftMargin() }) - .markAnchor({ x: this.listNodeDataSource.getFlagLine().xOffset, - y: this.listNodeDataSource.getFlagLine().yTopOffset }) - Row({}) { - Row({}) { - if (item.getNodeItem().imageNode) { - Row() { - Image(item.getNodeItem().imageNode.source) - .objectFit(ImageFit.Contain) - .height(item.getNodeItem().imageNode.itemHeight) - .width(item.getNodeItem().imageNode.itemWidth) - .opacity(!item.getIsSelected() && !item.getIsHighLight() ? - item.getNodeItem().imageNode.opacity : item.getNodeItem().imageNode.noOpacity) - .focusable(item.getNodeItem().mainTitleNode != null ? false : true) - .onFocus(() => { - let that = this; - that.listNodeDataSource.handleEvent(Event.FOCUS, - findCurrentNodeIndex.call(that, item.getNodeCurrentNodeId())); - }) - .onBlur(() => { - let that = this; - that.listNodeDataSource.handleEvent(Event.BLUR, - findCurrentNodeIndex.call(that, item.getNodeCurrentNodeId())); - }) - } - .backgroundColor(COLOR_IMAGE_ROW) - .margin({ right: item.getNodeItem().imageNode.itemRightMargin }) - .height(item.getNodeItem().imageNode.itemHeight) - .width(item.getNodeItem().imageNode.itemWidth) - } - Row() { - if (item.getNodeItem().mainTitleNode && item.getIsShowTitle()) { - Text(item.getNodeItem().mainTitleNode.title) - .maxLines(1) // max line - .fontSize(item.getNodeItem().mainTitleNode.size) - .fontColor(item.getNodeItem().mainTitleNode.color) - .margin({ right: item.getNodeItem().mainTitleNode.itemRightMargin }) - .textOverflow({ overflow: TextOverflow.Ellipsis }) - .fontWeight(item.getNodeItem().mainTitleNode.weight) - .focusable(true) - .onFocus(() => { - let that = this; - this.listNodeDataSource.handleEvent(Event.FOCUS, - findCurrentNodeIndex.call(that, item.getNodeCurrentNodeId())); - }) - .onBlur(() => { - let that = this; - that.listNodeDataSource.handleEvent(Event.BLUR, - findCurrentNodeIndex.call(that, item.getNodeCurrentNodeId())); - }) - } - if (item.getNodeItem().mainTitleNode && - item.getNodeItem().inputText && - item.getIsShowInputText()) { - Row() { - TextInput({ text: item.getNodeItem().mainTitleNode.title }) - .height(item.getNodeItem().inputText.itemHeight) - .fontSize(item.getNodeItem().inputText.size) - .fontColor(item.getNodeItem().inputText.color) - .borderRadius(item.getNodeItem().inputText.borderRadius) - .backgroundColor(item.getNodeItem().inputText.backgroundColor) - .enterKeyType(EnterKeyType.Done) - .padding({ left: this.textInputPadding.left, right: this.textInputPadding.right, - top: this.textInputPadding.top, bottom: this.textInputPadding.bottom }) - .onChange((value: string) => { - let that = this; - var thisIndex = findCurrentNodeIndex.call(that, item.getNodeCurrentNodeId()); - let res: string = ''; - let isInvalidError: boolean = false; - let isLengthError: boolean = false; - if (that.checkInvalidPattern(value)) { - for (let i = 0; i < value.length; i++) { - if (!that.checkInvalidPattern(value[i])) { - res += value[i]; - } - } - isInvalidError = true; - that.listNodeDataSource.setPopUpInfo(PopUpType.WARNINGS, - InputError.INVALID_ERROR, true, thisIndex); - } else { - res = value; - isInvalidError = false; - that.listNodeDataSource.setPopUpInfo(PopUpType.WARNINGS, - InputError.INVALID_ERROR, false, thisIndex); - } - if ((that.checkIsAllCN(res) && res.length > this.MAX_CN_LENGTH) || - (!that.checkIsAllCN(res) && res.length > this.MAX_EN_LENGTH)) { - res = that.checkIsAllCN(res) ? - res.substr(0, this.MAX_CN_LENGTH) : res.substr(0, this.MAX_EN_LENGTH); - isLengthError = true; - that.listNodeDataSource.setPopUpInfo(PopUpType.WARNINGS, - InputError.LENGTH_ERROR, true, thisIndex); - } else { - isLengthError = false; - } - if (!isLengthError && !isInvalidError) { - that.listNodeDataSource.setPopUpInfo(PopUpType.WARNINGS, - InputError.LENGTH_ERROR, false, thisIndex); - that.listNodeDataSource.setMainTitleNameOnEdit(thisIndex, res); - } - - }) - .onSubmit((enterKey: EnterKeyType) => { - let that = this; - var thisIndex = findCurrentNodeIndex.call(that, item.getNodeCurrentNodeId()); - that.listNodeDataSource.setPopUpInfo(PopUpType.WARNINGS, InputError.NONE, false, thisIndex); - that.listNodeDataSource.setItemVisibilityOnEdit(thisIndex, MenuOperation.COMMIT_NODE); - }) - }.backgroundColor(item.getNodeItem().inputText.backgroundColor) - .borderRadius(item.getNodeItem().inputText.borderRadius) - .margin({ right: item.getNodeItem().inputText.itemRightMargin }) - } - Blank() - }.layoutWeight(1) - - if (this.listNodeDataSource.hasSubtitle(item.getCurrentNodeId())) { - Row() { - Text(this.listNodeDataSource.getSubtitle(item.getCurrentNodeId())) - .fontSize(this.listNodeDataSource.getSubTitlePara().fontSize) - .fontColor(this.listNodeDataSource.getSubTitleFontColor(item.getIsHighLight() || item.getIsModify())) - .fontWeight(this.listNodeDataSource.getSubTitlePara().fontWeight) - } - .margin({ left: this.listNodeDataSource.getSubTitlePara().margin.left, - right: item.getNodeItem().imageCollapse ? - 0 : this.listNodeDataSource.getSubTitlePara().margin.right }) - } - - if (item.getNodeItem().imageCollapse) { - Row() { - Image(item.getNodeItem().imageCollapse.collapseSource) - .fillColor(item.getNodeItem().imageCollapse.isCollapse ? COLOR_IMAGE_ROW : COLOR_IMAGE_EDIT) - .align(Alignment.End) - .objectFit(ImageFit.Contain) - .height(item.getNodeItem().imageCollapse.itemHeight) - .width(item.getNodeItem().imageCollapse.itemWidth) - .opacity(!item.getIsHighLight() ? - item.getNodeItem().imageCollapse.opacity : item.getNodeItem().imageCollapse.noOpacity) - .onTouch((event: TouchEvent) => { - if (event.type === TouchType.Down) { - let that = this; - that.listNodeDataSource.expandAndCollapseNode( - findCurrentNodeIndex.call(that, item.getNodeCurrentNodeId())); - this.listNodeDataSource.setCurrentFocusNodeId(item.getCurrentNodeId()); - } - event.stopPropagation(); - }) - } - .backgroundColor(COLOR_IMAGE_ROW) - .height(item.getNodeItem().imageCollapse.itemHeight) - .width(item.getNodeItem().imageCollapse.itemWidth) - } - } - .width('100%') - .onTouch((event: TouchEvent) => { - let that = this; - let index = findCurrentNodeIndex.call(that, item.getNodeCurrentNodeId()); - let currentId = item.getNodeCurrentNodeId(); - that.listNodeDataSource.setClickIndex(index); - if (event.type === TouchType.Down) { - this.touchDownCount ++; - this.isMultiPress = this.touchDownCount > this.MAX_TOUCH_DOWN_COUNT ? true : false; - if (!this.listNodeDataSource.getIsTouchDown()) { - that.listNodeDataSource.handleEvent(Event.TOUCH_DOWN, index); - } - } - if (event.type === TouchType.Up) { - this.touchDownCount--; - if (this.touchDownCount < this.MAX_TOUCH_DOWN_COUNT) { - this.isMultiPress = false; - } - let callbackParam = { currentNodeId: currentId } - this.appEventBus.emit(TreeListenType.NODE_CLICK, [callbackParam]); - that.listNodeDataSource.handleEvent(Event.TOUCH_UP, index); - } - }) - .onHover((isHover: boolean) => { - let that = this; - let index = findCurrentNodeIndex.call(that, item.getNodeCurrentNodeId()) - if (isHover) { - that.listNodeDataSource.handleEvent(Event.HOVER, index); - } else { - if (!that.listNodeDataSource.getIsTouchDown()) { - that.listNodeDataSource.handleEvent(Event.HOVER_OVER, index); - } - } - }) - .gesture( - TapGesture({ count: 2 }) // doubleClick - .onAction((event: GestureEvent) => { - let that = this; - that.listNodeDataSource.expandAndCollapseNode( - findCurrentNodeIndex.call(that, item.getNodeCurrentNodeId())); - }) - ) - .height(item.getNodeHeight()) - .padding({ left: item.getNodeLeftPadding() }) - /* backgroundColor when editing and in other states. */ - .backgroundColor((item.getNodeItem().mainTitleNode && item.getNodeItem().inputText && - item.getIsShowInputText()) ? item.getNodeItem().inputText.editColor : item.getNodeColor()) - .border({ - width: item.getNodeBorder().borderWidth, - color: item.getNodeBorder().borderColor, - radius: item.getNodeBorder().borderRadius - }) - .bindContextMenu(this.builder, ResponseType.RightClick) - } - .opacity(this.listNodeDataSource.getListItemOpacity(item)) - .markAnchor({ x: this.listNodeDataSource.getFlagLine().xOffset, - y: this.listNodeDataSource.getFlagLine().yBasePlateOffset }) - if (item.getCanShowBottomFlagLine()) { - if (this.listNodeDataSource.getPassIndex() == this.listNodeDataSource.totalCount() - 1 && - !item.getIsHighLight()) { - Divider() - .height(this.listNodeDataSource.getFlagLine().flagLineHeight) - .color(this.listNodeDataSource.getFlagLine().flagLineColor) - .visibility(Visibility.Visible) - .lineCap(LineCapStyle.Round) - .margin({ left: item.getFlagLineLeftMargin() }) - .markAnchor({ x: this.listNodeDataSource.getFlagLine().xOffset, - y: this.listNodeDataSource.getFlagLine().yBottomOffset }) - } - } - } - .focusable(true) - .onMouse((event: MouseEvent) => { - let that = this; - let thisIndex = findCurrentNodeIndex.call(that, item.getNodeCurrentNodeId()); - if (event.button == MouseButton.Right) { - that.listNodeDataSource.handleEvent(Event.MOUSE_BUTTON_RIGHT, - findCurrentNodeIndex.call(that, item.getNodeCurrentNodeId())); - this.listTreeViewMenu = item.getMenu(); - that.listNodeDataSource.setClickIndex(thisIndex); - that.listNodeDataSource.setPopUpInfo(PopUpType.HINTS, InputError.NONE, false, thisIndex); - clearTimeout(item.getNodeItem().mainTitleNode.popUpTimeout); - } - event.stopPropagation(); - }) - .padding({ top: this.itemPadding.top, bottom: this.itemPadding.bottom }) - .bindPopup(item.getPopUpInfo().popUpIsShow, { - builder: this.popupForShowTitle(item.getPopUpInfo().popUpText, item.getPopUpInfo().popUpColor, - item.getPopUpInfo().popUpTextColor), - placement: Placement.BottomLeft, - placementOnTop: false, - popupColor: item.getPopUpInfo().popUpColor, - autoCancel: true, - enableArrow: item.getPopUpInfo().popUpEnableArrow - }) - } - - } - .width('100%').height(item.getListItemHeight()) - .padding({ left: this.itemPadding.left, right: this.itemPadding.right}) - .align(Alignment.Start) - .onDragStart((event: DragEvent, extraParams: string) => { - if (this.listNodeDataSource.getIsDrag() || this.listNodeDataSource.getIsInnerDrag() || this.isMultiPress) { - console.error('drag error, a item has been dragged'); - return; - } - this.dropSelectedIndex = JSON.parse(extraParams).selectedIndex; - let currentNodeIndex = JSON.parse(extraParams).selectedIndex; - let currentNodeInfo = this.listNodeDataSource.getData(currentNodeIndex); - let currentItemNodeId = item.getNodeCurrentNodeId(); - - /* handle the situation of drag error, currentNodeIndex is not found in onDragStart. */ - if (currentNodeIndex >= this.listNodeDataSource.totalCount() || currentNodeIndex == undefined) { - console.error('drag error, currentNodeIndex is not found in onDragStart'); - return; - } - - this.listNodeDataSource.setIsInnerDrag(true); - this.listNodeDataSource.setIsDrag(true); - this.listNodeDataSource.setCurrentNodeInfo(currentNodeInfo); - this.listNodeDataSource.setDraggingCurrentNodeId(currentNodeInfo.getNodeCurrentNodeId()); - this.listNodeDataSource.setDraggingParentNodeId(currentNodeInfo.getNodeParentNodeId()); - - /* set the opacity of the dragging node. */ - let draggingNodeOpacity: number = DRAG_OPACITY; - this.listNodeDataSource.setListItemOpacity(draggingNodeOpacity); - this.listNodeDataSource.notifyDataChange(currentNodeIndex); - - /* - * handle the situation of drag is too fast,it attribute a fault to OH. - * OH has Solved on real machine. - */ - if (currentItemNodeId != currentNodeInfo.getNodeCurrentNodeId()) { - console.error('drag is too fast,it attribute a fault to OH'); - this.listNodeDataSource.setIsDrag(false); - return; - } - return this.draggingPopup(currentNodeInfo); - }) - }, item => JSON.stringify(item)) - }.width(this.listTreeViewWidth).height(this.listTreeViewHeight) - - /* Move the dragged node. */ - .onDragMove((event: DragEvent) => { - if (this.isMultiPress) { - console.error('drag error, a item has been dragged'); - return; - } - let nodeHeight: number = LIST_ITEM_HEIGHT; - - /* flag the position of the focus on the node. */ - let flag: Flag = Math.floor(event.getY() / (nodeHeight / FLAG_NUMBER)) % FLAG_NUMBER ? Flag.DOWN_FLAG : Flag.UP_FLAG; - - /* Record the node position to which the dragged node moves. */ - let index: number = Math.floor(event.getY() / nodeHeight); - - /* Handle the situation where the focus(index) exceeds the list area. */ - let isOverBorder: boolean = false; - if (index >= this.listNodeDataSource.totalCount()) { - flag = Flag.DOWN_FLAG; - index = this.listNodeDataSource.totalCount() - 1; - this.listNodeDataSource.getData(index).setIsOverBorder(true); - isOverBorder = true; - } else { - this.listNodeDataSource.getData(index).setIsOverBorder(false); - } - - let currentNodeInfo: NodeInfo = this.listNodeDataSource.getData(index); - let currentNodeId: number = currentNodeInfo.getCurrentNodeId(); - - /* - * handle a situation that "draggingCurrentNodeId" is parent of "insertNodeCurrentNodeId"; - * do not perform some functions. - */ - if (index != this.listNodeDataSource.getLastPassIndex() && this.listNodeDataSource.getIsInnerDrag()) { - let isParentNodeOfInsertNode: boolean = this.listNodeDataSource.getIsParentOfInsertNode(currentNodeId); - if (isParentNodeOfInsertNode) { - this.listNodeDataSource.setPassIndex(index); - let that = this; - this.listNodeDataSource.clearTimeOutAboutDelayHighLightAndExpand(findCurrentNodeIndex.call(that, - currentNodeId)); - this.listNodeDataSource.setFlag(Flag.NONE); - return; - } - } - this.listNodeDataSource.setLastPassIndex(index); - - /* Set the visibility of the flag line. */ - this.listNodeDataSource.setVisibility(flag, index, isOverBorder); - - /* Automatically HighLight one second delay and expand after two second delay. */ - if (currentNodeId != this.listNodeDataSource.getDraggingCurrentNodeId()) { - let that = this; - this.listNodeDataSource.delayHighLightAndExpandNode(findCurrentNodeIndex.call(that, currentNodeId), - currentNodeId, index); - } - }) - - /* DragEvent Enter. */ - .onDragEnter((event: DragEvent, extraParams: string) => { - if (this.listNodeDataSource.getIsInnerDrag()) { - this.listNodeDataSource.setIsDrag(true); - - /* set the opacity of the dragging node. */ - let draggingNodeOpacity: number = DRAG_OPACITY; - this.listNodeDataSource.setListItemOpacity(draggingNodeOpacity); - } - }) - - /* DragEvent Leave. */ - .onDragLeave((event: DragEvent, extraParams: string) => { - this.listNodeDataSource.hideLastLine(); - this.listNodeDataSource.clearLastTimeoutHighLight(); - this.listNodeDataSource.clearLastTimeoutExpand(); - let draggingNodeOpacity: number = DRAG_OPACITY_NONE; - this.listNodeDataSource.setListItemOpacity(draggingNodeOpacity); - this.listNodeDataSource.setIsDrag(false); - this.listNodeDataSource.notifyDataReload(); - }) - - /* DragEvent Drop. */ - .onDrop((event: DragEvent, extraParams: string) => { - this.listNodeDataSource.clearLastTimeoutExpand(); - let draggingNodeOpacity: number = DRAG_OPACITY_NONE; - this.listNodeDataSource.setListItemOpacity(draggingNodeOpacity); - let insertNodeIndex: number = this.listNodeDataSource.getPassIndex(); - let currentNodeIndex: number = this.dropSelectedIndex; - - if (currentNodeIndex - 1 > this.listNodeDataSource.totalCount() || currentNodeIndex == undefined) { - console.error('drag error, currentNodeIndex is not found'); - this.listNodeDataSource.setIsDrag(false); - return; - } - - if (insertNodeIndex == this.listNodeDataSource.totalCount()) { - console.log('need to insert into the position of the last line, now insertNodeIndex = insertNodeIndex - 1'); - insertNodeIndex -= 1; - } - - let insertNodeInfo: NodeInfo = this.listNodeDataSource.getData(insertNodeIndex); - let insertNodeCurrentNodeId: number = insertNodeInfo.getNodeCurrentNodeId(); - - /* outer node is move in. */ - if (!this.listNodeDataSource.getIsDrag() || !this.listNodeDataSource.getIsInnerDrag()) { - this.listNodeDataSource.clearLastTimeoutHighLight(); - this.listNodeDataSource.setIsInnerDrag(false); - this.listNodeDataSource.hideLastLine(); - this.listNodeDataSource.initialParameterAboutDelayHighLightAndExpandIndex(); - this.listNodeDataSource.refreshSubtitle(insertNodeCurrentNodeId); - this.listNodeDataSource.notifyDataReload(); - return; - } - - let currentNodeInfo: NodeInfo = this.listNodeDataSource.getCurrentNodeInfo(); - let insertNodeParentNodeId: number = insertNodeInfo.getNodeParentNodeId(); - let draggingCurrentNodeId: number = this.listNodeDataSource.getDraggingCurrentNodeId(); - let draggingParentNodeId: number = this.listNodeDataSource.getDraggingParentNodeId(); - - /* - * handle a situation that "draggingCurrentNodeId" is parent of "insertNodeCurrentNodeId". - * drag is fail. - */ - let isParentNodeOfInsertNode: boolean = this.listNodeDataSource.getIsParentOfInsertNode(insertNodeCurrentNodeId); - if (isParentNodeOfInsertNode) { - this.listNodeDataSource.clearLastTimeoutHighLight(); - this.listNodeDataSource.setIsInnerDrag(false); - this.listNodeDataSource.hideLastLine(); - this.listNodeDataSource.notifyDataChange(insertNodeIndex); - this.listNodeDataSource.initialParameterAboutDelayHighLightAndExpandIndex(); - this.listNodeDataSource.setIsDrag(false); - - /* set the position of focus. */ - let that = this; - let currentFocusIndex: number = findCurrentNodeIndex.call(that, draggingCurrentNodeId); - this.listNodeDataSource.setClickIndex(currentFocusIndex); - this.listNodeDataSource.handleEvent(Event.DRAG, currentFocusIndex); - return; - } - - /* Collapse drag node. */ - if (this.listNodeDataSource.getExpandAndCollapseInfo(draggingCurrentNodeId) == NodeStatus.Expand) { - let that = this; - this.listNodeDataSource.expandAndCollapseNode( - findCurrentNodeIndex.call(that, draggingCurrentNodeId)); - } - - /* Expand insert node. */ - if (this.listNodeDataSource.getExpandAndCollapseInfo(insertNodeCurrentNodeId) == NodeStatus.Collapse) { - let that = this; - let currentIndex: number = findCurrentNodeIndex.call(that, insertNodeCurrentNodeId); - if (this.listNodeDataSource.ListNode[currentIndex].getIsHighLight()) { - this.listNodeDataSource.expandAndCollapseNode(currentIndex); - } - } - - /* alter dragNode. */ - this.listNodeDataSource.setLastDelayHighLightId(); - if (draggingCurrentNodeId != insertNodeCurrentNodeId) { - this.listNodeDataSource.alterDragNode(insertNodeParentNodeId, insertNodeCurrentNodeId, insertNodeInfo, - draggingParentNodeId, draggingCurrentNodeId, currentNodeInfo); - this.listNodeDataSource.hideLastLine(); - } else { - /*the position of dragNode is equal with the position of insertNode. */ - this.listNodeDataSource.hideLastLine(); - this.listNodeDataSource.setLastPassId(draggingCurrentNodeId); - this.listNodeDataSource.hideLastLine(); - } - - let that = this; - let lastDelayHighLightIndex: number = findCurrentNodeIndex.call(that, - this.listNodeDataSource.getLastDelayHighLightId()); - this.listNodeDataSource.setLastDelayHighLightIndex(lastDelayHighLightIndex); - this.listNodeDataSource.clearLastTimeoutHighLight(); - this.listNodeDataSource.initialParameterAboutDelayHighLightAndExpandIndex(); - this.listNodeDataSource.setIsDrag(false); - - /* set the position of focus. */ - let currentFocusIndex: number = findCurrentNodeIndex.call(that, draggingCurrentNodeId); - this.listNodeDataSource.setClickIndex(currentFocusIndex); - this.listNodeDataSource.handleEvent(Event.DRAG, currentFocusIndex); - - /* innerDrag is over. */ - this.listNodeDataSource.setIsInnerDrag(false); - this.listNodeDataSource.notifyDataReload(); - }) - } - } - - // Declare NodeParam - export interface NodeParam { - parentNodeId?: number, - currentNodeId?: number, - isFolder?: boolean, - icon?: Resource, - selectedIcon?: Resource, - editIcon? : Resource, - primaryTitle?: string, - secondaryTitle?: number | string, - menu?: () => void, - } - - - // Declare CallbackParam - export interface CallbackParam { - currentNodeId: number, - parentNodeId?: number, - childIndex?: number, - } - - /** - * Create a tree view control proxy class to generate a tree view. - * - * @since 10 - */ - export class TreeController { - readonly ROOT_NODE_ID: number = -1; - private nodeIdList: number[] = []; - private listNodeUtils : ListNodeUtils = new ListNodeUtils(); - private listNodeDataSource : ListNodeDataSource = new ListNodeDataSource(); - - /** - * After the addNode interface is invoked, - * this interface is used to obtain the initialization data of - * the tree view component for creating a tree view component. - * - * @return ListNodeDataSource Obtains the initialization data of the tree view component. - * - * @since 10 - */ - public getListNodeDataSource(): ListNodeDataSource { - return this.listNodeDataSource; - } - - /** - * Obtains the subNode information of the currently clicked node. - * - * @return Array Returns an array that stores the configuration information of each node. - * If there is no child node, an empty array is returned. - * - * @since 10 - */ - public getClickNodeChildrenInfo(): Array<{ itemId: number, itemIcon: Resource, itemTitle: string, - isFolder: boolean }> { - let clickNodeId = this.listNodeDataSource.getClickNodeId(); - return this.listNodeUtils.getClickNodeChildrenInfo(clickNodeId); - } - - public getChildrenId(): Array { - let clickNodeId = this.listNodeDataSource.getClickNodeId(); - return this.listNodeUtils.getClickChildId(clickNodeId); - } - - /** - * Delete a node. - * - * Register an ON_ITEM_DELETE callback through the EventBus mechanism to obtain the IDs of all deleted nodes. - * - * @since 10 - */ - public removeNode(): void { - let clickNodeId = this.listNodeDataSource.getClickNodeId(); - let parentNodeId = this.listNodeUtils.findParentNodeId(clickNodeId); - let removeNodeIdList: number[] = this.listNodeUtils.removeNode(clickNodeId, - parentNodeId, this.listNodeUtils.traverseNodeBF); - this.listNodeDataSource.refreshData(this.listNodeUtils, MenuOperation.REMOVE_NODE, parentNodeId, removeNodeIdList); - this.nodeIdList.splice(this.nodeIdList.indexOf(clickNodeId), 1); - } - - /** - * Modify the node name. - * - * Register an ON_ITEM_MODIFY callback to obtain the ID, parent node ID, and node name of the modified node. - * - * @since 10 - */ - public modifyNode(): void { - let clickNodeId = this.listNodeDataSource.getClickNodeId(); - this.listNodeDataSource.setItemVisibilityOnEdit(clickNodeId, MenuOperation.MODIFY_NODE); - } - - /** - * Add a node. - * - * Icon of a new node, which is generated by the system by default. - * If there is a same-level node, the icon of the first node of the same-level node is used. - * If no icon is set for the first node of the same-level node, the new node does not have an icon. - * If there is no peer node, the icon of the parent node is used. - * If no icon is set for the parent node, the new node does not have an icon. - * The system generates an ID for the new node and registers an ON_ITEM_ADD callback through - * the EventBus mechanism to obtain the ID, parent node ID, node name, normal icon, selected icon, - * edit icon of the new node. - * - * @since 10 - */ - public add(): void { - let clickNodeId: number = this.listNodeDataSource.getClickNodeId(); - if (clickNodeId == this.listNodeDataSource.ROOT_NODE_ID || !this.listNodeDataSource.getIsFolder(clickNodeId)) { - return; - } - let newNodeInfo: { isFolder: boolean, icon: Resource, selectedIcon: Resource, editIcon: Resource, - menu: () =>any, secondaryTitle: number | string } = - { isFolder: true, icon: null, selectedIcon: null, editIcon: null, menu: null, secondaryTitle: '' }; - newNodeInfo = this.listNodeUtils.getNewNodeInfo(clickNodeId); - this.nodeIdList.push(this.nodeIdList[this.nodeIdList.length - 1] + 1); - let newNodeId: number = this.nodeIdList[this.nodeIdList.length - 1]; - this.listNodeUtils.addNewNodeId = newNodeId; - this.listNodeUtils.addNode(clickNodeId, newNodeId, - { isFolder: newNodeInfo.isFolder, icon: newNodeInfo.icon, selectedIcon: newNodeInfo.selectedIcon, - editIcon: newNodeInfo.editIcon, primaryTitle: '新建文件夹', menu: newNodeInfo.menu, - secondaryTitle: newNodeInfo.secondaryTitle }); - this.listNodeDataSource.refreshData(this.listNodeUtils, MenuOperation.ADD_NODE, clickNodeId, [newNodeId]); - } - - public addNodeParam(nodeParam: NodeParam): TreeController { - if (nodeParam.primaryTitle != null && - !this.listNodeUtils.checkMainTitleIsValid(nodeParam.primaryTitle)) { - throw new Error('ListTreeNode[addNode]: ' + - 'The directory name cannot contain the following characters\ /: *? "< > | or exceeds the maximum length.'); - return null; - } - if (nodeParam.primaryTitle == null && nodeParam.icon == null) { - throw new Error('ListTreeNode[addNode]: ' + - 'The icon and directory name cannot be empty at the same time.'); - return null; - } - if (nodeParam.currentNodeId === this.ROOT_NODE_ID || nodeParam.currentNodeId === null) { - throw new Error('ListTreeNode[addNode]: currentNodeId can not be -1 or null.'); - return null; - } - this.nodeIdList.push(nodeParam.currentNodeId); - this.listNodeUtils.addNode(nodeParam.parentNodeId, nodeParam.currentNodeId, nodeParam); - return this; - } - - /** - * Initialize the interface of the tree view. This interface is used to generate ListNodeDataSource data. - * addNode is only designed for initialization. It can only be invoked during initialization. - * - * A maximum of 50 directory levels can be added. - * - * @param parentNodeId ID of the parent node. - * @param currentNodeId ID of the new node. The value cannot be -1 or null. - * @param nodeParam Configuration information of the newly added node. - * For details, see the comment description of NodeParam. - * @return ListTreeNode Tree view component proxy class. - * - * @since 10 - */ - public addNode(nodeParam?: NodeParam): TreeController { - if (nodeParam == null) { - this.add(); - } else { - if (nodeParam.primaryTitle != null && - !this.listNodeUtils.checkMainTitleIsValid(nodeParam.primaryTitle)) { - throw new Error('ListTreeNode[addNode]: ' + - 'The directory name cannot contain the following characters\ /: *? "< > | or exceeds the maximum length.'); - return null; - } - if (nodeParam.primaryTitle == null && nodeParam.icon == null) { - throw new Error('ListTreeNode[addNode]: ' + - 'The icon and directory name cannot be empty at the same time.'); - return null; - } - if (nodeParam.currentNodeId === this.ROOT_NODE_ID || nodeParam.currentNodeId === null) { - throw new Error('ListTreeNode[addNode]: currentNodeId can not be -1 or null.'); - return null; - } - this.nodeIdList.push(nodeParam.currentNodeId); - this.listNodeUtils.addNode(nodeParam.parentNodeId, nodeParam.currentNodeId, nodeParam); - return this; - } - } - - /** - * After the initialization is complete by calling the addNode interface, - * call this interface to complete initialization. - * - * This interface must be called when you finish initializing the ListTreeView by addNode. - * @since 10 - */ - public buildDone() { - this.listNodeDataSource.init(this.listNodeUtils); - this.nodeIdList.sort((a, b) => a - b); - } - - public refreshNode(parentId: number, parentSubTitle: ResourceStr = '', - currentSubtitle: ResourceStr = '') { - this.listNodeDataSource.setNodeSubtitlePara(parentId, parentSubTitle, currentSubtitle); - } - } -} \ No newline at end of file