|
@@ -3,7 +3,13 @@ import { SZYXLocalStorageHelper, ToolsHelper } from '../../../../Index'
|
|
|
@Component
|
|
@Component
|
|
|
export struct SwipeView {
|
|
export struct SwipeView {
|
|
|
private _scroller: Scroller = new Scroller()
|
|
private _scroller: Scroller = new Scroller()
|
|
|
- @State h: Length = 40
|
|
|
|
|
|
|
+ @State h: number = 40
|
|
|
|
|
+ marginBottom: number = 0
|
|
|
|
|
+ marginTop: number = 0
|
|
|
|
|
+ brtLeft: number = 0
|
|
|
|
|
+ brtRight: number = 0
|
|
|
|
|
+ brbLeft: number = 0
|
|
|
|
|
+ brbRight: number = 0
|
|
|
@State downX: number = 0
|
|
@State downX: number = 0
|
|
|
onItemClick?: () => void
|
|
onItemClick?: () => void
|
|
|
onDelete?: () => void
|
|
onDelete?: () => void
|
|
@@ -23,6 +29,16 @@ export struct SwipeView {
|
|
|
doNothingBuilder() {
|
|
doNothingBuilder() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ toNumber(len?: Length): number {
|
|
|
|
|
+ if (typeof len === "number") {
|
|
|
|
|
+ return len;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (typeof len === "string") {
|
|
|
|
|
+ return Number(len);
|
|
|
|
|
+ }
|
|
|
|
|
+ return 70
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@BuilderParam customBuilderParam: () => void = this.doNothingBuilder
|
|
@BuilderParam customBuilderParam: () => void = this.doNothingBuilder
|
|
|
|
|
|
|
|
// @BuilderParam btnBuilder: () => void = this.doNothingBuilder
|
|
// @BuilderParam btnBuilder: () => void = this.doNothingBuilder
|
|
@@ -45,9 +61,15 @@ export struct SwipeView {
|
|
|
.backgroundColor('red')
|
|
.backgroundColor('red')
|
|
|
.width(70)
|
|
.width(70)
|
|
|
.fontColor('white')
|
|
.fontColor('white')
|
|
|
- .height(this.h)
|
|
|
|
|
|
|
+ .height(this.h - this.marginBottom - this.marginTop)
|
|
|
.textAlign(TextAlign.Center)
|
|
.textAlign(TextAlign.Center)
|
|
|
.fontSize(16)
|
|
.fontSize(16)
|
|
|
|
|
+ .borderRadius({
|
|
|
|
|
+ topLeft: this.brtLeft,
|
|
|
|
|
+ topRight: this.brtRight,
|
|
|
|
|
+ bottomLeft: this.brbLeft,
|
|
|
|
|
+ bottomRight: this.brbRight
|
|
|
|
|
+ })
|
|
|
.onClick(() => {
|
|
.onClick(() => {
|
|
|
// SZYXLocalStorageHelper.storage.setOrCreate('XBasicSwipeClick', this.ids)
|
|
// SZYXLocalStorageHelper.storage.setOrCreate('XBasicSwipeClick', this.ids)
|
|
|
this._scroller.scrollTo({
|
|
this._scroller.scrollTo({
|
|
@@ -56,14 +78,8 @@ export struct SwipeView {
|
|
|
})
|
|
})
|
|
|
this.onDelete && this.onDelete()
|
|
this.onDelete && this.onDelete()
|
|
|
})
|
|
})
|
|
|
- // if (this.btnBuilder === this.doNothingBuilder) {
|
|
|
|
|
- // Text('删除')
|
|
|
|
|
- // }
|
|
|
|
|
- // if (this.btnBuilder !== this.doNothingBuilder) {
|
|
|
|
|
- // this.btnBuilder()
|
|
|
|
|
- // }
|
|
|
|
|
}.onSizeChange((oldValue: SizeOptions, newValue: SizeOptions) => {
|
|
}.onSizeChange((oldValue: SizeOptions, newValue: SizeOptions) => {
|
|
|
- this.h = newValue.height ?? 40
|
|
|
|
|
|
|
+ this.h = this.toNumber(newValue.height) ?? 40
|
|
|
}).alignItems(VerticalAlign.Center)
|
|
}).alignItems(VerticalAlign.Center)
|
|
|
|
|
|
|
|
}.width('100%').scrollable(ScrollDirection.Horizontal).scrollBar(BarState.Off)
|
|
}.width('100%').scrollable(ScrollDirection.Horizontal).scrollBar(BarState.Off)
|