diff --git a/AbilityKit/entry/src/main/ets/pages/StartAbility.ets b/AbilityKit/entry/src/main/ets/pages/StartAbility.ets index 8eebd91f6a825243d9b588b2c9a3a74d4973adae..e213a7231eec29d9f33aadd76de7651d4f6de047 100644 --- a/AbilityKit/entry/src/main/ets/pages/StartAbility.ets +++ b/AbilityKit/entry/src/main/ets/pages/StartAbility.ets @@ -33,12 +33,37 @@ let wantInfo: Want = { } // [End request_want] -// [Start start_ability] -// Call the startAbility interface to open files -let context = getContext(this) as common.UIAbilityContext; -context.startAbility(wantInfo).then(() => { - // ... -}).catch((err: BusinessError) => { - // ... -}) -// [End start_ability] \ No newline at end of file +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + aboutToAppear(): void { + // [Start start_ability] + // Call the startAbility interface to open files + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; + context.startAbility(wantInfo).then(() => { + // ... + }).catch((err: BusinessError) => { + // ... + }) + // [End start_ability] + } + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/ArkUI/entry/src/main/ets/entryability/EntryAbilityImmersiveStatusBar.ets b/ArkUI/entry/src/main/ets/entryability/EntryAbilityImmersiveStatusBar.ets index ebfed506c636b6c3f64dfd0152b3c14cb1a8fcc0..dac00268ec1e1e18c6b682cead52110371c95b2a 100644 --- a/ArkUI/entry/src/main/ets/entryability/EntryAbilityImmersiveStatusBar.ets +++ b/ArkUI/entry/src/main/ets/entryability/EntryAbilityImmersiveStatusBar.ets @@ -38,20 +38,12 @@ export default class EntryAbility extends UIAbility { // 2.Realize immersive effects. Method 1: Set the navigation bar and status bar to not display. let names = []; - windowClass.setWindowSystemBarEnable(names, (err) => { - if (err.code) { - console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); - return; - } + windowClass.setWindowSystemBarEnable(names).then(() => { console.info('Succeeded in setting the system bar to be visible.'); }); // 2.Realize immersive effects. Method 2: Set the window to a full screen layout, and coordinate with the transparency, background/text color, and highlighted icons of the navigation bar and status bar to maintain consistency with the main window display. let isLayoutFullScreen = true; - windowClass.setWindowLayoutFullScreen(isLayoutFullScreen, (err) => { - if (err.code) { - console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); - return; - } + windowClass.setWindowLayoutFullScreen(isLayoutFullScreen).then(() => { console.info('Succeeded in setting the window layout to full-screen mode.'); }); let sysBarProps: window.SystemBarProperties = { @@ -61,11 +53,7 @@ export default class EntryAbility extends UIAbility { statusBarContentColor: '#ffffff', navigationBarContentColor: '#ffffff' }; - windowClass.setWindowSystemBarProperties(sysBarProps, (err) => { - if (err.code) { - console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); - return; - } + windowClass.setWindowSystemBarProperties(sysBarProps).then(() => { console.info('Succeeded in setting the system bar properties.'); }); }) diff --git a/ArkUI/entry/src/main/ets/entryability/EntryAbilityImmersiveWindow.ets b/ArkUI/entry/src/main/ets/entryability/EntryAbilityImmersiveWindow.ets index 4636d2e7666b99f4ab1d358a954554e79e59827f..401abe162f310f06690dd5110d41a33d5df6f117 100644 --- a/ArkUI/entry/src/main/ets/entryability/EntryAbilityImmersiveWindow.ets +++ b/ArkUI/entry/src/main/ets/entryability/EntryAbilityImmersiveWindow.ets @@ -37,22 +37,12 @@ export default class EntryAbility extends UIAbility { // 2.Realize immersive effects. Method 1: Set the navigation bar and status bar to not display. let names: Array<'status' | 'navigation'> = []; - windowClass.setWindowSystemBarEnable(names, (err: BusinessError) => { - let errCode: number = err.code; - if (errCode) { - console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); - return; - } + windowClass.setWindowSystemBarEnable(names).then(() => { console.info('Succeeded in setting the system bar to be visible.'); }); // 2.Realize immersive effects. Method 2: Set the window to a full screen layout, and coordinate with the transparency, background/text color, and highlighted icons of the navigation bar and status bar to maintain consistency with the main window display. let isLayoutFullScreen = true; - windowClass.setWindowLayoutFullScreen(isLayoutFullScreen, (err: BusinessError) => { - let errCode: number = err.code; - if (errCode) { - console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); - return; - } + windowClass.setWindowLayoutFullScreen(isLayoutFullScreen).then(() => { console.info('Succeeded in setting the window layout to full-screen mode.'); }); let sysBarProps: window.SystemBarProperties = { @@ -61,12 +51,7 @@ export default class EntryAbility extends UIAbility { statusBarContentColor: '#ffffff', navigationBarContentColor: '#ffffff' }; - windowClass.setWindowSystemBarProperties(sysBarProps, (err: BusinessError) => { - let errCode: number = err.code; - if (errCode) { - console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); - return; - } + windowClass.setWindowSystemBarProperties(sysBarProps).then(() => { console.info('Succeeded in setting the system bar properties.'); }); }) diff --git a/ArkUI/entry/src/main/ets/pages/ChangeTheFontColorOfTheStatusBar.ets b/ArkUI/entry/src/main/ets/pages/ChangeTheFontColorOfTheStatusBar.ets index 9e7393bc817147ddbdcda5db90bf8e35fb5f967c..e61693be643718eb7bbbc0a1611417d5a4ff35db 100644 --- a/ArkUI/entry/src/main/ets/pages/ChangeTheFontColorOfTheStatusBar.ets +++ b/ArkUI/entry/src/main/ets/pages/ChangeTheFontColorOfTheStatusBar.ets @@ -32,12 +32,7 @@ struct ChangeStatusBar { statusBarColor: '#000000', statusBarContentColor: '#ffffff' }; - this.mainWin.setWindowSystemBarProperties(sysBarProps, (err: BusinessError) => { - let errCode: number = err.code; - if (errCode) { - console.error('[StaticUtils] Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); - return; - } + this.mainWin.setWindowSystemBarProperties(sysBarProps).then(() => { console.info('[StaticUtils] Succeeded in setting the system bar properties.'); }); } diff --git a/ArkUI/entry/src/main/ets/pages/FontResources.ets b/ArkUI/entry/src/main/ets/pages/FontResources.ets index 6db929589bcdf6fb92d358d450f79cc2cd50ebad..69dd5d19ea7c4330d55b1cff5963c6e3ca8cd128 100644 --- a/ArkUI/entry/src/main/ets/pages/FontResources.ets +++ b/ArkUI/entry/src/main/ets/pages/FontResources.ets @@ -9,7 +9,7 @@ struct Index { @State message: string = 'Hello World'; aboutToAppear(): void { // [Start set_font] - font.registerFont({ + this.getUIContext().getFont().registerFont({ familyName: 'Gealova', familySrc: $rawfile('font/gealova.otf') }) diff --git a/ArkUI/entry/src/main/ets/pages/ImplementPageSwitchingAnimation_One.ets b/ArkUI/entry/src/main/ets/pages/ImplementPageSwitchingAnimation_One.ets index 6d8b62635d13eff4c00275f4bcf730a6daff39a0..a2298aa1fc0031b2b282b1e4859975248bc5cd52 100644 --- a/ArkUI/entry/src/main/ets/pages/ImplementPageSwitchingAnimation_One.ets +++ b/ArkUI/entry/src/main/ets/pages/ImplementPageSwitchingAnimation_One.ets @@ -22,9 +22,11 @@ @Entry @Component struct PageTransition1 { + pageInfos: NavPathStack = new NavPathStack(); + build() { Stack({ alignContent: Alignment.Bottom }) { - Navigator({ target: 'pages/Page1'}) { + Navigation(this.pageInfos) { Image($r('app.media.ic_banner01')).width('100%').height(200) // The image is stored in the media folder } }.height('100%').width('100%') diff --git a/ArkUI/entry/src/main/ets/pages/ImplementPageSwitchingAnimation_Two.ets b/ArkUI/entry/src/main/ets/pages/ImplementPageSwitchingAnimation_Two.ets index d051b0a40c7ff44cdd5ed638e4cbfdf5f746de39..a1fd5243c71752448314bd62452fcd6a7c240500 100644 --- a/ArkUI/entry/src/main/ets/pages/ImplementPageSwitchingAnimation_Two.ets +++ b/ArkUI/entry/src/main/ets/pages/ImplementPageSwitchingAnimation_Two.ets @@ -22,9 +22,11 @@ @Entry @Component struct PageTransition2 { + pageInfos: NavPathStack = new NavPathStack(); + build() { Stack({ alignContent: Alignment.Bottom }) { - Navigator({ target: 'pages/Index'}) { + Navigation(this.pageInfos) { Image($r('app.media.ic_banner02')).width('100%').height(200) // The image is stored in the media folder } }.height('100%').width('100%') diff --git a/ImageKit/entry/src/main/ets/pages/SaveWebPictureToAlbum.ets b/ImageKit/entry/src/main/ets/pages/SaveWebPictureToAlbum.ets index 4d40dee6636024bc360ba5b597c12a9ba52e2210..159544408ac55e6e81ffac105f99b30e8afeed50 100644 --- a/ImageKit/entry/src/main/ets/pages/SaveWebPictureToAlbum.ets +++ b/ImageKit/entry/src/main/ets/pages/SaveWebPictureToAlbum.ets @@ -78,7 +78,7 @@ struct SaveImage { let file = await fs.open(uri, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); // 写入文件 await fs.write(file.fd, buffer); - this.getUIContext().promptAction.showToast({ message: '已保存至相册!' }); + this.getUIContext().getPromptAction().showToast({ message: '已保存至相册!' }); // 关闭文件 await fs.close(file.fd); } catch (error) { @@ -107,7 +107,7 @@ struct SaveImage { if (result === SaveButtonOnClickResult.SUCCESS) { this.loadImageWithUrl('https://agc-storage-drcn.platform.dbankcloud.cn/v0/test-rqcjj/test.png'); } else { - this.getUIContext().promptAction.showToast({ message: '设置权限失败!' }); + this.getUIContext().getPromptAction().showToast({ message: '设置权限失败!' }); } }) }