1# FolderStack 2 3FolderStack继承于Stack(层叠布局)控件,新增了折叠屏悬停能力,通过识别upperItems自动避让折叠屏折痕区后移到上半屏 4 5> **说明:** 6> 7> 该组件从API Version 11开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 8 9 10## 子组件 11 12可以包含多个子组件。 13 14 15## 接口 16 17FolderStack(value?: { upperItems?: Array<string\>}) 18 19从API version 11开始,该接口支持在ArkTS卡片中使用。 20 21**参数:** 22 23| 参数名 | 参数类型 | 必填 | 参数描述 | 24| ------------ | ------------------------------------------- | ---- |----------------------------------------------------------------------| 25| upperItems | Array<string\> | 否 | 定义悬停态会被移到上半屏的子组件的id,组件id在此数组中的子组件悬停触发时自动避让折叠屏折痕区后移到上半屏,其它组件堆叠在下半屏区域。 | 26 27 28 29## 属性 30 31除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: 32 33| 名称 | 参数类型 | 描述 | 34|-----------------|---------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------| 35| alignContent | [Alignment](ts-appendix-enums.md#alignment) | 设置子组件在容器内的对齐方式。<br/>默认值:Alignment.Center<br/>**说明:** <br/>该属性与[通用属性align](ts-universal-attributes-location.md)同时设置时,后设置的属性生效。 | 36| enableAnimation | boolean | 设置是否使用默认动效。<br/>默认值:true。 | 37| autoHalfFold | boolean | 是否开启自动旋转,仅在系统自动旋转关闭时该属性生效。<br/>默认值:true。 | 38> **说明:** 39> 40> 设置offset和margin属性,可能会导致上下半屏遮挡折痕区,不建议开发者使用。 41 42## 事件 43 44除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件: 45 46| 名称 | 功能描述 | 47|-------------------------------------------------------------------|------------------------------------------------| 48| onFolderStateChange (callback: (event: { foldStatus: [FoldStatus](ts-appendix-enums.md#foldstatus11) }) => void) | 当折叠状态改变的时候回调,仅在横屏状态下生效。<br/>- foldStatus:当前设备的折叠状态。 | 49 50## 示例 51 52```ts 53@Entry 54@Component 55struct Index { 56 @State len_wid: number = 480 57 @State w: string = "40%" 58 build() { 59 Column() { 60 // upperItems将所需要的悬停到上半屏的id放入upperItems传入,其余组件会堆叠在下半屏区域 61 FolderStack({ upperItems: ["upperitemsId"] }) { 62 // 此Column会自动上移到上半屏 63 Column() { 64 Text("vedio zone").height("100%").width("100%").textAlign(TextAlign.Center).fontSize(25) 65 }.backgroundColor(Color.Pink).width("100%").height("100%").id("upperitemsId") 66 67 // 下列两个Column堆叠在下半屏区域 68 Column() { 69 Text("vedio title") 70 .width("100%") 71 .height(50) 72 .textAlign(TextAlign.Center) 73 .backgroundColor(Color.Red) 74 .fontSize(25) 75 }.width("100%").height("100%").justifyContent(FlexAlign.Start) 76 77 Column() { 78 Text("vedie bar ") 79 .width("100%") 80 .height(50) 81 .textAlign(TextAlign.Center) 82 .backgroundColor(Color.Red) 83 .fontSize(25) 84 }.width("100%").height("100%").justifyContent(FlexAlign.End) 85 } 86 .backgroundColor(Color.Yellow) 87 // 是否启动动效 88 .enableAnimation(true) 89 // 是否自动旋转 90 .autoHalfFold(true) 91 // folderStack回调 当折叠状态改变时回调 92 .onFolderStateChange((msg) => { 93 if (msg.foldStatus === FoldStatus.FOLD_STATUS_EXPANDED) { 94 console.info("The device is currently in the expanded state") 95 } else if (msg.foldStatus === FoldStatus.FOLD_STATUS_HALF_FOLDED) { 96 console.info("The device is currently in the half folded state") 97 } else { 98 // ............. 99 } 100 }) 101 // folderStack如果不撑满页面全屏,作为普通Stack使用 102 .alignContent(Alignment.Bottom) 103 .height("100%") 104 .width("100%") 105 .borderWidth(1) 106 .backgroundColor(Color.Yellow) 107 108 } 109 .height("100%") 110 .width("100%") 111 .borderWidth(1) 112 .backgroundColor(Color.Pink) 113 .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM]) 114 115 } 116} 117```