diff --git a/entry/src/main/ets/pages/compontents/Header.ets b/entry/src/main/ets/pages/compontents/Header.ets index 42595ab..7f15142 100644 --- a/entry/src/main/ets/pages/compontents/Header.ets +++ b/entry/src/main/ets/pages/compontents/Header.ets @@ -8,7 +8,6 @@ */ import dayTs from '../../utils/Date' import router from '@ohos.router' -import Prompt from '@system.prompt' import common from '@ohos.app.ability.common' @Component @@ -24,6 +23,10 @@ export default struct HeaderComponent { // 扩充Logo后面区域 @BuilderParam logoExpansionBuilder?: () => void = this.customBuilder + exitDialogController: CustomDialogController = new CustomDialogController({ + builder: exitDialogComponent(), + customStyle: true + }) @Builder customBuilder() { @@ -84,23 +87,8 @@ export default struct HeaderComponent { }, router.RouterMode.Single); }) Image($r('app.media.btn_back')).height(100).onClick(() => { - Prompt.showDialog({ - title: "提示", - message: "确定要退出吗?", - buttons: [ - { - text: '取消', - color: '#666666' - }, - { - text: '退出', - color: '#666666' - } - ], - success: () => { - (getContext(this) as common.UIAbilityContext).terminateSelf() - } - }) + this.exitDialogController.open() + }) } } @@ -109,4 +97,62 @@ export default struct HeaderComponent { }.width("100%") .height(100) } +} + +@CustomDialog +struct exitDialogComponent { + private controller?: CustomDialogController; + + build() { + Column() { + Text("提示信息").fontSize(26).margin({ + top: 40 + }).fontWeight(FontWeight.Bold) + Row() { + Text("是否确认退出程序?").fontSize(28) + }.margin({ + top: 100, + bottom: 90 + }) + + Row() { + BtnComponent({ + text: "取消" + }).onClick(() => { + this.controller?.close() + }) + BtnComponent().onClick(() => { + (getContext(this) as common.UIAbilityContext).terminateSelf() + }) + } + } + .backgroundImage($r("app.media.km_open")) + .backgroundImageSize({ + width: "100%", + height: "100%" + }).width(800).height(400) + } +} + +@Component +struct BtnComponent { + @State text: string = "确认" + + build() { + Row() { + Text(this.text).fontColor("#F4EEE7").fontSize(28) + } + .backgroundImage($r("app.media.nor_btn")) + .backgroundImageSize({ + width: "100%", + height: "100%" + }) + .width(200) + .height(80) + .justifyContent(FlexAlign.Center) + .alignItems(VerticalAlign.Center) + .margin({ + left: 20 + }) + } } \ No newline at end of file diff --git a/entry/src/main/resources/base/media/nor_btn.png b/entry/src/main/resources/base/media/nor_btn.png new file mode 100644 index 0000000..cb2dd95 Binary files /dev/null and b/entry/src/main/resources/base/media/nor_btn.png differ