diff --git a/src/main/ets/view/SwipeView.ets b/src/main/ets/view/SwipeView.ets index b68d066..191473d 100644 --- a/src/main/ets/view/SwipeView.ets +++ b/src/main/ets/view/SwipeView.ets @@ -3,7 +3,13 @@ import { SZYXLocalStorageHelper, ToolsHelper } from '../../../../Index' @Component export struct SwipeView { 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 onItemClick?: () => void onDelete?: () => void @@ -23,6 +29,16 @@ export struct SwipeView { 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 btnBuilder: () => void = this.doNothingBuilder @@ -45,9 +61,15 @@ export struct SwipeView { .backgroundColor('red') .width(70) .fontColor('white') - .height(this.h) + .height(this.h - this.marginBottom - this.marginTop) .textAlign(TextAlign.Center) .fontSize(16) + .borderRadius({ + topLeft: this.brtLeft, + topRight: this.brtRight, + bottomLeft: this.brbLeft, + bottomRight: this.brbRight + }) .onClick(() => { // SZYXLocalStorageHelper.storage.setOrCreate('XBasicSwipeClick', this.ids) this._scroller.scrollTo({ @@ -56,14 +78,8 @@ export struct SwipeView { }) this.onDelete && this.onDelete() }) - // if (this.btnBuilder === this.doNothingBuilder) { - // Text('删除') - // } - // if (this.btnBuilder !== this.doNothingBuilder) { - // this.btnBuilder() - // } }.onSizeChange((oldValue: SizeOptions, newValue: SizeOptions) => { - this.h = newValue.height ?? 40 + this.h = this.toNumber(newValue.height) ?? 40 }).alignItems(VerticalAlign.Center) }.width('100%').scrollable(ScrollDirection.Horizontal).scrollBar(BarState.Off)