From 72a54977624c0573cab769b871e6a4afc0cb08b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=8B=A4=E6=B0=91?= Date: Sun, 20 Oct 2024 15:05:08 +0800 Subject: [PATCH] SafeView.ets --- src/main/ets/view/SafeView.ets | 41 ++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/main/ets/view/SafeView.ets b/src/main/ets/view/SafeView.ets index 0fdbceb..c87c5fb 100644 --- a/src/main/ets/view/SafeView.ets +++ b/src/main/ets/view/SafeView.ets @@ -11,7 +11,7 @@ export interface TitleBarBtn { @Preview @Component export struct SafeView { - @Consume('pageInfos') pageInfos?: NavPathStack + pageInfos?: NavPathStack @Prop isLoading: boolean // 是不是沉浸式 @Prop isImmersive: boolean @@ -96,12 +96,12 @@ export struct SafeView { Row() { if (!this.onClickLeft?.img && this.onClickLeft) { Badge({ - count:this.showBadgeLeft?1:0, - style:{ - badgeSize:6, + count: this.showBadgeLeft ? 1 : 0, + style: { + badgeSize: 6, badgeColor: Color.Red } - }){ + }) { Text(`${this.onClickLeft?.text}` ?? '确定') .fontColor(this.onClickLeft?.color ?? '#17171A') .onClick(() => { @@ -111,13 +111,13 @@ export struct SafeView { } if (this.onClickLeft?.img && this.onClickLeft) { Badge({ - count:this.showBadgeLeft?1:0, - style:{ - badgeSize:6, + count: this.showBadgeLeft ? 1 : 0, + style: { + badgeSize: 6, badgeColor: '#FF6500', color: '#FF6500' } - }){ + }) { Image(this.onClickLeft.img) .onClick(() => { this.onClickLeft?.onClick && this.onClickLeft?.onClick() @@ -129,13 +129,13 @@ export struct SafeView { } if (!this.onClickRight?.img && this.onClickRight) { Badge({ - count:this.showBadgeRight?1:0, - style:{ - badgeSize:6, + count: this.showBadgeRight ? 1 : 0, + style: { + badgeSize: 6, badgeColor: '#FF6500', color: '#FF6500' } - }){ + }) { Text(this.onClickRight?.text ?? '确定') .fontColor(this.onClickRight?.color ?? '#17171A') .onClick(() => { @@ -148,13 +148,13 @@ export struct SafeView { } if (this.onClickRight?.img && this.onClickRight) { Badge({ - count:this.showBadgeRight?1:0, - style:{ - badgeSize:6, + count: this.showBadgeRight ? 1 : 0, + style: { + badgeSize: 6, badgeColor: '#FF6500', color: '#FF6500' } - }){ + }) { Image(this.onClickRight.img) .onClick(() => { this.onClickRight?.onClick && this.onClickRight?.onClick() @@ -208,14 +208,17 @@ export struct SafeView { .hideTitleBar(true) .width('100%') .height('100%') - .backgroundColor(this.backgroundColorView??'#ffffff') + .backgroundColor(this.backgroundColorView ?? '#ffffff') .onBackPressed(() => { if (this.onBackEvent) { this.onBackEvent() + return true } else if (this.pageInfos) { this.pageInfos.pop() + return true + } else { + return false } - return true }) } } \ No newline at end of file