feat(SwipeView): 为 SwipeView 组件添加点击和删除事件回调
- 在 SwipeView 组件中添加 onItemClick 和 onDelete 属性- 修改 AIDocumentView 中的 SwipeView 使用新增的事件回调- 优化 SwipeView 的点击和删除逻辑,支持外部自定义操作
这个提交包含在:
父节点
19c6da53f9
当前提交
a872e82cd6
@ -3,6 +3,8 @@ export struct SwipeView {
|
|||||||
private _scroller: Scroller = new Scroller()
|
private _scroller: Scroller = new Scroller()
|
||||||
@State h: Length = 40
|
@State h: Length = 40
|
||||||
@State downX: number = 0
|
@State downX: number = 0
|
||||||
|
onItemClick?: () => void
|
||||||
|
onDelete?: () => void
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
doNothingBuilder() {
|
doNothingBuilder() {
|
||||||
@ -15,7 +17,16 @@ export struct SwipeView {
|
|||||||
build() {
|
build() {
|
||||||
Scroll(this._scroller) {
|
Scroll(this._scroller) {
|
||||||
Row() {
|
Row() {
|
||||||
|
Column() {
|
||||||
this.customBuilderParam()
|
this.customBuilderParam()
|
||||||
|
}.width('100%').onClick(() => {
|
||||||
|
this._scroller.scrollTo({
|
||||||
|
xOffset: 0, yOffset: 0,
|
||||||
|
animation: { duration: 100, curve: Curve.Linear }
|
||||||
|
})
|
||||||
|
this.onItemClick && this.onItemClick()
|
||||||
|
})
|
||||||
|
|
||||||
Text('删除')
|
Text('删除')
|
||||||
.backgroundColor('red')
|
.backgroundColor('red')
|
||||||
.width(70)
|
.width(70)
|
||||||
@ -23,6 +34,13 @@ export struct SwipeView {
|
|||||||
.height(this.h)
|
.height(this.h)
|
||||||
.textAlign(TextAlign.Center)
|
.textAlign(TextAlign.Center)
|
||||||
.fontSize(16)
|
.fontSize(16)
|
||||||
|
.onClick(() => {
|
||||||
|
this._scroller.scrollTo({
|
||||||
|
xOffset: 0, yOffset: 0,
|
||||||
|
animation: { duration: 100, curve: Curve.Linear }
|
||||||
|
})
|
||||||
|
this.onDelete && this.onDelete()
|
||||||
|
})
|
||||||
// if (this.btnBuilder === this.doNothingBuilder) {
|
// if (this.btnBuilder === this.doNothingBuilder) {
|
||||||
// Text('删除')
|
// Text('删除')
|
||||||
// }
|
// }
|
||||||
@ -59,8 +77,10 @@ export struct SwipeView {
|
|||||||
toxOffset = 70
|
toxOffset = 70
|
||||||
}
|
}
|
||||||
// 滑动指定位置,设置动画
|
// 滑动指定位置,设置动画
|
||||||
this._scroller.scrollTo({ xOffset: toxOffset, yOffset: 0,
|
this._scroller.scrollTo({
|
||||||
animation: { duration: 300, curve: Curve.Linear } })
|
xOffset: toxOffset, yOffset: 0,
|
||||||
|
animation: { duration: 300, curve: Curve.Linear }
|
||||||
|
})
|
||||||
// 重置按下的x轴坐标
|
// 重置按下的x轴坐标
|
||||||
this.downX = 0
|
this.downX = 0
|
||||||
break
|
break
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户