Skip to content

Commit

Permalink
提交1.0.8版本
Browse files Browse the repository at this point in the history
  • Loading branch information
AbnerMing committed May 15, 2024
1 parent 9e49b72 commit b2781e4
Show file tree
Hide file tree
Showing 10 changed files with 265 additions and 14 deletions.
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

基于ArkUI封装的上拉下拉刷新组件,支持列表、网格、瀑布流、支持各种任意组件刷新。

截至2024年5月11日,功能点如下
截至2024年5月15日,功能点如下

- 1、**支持ListView列表/下拉刷新/上拉加载**
- 2、**支持GridView网格列表/下拉刷新/上拉加载**
Expand All @@ -12,13 +12,14 @@
- 6、**支持列表(ListView)右侧侧滑展示按钮**
- 7、**支持下滑进入二楼/半楼功能(仿京东或淘宝)**
- 8、**数据操作(增删改查)提供便捷方式,适应更多场景运用**
- 9、**支持页面刷新加载吸顶效果(ListView/GridView/StaggeredGridView)**

## 效果

### 所有功能

<p align="center">
<img src="https://vipandroid-image.oss-cn-beijing.aliyuncs.com/harmony/refresh/refresh_all.png" width="300px" />
<img src="https://vipandroid-image.oss-cn-beijing.aliyuncs.com/harmony/refresh/root_001.png" width="300px" />
</p>

### 刷新效果
Expand All @@ -43,12 +44,19 @@
<img src="https://vipandroid-image.oss-cn-beijing.aliyuncs.com/harmony/refresh/refresh_243_07.png" width="200px" />
</p>

### 吸顶效果

<p align="center">
<img src="https://vipandroid-image.oss-cn-beijing.aliyuncs.com/harmony/refresh/sticky_top.png" width="200px" />
</p>

**动态效果:**

<p align="center">
<img src="https://vipandroid-image.oss-cn-beijing.aliyuncs.com/harmony/refresh/refresh_01.gif" width="200px" />
<img src="https://vipandroid-image.oss-cn-beijing.aliyuncs.com/harmony/refresh/refresh_243_06.gif" width="200px" />
<img src="https://vipandroid-image.oss-cn-beijing.aliyuncs.com/harmony/refresh/refresh_sf.gif" width="200px" />
<img src="https://vipandroid-image.oss-cn-beijing.aliyuncs.com/harmony/refresh/sticky_grid.gif" width="200px" />
</p>


Expand Down Expand Up @@ -935,7 +943,7 @@ this.dataSource.changeData(3, 9999)

## 关注公众号

鸿蒙先驱者,只分享精华的鸿蒙或者移动端技术文章,可扫码关注
鸿蒙先驱者,只分享精华的鸿蒙或者移动端技术文章,可微信扫码关注

<p><img src="https://vipandroid-image.oss-cn-beijing.aliyuncs.com/harmony/abner.jpg" width="150px" /></p>

Expand Down Expand Up @@ -963,7 +971,8 @@ this.dataSource.changeData(3, 9999)
- 5、鸿蒙脚手架,正在研发中,可首批次体验使用。


### License

## License

