聊天页面,订单卡片
这个提交包含在:
父节点
62f6fb563d
当前提交
ecfef2154b
@ -1,5 +1,6 @@
|
|||||||
export interface RefreshController {
|
export interface RefreshController {
|
||||||
toTop: (smooth?: boolean) => void
|
toTop: (smooth?: boolean) => void
|
||||||
toBottom: (smooth?: boolean) => void
|
toBottom: (smooth?: boolean) => void
|
||||||
|
toIndex: (value: number, smooth?: boolean, align?: ScrollAlign) => void
|
||||||
isAtEnd: () => boolean
|
isAtEnd: () => boolean
|
||||||
}
|
}
|
||||||
@ -35,12 +35,16 @@ export struct RefreshView {
|
|||||||
} else if (this._toBottom) {
|
} else if (this._toBottom) {
|
||||||
this.toBottom()
|
this.toBottom()
|
||||||
this._toBottom = false
|
this._toBottom = false
|
||||||
|
} else if (this._toIndex) {
|
||||||
|
this.toIndex()
|
||||||
|
this._toIndex = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private _firstFinish = false
|
private _firstFinish = false
|
||||||
private _isLoad = false
|
private _isLoad = false
|
||||||
private _toTop = false
|
private _toTop = false
|
||||||
|
private _toIndex = false
|
||||||
private _toBottom = false
|
private _toBottom = false
|
||||||
|
|
||||||
change() {
|
change() {
|
||||||
@ -58,11 +62,31 @@ export struct RefreshView {
|
|||||||
this.controller.toBottom = (smooth?: boolean) => {
|
this.controller.toBottom = (smooth?: boolean) => {
|
||||||
this.toBottom(smooth)
|
this.toBottom(smooth)
|
||||||
}
|
}
|
||||||
|
this.controller.toIndex = (value: number, smooth?: boolean, align?: ScrollAlign) => {
|
||||||
|
this.toIndex(value, smooth, align)
|
||||||
|
}
|
||||||
this.controller.isAtEnd = () => this._scroller.isAtEnd()
|
this.controller.isAtEnd = () => this._scroller.isAtEnd()
|
||||||
}
|
}
|
||||||
this._listener.on('draw', this.onDrawComplete)
|
this._listener.on('draw', this.onDrawComplete)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@State value: number = -1
|
||||||
|
@State smooth?: boolean = false
|
||||||
|
@State aligns?: ScrollAlign = undefined
|
||||||
|
|
||||||
|
toIndex(value?: number, smooth?: boolean, align?: ScrollAlign) {
|
||||||
|
if (!this._isLoad) {
|
||||||
|
if (value || this.value != -1 || value === 0) {
|
||||||
|
this._scroller.scrollToIndex(value ?? this.value, smooth, align)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.value = value ?? this.value
|
||||||
|
this.smooth = smooth
|
||||||
|
this.aligns = align
|
||||||
|
this._toIndex = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
toTop(smooth?: boolean) {
|
toTop(smooth?: boolean) {
|
||||||
if (!this._isLoad) {
|
if (!this._isLoad) {
|
||||||
this._scroller.scrollToIndex(0, smooth, ScrollAlign.START)
|
this._scroller.scrollToIndex(0, smooth, ScrollAlign.START)
|
||||||
@ -73,7 +97,7 @@ export struct RefreshView {
|
|||||||
|
|
||||||
toBottom(smooth?: boolean) {
|
toBottom(smooth?: boolean) {
|
||||||
if (!this._isLoad) {
|
if (!this._isLoad) {
|
||||||
this._scroller.scrollToIndex(this.data.length - 1, smooth, ScrollAlign.END)
|
this._scroller.scrollToIndex(this.data.length, smooth, ScrollAlign.END)
|
||||||
} else {
|
} else {
|
||||||
this._toBottom = true
|
this._toBottom = true
|
||||||
}
|
}
|
||||||
@ -83,8 +107,13 @@ export struct RefreshView {
|
|||||||
this._listener.off('draw', this.onDrawComplete);
|
this._listener.off('draw', this.onDrawComplete);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
doNothingBuilder() {
|
||||||
|
};
|
||||||
|
|
||||||
// 使用父组件@Builder装饰的方法初始化子组件@BuilderParam
|
// 使用父组件@Builder装饰的方法初始化子组件@BuilderParam
|
||||||
@BuilderParam customBuilderParam: (item: ESObject, index: number) => void
|
@BuilderParam customBuilderParam: (item: ESObject, index: number) => void
|
||||||
|
@BuilderParam headBuilderParam: () => void = this.doNothingBuilder;
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
|
|
||||||
@ -93,6 +122,10 @@ export struct RefreshView {
|
|||||||
List({
|
List({
|
||||||
scroller: this._scroller,
|
scroller: this._scroller,
|
||||||
}) {
|
}) {
|
||||||
|
ListItem() {
|
||||||
|
this.headBuilderParam()
|
||||||
|
}
|
||||||
|
|
||||||
ForEach(this.data ?? [], (item: ESObject, index: number) => {
|
ForEach(this.data ?? [], (item: ESObject, index: number) => {
|
||||||
ListItem() {
|
ListItem() {
|
||||||
this.customBuilderParam(item, index)
|
this.customBuilderParam(item, index)
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户