diff --git a/ArkUI/entry/src/main/ets/entryability/EntryAbilityFullScreenStatus.ets b/ArkUI/entry/src/main/ets/entryability/EntryAbilityFullScreenStatus.ets index 7ce58b5d497e5671dab8b9d5363eef8d37efc098..3ad811d1f1dc17372e86a894d08905c1b6c3ef69 100644 --- a/ArkUI/entry/src/main/ets/entryability/EntryAbilityFullScreenStatus.ets +++ b/ArkUI/entry/src/main/ets/entryability/EntryAbilityFullScreenStatus.ets @@ -27,12 +27,11 @@ export default class EntryAbility extends UIAbility { // [Start entry_ability_full_screen_status] // EntryAbility.ets - onWindowStageCreate(windowStage: window.WindowStage): void { // Main window is created, set main page for this ability hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - + // Handle window content loading error windowStage.loadContent('pages/GridImage', (err) => { if (err.code) { hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); @@ -40,12 +39,11 @@ export default class EntryAbility extends UIAbility { } hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - - let windowClass: window.Window = windowStage.getMainWindowSync(); // 获取应用主窗口 - // 1. 设置窗口全屏 + let windowClass: window.Window = windowStage.getMainWindowSync(); // Get the main application window + // 1. Set the window to fullscreen let isLayoutFullScreen = true; windowClass.setWindowLayoutFullScreen(isLayoutFullScreen); - // 2. 缓存window窗口对象 + // 2. Cache the window object AppStorage.setOrCreate('windowClass', windowClass); }); } diff --git a/ArkUI/entry/src/main/ets/entryability/EntryAbilityImmersivePages.ets b/ArkUI/entry/src/main/ets/entryability/EntryAbilityImmersivePages.ets index 95beab0b96fa3e3b6efe157324aefe7705b6fa7b..45410fe272e4141ee39bfc8dc32b973f30fa1392 100644 --- a/ArkUI/entry/src/main/ets/entryability/EntryAbilityImmersivePages.ets +++ b/ArkUI/entry/src/main/ets/entryability/EntryAbilityImmersivePages.ets @@ -22,12 +22,15 @@ import { UIAbility } from '@kit.AbilityKit'; import { window } from '@kit.ArkUI'; import { BusinessError } from '@kit.BasicServicesKit'; - export default class EntryAbility extends UIAbility { onWindowStageCreate(windowStage: window.WindowStage) { // 1.Get the main window of the application. - let windowClass: window.Window | undefined = undefined; windowStage.getMainWindow().then(windowClass => { + if (!windowClass) { + console.error('Window is undefined'); + return; + } + console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(windowClass)); // 2.Set the window to full screen to achieve immersive effects. windowClass.setWindowLayoutFullScreen(true).then(() => { diff --git a/ArkUI/entry/src/main/ets/pages/ComponentAttributeCompatibilityJudgment.ets b/ArkUI/entry/src/main/ets/pages/ComponentAttributeCompatibilityJudgment.ets index c017c2aecb88022cced93ca1fb268e00c70cbaff..4bd4529e0dd3b74f141a660803c66f477b971b06 100644 --- a/ArkUI/entry/src/main/ets/pages/ComponentAttributeCompatibilityJudgment.ets +++ b/ArkUI/entry/src/main/ets/pages/ComponentAttributeCompatibilityJudgment.ets @@ -38,7 +38,7 @@ struct ComponentAttributeCompatibilityJudgment { class MyListModifier implements AttributeModifier { applyNormalAttribute(instance: ListAttribute): void { // Determine based on the API version information of deviceInfo - if (deviceInfo.sdkApiVersion > 14) { + if (deviceInfo?.sdkApiVersion > 14) { // The property to be adapted is the backToTop attribute of the List component // The instance is an attribute object of the List, and its properties can be modified through the instance instance.backToTop(true); diff --git a/ArkUI/entry/src/main/ets/pages/DisappearanceAnimationOffsetFlicker.ets b/ArkUI/entry/src/main/ets/pages/DisappearanceAnimationOffsetFlicker.ets index 039d4a3527bb25ed280eee46bc4fd821e6d0dcde..4c366bc77c14740369c4e9dfd739a0aae439c2a4 100644 --- a/ArkUI/entry/src/main/ets/pages/DisappearanceAnimationOffsetFlicker.ets +++ b/ArkUI/entry/src/main/ets/pages/DisappearanceAnimationOffsetFlicker.ets @@ -37,7 +37,7 @@ struct DisappearanceAnimationOffsetFlicker { .width('100%') .height('100%') .onClick(() => { - this.isShow = !this.isShow + this.isShow = !this.isShow; }) } } diff --git a/ArkUI/entry/src/main/ets/pages/ImplementImmersivePages.ets b/ArkUI/entry/src/main/ets/pages/ImplementImmersivePages.ets index be88e0258ec4d0f0bd5a050d9824db85ed472adb..03780175fa8d15b42627b78e135fd596ac26e1d6 100644 --- a/ArkUI/entry/src/main/ets/pages/ImplementImmersivePages.ets +++ b/ArkUI/entry/src/main/ets/pages/ImplementImmersivePages.ets @@ -33,7 +33,6 @@ struct Example { // Set the top drawing to extend to the status bar .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP]) - Row() { Text('ROW2') .fontSize(40) @@ -41,7 +40,6 @@ struct Example { .backgroundColor(Color.Orange) .padding(20) - Row() { Text('ROW3') .fontSize(40) @@ -49,7 +47,6 @@ struct Example { .backgroundColor(Color.Orange) .padding(20) - Row() { Text('ROW4') .fontSize(40) @@ -57,7 +54,6 @@ struct Example { .backgroundColor(Color.Orange) .padding(20) - Row() { Text('ROW5') .fontSize(40) @@ -65,7 +61,6 @@ struct Example { .backgroundColor(Color.Orange) .padding(20) - Row() { Text('Bottom Row') .fontSize(40) diff --git a/ArkUI/entry/src/main/ets/pages/MockOnclick.ets b/ArkUI/entry/src/main/ets/pages/MockOnclick.ets index 3a955870ab5334ee1f9a948e6dd7bd908861734f..14f9a6d538f713893127414086b833af03249ee6 100644 --- a/ArkUI/entry/src/main/ets/pages/MockOnclick.ets +++ b/ArkUI/entry/src/main/ets/pages/MockOnclick.ets @@ -59,6 +59,7 @@ class MyNodeController extends NodeController { // Coordinate Conversion Example postTouchEvent(event: TouchEvent, uiContext: UIContext): boolean { + if (changedTouchLen === 0) return false; if (this.rootNode == null) { return false; } @@ -70,7 +71,7 @@ class MyNodeController extends NodeController { let offsetY: number | null | undefined = node?.getPositionToParent().y; let changedTouchLen = event.changedTouches.length; for (let i = 0; i < changedTouchLen; i++) { - if (offsetX != null && offsetY != null && offsetX != undefined && offsetY != undefined) { + if (offsetX != null && offsetY != null) { event.changedTouches[i].x = uiContext.vp2px(offsetX + event.changedTouches[i].x); event.changedTouches[i].y = uiContext.vp2px(offsetY + event.changedTouches[i].y); } diff --git a/ArkUI/entry/src/main/ets/pages/SetTabsMarginDemo.ets b/ArkUI/entry/src/main/ets/pages/SetTabsMarginDemo.ets index e494dafef86f36feb8dbc443fb6e61196d5a612f..d9e4b96212fd11d76912d01b3b68f291e501c8fc 100644 --- a/ArkUI/entry/src/main/ets/pages/SetTabsMarginDemo.ets +++ b/ArkUI/entry/src/main/ets/pages/SetTabsMarginDemo.ets @@ -25,10 +25,11 @@ struct SetTabsMarginDemo { @State currentIndex: number = 0; @Builder - TabBarBuilder(title: string, targetIndex: number) { - Column(){ + tabBarBuilder(title: string, targetIndex: number) { + Column() { Text(title) - .fontWeight(targetIndex === this.currentIndex ? FontWeight.Bold : FontWeight.Normal).margin({ left: 10, right: 10 }) + .fontWeight(targetIndex === this.currentIndex ? FontWeight.Bold : FontWeight.Normal) + .margin({ left: 10, right: 10 }) .fontColor(targetIndex === this.currentIndex ? Color.Orange : Color.Gray) .onClick(() => { this.tabsController.changeIndex(targetIndex) @@ -40,44 +41,44 @@ struct SetTabsMarginDemo { Row() { Column() { Flex({ direction: FlexDirection.Row }) { - this.TabBarBuilder('页签1', 0) - this.TabBarBuilder('页签2', 1) - this.TabBarBuilder('页签3', 2) + this.tabBarBuilder('tab1', 0) + this.tabBarBuilder('tab2', 1) + this.tabBarBuilder('tab3', 2) } Tabs({ barPosition: BarPosition.Start, controller: this.tabsController }) { TabContent() { Column() { - Text("页签1页面") + Text("tab1_page") } .height('100%') .width('100%') .backgroundColor(Color.Yellow) } // The place where the margins are correctly set. - .margin({left : 10, right :10}) + .margin({ left: 10, right: 10 }) TabContent() { Column() { - Text("页签2页面") + Text("tab2_page") } .height('100%') .width('100%') .backgroundColor(Color.Green) } // The place where the margins are correctly set. - .margin({left : 10, right :10}) + .margin({ left: 10, right: 10 }) TabContent() { Column() { - Text("页签3页面") + Text("tab3_page") } .height('100%') .width('100%') .backgroundColor(Color.Pink) } // The place where the margins are correctly set. - .margin({left : 10, right :10}) + .margin({ left: 10, right: 10 }) } // The parameter for adjusting the margins should not be added here, as it may affect the user experience. // .margin({left : 10, right :10}) @@ -88,4 +89,5 @@ struct SetTabsMarginDemo { } } } + // [End SetTabsMarginDemo] \ No newline at end of file diff --git a/ArkUI/entry/src/main/ets/viewmodel/DrawViewModel.ets b/ArkUI/entry/src/main/ets/viewmodel/DrawViewModel.ets index efa53e526e5641ce0e7d95b1db105db9872759d4..7e329c5e569393a1ba9cc39a2f420d3bdaac3179 100644 --- a/ArkUI/entry/src/main/ets/viewmodel/DrawViewModel.ets +++ b/ArkUI/entry/src/main/ets/viewmodel/DrawViewModel.ets @@ -49,7 +49,7 @@ export class DrawViewModel { private drawPath = new Path2D(); constructor() { - this.pattern = this.context.createPattern(this.drawModel.img, 'repeat'); + this.pattern = this.context.createPattern(this.drawModel.img, 'repeat') ?? null; } moveStart(x: number, y: number) { @@ -59,10 +59,12 @@ export class DrawViewModel { } moveUpdate(x: number, y: number) { - let lastPoint = this.points[this.points.length - 1]; - this.points.push({ x: x, y: y }); - this.drawPath.quadraticCurveTo((x + lastPoint.x) / 2, (y + lastPoint.y) / 2, x, y); - this.drawCurrentPathModel(); + if (this.points.length !== 0) { + let lastPoint = this.points[this.points.length - 1]; + this.points.push({ x: x, y: y }); + this.drawPath.quadraticCurveTo((x + lastPoint.x) / 2, (y + lastPoint.y) / 2, x, y); + this.drawCurrentPathModel(); + } } moveEnd() { @@ -95,4 +97,5 @@ export class DrawViewModel { this.context.stroke(this.drawPath); } } + // [End draw_view_model] \ No newline at end of file diff --git a/ArkUI/entry/src/main/moduleNavigationJumpToPageWithWhiteScreen.json5 b/ArkUI/entry/src/main/moduleNavigationJumpToPageWithWhiteScreen.json5 index 99abc862d9ea9653f821eb529b6ef80f76dccc06..b453140707798f685b744882827d3b8e84b41fae 100644 --- a/ArkUI/entry/src/main/moduleNavigationJumpToPageWithWhiteScreen.json5 +++ b/ArkUI/entry/src/main/moduleNavigationJumpToPageWithWhiteScreen.json5 @@ -20,7 +20,7 @@ // [Start json5] "module": { "name": "feature_splash", - "type": "feature", + "type": "shared", // The type needs to be either "har" or "shared" // [End json5] "description": "$string:module_desc",