瀏覽代碼

基础布局

徐勤民 6 月之前
父節點
當前提交
82e14a060b

+ 1 - 0
Index.ets

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

+ 80 - 15
src/main/ets/view/SafeView.ets

@@ -1,30 +1,95 @@
+import { WindowHelper } from '../utils/WindowHelper'
+import { inputMethod } from '@kit.IMEKit'
+
+
 @Preview
 @Component
 export struct SafeView {
+  @Consume('pageInfos') pageInfos?: NavPathStack
   @Link isLoading: boolean
+  @State _titleText: ResourceStr=''
+  private _onBackEvent?: () => void
 
   @Builder
   doNothingBuilder() {
   }
 
+  onBack(event: () => void) {
+    this._onBackEvent = event
+    return this
+  }
+
+  titleText(title: ResourceStr) {
+    this._titleText = title
+    return this
+  }
+
   @BuilderParam customBuilderParam: () => void = this.doNothingBuilder
 
   build() {
-    Stack() {
-      this.customBuilderParam()
-      Column() {
-        LoadingProgress()
-          .color(Color.White)
-          .width(80).height(80)
-        Text('努力加载中..')
-          .fontSize(16)
-          .fontColor(Color.White)
+    NavDestination() {
+      Stack() {
+        Column() {
+          Row()
+            .height(WindowHelper.topRectHeight)
+            .width('100%')
+            .backgroundColor('#999999')
+          Row() {
+
+            Image($r("app.media.base_back"))
+              .height(15)
+              .onClick(() => {
+                if (this._onBackEvent) {
+                  this._onBackEvent()
+                } else if (this.pageInfos) {
+                  this.pageInfos.pop()
+                }
+              })
+
+            Text(this._titleText ?? '')
+              .maxLines(1)
+              .ellipsisMode(EllipsisMode.CENTER)
+              .textOverflow({
+                overflow: TextOverflow.Ellipsis
+              })
+
+            Row() {
+
+            }
+          }
+          .justifyContent(FlexAlign.SpaceBetween)
+          .padding({
+            left: 15,
+            right: 15
+          })
+          .height(44)
+          .width('100%')
+
+          this.customBuilderParam()
+        }
+        .width('100%')
+        .height('100%')
+        .justifyContent(FlexAlign.Start)
+
+        Column() {
+          LoadingProgress()
+            .color(Color.White)
+            .width(80).height(80)
+          Text('努力加载中..')
+            .fontSize(16)
+            .fontColor(Color.White)
+        }
+        .visibility(this.isLoading ? Visibility.Visible : Visibility.None)
+        .width('100%')
+        .height('100%')
+        .backgroundColor('#40000000')
+        .justifyContent(FlexAlign.Center)
       }
-      .visibility(this.isLoading ? Visibility.Visible : Visibility.None)
-      .width('100%')
-      .height('100%')
-      .backgroundColor('#40000000')
-      .justifyContent(FlexAlign.Center)
-    }
+    }.onClick(() => {
+      inputMethod.getController().stopInputSession()
+    })
+    .hideTitleBar(true)
+    .width('100%')
+    .height('100%')
   }
 }

二進制
src/main/resources/mdpi/media/base_back.png


二進制
src/main/resources/sdpi/media/base_back.png


二進制
src/main/resources/xldpi/media/base_back.png


二進制
src/main/resources/xxldpi/media/base_back.png


二進制
src/main/resources/xxxldpi/media/base_back.png