SplashAdShowPage.ets
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { CSJSplashAd } from '@csj/openadsdk';
import { NodeController, window } from '@kit.ArkUI';
@Entry({
routeName: "GMSplashAdShowPage",
storage: LocalStorage.getShared()
})
@Component
export struct SplashAdShowPage {
@LocalStorageLink('GMSplashAd') splashAd: CSJSplashAd | undefined = undefined
@LocalStorageLink('GMSplashSubWindow') _window: window.Window | undefined = undefined
@LocalStorageProp('GMSplashCustomCloseBtn') splashCustomCloseBtn: boolean = false
@State splashAdComponent: NodeController | undefined = undefined
aboutToAppear(): void {
this.splashAdComponent = this.splashAd?.getAdComponent(this.splashCustomCloseBtn, this._window)
}
onPageShow(): void {
this._window?.setWindowLayoutFullScreen(true)
}
onPageHide(): void {
this._window?.setWindowLayoutFullScreen(false)
}
build() {
Stack() {
if (this.splashAdComponent) {
NodeContainer(this.splashAdComponent)
}
if (this.splashCustomCloseBtn) {
Text('close')
.textAlign(TextAlign.Center)
.backgroundColor(Color.Yellow)
.width(60)
.height(60)
.borderRadius(30)
.margin({ left: 50, top: 50 })
.onClick(() => {
this.closeBtnClicked()
})
}
}
.alignContent(Alignment.TopStart)
}
closeBtnClicked() {
this._window?.destroyWindow()
}
}