徐勤民 3 týždňov pred
rodič
commit
67a57048ad
2 zmenil súbory, kde vykonal 36 pridanie a 0 odobranie
  1. 1 0
      Index.ets
  2. 35 0
      src/main/ets/view/SwipeView.ets

+ 1 - 0
Index.ets

@@ -57,6 +57,7 @@ export { WindowHelper } from './src/main/ets/utils/WindowHelper'
 export { LoadingView } from './src/main/ets/view/LoadingView'
 export { SafeView } from './src/main/ets/view/SafeView'
 export { RefreshView } from './src/main/ets/view/refresh/RefreshView'
+export { SwipeView } from './src/main/ets/view/SwipeView'
 /**
  * 自定义view
  */

+ 35 - 0
src/main/ets/view/SwipeView.ets

@@ -0,0 +1,35 @@
+@Component
+export struct SwipeView {
+  @State h: Length = 40
+
+  @Builder
+  doNothingBuilder() {
+  }
+
+  @BuilderParam customBuilderParam: () => void = this.doNothingBuilder
+
+  // @BuilderParam btnBuilder: () => void = this.doNothingBuilder
+
+  build() {
+    Scroll() {
+      Row() {
+        this.customBuilderParam()
+        Text('删除')
+          .backgroundColor('red')
+          .width(70)
+          .fontColor('white')
+          .height(this.h)
+          .textAlign(TextAlign.Center)
+          .fontSize(16)
+        // if (this.btnBuilder === this.doNothingBuilder) {
+        //   Text('删除')
+        // }
+        // if (this.btnBuilder !== this.doNothingBuilder) {
+        //   this.btnBuilder()
+        // }
+      }.onSizeChange((oldValue: SizeOptions, newValue: SizeOptions) => {
+        this.h = newValue.height ?? 40
+      }).alignItems(VerticalAlign.Center)
+    }.width('100%').scrollable(ScrollDirection.Horizontal).scrollBar(BarState.Off)
+  }
+}