1e41f4b71Sopenharmony_ci# FoldSplitContainer 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci**FoldSplitContainer** is a layout container designed to manage regions for two-panel and three-panel arrangements on a foldable device across various states, including the expanded state, the hover state, and the folded state. 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci> **NOTE** 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci> This component is supported since API version 12. Updates will be marked with a superscript to indicate their earliest API version. 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci## Child Components 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ciNot supported 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci## FoldSplitContainer 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ciFoldSplitContainer({ 19e41f4b71Sopenharmony_ci primary: Callback<void>, 20e41f4b71Sopenharmony_ci secondary: Callback<void>, 21e41f4b71Sopenharmony_ci extra?: Callback<void>, 22e41f4b71Sopenharmony_ci expandedLayoutOptions?: ExpandedRegionLayoutOptions, 23e41f4b71Sopenharmony_ci hoverModeLayoutOptions?: HoverModeRegionLayoutOptions, 24e41f4b71Sopenharmony_ci foldedLayoutOptions?: FoldedRegionLayoutOptions, 25e41f4b71Sopenharmony_ci animationOptions?: AnimateParam, 26e41f4b71Sopenharmony_ci onHoverStatusChange?: onHoverStatusChangeHandler 27e41f4b71Sopenharmony_ci}) 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci**Decorator**: \@Component 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci**Parameters** 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Decorator| Description| 38e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 39e41f4b71Sopenharmony_ci| primary | ()=>void | No| @BuilderParam | Callback function for the primary region.| 40e41f4b71Sopenharmony_ci| secondary | ()=>void | No| @BuilderParam | Callback function for the secondary region.| 41e41f4b71Sopenharmony_ci| extra | ()=>void | No| @BuilderParam | Callback function for the extra region. If this parameter is not provided, there is no corresponding region.| 42e41f4b71Sopenharmony_ci| expandedLayoutOptions | [ExpandedRegionLayoutOptions](#expandedregionlayoutoptions) | No| @Prop | Layout information for the expanded state.| 43e41f4b71Sopenharmony_ci| hoverModeLayoutOptions | [HoverModeRegionLayoutOptions](#hovermoderegionlayoutoptions) | No| @Prop | Layout information for the hover state.| 44e41f4b71Sopenharmony_ci| foldedLayoutOptions | [FoldedRegionLayoutOptions](#foldedregionlayoutoptions) | No| @Prop | Layout information for the folded state.| 45e41f4b71Sopenharmony_ci| animationOptions | [AnimateParam](ts-explicit-animation.md#animateparam) \| null | No| @Prop | Animation settings. The value **null** indicates that the animation is disabled.| 46e41f4b71Sopenharmony_ci| onHoverStatusChange | [onHoverStatusChangeHandler](#onhoverstatuschangehandler) | No| - | Callback function triggered when the foldable device enters or exits the hover state.| 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_ci## ExpandedRegionLayoutOptions 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ci**Decorator**: \@Prop 51e41f4b71Sopenharmony_ci 52e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 53e41f4b71Sopenharmony_ci 54e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ciDefines the layout information for the expanded state. 57e41f4b71Sopenharmony_ci 58e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 59e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 60e41f4b71Sopenharmony_ci| isExtraRegionPerpendicular | boolean | No| Whether the extra region extends perpendicularly through the entire component from top to bottom. This setting takes effect only when **extra** is effective.<br>Default value: **true** | 61e41f4b71Sopenharmony_ci| verticalSplitRatio | number | No| Height ratio between the primary and secondary regions.<br/>Default value: **PresetSplitRatio.LAYOUT_1V1** | 62e41f4b71Sopenharmony_ci| horizontalSplitRatio | number | No| Width ratio between the primary and extra regions. This setting takes effect only when **extra** is effective.<br/>Default value: **PresetSplitRatio.LAYOUT_3V2** | 63e41f4b71Sopenharmony_ci| extraRegionPosition | [ExtraRegionPosition](#extraregionposition) | No| Position information of the extra region. This setting takes effect only when **isExtraRegionPerpendicular** is **false**.<br/>Default value: **ExtraRegionPosition.top** | 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci## HoverModeRegionLayoutOptions 66e41f4b71Sopenharmony_ci 67e41f4b71Sopenharmony_ci**Decorator**: \@Prop 68e41f4b71Sopenharmony_ci 69e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 70e41f4b71Sopenharmony_ci 71e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 72e41f4b71Sopenharmony_ci 73e41f4b71Sopenharmony_ciDefines the layout information for the hover state. 74e41f4b71Sopenharmony_ci 75e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 76e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 77e41f4b71Sopenharmony_ci| showExtraRegion | boolean | No| Whether to display the extra region in the half-folded state. Default value: **false**| 78e41f4b71Sopenharmony_ci| horizontalSplitRatio | number | No| Width ratio between the primary and extra regions. This setting takes effect only when **extra** is effective.<br/>Default value: **PresetSplitRatio.LAYOUT_3V2** | 79e41f4b71Sopenharmony_ci| extraRegionPosition | [ExtraRegionPosition](#extraregionposition) | No| Position information of the extra region. This setting takes effect only when **showExtraRegion** is set.<br/>Default value: **ExtraRegionPosition.top** | 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci> **NOTE** 82e41f4b71Sopenharmony_ci> 83e41f4b71Sopenharmony_ci> 1. When the device is in the hover state, there is an avoid area, and layout calculations need to account for the impact of the avoid area on the layout. 84e41f4b71Sopenharmony_ci> 2. In the hover state, the upper half screen is used for display, and the lower half is used for interaction. 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ci## FoldedRegionLayoutOptions 87e41f4b71Sopenharmony_ci 88e41f4b71Sopenharmony_ci**Decorator**: \@Prop 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ciDefines the layout information for the folded state. 95e41f4b71Sopenharmony_ci 96e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 97e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 98e41f4b71Sopenharmony_ci| verticalSplitRatio | number | Yes| Height ratio between the primary and secondary regions. Default value: **PresetSplitRatio.LAYOUT_1V1**| 99e41f4b71Sopenharmony_ci 100e41f4b71Sopenharmony_ci## onHoverStatusChangeHandler 101e41f4b71Sopenharmony_ci 102e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 103e41f4b71Sopenharmony_ci 104e41f4b71Sopenharmony_ciImplements a handler for the **onHoverStatusChange** event. 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 107e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 108e41f4b71Sopenharmony_ci| callback | (status: [HoverModeStatus](#hovermodestatus)) => void | Yes| Callback function triggered when the foldable device enters or exits the hover state.| 109e41f4b71Sopenharmony_ci 110e41f4b71Sopenharmony_ci## HoverModeStatus 111e41f4b71Sopenharmony_ci 112e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ciProvides the layout information of the folded state. 117e41f4b71Sopenharmony_ci 118e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 119e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 120e41f4b71Sopenharmony_ci| foldStatus | [FoldStatus<sup>10+</sup>](../js-apis-display.md#foldstatus10) | Yes| Fold status of the device.| 121e41f4b71Sopenharmony_ci| isHoverMode | boolean | Yes| Whether the application is in the hover state.| 122e41f4b71Sopenharmony_ci| appRotation | number | Yes| Rotation angle of the application.| 123e41f4b71Sopenharmony_ci| windowStatusType | [WindowStatusType<sup>11+</sup>](../js-apis-window.md#windowstatustype11) | Yes| Window mode.| 124e41f4b71Sopenharmony_ci 125e41f4b71Sopenharmony_ci## ExtraRegionPosition 126e41f4b71Sopenharmony_ci 127e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 128e41f4b71Sopenharmony_ci 129e41f4b71Sopenharmony_ciProvides the position information of the extra region. 130e41f4b71Sopenharmony_ci 131e41f4b71Sopenharmony_ci| Name| Value| Description| 132e41f4b71Sopenharmony_ci| -------- | -------- | -------- | 133e41f4b71Sopenharmony_ci| top | 1 | The extra region is in the upper half of the component.| 134e41f4b71Sopenharmony_ci| bottom | 2 | The extra region is in the lower half of the component.| 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ci## PresetSplitRatio 137e41f4b71Sopenharmony_ci 138e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 139e41f4b71Sopenharmony_ci 140e41f4b71Sopenharmony_ciEnumerates the split ratios. 141e41f4b71Sopenharmony_ci 142e41f4b71Sopenharmony_ci| Name| Value| Description| 143e41f4b71Sopenharmony_ci| -------- | -------- | -------- | 144e41f4b71Sopenharmony_ci| LAYOUT_1V1 | 1/1 | 1:1.| 145e41f4b71Sopenharmony_ci| LAYOUT_3V2 | 3/2 | 3:2.| 146e41f4b71Sopenharmony_ci| LAYOUT_2V3 | 2/3 | 2:3.| 147e41f4b71Sopenharmony_ci 148e41f4b71Sopenharmony_ci## Example 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci### Example 1 151e41f4b71Sopenharmony_ci 152e41f4b71Sopenharmony_ci```ts 153e41f4b71Sopenharmony_ciimport { FoldSplitContainer } from '@kit.ArkUI'; 154e41f4b71Sopenharmony_ci 155e41f4b71Sopenharmony_ci@Entry 156e41f4b71Sopenharmony_ci@Component 157e41f4b71Sopenharmony_cistruct TwoColumns { 158e41f4b71Sopenharmony_ci @Builder 159e41f4b71Sopenharmony_ci privateRegion() { 160e41f4b71Sopenharmony_ci Text("Primary") 161e41f4b71Sopenharmony_ci .backgroundColor('rgba(255, 0, 0, 0.1)') 162e41f4b71Sopenharmony_ci .fontSize(28) 163e41f4b71Sopenharmony_ci .textAlign(TextAlign.Center) 164e41f4b71Sopenharmony_ci .height('100%') 165e41f4b71Sopenharmony_ci .width('100%') 166e41f4b71Sopenharmony_ci } 167e41f4b71Sopenharmony_ci 168e41f4b71Sopenharmony_ci @Builder 169e41f4b71Sopenharmony_ci secondaryRegion() { 170e41f4b71Sopenharmony_ci Text("Secondary") 171e41f4b71Sopenharmony_ci .backgroundColor('rgba(0, 255, 0, 0.1)') 172e41f4b71Sopenharmony_ci .fontSize(28) 173e41f4b71Sopenharmony_ci .textAlign(TextAlign.Center) 174e41f4b71Sopenharmony_ci .height('100%') 175e41f4b71Sopenharmony_ci .width('100%') 176e41f4b71Sopenharmony_ci } 177e41f4b71Sopenharmony_ci 178e41f4b71Sopenharmony_ci build() { 179e41f4b71Sopenharmony_ci RelativeContainer() { 180e41f4b71Sopenharmony_ci FoldSplitContainer({ 181e41f4b71Sopenharmony_ci primary: () => { 182e41f4b71Sopenharmony_ci this.privateRegion() 183e41f4b71Sopenharmony_ci }, 184e41f4b71Sopenharmony_ci secondary: () => { 185e41f4b71Sopenharmony_ci this.secondaryRegion() 186e41f4b71Sopenharmony_ci } 187e41f4b71Sopenharmony_ci }) 188e41f4b71Sopenharmony_ci } 189e41f4b71Sopenharmony_ci .height('100%') 190e41f4b71Sopenharmony_ci .width('100%') 191e41f4b71Sopenharmony_ci } 192e41f4b71Sopenharmony_ci} 193e41f4b71Sopenharmony_ci``` 194e41f4b71Sopenharmony_ci 195e41f4b71Sopenharmony_ci| Folded| Expanded| Hover| 196e41f4b71Sopenharmony_ci| ----- | ------ | ------ | 197e41f4b71Sopenharmony_ci|  |  |  | 198e41f4b71Sopenharmony_ci 199e41f4b71Sopenharmony_ci 200e41f4b71Sopenharmony_ci### Example 2 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci```ts 203e41f4b71Sopenharmony_ciimport { FoldSplitContainer } from '@kit.ArkUI'; 204e41f4b71Sopenharmony_ci 205e41f4b71Sopenharmony_ci@Entry 206e41f4b71Sopenharmony_ci@Component 207e41f4b71Sopenharmony_cistruct ThreeColumns { 208e41f4b71Sopenharmony_ci @Builder 209e41f4b71Sopenharmony_ci privateRegion() { 210e41f4b71Sopenharmony_ci Text("Primary") 211e41f4b71Sopenharmony_ci .backgroundColor('rgba(255, 0, 0, 0.1)') 212e41f4b71Sopenharmony_ci .fontSize(28) 213e41f4b71Sopenharmony_ci .textAlign(TextAlign.Center) 214e41f4b71Sopenharmony_ci .height('100%') 215e41f4b71Sopenharmony_ci .width('100%') 216e41f4b71Sopenharmony_ci } 217e41f4b71Sopenharmony_ci 218e41f4b71Sopenharmony_ci @Builder 219e41f4b71Sopenharmony_ci secondaryRegion() { 220e41f4b71Sopenharmony_ci Text("Secondary") 221e41f4b71Sopenharmony_ci .backgroundColor('rgba(0, 255, 0, 0.1)') 222e41f4b71Sopenharmony_ci .fontSize(28) 223e41f4b71Sopenharmony_ci .textAlign(TextAlign.Center) 224e41f4b71Sopenharmony_ci .height('100%') 225e41f4b71Sopenharmony_ci .width('100%') 226e41f4b71Sopenharmony_ci } 227e41f4b71Sopenharmony_ci 228e41f4b71Sopenharmony_ci @Builder 229e41f4b71Sopenharmony_ci extraRegion() { 230e41f4b71Sopenharmony_ci Text("Extra") 231e41f4b71Sopenharmony_ci .backgroundColor('rgba(0, 0, 255, 0.1)') 232e41f4b71Sopenharmony_ci .fontSize(28) 233e41f4b71Sopenharmony_ci .textAlign(TextAlign.Center) 234e41f4b71Sopenharmony_ci .height('100%') 235e41f4b71Sopenharmony_ci .width('100%') 236e41f4b71Sopenharmony_ci } 237e41f4b71Sopenharmony_ci 238e41f4b71Sopenharmony_ci build() { 239e41f4b71Sopenharmony_ci RelativeContainer() { 240e41f4b71Sopenharmony_ci FoldSplitContainer({ 241e41f4b71Sopenharmony_ci primary: () => { 242e41f4b71Sopenharmony_ci this.privateRegion() 243e41f4b71Sopenharmony_ci }, 244e41f4b71Sopenharmony_ci secondary: () => { 245e41f4b71Sopenharmony_ci this.secondaryRegion() 246e41f4b71Sopenharmony_ci }, 247e41f4b71Sopenharmony_ci extra: () => { 248e41f4b71Sopenharmony_ci this.extraRegion() 249e41f4b71Sopenharmony_ci } 250e41f4b71Sopenharmony_ci }) 251e41f4b71Sopenharmony_ci } 252e41f4b71Sopenharmony_ci .height('100%') 253e41f4b71Sopenharmony_ci .width('100%') 254e41f4b71Sopenharmony_ci } 255e41f4b71Sopenharmony_ci} 256e41f4b71Sopenharmony_ci``` 257e41f4b71Sopenharmony_ci 258e41f4b71Sopenharmony_ci| Folded| Expanded| Hover| 259e41f4b71Sopenharmony_ci| ----- | ------ | ------ | 260e41f4b71Sopenharmony_ci|  |  |  | 261e41f4b71Sopenharmony_ci 262e41f4b71Sopenharmony_ci### Example 3 263e41f4b71Sopenharmony_ci 264e41f4b71Sopenharmony_ci```ts 265e41f4b71Sopenharmony_ciimport { 266e41f4b71Sopenharmony_ci FoldSplitContainer, 267e41f4b71Sopenharmony_ci PresetSplitRatio, 268e41f4b71Sopenharmony_ci ExtraRegionPosition, 269e41f4b71Sopenharmony_ci ExpandedRegionLayoutOptions, 270e41f4b71Sopenharmony_ci HoverModeRegionLayoutOptions, 271e41f4b71Sopenharmony_ci FoldedRegionLayoutOptions 272e41f4b71Sopenharmony_ci} from '@kit.ArkUI'; 273e41f4b71Sopenharmony_ci 274e41f4b71Sopenharmony_ci@Component 275e41f4b71Sopenharmony_cistruct Region { 276e41f4b71Sopenharmony_ci @Prop title: string; 277e41f4b71Sopenharmony_ci @BuilderParam content: () => void; 278e41f4b71Sopenharmony_ci @Prop compBackgroundColor: string; 279e41f4b71Sopenharmony_ci 280e41f4b71Sopenharmony_ci build() { 281e41f4b71Sopenharmony_ci Column({ space: 8 }) { 282e41f4b71Sopenharmony_ci Text(this.title) 283e41f4b71Sopenharmony_ci .fontSize("24fp") 284e41f4b71Sopenharmony_ci .fontWeight(600) 285e41f4b71Sopenharmony_ci 286e41f4b71Sopenharmony_ci Scroll() { 287e41f4b71Sopenharmony_ci this.content() 288e41f4b71Sopenharmony_ci } 289e41f4b71Sopenharmony_ci .layoutWeight(1) 290e41f4b71Sopenharmony_ci .width("100%") 291e41f4b71Sopenharmony_ci } 292e41f4b71Sopenharmony_ci .backgroundColor(this.compBackgroundColor) 293e41f4b71Sopenharmony_ci .width("100%") 294e41f4b71Sopenharmony_ci .height("100%") 295e41f4b71Sopenharmony_ci .padding(12) 296e41f4b71Sopenharmony_ci } 297e41f4b71Sopenharmony_ci} 298e41f4b71Sopenharmony_ci 299e41f4b71Sopenharmony_ciconst noop = () => { 300e41f4b71Sopenharmony_ci}; 301e41f4b71Sopenharmony_ci 302e41f4b71Sopenharmony_ci@Component 303e41f4b71Sopenharmony_cistruct SwitchOption { 304e41f4b71Sopenharmony_ci @Prop label: string = "" 305e41f4b71Sopenharmony_ci @Prop value: boolean = false 306e41f4b71Sopenharmony_ci public onChange: (checked: boolean) => void = noop; 307e41f4b71Sopenharmony_ci 308e41f4b71Sopenharmony_ci build() { 309e41f4b71Sopenharmony_ci Row() { 310e41f4b71Sopenharmony_ci Text(this.label) 311e41f4b71Sopenharmony_ci Blank() 312e41f4b71Sopenharmony_ci Toggle({ type: ToggleType.Switch, isOn: this.value }) 313e41f4b71Sopenharmony_ci .onChange((isOn) => { 314e41f4b71Sopenharmony_ci this.onChange(isOn); 315e41f4b71Sopenharmony_ci }) 316e41f4b71Sopenharmony_ci } 317e41f4b71Sopenharmony_ci .backgroundColor(Color.White) 318e41f4b71Sopenharmony_ci .borderRadius(8) 319e41f4b71Sopenharmony_ci .padding(8) 320e41f4b71Sopenharmony_ci .width("100%") 321e41f4b71Sopenharmony_ci } 322e41f4b71Sopenharmony_ci} 323e41f4b71Sopenharmony_ci 324e41f4b71Sopenharmony_ciinterface RadioOptions { 325e41f4b71Sopenharmony_ci label: string; 326e41f4b71Sopenharmony_ci value: Object | undefined | null; 327e41f4b71Sopenharmony_ci onChecked: () => void; 328e41f4b71Sopenharmony_ci} 329e41f4b71Sopenharmony_ci 330e41f4b71Sopenharmony_ci@Component 331e41f4b71Sopenharmony_cistruct RadioOption { 332e41f4b71Sopenharmony_ci @Prop label: string; 333e41f4b71Sopenharmony_ci @Prop value: Object | undefined | null; 334e41f4b71Sopenharmony_ci @Prop options: Array<RadioOptions>; 335e41f4b71Sopenharmony_ci 336e41f4b71Sopenharmony_ci build() { 337e41f4b71Sopenharmony_ci Row() { 338e41f4b71Sopenharmony_ci Text(this.label) 339e41f4b71Sopenharmony_ci Blank() 340e41f4b71Sopenharmony_ci Column({ space: 4 }) { 341e41f4b71Sopenharmony_ci ForEach(this.options, (option: RadioOptions) => { 342e41f4b71Sopenharmony_ci Row() { 343e41f4b71Sopenharmony_ci Radio({ 344e41f4b71Sopenharmony_ci group: this.label, 345e41f4b71Sopenharmony_ci value: JSON.stringify(option.value), 346e41f4b71Sopenharmony_ci }) 347e41f4b71Sopenharmony_ci .checked(this.value === option.value) 348e41f4b71Sopenharmony_ci .onChange((checked) => { 349e41f4b71Sopenharmony_ci if (checked) { 350e41f4b71Sopenharmony_ci option.onChecked(); 351e41f4b71Sopenharmony_ci } 352e41f4b71Sopenharmony_ci }) 353e41f4b71Sopenharmony_ci Text(option.label) 354e41f4b71Sopenharmony_ci } 355e41f4b71Sopenharmony_ci }) 356e41f4b71Sopenharmony_ci } 357e41f4b71Sopenharmony_ci .alignItems(HorizontalAlign.Start) 358e41f4b71Sopenharmony_ci } 359e41f4b71Sopenharmony_ci .alignItems(VerticalAlign.Top) 360e41f4b71Sopenharmony_ci .backgroundColor(Color.White) 361e41f4b71Sopenharmony_ci .borderRadius(8) 362e41f4b71Sopenharmony_ci .padding(8) 363e41f4b71Sopenharmony_ci .width("100%") 364e41f4b71Sopenharmony_ci } 365e41f4b71Sopenharmony_ci} 366e41f4b71Sopenharmony_ci 367e41f4b71Sopenharmony_ci@Entry 368e41f4b71Sopenharmony_ci@Component 369e41f4b71Sopenharmony_cistruct Index { 370e41f4b71Sopenharmony_ci @State expandedRegionLayoutOptions: ExpandedRegionLayoutOptions = { 371e41f4b71Sopenharmony_ci horizontalSplitRatio: PresetSplitRatio.LAYOUT_3V2, 372e41f4b71Sopenharmony_ci verticalSplitRatio: PresetSplitRatio.LAYOUT_1V1, 373e41f4b71Sopenharmony_ci isExtraRegionPerpendicular: true, 374e41f4b71Sopenharmony_ci extraRegionPosition: ExtraRegionPosition.TOP 375e41f4b71Sopenharmony_ci }; 376e41f4b71Sopenharmony_ci @State foldingRegionLayoutOptions: HoverModeRegionLayoutOptions = { 377e41f4b71Sopenharmony_ci horizontalSplitRatio: PresetSplitRatio.LAYOUT_3V2, 378e41f4b71Sopenharmony_ci showExtraRegion: false, 379e41f4b71Sopenharmony_ci extraRegionPosition: ExtraRegionPosition.TOP 380e41f4b71Sopenharmony_ci }; 381e41f4b71Sopenharmony_ci @State foldedRegionLayoutOptions: FoldedRegionLayoutOptions = { 382e41f4b71Sopenharmony_ci verticalSplitRatio: PresetSplitRatio.LAYOUT_1V1 383e41f4b71Sopenharmony_ci }; 384e41f4b71Sopenharmony_ci 385e41f4b71Sopenharmony_ci @Builder 386e41f4b71Sopenharmony_ci MajorRegion() { 387e41f4b71Sopenharmony_ci Region({ 388e41f4b71Sopenharmony_ci title: "Folded state settings", 389e41f4b71Sopenharmony_ci compBackgroundColor: "rgba(255, 0, 0, 0.1)", 390e41f4b71Sopenharmony_ci }) { 391e41f4b71Sopenharmony_ci Column({ space: 4 }) { 392e41f4b71Sopenharmony_ci RadioOption({ 393e41f4b71Sopenharmony_ci label: "Height ratio", 394e41f4b71Sopenharmony_ci value: this.foldedRegionLayoutOptions.verticalSplitRatio, 395e41f4b71Sopenharmony_ci options: [ 396e41f4b71Sopenharmony_ci { 397e41f4b71Sopenharmony_ci label: "1:1", 398e41f4b71Sopenharmony_ci value: PresetSplitRatio.LAYOUT_1V1, 399e41f4b71Sopenharmony_ci onChecked: () => { 400e41f4b71Sopenharmony_ci this.foldedRegionLayoutOptions.verticalSplitRatio = PresetSplitRatio.LAYOUT_1V1 401e41f4b71Sopenharmony_ci } 402e41f4b71Sopenharmony_ci }, 403e41f4b71Sopenharmony_ci { 404e41f4b71Sopenharmony_ci label: "2:3", 405e41f4b71Sopenharmony_ci value: PresetSplitRatio.LAYOUT_2V3, 406e41f4b71Sopenharmony_ci onChecked: () => { 407e41f4b71Sopenharmony_ci this.foldedRegionLayoutOptions.verticalSplitRatio = PresetSplitRatio.LAYOUT_2V3 408e41f4b71Sopenharmony_ci } 409e41f4b71Sopenharmony_ci }, 410e41f4b71Sopenharmony_ci { 411e41f4b71Sopenharmony_ci label: "3:2", 412e41f4b71Sopenharmony_ci value: PresetSplitRatio.LAYOUT_3V2, 413e41f4b71Sopenharmony_ci onChecked: () => { 414e41f4b71Sopenharmony_ci this.foldedRegionLayoutOptions.verticalSplitRatio = PresetSplitRatio.LAYOUT_3V2 415e41f4b71Sopenharmony_ci } 416e41f4b71Sopenharmony_ci }, 417e41f4b71Sopenharmony_ci { 418e41f4b71Sopenharmony_ci label: "Not set", 419e41f4b71Sopenharmony_ci value: undefined, 420e41f4b71Sopenharmony_ci onChecked: () => { 421e41f4b71Sopenharmony_ci this.foldedRegionLayoutOptions.verticalSplitRatio = undefined 422e41f4b71Sopenharmony_ci } 423e41f4b71Sopenharmony_ci } 424e41f4b71Sopenharmony_ci ] 425e41f4b71Sopenharmony_ci }) 426e41f4b71Sopenharmony_ci } 427e41f4b71Sopenharmony_ci .constraintSize({ minHeight: "100%" }) 428e41f4b71Sopenharmony_ci } 429e41f4b71Sopenharmony_ci } 430e41f4b71Sopenharmony_ci 431e41f4b71Sopenharmony_ci @Builder 432e41f4b71Sopenharmony_ci MinorRegion() { 433e41f4b71Sopenharmony_ci Region({ 434e41f4b71Sopenharmony_ci title: "Hover state settings", 435e41f4b71Sopenharmony_ci compBackgroundColor: "rgba(0, 255, 0, 0.1)" 436e41f4b71Sopenharmony_ci }) { 437e41f4b71Sopenharmony_ci Column({ space: 4 }) { 438e41f4b71Sopenharmony_ci RadioOption({ 439e41f4b71Sopenharmony_ci label: "Width ratio", 440e41f4b71Sopenharmony_ci value: this.foldingRegionLayoutOptions.horizontalSplitRatio, 441e41f4b71Sopenharmony_ci options: [ 442e41f4b71Sopenharmony_ci { 443e41f4b71Sopenharmony_ci label: "1:1", 444e41f4b71Sopenharmony_ci value: PresetSplitRatio.LAYOUT_1V1, 445e41f4b71Sopenharmony_ci onChecked: () => { 446e41f4b71Sopenharmony_ci this.foldingRegionLayoutOptions.horizontalSplitRatio = PresetSplitRatio.LAYOUT_1V1 447e41f4b71Sopenharmony_ci } 448e41f4b71Sopenharmony_ci }, 449e41f4b71Sopenharmony_ci { 450e41f4b71Sopenharmony_ci label: "2:3", 451e41f4b71Sopenharmony_ci value: PresetSplitRatio.LAYOUT_2V3, 452e41f4b71Sopenharmony_ci onChecked: () => { 453e41f4b71Sopenharmony_ci this.foldingRegionLayoutOptions.horizontalSplitRatio = PresetSplitRatio.LAYOUT_2V3 454e41f4b71Sopenharmony_ci } 455e41f4b71Sopenharmony_ci }, 456e41f4b71Sopenharmony_ci { 457e41f4b71Sopenharmony_ci label: "3:2", 458e41f4b71Sopenharmony_ci value: PresetSplitRatio.LAYOUT_3V2, 459e41f4b71Sopenharmony_ci onChecked: () => { 460e41f4b71Sopenharmony_ci this.foldingRegionLayoutOptions.horizontalSplitRatio = PresetSplitRatio.LAYOUT_3V2 461e41f4b71Sopenharmony_ci } 462e41f4b71Sopenharmony_ci }, 463e41f4b71Sopenharmony_ci { 464e41f4b71Sopenharmony_ci label: "Not set", 465e41f4b71Sopenharmony_ci value: undefined, 466e41f4b71Sopenharmony_ci onChecked: () => { 467e41f4b71Sopenharmony_ci this.foldingRegionLayoutOptions.horizontalSplitRatio = undefined 468e41f4b71Sopenharmony_ci } 469e41f4b71Sopenharmony_ci }, 470e41f4b71Sopenharmony_ci ] 471e41f4b71Sopenharmony_ci }) 472e41f4b71Sopenharmony_ci 473e41f4b71Sopenharmony_ci SwitchOption({ 474e41f4b71Sopenharmony_ci label: "Show extra region", 475e41f4b71Sopenharmony_ci value: this.foldingRegionLayoutOptions.showExtraRegion, 476e41f4b71Sopenharmony_ci onChange: (checked) => { 477e41f4b71Sopenharmony_ci this.foldingRegionLayoutOptions.showExtraRegion = checked; 478e41f4b71Sopenharmony_ci } 479e41f4b71Sopenharmony_ci }) 480e41f4b71Sopenharmony_ci 481e41f4b71Sopenharmony_ci if (this.foldingRegionLayoutOptions.showExtraRegion) { 482e41f4b71Sopenharmony_ci RadioOption({ 483e41f4b71Sopenharmony_ci label: "Extra region location," 484e41f4b71Sopenharmony_ci value: this.foldingRegionLayoutOptions.extraRegionPosition, 485e41f4b71Sopenharmony_ci options: [ 486e41f4b71Sopenharmony_ci { 487e41f4b71Sopenharmony_ci label: "Top," 488e41f4b71Sopenharmony_ci value: ExtraRegionPosition.TOP, 489e41f4b71Sopenharmony_ci onChecked: () => { 490e41f4b71Sopenharmony_ci this.foldingRegionLayoutOptions.extraRegionPosition = ExtraRegionPosition.TOP 491e41f4b71Sopenharmony_ci } 492e41f4b71Sopenharmony_ci }, 493e41f4b71Sopenharmony_ci { 494e41f4b71Sopenharmony_ci label: "Bottom," 495e41f4b71Sopenharmony_ci value: ExtraRegionPosition.BOTTOM, 496e41f4b71Sopenharmony_ci onChecked: () => { 497e41f4b71Sopenharmony_ci this.foldingRegionLayoutOptions.extraRegionPosition = ExtraRegionPosition.BOTTOM 498e41f4b71Sopenharmony_ci } 499e41f4b71Sopenharmony_ci }, 500e41f4b71Sopenharmony_ci { 501e41f4b71Sopenharmony_ci label: "Not set", 502e41f4b71Sopenharmony_ci value: undefined, 503e41f4b71Sopenharmony_ci onChecked: () => { 504e41f4b71Sopenharmony_ci this.foldingRegionLayoutOptions.extraRegionPosition = undefined 505e41f4b71Sopenharmony_ci } 506e41f4b71Sopenharmony_ci }, 507e41f4b71Sopenharmony_ci ] 508e41f4b71Sopenharmony_ci }) 509e41f4b71Sopenharmony_ci } 510e41f4b71Sopenharmony_ci } 511e41f4b71Sopenharmony_ci .constraintSize({ minHeight: "100%" }) 512e41f4b71Sopenharmony_ci } 513e41f4b71Sopenharmony_ci } 514e41f4b71Sopenharmony_ci 515e41f4b71Sopenharmony_ci @Builder 516e41f4b71Sopenharmony_ci ExtraRegion() { 517e41f4b71Sopenharmony_ci Region({ 518e41f4b71Sopenharmony_ci title: "Expanded state settings," 519e41f4b71Sopenharmony_ci compBackgroundColor: "rgba(0, 0, 255, 0.1)" 520e41f4b71Sopenharmony_ci }) { 521e41f4b71Sopenharmony_ci Column({ space: 4 }) { 522e41f4b71Sopenharmony_ci RadioOption({ 523e41f4b71Sopenharmony_ci label: "Width ratio," 524e41f4b71Sopenharmony_ci value: this.expandedRegionLayoutOptions.horizontalSplitRatio, 525e41f4b71Sopenharmony_ci options: [ 526e41f4b71Sopenharmony_ci { 527e41f4b71Sopenharmony_ci label: "1:1", 528e41f4b71Sopenharmony_ci value: PresetSplitRatio.LAYOUT_1V1, 529e41f4b71Sopenharmony_ci onChecked: () => { 530e41f4b71Sopenharmony_ci this.expandedRegionLayoutOptions.horizontalSplitRatio = PresetSplitRatio.LAYOUT_1V1 531e41f4b71Sopenharmony_ci } 532e41f4b71Sopenharmony_ci }, 533e41f4b71Sopenharmony_ci { 534e41f4b71Sopenharmony_ci label: "2:3", 535e41f4b71Sopenharmony_ci value: PresetSplitRatio.LAYOUT_2V3, 536e41f4b71Sopenharmony_ci onChecked: () => { 537e41f4b71Sopenharmony_ci this.expandedRegionLayoutOptions.horizontalSplitRatio = PresetSplitRatio.LAYOUT_2V3 538e41f4b71Sopenharmony_ci } 539e41f4b71Sopenharmony_ci }, 540e41f4b71Sopenharmony_ci { 541e41f4b71Sopenharmony_ci label: "3:2", 542e41f4b71Sopenharmony_ci value: PresetSplitRatio.LAYOUT_3V2, 543e41f4b71Sopenharmony_ci onChecked: () => { 544e41f4b71Sopenharmony_ci this.expandedRegionLayoutOptions.horizontalSplitRatio = PresetSplitRatio.LAYOUT_3V2 545e41f4b71Sopenharmony_ci } 546e41f4b71Sopenharmony_ci }, 547e41f4b71Sopenharmony_ci { 548e41f4b71Sopenharmony_ci label: "Not set", 549e41f4b71Sopenharmony_ci value: undefined, 550e41f4b71Sopenharmony_ci onChecked: () => { 551e41f4b71Sopenharmony_ci this.expandedRegionLayoutOptions.horizontalSplitRatio = undefined 552e41f4b71Sopenharmony_ci } 553e41f4b71Sopenharmony_ci }, 554e41f4b71Sopenharmony_ci ] 555e41f4b71Sopenharmony_ci }) 556e41f4b71Sopenharmony_ci 557e41f4b71Sopenharmony_ci RadioOption({ 558e41f4b71Sopenharmony_ci label: "Height ratio", 559e41f4b71Sopenharmony_ci value: this.expandedRegionLayoutOptions.verticalSplitRatio, 560e41f4b71Sopenharmony_ci options: [ 561e41f4b71Sopenharmony_ci { 562e41f4b71Sopenharmony_ci label: "1:1", 563e41f4b71Sopenharmony_ci value: PresetSplitRatio.LAYOUT_1V1, 564e41f4b71Sopenharmony_ci onChecked: () => { 565e41f4b71Sopenharmony_ci this.expandedRegionLayoutOptions.verticalSplitRatio = PresetSplitRatio.LAYOUT_1V1 566e41f4b71Sopenharmony_ci } 567e41f4b71Sopenharmony_ci }, 568e41f4b71Sopenharmony_ci { 569e41f4b71Sopenharmony_ci label: "2:3", 570e41f4b71Sopenharmony_ci value: PresetSplitRatio.LAYOUT_2V3, 571e41f4b71Sopenharmony_ci onChecked: () => { 572e41f4b71Sopenharmony_ci this.expandedRegionLayoutOptions.verticalSplitRatio = PresetSplitRatio.LAYOUT_2V3 573e41f4b71Sopenharmony_ci } 574e41f4b71Sopenharmony_ci }, 575e41f4b71Sopenharmony_ci { 576e41f4b71Sopenharmony_ci label: "3:2", 577e41f4b71Sopenharmony_ci value: PresetSplitRatio.LAYOUT_3V2, 578e41f4b71Sopenharmony_ci onChecked: () => { 579e41f4b71Sopenharmony_ci this.expandedRegionLayoutOptions.verticalSplitRatio = PresetSplitRatio.LAYOUT_3V2 580e41f4b71Sopenharmony_ci } 581e41f4b71Sopenharmony_ci }, 582e41f4b71Sopenharmony_ci { 583e41f4b71Sopenharmony_ci label: "Not set", 584e41f4b71Sopenharmony_ci value: undefined, 585e41f4b71Sopenharmony_ci onChecked: () => { 586e41f4b71Sopenharmony_ci this.expandedRegionLayoutOptions.verticalSplitRatio = undefined 587e41f4b71Sopenharmony_ci } 588e41f4b71Sopenharmony_ci } 589e41f4b71Sopenharmony_ci ] 590e41f4b71Sopenharmony_ci }) 591e41f4b71Sopenharmony_ci 592e41f4b71Sopenharmony_ci SwitchOption({ 593e41f4b71Sopenharmony_ci label: "Show extra region perpendicularly," 594e41f4b71Sopenharmony_ci value: this.expandedRegionLayoutOptions.isExtraRegionPerpendicular, 595e41f4b71Sopenharmony_ci onChange: (checked) => { 596e41f4b71Sopenharmony_ci this.expandedRegionLayoutOptions.isExtraRegionPerpendicular = checked; 597e41f4b71Sopenharmony_ci } 598e41f4b71Sopenharmony_ci }) 599e41f4b71Sopenharmony_ci 600e41f4b71Sopenharmony_ci if (!this.expandedRegionLayoutOptions.isExtraRegionPerpendicular) { 601e41f4b71Sopenharmony_ci RadioOption({ 602e41f4b71Sopenharmony_ci label: "Extra region location," 603e41f4b71Sopenharmony_ci value: this.expandedRegionLayoutOptions.extraRegionPosition, 604e41f4b71Sopenharmony_ci options: [ 605e41f4b71Sopenharmony_ci { 606e41f4b71Sopenharmony_ci label: "Top," 607e41f4b71Sopenharmony_ci value: ExtraRegionPosition.TOP, 608e41f4b71Sopenharmony_ci onChecked: () => { 609e41f4b71Sopenharmony_ci this.expandedRegionLayoutOptions.extraRegionPosition = ExtraRegionPosition.TOP 610e41f4b71Sopenharmony_ci } 611e41f4b71Sopenharmony_ci }, 612e41f4b71Sopenharmony_ci { 613e41f4b71Sopenharmony_ci label: "Bottom," 614e41f4b71Sopenharmony_ci value: ExtraRegionPosition.BOTTOM, 615e41f4b71Sopenharmony_ci onChecked: () => { 616e41f4b71Sopenharmony_ci this.expandedRegionLayoutOptions.extraRegionPosition = ExtraRegionPosition.BOTTOM 617e41f4b71Sopenharmony_ci } 618e41f4b71Sopenharmony_ci }, 619e41f4b71Sopenharmony_ci { 620e41f4b71Sopenharmony_ci label: "Not set", 621e41f4b71Sopenharmony_ci value: undefined, 622e41f4b71Sopenharmony_ci onChecked: () => { 623e41f4b71Sopenharmony_ci this.expandedRegionLayoutOptions.extraRegionPosition = undefined 624e41f4b71Sopenharmony_ci } 625e41f4b71Sopenharmony_ci }, 626e41f4b71Sopenharmony_ci ] 627e41f4b71Sopenharmony_ci }) 628e41f4b71Sopenharmony_ci } 629e41f4b71Sopenharmony_ci } 630e41f4b71Sopenharmony_ci .constraintSize({ minHeight: "100%" }) 631e41f4b71Sopenharmony_ci } 632e41f4b71Sopenharmony_ci } 633e41f4b71Sopenharmony_ci 634e41f4b71Sopenharmony_ci build() { 635e41f4b71Sopenharmony_ci Column() { 636e41f4b71Sopenharmony_ci FoldSplitContainer({ 637e41f4b71Sopenharmony_ci primary: () => { 638e41f4b71Sopenharmony_ci this.MajorRegion() 639e41f4b71Sopenharmony_ci }, 640e41f4b71Sopenharmony_ci secondary: () => { 641e41f4b71Sopenharmony_ci this.MinorRegion() 642e41f4b71Sopenharmony_ci }, 643e41f4b71Sopenharmony_ci extra: () => { 644e41f4b71Sopenharmony_ci this.ExtraRegion() 645e41f4b71Sopenharmony_ci }, 646e41f4b71Sopenharmony_ci expandedLayoutOptions: this.expandedRegionLayoutOptions, 647e41f4b71Sopenharmony_ci hoverModeLayoutOptions: this.foldingRegionLayoutOptions, 648e41f4b71Sopenharmony_ci foldedLayoutOptions: this.foldedRegionLayoutOptions, 649e41f4b71Sopenharmony_ci }) 650e41f4b71Sopenharmony_ci } 651e41f4b71Sopenharmony_ci .width("100%") 652e41f4b71Sopenharmony_ci .height("100%") 653e41f4b71Sopenharmony_ci } 654e41f4b71Sopenharmony_ci} 655e41f4b71Sopenharmony_ci``` 656e41f4b71Sopenharmony_ci 657e41f4b71Sopenharmony_ci| Folded| Expanded| Hover| 658e41f4b71Sopenharmony_ci| ----- | ------ | ------ | 659e41f4b71Sopenharmony_ci|  |  |  | 660e41f4b71Sopenharmony_ci| |  |  | 661e41f4b71Sopenharmony_ci| |  |  | 662