Skip to content

Commit

Permalink
提交1.0.6版本
Browse files Browse the repository at this point in the history
  • Loading branch information
AbnerMing committed May 10, 2024
1 parent 5c04780 commit 6730883
Show file tree
Hide file tree
Showing 16 changed files with 376 additions and 102 deletions.
285 changes: 201 additions & 84 deletions README.md

Large diffs are not rendered by default.

Binary file removed example/libs/refresh-1.0.5.har
Binary file not shown.
Binary file added example/libs/refresh-1.0.6.har
Binary file not shown.
8 changes: 4 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.

2 changes: 1 addition & 1 deletion example/oh-package.json5
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"main": "",
"version": "1.0.0",
"dependencies": {
"@abner/refresh": "file:libs/refresh-1.0.5.har"
"@abner/refresh": "file:libs/refresh-1.0.6.har"
}
}
8 changes: 7 additions & 1 deletion example/src/main/ets/exampleability/ExampleAbility.ets
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,20 @@ export default class ExampleAbility extends UIAbility {

let windowClass: window.Window = windowStage.getMainWindowSync(); // 获取应用主窗口


let sysBarProps: window.SystemBarProperties = {
statusBarColor: '#ff0000',
navigationBarColor: '#ff0000',
// 以下两个属性从API Version 8开始支持
statusBarContentColor: '#ffffff',
navigationBarContentColor: '#ffffff'
};

let area = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM)
let statusBarHeight = area.topRect.height

console.log("============" + JSON.stringify(area))


