harmony/RefreshLib/src/main/ets/RefreshController.ets
2025-07-10 09:27:17 +08:00

80 lines
2.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { PullStatus } from './PullStatus'
import { RefreshLayoutConfig } from './RefreshLayoutConfig'
export enum ViewState{
success=0,
loading,
empty,
error,
noNetwork
}
export class RefreshController {
/*刷新成功*/
refreshSuccess: (ignoreViewTips?:boolean) => void = (ignoreViewTips?:boolean) => {
}
/*刷新失败*/
refreshError: () => void = () => {
}
/*刷新完成true:成功false失败*/
refreshComplete: (isSuccess: boolean,ignoreViewTips?:boolean) => void = (isSuccess: boolean,ignoreViewTips?:boolean) => {
}
/*取消刷新*/
refreshCancel: () => void = () => {
}
/*加载成功*/
loadSuccess: (hasMore?: boolean) => void = (hasMore?: boolean) => {
}
/*加载失败*/
loadError: () => void = () => {
}
/*加载完成true:成功false失败*/
loadComplete: (isSuccess: boolean, hasMore?: boolean) => void = (isSuccess: boolean, hasMore?: boolean) => {
}
/*取消加载*/
loadCancel: () => void = () => {
}
/*显示加载中*/
viewLoading: () => void = () => {
this.viewState=ViewState.loading
}
/*显示空布局*/
viewEmpty: () => void = () => {
this.viewState=ViewState.empty
}
/*显示加载失败布局*/
viewError: () => void = () => {
this.viewState=ViewState.error
}
/*显示无网络布局*/
viewNoNetwork: () => void = () => {
this.viewState=ViewState.noNetwork
}
/**/
/*获取当前状态*/
getStatus: () => PullStatus = () => PullStatus.DEF
/*设置是否还有更多数据*/
hasMore: (hasMore: boolean) => void = (hasMore: boolean) => {
}
/*手动触发下拉刷新*/
refresh: () => void = () => {
}
/*手动触发上拉*/
load: () => void = () => {
}
/*下拉刷新开关是否打开*/
refreshIsEnable: () => boolean = () => true
/*下拉刷新开关是否打开*/
loadIsEnable: () => boolean = () => false
/*设置配置*/
/*由于v2装饰器@Param限制原因setConfig方法在v2版本上不提供*/
/*@Param装饰的变量在子组件中无法进行修改。但当装饰的变量类型为对象时在子组件中修改对象中属性是允许的。*/
// setConfig: (config: RefreshLayoutConfig) => void = () => {}
/*获取配置*/
getConfig: () => RefreshLayoutConfig = () => new RefreshLayoutConfig()
/*webview专用*/
onWebviewScroll: (xOffset: number, yOffset: number) => void = (xOffset: number, yOffset: number) => {
}
private viewState:ViewState=ViewState.success
public getViewState():ViewState{
return this.viewState
}
}