调整部分代码

This commit is contained in:
2024-04-30 12:48:28 +08:00
parent bcb748a9b1
commit 84272111c7
5 changed files with 45 additions and 33 deletions

View File

@@ -1,16 +1,18 @@
import { ScreenUtil } from '@devwiki/base';
import { WebPage } from './WebPage';
import { TitleBar } from '@devwiki/common_ui/src/main/ets/component/TitleBar';
@CustomDialog
export struct WebPageDialog {
@StorageLink(ScreenUtil.isPortraitKey)isPortrait: boolean = true;
@StorageLink(ScreenUtil.isPortraitKey) isPortrait: boolean = true;
dialogController: CustomDialogController;
build() {
WebPage({onTitleBarLeftClick: ()=> {
this.dialogController.close();
}}).height(this.isPortrait ? '95%' : '90%').width(this.isPortrait ? '100%' : '50%')
WebPage({
onTitleBarLeftClick: () => {
this.dialogController.close();
}
}).height(this.isPortrait ? '95%' : '90%').width(this.isPortrait ? '100%' : '50%')
}
}
@@ -18,6 +20,25 @@ export struct WebPageDialog {
@Component
export struct WebDialogPage {
dialogController: CustomDialogController = new CustomDialogController({
builder: WebPageDialog(),
alignment: DialogAlignment.BottomEnd,
customStyle: true
})
build() {
Column() {
TitleBar({
title: 'WebDialogPage',
onLeftClicked: () => {
this.getUIContext().getRouter().back()
}
})
Row(){
Button("Click").width(100).height(32).onClick(() => {
this.dialogController.open();
})
}.height('100%').width('100%').justifyContent(FlexAlign.Center)
}
}
}

View File

@@ -24,7 +24,13 @@ export struct WebPage {
RelativeContainer() {
TitleBar({
title: this.viewModel.pageTitle,
onLeftClicked: this.onTitleBarLeftClick,
onLeftClicked: () => {
if (this.onTitleBarLeftClick) {
this.onTitleBarLeftClick();
} else {
this.getUIContext().getRouter().back()
}
},
rightIcon: CommonRes.getIconRefresh(),
// 必须这么写 onTitleBarRightClick内部的代码才执行,
// 直接 onRightClicked: this.onTitleBarRightClick 这么写, 代码不执行
@@ -76,7 +82,7 @@ class WebPageViewModel {
webUrl: "https://devwiki.net"
};
pageTitle: ResourceStr = "";
pageTitle: ResourceStr = "WebPage";
constructor() {
}