windowClass.setWindowSystemBarProperties(sysBarProps, (err: BusinessError) => {
let errCode: number = err.code;
if (errCode) {
Expand Down
11 changes: 6 additions & 5 deletions example/src/main/ets/pages/Index.ets
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import router from '@ohos.router'
import { ActionBar } from './ActionBar'
import { ListView, RefreshController } from '@abner/refresh'
import { GridView, RefreshController } from '@abner/refresh'

/**
* AUTHOR:AbnerMing
Expand All @@ -16,7 +16,7 @@ struct Index {
"普通的列表ListView", "下拉刷新列表ListView", "刷新加载列表ListView", "带有头的ListView",
"普通的列表GridView", "下拉刷新列表GridView", "刷新加载列表GridView", "带有头的GridView",
"普通的瀑布流列表", "带有头的瀑布流列表",
"任意组件", "侧滑展示按钮"
"任意组件", "侧滑展示按钮", "下滑进入二楼"
]
private routerPaths: Array<string> = [
"pages/list/ListViewPage",
Expand All @@ -30,7 +30,8 @@ struct Index {
"pages/staggered/StaggeredPage",
"pages/staggered/StaggeredHeadPage",
"pages/layout/LayoutViewPage",
"pages/list/SlideMenuListViewPage"
"pages/list/SlideMenuListViewPage",
"pages/floor/SecondFloorPage"
]

/**
Expand All @@ -44,7 +45,7 @@ struct Index {
Text(item.toString())
.width("95%")
.height(50)
.margin(10)
.margin({ left: "2.5%", top: 10 })
.textAlign(TextAlign.Center)
.border({ width: 1, color: Color.Pink })
.onClick(() => {
Expand All @@ -56,7 +57,7 @@ struct Index {
Column() {
ActionBar({ title: "首页", hiddenBack: true })

ListView({
GridView({
items: this.array, //数据源 数组
itemLayout: (item, index) => this.itemLayout(item, index),
controller: this.controller, //控制器,负责关闭下拉和上拉
Expand Down
148 changes: 148 additions & 0 deletions example/src/main/ets/pages/floor/SecondFloorPage.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
import { SecondFloorLayout, SfRefreshController, WindowFullScreenUtil } from '@abner/refresh'
import { window } from '@kit.ArkUI'

@Entry
@Component
struct SecondFloorPage {
@State sfController: SfRefreshController = new SfRefreshController()
@State topViewHeight: number = 44
@State statusBarHeight: number = 0
@State mScrollInteraction: boolean = true

onPageShow(): void {

let sysBarProps: window.SystemBarProperties = {
statusBarColor: "#00000000",
navigationBarColor: '#00000000',
// 以下两个属性从API Version 8开始支持
statusBarContentColor: '#ffffff',
navigationBarContentColor: '#ffffff'
}

WindowFullScreenUtil.changeWindowFullScreen(true, {
sysBarProps: sysBarProps,
success: (win) => {
// 2. 获取布局避让遮挡的区域
let area = win.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM)
this.statusBarHeight = px2vp(area.topRect.height)
this.topViewHeight = this.topViewHeight + this.statusBarHeight
}
})
}

onBackPress(): boolean | void {
let sysBarProps: window.SystemBarProperties = {
statusBarColor: "#ff0000",
navigationBarColor: '#ff0000',
// 以下两个属性从API Version 8开始支持
statusBarContentColor: '#ffffff',
navigationBarContentColor: '#ffffff'
};
WindowFullScreenUtil.changeWindowFullScreen(false, { sysBarProps: sysBarProps })

}

/*
* Author:AbnerMing
* Describe:一楼视图
*/
@State listPosition: number = 0; // 0代表滚动到List顶部,1代表中间值,2代表滚动到List底部。

@Builder
firstFloorView(_this: SecondFloorPage) {
Scroll() {
Image($r("app.media.taobao_index"))
.width("100%")
}
.width("100%")
.height("100%")
.onReachStart(() => {
_this.listPosition = 0
})
.enableScrollInteraction(_this.mScrollInteraction)
.onScrollFrameBegin((offset: number, _: ScrollState) => {
_this.sfController.markStartLocation(_this.listPosition == 0)
if (_this.listPosition == 0 && offset <= 0) {
return { offsetRemain: 0 }
}
_this.listPosition = 1
return { offsetRemain: offset }
})

}

/*
* Author:AbnerMing
* Describe:二楼视图
*/
@Builder
secondFloorView() {
Column() {
Image($r("app.media.taobao_second_floor"))
.width("100%")
.height("100%")
}
.width("100%")
.height("100%")
}

/*
* Author:AbnerMing
* Describe:顶部固定视图
*/
@Builder
topFixedView(this_: SecondFloorPage) {
Column() {
Text("淘宝二楼")
.fontColor(Color.White)
}
.width("100%")
.height(this_.topViewHeight)
.padding({ top: this_.statusBarHeight })
.backgroundColor(Color.Red)
.justifyContent(FlexAlign.Center)
}

build() {
RelativeContainer() {
SecondFloorLayout({
firstFloorView: () => { //一楼视图
this.firstFloorView(this)
},
isNeedHalfFloor: false, //是否需要半楼功能
secondFloorView: this.secondFloorView, //二楼视图
enableScrollInteraction: (isInteraction: boolean) => {
//用于解决嵌套的滑动组件冲突
this.mScrollInteraction = isInteraction
},
topFixedView: () => {
//顶部固定视图
this.topFixedView(this)
},
sfController: this.sfController, //刷新控制器
refreshHeaderAttribute: (attr) => {
//刷新头及二楼滑动属性配置
attr.fontColor = Color.White
attr.timeFontColor = Color.White
},
onRefresh: () => {
//下拉刷新
setTimeout(() => {
this.sfController.finishRefresh()
}, 2000)
},
onScrollStatus: (status) => {
//当前的滑动状态

}
})
.id('SecondFloorView')
.alignRules({
center: { anchor: '__container__', align: VerticalAlign.Center },
middle: { anchor: '__container__', align: HorizontalAlign.Center }
})
}
.height('100%')
.width('100%')
}
}
2 changes: 1 addition & 1 deletion example/src/main/ets/pages/grid/GridViewPage.ets
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct GridViewPage {
ActionBar({ title: "普通的列表GridView" })
GridView({
items: this.array, //数据源 数组
itemLayout: (item, index) => this.itemLayout(item, index),
itemLayout: (item, index) => this.itemLayout(item, index)
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions example/src/main/ets/pages/list/ListViewRefreshPage.ets
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ struct ListViewRefreshPage {
Column() {
ActionBar({ title: "下拉刷新列表ListView" })
ListView({
items: this.array, //数据源 数组
itemLayout: (item, index) => {
this.itemLayout(item as number, index)
items: this.array, //数据源 数组,可以任意类型,自定义对象[],number[],string[]……
itemLayout: (item:Object, index:number) => {
this.itemLayout(item as number, index)//转成你需要的对象
},
controller: this.controller, //控制器,负责关闭下拉和上拉
onRefresh: () => {
Expand Down
5 changes: 3 additions & 2 deletions example/src/main/ets/pages/list/SlideMenuListViewPage.ets
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ struct SlideMenuListViewPage {
ActionBar({ title: "侧滑右侧展示按钮" })
ListView({
items: this.array, //数据源 数组
itemLayout: (item, index) => this.itemLayout(item, index),
slideRightMenuLayout: this.slideRightMenuLayout,
itemLayout: (item, index) => this.itemLayout(item, index),//条目视图
slideRightMenuLayout: this.slideRightMenuLayout,//侧滑视图
slideMenuAttr: (attr) => {
//设置侧滑属性
attr.rightMenuWidth = 100
},
onLazyDataSource: (dataSource: RefreshDataSource) => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion example/src/main/resources/base/profile/main_pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"pages/layout/LayoutViewPage",
"pages/staggered/StaggeredPage",
"pages/staggered/StaggeredHeadPage",
"pages/list/SlideMenuListViewPage"
"pages/list/SlideMenuListViewPage",
"pages/floor/SecondFloorPage"
]
}
Binary file added images/refresh_all.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/refresh_sf.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6730883

Please sign in to comment.