1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit ArkUI 19 */ 20 21import { UIContext } from '../@ohos.arkui.UIContext'; 22import { FrameNode } from './FrameNode'; 23import { Size } from './Graphics'; 24 25/** 26 * Defined the controller of node container.Provides lifecycle callbacks for the associated NodeContainer 27 * and methods to control the child node of the NodeContainer. 28 * 29 * @syscap SystemCapability.ArkUI.ArkUI.Full 30 * @crossplatform 31 * @since 11 32 */ 33/** 34 * Defined the controller of node container.Provides lifecycle callbacks for the associated NodeContainer 35 * and methods to control the child node of the NodeContainer. 36 * 37 * @syscap SystemCapability.ArkUI.ArkUI.Full 38 * @crossplatform 39 * @atomicservice 40 * @since 12 41 */ 42export abstract class NodeController { 43 /** 44 * MakeNode Method. Used to build a node tree and return the a FrameNode or null, and 45 * attach the return result to the associated NodeContainer. 46 * Executed when the associated NodeContainer is created or the rebuild function is called. 47 * 48 * @param { UIContext } uiContext - uiContext used to makeNode 49 * @returns { FrameNode | null } - Returns a FrameNode or null. 50 * @syscap SystemCapability.ArkUI.ArkUI.Full 51 * @crossplatform 52 * @since 11 53 */ 54 /** 55 * MakeNode Method. Used to build a node tree and return the a FrameNode or null, and 56 * attach the return result to the associated NodeContainer. 57 * Executed when the associated NodeContainer is created or the rebuild function is called. 58 * 59 * @param { UIContext } uiContext - uiContext used to makeNode 60 * @returns { FrameNode | null } - Returns a FrameNode or null. 61 * @syscap SystemCapability.ArkUI.ArkUI.Full 62 * @crossplatform 63 * @atomicservice 64 * @since 12 65 */ 66 abstract makeNode(uiContext: UIContext): FrameNode | null; 67 68 /** 69 * AboutToResize Method. Executed when the associated NodeContainer performs the measure method. 70 * 71 * @param { Size } size - size used to resize 72 * @syscap SystemCapability.ArkUI.ArkUI.Full 73 * @crossplatform 74 * @since 11 75 */ 76 /** 77 * AboutToResize Method. Executed when the associated NodeContainer performs the measure method. 78 * 79 * @param { Size } size - size used to resize 80 * @syscap SystemCapability.ArkUI.ArkUI.Full 81 * @crossplatform 82 * @atomicservice 83 * @since 12 84 */ 85 aboutToResize?(size: Size): void; 86 87 /** 88 * AboutToAppear Method. Executed when the associated NodeContainer is aboutToAppear. 89 * 90 * @syscap SystemCapability.ArkUI.ArkUI.Full 91 * @crossplatform 92 * @since 11 93 */ 94 /** 95 * AboutToAppear Method. Executed when the associated NodeContainer is aboutToAppear. 96 * 97 * @syscap SystemCapability.ArkUI.ArkUI.Full 98 * @crossplatform 99 * @atomicservice 100 * @since 12 101 */ 102 aboutToAppear?(): void; 103 104 /** 105 * AboutToDisappear Method. Executed when the associated NodeContainer is aboutToDisappear. 106 * 107 * @syscap SystemCapability.ArkUI.ArkUI.Full 108 * @crossplatform 109 * @since 11 110 */ 111 /** 112 * AboutToDisappear Method. Executed when the associated NodeContainer is aboutToDisappear. 113 * 114 * @syscap SystemCapability.ArkUI.ArkUI.Full 115 * @crossplatform 116 * @atomicservice 117 * @since 12 118 */ 119 aboutToDisappear?(): void; 120 121 /** 122 * Rebuild Method. Used to invoke the makeNode method. 123 * 124 * @syscap SystemCapability.ArkUI.ArkUI.Full 125 * @crossplatform 126 * @since 11 127 */ 128 /** 129 * Rebuild Method. Used to re invoke the makeNode method. 130 * 131 * @syscap SystemCapability.ArkUI.ArkUI.Full 132 * @crossplatform 133 * @atomicservice 134 * @since 12 135 */ 136 rebuild(): void; 137 138 /** 139 * OnTouchEvent Method. Executed when associated NodeContainer is touched. 140 * 141 * @param { TouchEvent } event - The TouchEvent when associated NodeContainer is touched. 142 * @syscap SystemCapability.ArkUI.ArkUI.Full 143 * @crossplatform 144 * @since 11 145 */ 146 /** 147 * OnTouchEvent Method. Executed when associated NodeContainer is touched. 148 * 149 * @param { TouchEvent } event - The TouchEvent when associated NodeContainer is touched. 150 * @syscap SystemCapability.ArkUI.ArkUI.Full 151 * @crossplatform 152 * @atomicservice 153 * @since 12 154 */ 155 onTouchEvent?(event: TouchEvent): void; 156 157 /** 158 * OnAttach Method. Executed when the associated NodeContainer is attached to the main tree. 159 * 160 * @syscap SystemCapability.ArkUI.ArkUI.Full 161 * @crossplatform 162 * @atomicservice 163 * @since 18 164 */ 165 onAttach?(): void; 166 167 /** 168 * OnDetach Method. Executed when the associated NodeContainer is detached from the main tree. 169 * 170 * @syscap SystemCapability.ArkUI.ArkUI.Full 171 * @crossplatform 172 * @atomicservice 173 * @since 18 174 */ 175 onDetach?(): void; 176 177 /** 178 * OnWillBind Method. Executed before the NodeController is bound to a NodeContainer. 179 * 180 * @param { number } containerId - the uniqueId of the NodeContainer. 181 * @syscap SystemCapability.ArkUI.ArkUI.Full 182 * @crossplatform 183 * @atomicservice 184 * @since 18 185 */ 186 onWillBind?(containerId: number): void; 187 188 /** 189 * OnWillUnbind Method. Executed before the NodeController is unbind with the NodeContainer. 190 * 191 * @param { number } containerId - the uniqueId of the NodeContainer. 192 * @syscap SystemCapability.ArkUI.ArkUI.Full 193 * @crossplatform 194 * @atomicservice 195 * @since 18 196 */ 197 onWillUnbind?(containerId: number): void; 198 199 /** 200 * OnBind Method. Executed after the NodeController is bound to a NodeContainer. 201 * 202 * @param { number } containerId - the uniqueId of the NodeContainer. 203 * @syscap SystemCapability.ArkUI.ArkUI.Full 204 * @crossplatform 205 * @atomicservice 206 * @since 18 207 */ 208 onBind?(containerId: number): void; 209 210 /** 211 * OnUnbind Method. Executed after the NodeController is unbind with the NodeContainer. 212 * 213 * @param { number } containerId - the uniqueId of the NodeContainer. 214 * @syscap SystemCapability.ArkUI.ArkUI.Full 215 * @crossplatform 216 * @atomicservice 217 * @since 18 218 */ 219 onUnbind?(containerId: number): void; 220} 221