调整部分代码
This commit is contained in:
parent
bcb748a9b1
commit
84272111c7
@ -8,22 +8,6 @@ import { Log } from '@devwiki/base';
|
||||
import { BaseLocalStorage, ScreenUtil } from '@devwiki/base';
|
||||
import { HomeItem, HomeItemGroup } from '../model/Home';
|
||||
|
||||
@CustomDialog
|
||||
struct WebViewDialog {
|
||||
webUrl: string = "https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/password"
|
||||
private webviewController: web_webview.WebviewController = new web_webview.WebviewController();
|
||||
dialogController: CustomDialogController;
|
||||
@StorageLink(ScreenUtil.isPortraitKey) isPortrait: boolean = true;
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Web({ src: this.webUrl, controller: this.webviewController })
|
||||
.javaScriptAccess(true)// 允许使用 js
|
||||
.width('100%')
|
||||
.height('100%');
|
||||
}.height(this.isPortrait ? '95%' : '90%').width(this.isPortrait ? '100%' : '50%')
|
||||
}
|
||||
}
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
@ -62,13 +46,6 @@ struct Index {
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
dialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: WebViewDialog(),
|
||||
alignment: DialogAlignment.BottomEnd,
|
||||
customStyle: true
|
||||
})
|
||||
|
||||
aboutToAppear(): void {
|
||||
ScreenUtil.getInstance().initScreenSize();
|
||||
BaseLocalStorage.getInstance().init(getContext(this));
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { TitleBar } from '@devwiki/common_ui/Index';
|
||||
|
||||
import media from '@ohos.multimedia.media';
|
||||
import Prompt from '@system.prompt';
|
||||
@ -58,11 +59,18 @@ struct AVPlayerPage{
|
||||
|
||||
build() {
|
||||
Column(){
|
||||
Button('播放').height(48).width(96)
|
||||
TitleBar({
|
||||
title: "AVPlayer",
|
||||
onLeftClicked: () => {
|
||||
this.getUIContext().getRouter().back();
|
||||
}
|
||||
});
|
||||
|
||||
Button('播放').height(48).width(96).margin({top: 100})
|
||||
.onClick(()=>{
|
||||
this.playMusic();
|
||||
})
|
||||
}.justifyContent(FlexAlign.Center).align(Alignment.Center).width('100%').height('100%')
|
||||
}.align(Alignment.Center).width('100%').height('100%')
|
||||
}
|
||||
|
||||
async playMusic() {
|
||||
|
@ -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: ()=> {
|
||||
WebPage({
|
||||
onTitleBarLeftClick: () => {
|
||||
this.dialogController.close();
|
||||
}}).height(this.isPortrait ? '95%' : '90%').width(this.isPortrait ? '100%' : '50%')
|
||||
}
|
||||
}).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)
|
||||
}
|
||||
}
|
||||
}
|
@ -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() {
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ export struct TitleBar {
|
||||
|
||||
@Prop rightText: ResourceStr = "";
|
||||
@Prop rightIcon: Resource = $r("app.media.ic_close");
|
||||
@Prop rightMenuType: TitleBarMenuType = TitleBarMenuType.Icon;
|
||||
@Prop rightMenuType: TitleBarMenuType = TitleBarMenuType.None;
|
||||
|
||||
@Prop titleTextAlign: TextAlign = TextAlign.Start;
|
||||
@Prop titleVisible: Visibility = Visibility.Visible;
|
||||
|
Loading…
Reference in New Issue
Block a user