1/* 2* Copyright (C) 2024 Huawei Device Co., Ltd. 3* Licensed under the Apache License, Version 2.0 (the "License"); 4* you may not use this file except in compliance with the License. 5* You may obtain a copy of the License at 6* 7* http://www.apache.org/licenses/LICENSE-2.0 8* 9* Unless required by applicable law or agreed to in writing, software 10* distributed under the License is distributed on an "AS IS" BASIS, 11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12* See the License for the specific language governing permissions and 13* limitations under the License. 14*/ 15 16/** 17 * @file Defines FoldSplitContainer component. 18 * @kit ArkUI 19 */ 20 21import display from '@ohos.display'; 22import window from '@ohos.window'; 23import { Position, Size } from '@ohos.arkui.node'; 24import { Callback } from '@ohos.base'; 25 26/** 27 * Position enum of the extra region 28 * 29 * @enum { number } 30 * @syscap SystemCapability.ArkUI.ArkUI.Full 31 * @atomicservice 32 * @since 12 33 */ 34export declare enum ExtraRegionPosition { 35 /** 36 * The extra region position is in the top. 37 * 38 * @syscap SystemCapability.ArkUI.ArkUI.Full 39 * @atomicservice 40 * @since 12 41 */ 42 TOP = 1, 43 /** 44 * The extra region position is in the bottom. 45 * 46 * @syscap SystemCapability.ArkUI.ArkUI.Full 47 * @atomicservice 48 * @since 12 49 */ 50 BOTTOM = 2 51} 52/** 53 * The layout options for the container when the foldable screen is expanded. 54 * 55 * @interface ExpandedRegionLayoutOptions 56 * @syscap SystemCapability.ArkUI.ArkUI.Full 57 * @atomicservice 58 * @since 12 59 */ 60export interface ExpandedRegionLayoutOptions { 61 /** 62 * The ratio of the widths of two areas in the horizontal direction. 63 * 64 * @type { ?number } 65 * @syscap SystemCapability.ArkUI.ArkUI.Full 66 * @atomicservice 67 * @since 12 68 */ 69 horizontalSplitRatio?: number; 70 /** 71 * The ratio of the heights of two areas in the vertical direction. 72 * 73 * @type { ?number } 74 * @syscap SystemCapability.ArkUI.ArkUI.Full 75 * @atomicservice 76 * @since 12 77 */ 78 verticalSplitRatio?: number; 79 /** 80 * Does the extended area span from top to bottom within the container? 81 * 82 * @type { ?boolean } 83 * @syscap SystemCapability.ArkUI.ArkUI.Full 84 * @atomicservice 85 * @since 12 86 */ 87 isExtraRegionPerpendicular?: boolean; 88 /** 89 * Specify the position of the extra area when the extra area does not vertically span the container. 90 * 91 * @type { ?ExtraRegionPosition } 92 * @syscap SystemCapability.ArkUI.ArkUI.Full 93 * @atomicservice 94 * @since 12 95 */ 96 extraRegionPosition?: ExtraRegionPosition; 97} 98/** 99 * The layout options for the container when the foldable screen is in hover mode. 100 * 101 * @typedef HoverModeRegionLayoutOptions 102 * @syscap SystemCapability.ArkUI.ArkUI.Full 103 * @atomicservice 104 * @since 12 105 */ 106export interface HoverModeRegionLayoutOptions { 107 /** 108 * The ratio of the widths of two areas in the horizontal direction. 109 * 110 * @type { ?number } 111 * @syscap SystemCapability.ArkUI.ArkUI.Full 112 * @atomicservice 113 * @since 12 114 */ 115 horizontalSplitRatio?: number; 116 /** 117 * Does the foldable screen display an extra area when it's in the half-folded state? 118 * 119 * @type { ?boolean } 120 * @syscap SystemCapability.ArkUI.ArkUI.Full 121 * @atomicservice 122 * @since 12 123 */ 124 showExtraRegion?: boolean; 125 /** 126 * Specify the position of the extra area when the foldable screen is in the half-folded state. 127 * 128 * @type { ?ExtraRegionPosition } 129 * @syscap SystemCapability.ArkUI.ArkUI.Full 130 * @atomicservice 131 * @since 12 132 */ 133 extraRegionPosition?: ExtraRegionPosition; 134} 135/** 136 * The layout options for the container when the foldable screen is folded. 137 * 138 * @interface FoldedRegionLayoutOptions 139 * @syscap SystemCapability.ArkUI.ArkUI.Full 140 * @atomicservice 141 * @since 12 142 */ 143export interface FoldedRegionLayoutOptions { 144 /** 145 * The ratio of the heights of two areas in the vertical direction. 146 * 147 * @type { ?number } 148 * @syscap SystemCapability.ArkUI.ArkUI.Full 149 * @atomicservice 150 * @since 12 151 */ 152 verticalSplitRatio?: number; 153} 154/** 155 * Preset split ratio. 156 * 157 * @enum { number } 158 * @syscap SystemCapability.ArkUI.ArkUI.Full 159 * @atomicservice 160 * @since 12 161 */ 162export declare enum PresetSplitRatio { 163 /** 164 * 1:1 165 * 166 * @syscap SystemCapability.ArkUI.ArkUI.Full 167 * @atomicservice 168 * @since 12 169 */ 170 LAYOUT_1V1 = 1, 171 /** 172 * 2:3 173 * 174 * @syscap SystemCapability.ArkUI.ArkUI.Full 175 * @atomicservice 176 * @since 12 177 */ 178 LAYOUT_2V3 = 0.6666666666666666, 179 /** 180 * 3:2 181 * 182 * @syscap SystemCapability.ArkUI.ArkUI.Full 183 * @atomicservice 184 * @since 12 185 */ 186 LAYOUT_3V2 = 1.5 187} 188/** 189 * The status of hover mode. 190 * 191 * @interface HoverStatus 192 * @syscap SystemCapability.ArkUI.ArkUI.Full 193 * @atomicservice 194 * @since 12 195 */ 196export interface HoverModeStatus { 197 /** 198 * The fold status of devices. 199 * 200 * @type { display.FoldStatus } 201 * @syscap SystemCapability.ArkUI.ArkUI.Full 202 * @atomicservice 203 * @since 12 204 */ 205 foldStatus: display.FoldStatus; 206 /** 207 * Is the app currently in hover mode? 208 * In hover mode, the upper half of the screen is used for display, and the lower half is used for operation. 209 * 210 * @type { boolean } 211 * @syscap SystemCapability.ArkUI.ArkUI.Full 212 * @atomicservice 213 * @since 12 214 */ 215 isHoverMode: boolean; 216 /** 217 * The angle of rotation applied. 218 * 219 * @type { number } 220 * @syscap SystemCapability.ArkUI.ArkUI.Full 221 * @atomicservice 222 * @since 12 223 */ 224 appRotation: number; 225 /** 226 * The status of window. 227 * 228 * @type { window.WindowStatusType } 229 * @syscap SystemCapability.ArkUI.ArkUI.Full 230 * @atomicservice 231 * @since 12 232 */ 233 windowStatusType: window.WindowStatusType; 234} 235/** 236 * The handler of onHoverStatusChange event 237 * 238 * @typedef { function } OnHoverStatusChangeHandler 239 * @param { HoverModeStatus } status - The status of hover mode 240 * @syscap SystemCapability.ArkUI.ArkUI.Full 241 * @atomicservice 242 * @since 12 243 */ 244export type OnHoverStatusChangeHandler = (status: HoverModeStatus) => void; 245/** 246 * Defines FoldSplitContainer container. 247 * 248 * @interface FoldSplitContainer 249 * @syscap SystemCapability.ArkUI.ArkUI.Full 250 * @atomicservice 251 * @since 12 252 */ 253@Component 254export declare struct FoldSplitContainer { 255 /** 256 * The builder function which will be rendered in the major region of container. 257 * 258 * @type { Callback<void> } 259 * @syscap SystemCapability.ArkUI.ArkUI.Full 260 * @atomicservice 261 * @since 12 262 */ 263 @BuilderParam 264 primary: Callback<void>; 265 /** 266 * The builder function which will be rendered in the minor region of container. 267 * 268 * @type { Callback<void> } 269 * @syscap SystemCapability.ArkUI.ArkUI.Full 270 * @atomicservice 271 * @since 12 272 */ 273 @BuilderParam 274 secondary: Callback<void>; 275 /** 276 * The builder function which will be rendered in the extra region of container. 277 * 278 * @type { ?Callback<void> } 279 * @syscap SystemCapability.ArkUI.ArkUI.Full 280 * @atomicservice 281 * @since 12 282 */ 283 @BuilderParam 284 extra?: Callback<void>; 285 /** 286 * The layout options for the container when the foldable screen is expanded. 287 * 288 * @type { ExpandedRegionLayoutOptions } 289 * @syscap SystemCapability.ArkUI.ArkUI.Full 290 * @atomicservice 291 * @since 12 292 */ 293 @Prop 294 expandedLayoutOptions: ExpandedRegionLayoutOptions; 295 /** 296 * The layout options for the container when the foldable screen is in hover mode. 297 * 298 * @type { HoverModeRegionLayoutOptions } 299 * @syscap SystemCapability.ArkUI.ArkUI.Full 300 * @atomicservice 301 * @since 12 302 */ 303 @Prop 304 hoverModeLayoutOptions: HoverModeRegionLayoutOptions; 305 /** 306 * The layout options for the container when the foldable screen is folded. 307 * 308 * @type { FoldedRegionLayoutOptions } 309 * @syscap SystemCapability.ArkUI.ArkUI.Full 310 * @atomicservice 311 * @since 12 312 */ 313 @Prop 314 foldedLayoutOptions: FoldedRegionLayoutOptions; 315 /** 316 * The animation options of layout 317 * 318 * @type { ?(AnimateParam | null) } 319 * @syscap SystemCapability.ArkUI.ArkUI.Full 320 * @atomicservice 321 * @since 12 322 */ 323 @Prop 324 animationOptions?: AnimateParam | null; 325 /** 326 * The callback function that is triggered when the foldable screen enters or exits hover mode. 327 * In hover mode, the upper half of the screen is used for display, and the lower half is used for operation. 328 * 329 * @type { ?OnHoverStatusChangeHandler } 330 * @syscap SystemCapability.ArkUI.ArkUI.Full 331 * @atomicservice 332 * @since 12 333 */ 334 onHoverStatusChange?: OnHoverStatusChangeHandler; 335} 336