diff --git a/AppScope/app.json5 b/AppScope/app.json5 index b70cbd848db4563d8ff19e6dc57a6a9d5241ef23..13b11b45367a594e9f8ee51cf13466a9b542eed0 100644 --- a/AppScope/app.json5 +++ b/AppScope/app.json5 @@ -3,7 +3,7 @@ "bundleName": "cn.openharmony.vlayout", "vendor": "example", "versionCode": 1000000, - "versionName": "1.0.0", + "versionName": "2.1.0-rc.0", "icon": "$media:app_icon", "label": "$string:app_name" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ad211065b4dabaf83385c09331d7da6ef639b4a..91b924b05288f141be065767bacecf08a7b1b301 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## 2.1.0-rc.0 - 适配ComponentV2装饰器 +- 修改STICKY_LAYOUT布局结合LINEAR_LAYOUT布局滑动固定 ## 2.0.0 - 适配DevEco Studio 版本:4.1 Canary(4.1.3.317),OpenHarmony SDK:API11 (4.1.0.36) diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 index a931f96ae9f30df316b94bb516e1c42c1c0e5ad2..5f0271164bb197cdc54414c811304926d027169f 100644 --- a/entry/oh-package.json5 +++ b/entry/oh-package.json5 @@ -5,7 +5,7 @@ "name": "entry", "description": "example description.", "main": "", - "version": "2.0.0", + "version": "2.1.0-rc.0", "dependencies": { "@ohos/vlayout": "file:../library" } diff --git a/entry/src/main/ets/pages/OnePlusNLayoutSample.ets b/entry/src/main/ets/pages/OnePlusNLayoutSample.ets index a5640c279c313b816da5a29b46155b68f5b364b6..f51b0e94c12d667b5a11b37f79b2891cfa8fd340 100644 --- a/entry/src/main/ets/pages/OnePlusNLayoutSample.ets +++ b/entry/src/main/ets/pages/OnePlusNLayoutSample.ets @@ -25,6 +25,7 @@ import { layoutDataType, dataType } from '@ohos/vlayout' +import { display } from '@kit.ArkUI'; @Entry @ComponentV2 @@ -40,7 +41,7 @@ struct OnePlusNLayoutSample { @Local data: dataType[] = [ { layoutData: [0, 1, 2, 3, 4, 5] }, //BANNER_LAYOUT { layoutData: [{ layoutText: 1 }, { layoutText: 2 }, { layoutText: 3 }, { layoutText: 4 }, - { layoutText: 5 }, { layoutText: 6 }, { layoutText: 7 }, { layoutText: 8 },] }, //GRID_LAYOUT + { layoutText: 5 }, { layoutText: 6 }, { layoutText: 7 }, { layoutText: 8 },] }, //GRID_LAYOUT { layoutData: [{ layoutText: 9 }, { layoutText: 10 },] }, //GRID_LAYOUT { layoutData: [ { layoutText: 11 }, @@ -208,7 +209,7 @@ struct OnePlusNLayoutSample { @Builder stickyLayoutContent(item: layoutDataType, position: number | undefined) { Text(`${item}`) .width('100%') - .height('20%') + .height('100%') .backgroundColor(0x22EEEEEE) .border({ width: 1, color: '#000000', radius: 0, style: BorderStyle.Solid }) .fontSize(25) @@ -254,6 +255,21 @@ struct OnePlusNLayoutSample { }) } + @Builder + itemHead() { + STICKY_LAYOUT({ + vLayoutContent: (item: layoutDataType, position: number | undefined) => { + this.stickyLayoutContent(item, position) + }, + vLayoutData: [65], + vLayoutAttribute: { + aspectRatio: 4, + bgColor: '#22EEEEEE', + } + }) + } + + build() { Stack({ alignContent: Alignment.Bottom }) { List({ scroller: this.vScroller }) { @@ -513,33 +529,23 @@ struct OnePlusNLayoutSample { } }) } - - ListItem() { - STICKY_LAYOUT({ - vLayoutContent: (item: layoutDataType, position: number | undefined) => { - this.stickyLayoutContent(item, position) - }, - vLayoutData: [65], - vLayoutAttribute: { - aspectRatio: 4, - bgColor: '#22EEEEEE', - } - }) - }.sticky(Sticky.Normal) - - ListItem() { - LINEAR_LAYOUT({ - vLayoutContent: (item: layoutDataType, position: number | undefined) => { - this.linearLayoutContent(item, position) - }, - vLayoutData: [67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166], - vLayoutAttribute: { - aspectRatio: 4, - bgColor: '#AAAAAA', - }, - }) + ListItemGroup({ header: this.itemHead(), footer: undefined }) { + ListItem() { + LINEAR_LAYOUT({ + vLayoutContent: (item: layoutDataType, position: number | undefined) => { + this.linearLayoutContent(item, position) + }, + vLayoutData: [67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166], + vLayoutAttribute: { + layoutHeight: display.getDefaultDisplaySync().width, + aspectRatio: 4, + bgColor: '#AAAAAA', + }, + }) + } } - } + }.height("100%") + .sticky(StickyStyle.Header) .edgeEffect(EdgeEffect.None) .onScrollIndex((start: number, end: number) => { //获取First diff --git a/library/src/main/ets/components/common/LinearLayoutHelper.ets b/library/src/main/ets/components/common/LinearLayoutHelper.ets index 51e0613b3ec8b496df9d9310f8ca8bd5cbaff52b..70be2dfa74dea137a73ac64e521b00058e4680e9 100644 --- a/library/src/main/ets/components/common/LinearLayoutHelper.ets +++ b/library/src/main/ets/components/common/LinearLayoutHelper.ets @@ -153,10 +153,10 @@ export struct LINEAR_LAYOUT { }) }) } + .nestedScroll({ scrollForward: NestedScrollMode.PARENT_FIRST, scrollBackward: NestedScrollMode.SELF_FIRST}) .onAreaChange((oldValue, newValue) => { this.listWidth = (Number(newValue.width)) this.listHeight = (Number(newValue.height)) - console.info(TAG + 'List listWidth = ' + this.listWidth + ', listHeight = ' + this.listHeight) }) .width(undefined) .height(this.linearInfo.layoutHeight == undefined ? this.layoutHeight : this.linearInfo.layoutHeight) diff --git a/oh-package.json5 b/oh-package.json5 index 79dbbbed0a3db9fb2d49e0862b939fed28895b16..96cd49ccec876dd599b64a3705d911a87aa78df6 100644 --- a/oh-package.json5 +++ b/oh-package.json5 @@ -1,4 +1,5 @@ { + "modelVersion": "5.0.0", "license": "Apache-2.0", "devDependencies": { "@ohos/hypium": "1.0.6" @@ -7,6 +8,6 @@ "name": "vlayout", "description": "Please describe the basic information.", "main": "", - "version": "2.0.0", + "version": "2.1.0-rc.0", "dependencies": {} -} +} \ No newline at end of file