```
Copyright (C) AbnerMing, HarmonyOsRefresh Open Source Project
Expand Down
Binary file removed example/libs/refresh-1.0.7.har
Binary file not shown.
Binary file added example/libs/refresh-1.0.8.har
Binary file not shown.
16 changes: 12 additions & 4 deletions example/oh-package-lock.json5

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion example/oh-package.json5
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"main": "",
"version": "1.0.0",
"dependencies": {
"@abner/refresh": "file:libs/refresh-1.0.7.har"
"@abner/refresh": "file:libs/refresh-1.0.8.har",
"@abner/tab": "^1.0.0"
}
}
7 changes: 5 additions & 2 deletions example/src/main/ets/pages/Index.ets
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ struct Index {
"普通的列表ListView", "下拉刷新列表ListView", "刷新加载列表ListView", "带有头的ListView",
"普通的列表GridView", "下拉刷新列表GridView", "刷新加载列表GridView", "带有头的GridView",
"普通的瀑布流列表", "带有头的瀑布流列表",
"任意组件", "侧滑展示按钮", "下滑进入二楼", "普通加载数据操作", "懒加载数据操作"
"任意组件", "侧滑展示按钮", "下滑进入二楼", "普通加载数据操作", "懒加载数据操作",
"列表页面吸顶","瀑布流页面吸顶"
]
private routerPaths: Array<string> = [
"pages/list/ListViewPage",
Expand All @@ -33,7 +34,9 @@ struct Index {
"pages/list/SlideMenuListViewPage",
"pages/floor/SecondFloorPage",
"pages/data/DataOperationPage",
"pages/data/LazyDataOperationPage"
"pages/data/LazyDataOperationPage",
"pages/sticky/StickyTopPage",
"pages/sticky/StickyTopStaggeredPage"
]

/**
Expand Down
5 changes: 3 additions & 2 deletions example/src/main/ets/pages/list/ListViewRefreshPage.ets
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ActionBar } from '../ActionBar'
import { ListView, RefreshController } from '@abner/refresh'
import { RefreshLayoutStatus } from '@abner/refresh/src/main/ets/constants/RefreshLayoutStatus'

/**
* AUTHOR:AbnerMing
Expand Down Expand Up @@ -40,8 +41,8 @@ struct ListViewRefreshPage {
ActionBar({ title: "下拉刷新列表ListView" })
ListView({
items: this.array, //数据源 数组,可以任意类型,自定义对象[],number[],string[]……
itemLayout: (item:Object, index:number) => {
this.itemLayout(item as number, index)//转成你需要的对象
itemLayout: (item: Object, index: number) => {
this.itemLayout(item as number, index) //转成你需要的对象
},
controller: this.controller, //控制器,负责关闭下拉和上拉
onRefresh: () => {
Expand Down
104 changes: 104 additions & 0 deletions example/src/main/ets/pages/sticky/StickyTopPage.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { ListView, RefreshController } from '@abner/refresh'

/**
* AUTHOR:AbnerMing
* DATE:2024/5/14
* INTRODUCE:吸顶页面
* */

@Entry
@Component
struct StickyTopPage {
@State controller: RefreshController = new RefreshController() //刷新控制器
@State arr: number[] = []
@State listPosition: number = 0

@Builder
itemLayout(item: Object, _: number) {
Text("item" + item)
.fontSize(16)
.width("100%")
.height(60)
}

build() {
Scroll() {
Column() {
Text("头View")
.fontColor(Color.White)
.width("100%")
.height("40%")
.backgroundColor(Color.Red)
.textAlign(TextAlign.Center)
Tabs({ barPosition: BarPosition.Start }) {
TabContent() {
this.testLayout()
}.tabBar("Tab1")

TabContent() {
this.testLayout()
}.tabBar("Tab2")
}
.vertical(false)
.height("100%")
}.width("100%")
}
.friction(0.6)
.scrollBar(BarState.Off)
.width('100%')
.height('100%')
// 下拉刷新相关
.onReachStart(() => {
this.listPosition = 0
})
.onScrollFrameBegin((offset: number, _: ScrollState) => {
//设置起始位置,保障在顶部时,才能执行下拉刷新
this.controller.markStartLocation(this.listPosition == 0)
if (this.listPosition == 0 && offset <= 0) {
return { offsetRemain: 0 }
}
this.listPosition = 1
return { offsetRemain: offset }
})

}

aboutToAppear() {
for (let i = 0; i < 30; i++) {
this.arr.push(i)
}
}

/*
* Author:AbnerMing
* Describe:测试布局
*/
@Builder
testLayout() {
ListView({
items: this.arr,
itemLayout: this.itemLayout,
controller: this.controller,
onRefresh: () => {
//下拉刷新
//模拟耗时
setTimeout(() => {
this.controller.finishRefresh()
}, 1000)
},
onLoadMore: () => {
// 上拉加载
//模拟耗时
setTimeout(() => {
this.controller.finishLoadMore()
}, 1000)
},
listAttribute: (attr) => {
attr.nestedScroll = {
scrollForward: NestedScrollMode.PARENT_FIRST,
scrollBackward: NestedScrollMode.SELF_FIRST
}
}
})
}
}
123 changes: 123 additions & 0 deletions example/src/main/ets/pages/sticky/StickyTopStaggeredPage.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import { RefreshController, StaggeredGridView } from '@abner/refresh'

/**
* AUTHOR:AbnerMing
* DATE:2024/5/14
* INTRODUCE:吸顶页面-瀑布流方式
* */

@Entry
@Component
struct StickyTopStaggeredPage {
@State controller: RefreshController = new RefreshController() //刷新控制器
@State arr: number[] = []
@State listPosition: number = 0
private itemHeightArray: number[] = []
@State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F]
@State minSize: number = 80
@State maxSize: number = 180

// 计算FlowItem宽/高
getSize() {
let ret = Math.floor(Math.random() * this.maxSize)
return (ret > this.minSize ? ret : this.minSize)
}

// 设置FlowItem的宽/高数组
setItemSizeArray() {
for (let i = 0; i < 100; i++) {
this.itemHeightArray.push(this.getSize())
}
}

aboutToAppear() {
for (let i = 0; i < 50; i++) {
this.arr.push(i)
}
this.setItemSizeArray()
}

@Builder
itemLayout(_this: StickyTopStaggeredPage, _: Object, index: number) {
Column() {
Text("测试数据" + index)
}.width("100%")
.height(this.itemHeightArray[index % 100])
.backgroundColor(this.colors[index % 5])
}

build() {
Scroll() {
Column() {
Text("头View")
.fontColor(Color.White)
.width("100%")
.height("40%")
.backgroundColor(Color.Red)
.textAlign(TextAlign.Center)
Tabs({ barPosition: BarPosition.Start }) {
TabContent() {
this.testLayout()
}.tabBar("Tab1")

TabContent() {
this.testLayout()
}.tabBar("Tab2")
}
.vertical(false)
.height("100%")
}.width("100%")
}
.friction(0.6)
.scrollBar(BarState.Off)
.width('100%')
.height('100%')
// 下拉刷新相关
.onReachStart(() => {
this.listPosition = 0
})
.onScrollFrameBegin((offset: number, _: ScrollState) => {
//设置起始位置,保障在顶部时,才能执行下拉刷新
this.controller.markStartLocation(this.listPosition == 0)
if (this.listPosition == 0 && offset <= 0) {
return { offsetRemain: 0 }
}
this.listPosition = 1
return { offsetRemain: offset }
})

}

/*
* Author:AbnerMing
* Describe:测试布局
*/
@Builder
testLayout() {
StaggeredGridView({
items: this.arr,
itemLayout: (item: Object, index: number) => {
this.itemLayout(this, item, index)
},
controller: this.controller,
onRefresh: () => {
//下拉刷新
//模拟耗时
setTimeout(() => {
this.controller.finishRefresh()
}, 1000)
},
onLoadMore: () => {
// 上拉加载
//模拟耗时
setTimeout(() => {
this.controller.finishLoadMore()
}, 1000)
},
nestedScroll: {
scrollForward: NestedScrollMode.PARENT_FIRST,
scrollBackward: NestedScrollMode.SELF_FIRST
}
})
}
}
4 changes: 3 additions & 1 deletion example/src/main/resources/base/profile/main_pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"pages/list/SlideMenuListViewPage",
"pages/floor/SecondFloorPage",
"pages/data/DataOperationPage",
"pages/data/LazyDataOperationPage"
"pages/data/LazyDataOperationPage",
"pages/sticky/StickyTopPage",
"pages/sticky/StickyTopStaggeredPage"
]
}

0 comments on commit b2781e4

Please sign in to comment.