From 6a172adb14e3bb811175f67d443b47f8f4cc3dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=8B=E8=83=BD=5F=E5=BC=A0=E5=BE=B7=E7=9B=9B?= Date: Fri, 19 Sep 2025 16:25:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commons/base/src/main/ets/utils/table.json5 | 15 - .../home/src/main/ets/view/VideoDaily.ets | 287 ------------------ .../home/src/main/ets/view/exampleTest.ets | 52 ---- .../src/main/ets/view/VideoDetailChange.ets | 281 ----------------- .../ets/entryability/EntryAbilityChange.ets | 33 -- .../main/ets/entryability/EntryAbilityNew.ets | 60 ---- 6 files changed, 728 deletions(-) delete mode 100644 commons/base/src/main/ets/utils/table.json5 delete mode 100644 features/home/src/main/ets/view/VideoDaily.ets delete mode 100644 features/home/src/main/ets/view/exampleTest.ets delete mode 100644 features/videoDetail/src/main/ets/view/VideoDetailChange.ets delete mode 100644 products/phone/src/main/ets/entryability/EntryAbilityChange.ets delete mode 100644 products/phone/src/main/ets/entryability/EntryAbilityNew.ets diff --git a/commons/base/src/main/ets/utils/table.json5 b/commons/base/src/main/ets/utils/table.json5 deleted file mode 100644 index 5414dc1..0000000 --- a/commons/base/src/main/ets/utils/table.json5 +++ /dev/null @@ -1,15 +0,0 @@ -/* -* 最佳实践: 平板开发实践 -*/ -{ - "module": { - "name": "base", - "type": "har", - // [Start tablet_Types] - "deviceTypes": [ - "phone", - "tablet" // (There can't be any) - ], - // [End tablet_Types] - } -} \ No newline at end of file diff --git a/features/home/src/main/ets/view/VideoDaily.ets b/features/home/src/main/ets/view/VideoDaily.ets deleted file mode 100644 index d8d11c4..0000000 --- a/features/home/src/main/ets/view/VideoDaily.ets +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AvPlayerUtil, BreakpointConstants, CommonConstants, WindowUtil } from '@ohos/commons'; -import { BreakpointType } from '@ohos/commons'; -import { HomeConstants } from '../constants/HomeConstants'; -import { VideoImage, VideoImgViewModel } from '../viewmodel/VideoImgViewModel'; -import { getTabIndex, SubtitleComponent, VideoImgComponent, VideoImgPlay, VideoImgRating } from './CommonView'; -import { display, window } from '@kit.ArkUI'; -import { deviceInfo } from '@kit.BasicServicesKit'; -import { KeyCode } from '@kit.InputKit'; - -@Component -export struct DailyVideo { - @State scrollHeight: number =0; - @StorageLink('currentWidthBreakpoint') currentWidthBreakpoint: string = 'lg'; - @StorageLink('currentHeightBreakpoint') currentHeightBreakpoint: string = 'lg'; - @StorageLink('windowWidth') windowWidth: number = 0; - @StorageLink('currentTopIndex') currentTopIndex: number = 0; - @State isShowingMainBorder: boolean = false; - private mainWindowClass?: window.Window; - @StorageLink('isFullScreen') isFullScreen: boolean = false; - private windowUtil?: WindowUtil = WindowUtil.getInstance(); - @StorageLink('isHalfFolded') isHalfFolded: boolean = false; - private avPlayerUtil?: AvPlayerUtil; - private xComponentController: XComponentController = new XComponentController(); - - aboutToAppear(): void { - // [Start dd_judgment_of] - // Judgment of the horizontal window. (The actual application may need to be combined with other conditions, for example, determine the horizontal breakpoint) - if (this.currentHeightBreakpoint === 'sm' && this.currentWidthBreakpoint === 'md') { - // Horizontal window page layout. - } - // Judgment of the square window. (The actual use may need to be combined with other conditions, such as determining horizontal breakpoints) - if (this.currentHeightBreakpoint === 'md' && this.currentWidthBreakpoint === 'sm') { - // Square-like window page layout. - } - // [End dd_judgment_of] - - // [Start dd_set_preferred_orientation] - let currentHeightBreakpoint: string | undefined = AppStorage.get('currentHeightBreakpoint'); - if (currentHeightBreakpoint === 'md') { - this.mainWindowClass?.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); - } - // [End dd_set_preferred_orientation] - // [Start dd_isfullscreen] - if (this.isFullScreen) { - if (deviceInfo.deviceType !== '2in1') { - this.windowUtil!.disableWindowSystemBar(); - } - if ((!display.isFoldable() && deviceInfo.deviceType === 'phone') || - display.getFoldStatus() === display.FoldStatus.FOLD_STATUS_FOLDED) { - this.windowUtil!.setMainWindowOrientation(window.Orientation.AUTO_ROTATION_LANDSCAPE); - } - if (display.isFoldable()) { - if (this.isHalfFolded) { - this.windowUtil!.setMainWindowOrientation(window.Orientation.AUTO_ROTATION_LANDSCAPE); - } - } - } - // [End dd_isfullscreen] - } - build() { - Column(){ - // [Start dd_break_point_type_getValue] - Text('Test') - .fontSize(new BreakpointType('14fp', '16fp', '18fp').getValue(this.currentWidthBreakpoint)) - // [End dd_break_point_type_getValue] - - // [Start dd_movable_layout] - // Movable layout. - GridRow({ - columns: { sm: 4, md: 12, lg: 12 }, - gutter: 12, - breakpoints: { value: ['320vp', '600vp', '840vp'], reference: BreakpointsReference.WindowSize }, - direction: GridRowDirection.Row - }) { - GridCol({ - span: { sm: 4, md: 7, lg: 7 } - }) { - this.topTabBar() - } - .height(56) - - GridCol({ - span: { sm: 4, md: 5, lg: 5 } - }) { - this.topSearch() - } - .height(56) - } - .width('100%') - // [End dd_movable_layout] - - // [Start dd_carousel_layout] - // Carousel layout. - Swiper() { - } - .displayCount(new BreakpointType(1, 2, 3).getValue(this.currentWidthBreakpoint)) - .nextMargin(new BreakpointType(0, 16, 32).getValue(this.currentWidthBreakpoint)) - .prevMargin(new BreakpointType(0, 16, 32).getValue(this.currentWidthBreakpoint)) - .indicator(this.currentWidthBreakpoint === 'sm' ? Indicator.dot() - .itemWidth(6) - .itemHeight(6) - .selectedItemWidth(12) - .selectedItemHeight(6) - .color('#4DFFFFFF') - .bottom(6) - .selectedColor(Color.White) : false - ) - .padding({ - left: this.currentWidthBreakpoint === 'sm' ? 12 : 0, - right: this.currentWidthBreakpoint === 'sm' ? 12 : 0 - }) - // [End dd_carousel_layout] - - // [Start dd_palace_grid_layout] - // Palace grid layout. - Grid() { - } - .columnsTemplate('1fr '.repeat(this.currentWidthBreakpoint === 'sm' ? 4 : 8)) - .rowsTemplate(this.currentWidthBreakpoint === 'sm' ? '1fr 1fr' : '1fr') - .height(this.currentWidthBreakpoint === 'sm' ? 164 : 78) - .columnsGap(12) - .rowsGap(12) - // [End dd_palace_grid_layout] - - // [Start jh_xcomponent] - XComponent({ id: '', type: 'surface', controller: this.xComponentController }) - .onKeyEvent((event?: KeyEvent) => { - // If the button type is pressed, the subsequent code will not be executed; the specific button logic will be executed upon release. - if (!event || event.type !== KeyType.Down) { - return; - } - // Space key controls pause/play - if (event.keyCode === KeyCode.KEYCODE_SPACE) { - this.avPlayerUtil!.playerStateControl(); - } - // ESC key exits full screen - if (event.keyCode === KeyCode.KEYCODE_ESCAPE) { - this.windowUtil!.recover(); - } - // Right-click to fast forward - if (event.keyCode === KeyCode.KEYCODE_DPAD_RIGHT) { - this.avPlayerUtil!.fastForward(); - } - // Left-click to rewind - if (event.keyCode === KeyCode.KEYCODE_DPAD_LEFT) { - this.avPlayerUtil!.rewind(); - } - }) - // [End jh_xcomponent] - } - } - - @Builder - topTabBar() { - Row() { - Column() { - List() { - ForEach(HomeConstants.TOP_TOPIC_LIST, (item: string, index: number) => { - ListItem() { - Text(item) - .fontSize(this.currentTopIndex === index ? $r('app.float.search_tab_font_selected') : - $r('app.float.search_tab_font')) - .fontWeight(this.currentTopIndex === index ? 700 : - 500) - .width(this.currentTopIndex === index ? $r('app.float.top_text_width_selected') : - $r('app.float.top_text_width')) - .textAlign(TextAlign.Center) - .fontColor(this.currentTopIndex === 2 ? Color.White : $r('app.color.normal_font_color')) - .lineHeight(index === this.currentTopIndex ? $r('app.float.top_tab_list_height_selected') : - $r('app.float.top_tab_list_height')) - .focusable(true) - .groupDefaultFocus(index === 0 ? true : false) - .borderRadius($r('app.float.text_focus_radius')) - } - .align(Alignment.Center) - .margin({ - top: this.currentTopIndex === index ? $r('app.float.top_tab_list_top_selected') : - $r('app.float.top_tab_list_top'), - bottom: this.currentTopIndex === index ? $r('app.float.top_tab_list_bottom_selected') : - $r('app.float.top_tab_list_bottom') - }) - .padding({ - left: new BreakpointType(8, 12, 18).getValue(this.currentWidthBreakpoint), - right: new BreakpointType(8, 12, 18).getValue(this.currentWidthBreakpoint) - }) - .onClick(() => { - this.currentTopIndex = index; - this.scrollHeight = 0; - }) - }, (item: number, index: number) => index + JSON.stringify(item)) - } - .tabIndex(getTabIndex(HomeConstants.DIRECTION_LIST[1])) - .scrollBar(BarState.Off) - .listDirection(Axis.Horizontal) - .padding({ left: $r('app.float.search_top_padding') }) - } - .alignItems(HorizontalAlign.Center) - .layoutWeight(1) - Image($r('app.media.ic_public_more')) - .width($r('app.float.top_tab_img_size')) - .height($r('app.float.top_tab_img_size')) - .margin({ - left: $r('app.float.top_tab_img_margin'), - right: $r('app.float.top_tab_img_margin') - }) - .fillColor(this.currentTopIndex === 2 ? Color.White : Color.Black) - .visibility(this.currentWidthBreakpoint === 'sm' ? Visibility.Visible : Visibility.None) - } - .height($r('app.float.top_bar_height')) - .width('100%') - } - - @Builder - topSearch() { - Row() { - Column() { - List() { - ForEach(HomeConstants.TOP_TOPIC_LIST, (item: string, index: number) => { - ListItem() { - Text(item) - .fontSize(this.currentTopIndex === index ? $r('app.float.search_tab_font_selected') : - $r('app.float.search_tab_font')) - .fontWeight(this.currentTopIndex === index ? 700 : - 500) - .width(this.currentTopIndex === index ? $r('app.float.top_text_width_selected') : - $r('app.float.top_text_width')) - .textAlign(TextAlign.Center) - .fontColor(this.currentTopIndex === 2 ? Color.White : $r('app.color.normal_font_color')) - .lineHeight(index === this.currentTopIndex ? $r('app.float.top_tab_list_height_selected') : - $r('app.float.top_tab_list_height')) - .focusable(true) - .groupDefaultFocus(index === 0 ? true : false) - .borderRadius($r('app.float.text_focus_radius')) - } - .align(Alignment.Center) - .margin({ - top: this.currentTopIndex === index ? $r('app.float.top_tab_list_top_selected') : - $r('app.float.top_tab_list_top'), - bottom: this.currentTopIndex === index ? $r('app.float.top_tab_list_bottom_selected') : - $r('app.float.top_tab_list_bottom') - }) - .padding({ - left: new BreakpointType(8, 12, 18).getValue(this.currentWidthBreakpoint), - right: new BreakpointType(8, 12, 18).getValue(this.currentWidthBreakpoint) - }) - .onClick(() => { - this.currentTopIndex = index; - this.scrollHeight = 0; - }) - }, (item: number, index: number) => index + JSON.stringify(item)) - } - .tabIndex(getTabIndex(HomeConstants.DIRECTION_LIST[1])) - .scrollBar(BarState.Off) - .listDirection(Axis.Horizontal) - .padding({ left: $r('app.float.search_top_padding') }) - } - .alignItems(HorizontalAlign.Center) - .layoutWeight(1) - Image($r('app.media.ic_public_more')) - .width($r('app.float.top_tab_img_size')) - .height($r('app.float.top_tab_img_size')) - .margin({ - left: $r('app.float.top_tab_img_margin'), - right: $r('app.float.top_tab_img_margin') - }) - .fillColor(this.currentTopIndex === 2 ? Color.White : Color.Black) - .visibility(this.currentWidthBreakpoint === 'sm' ? Visibility.Visible : Visibility.None) - } - .height($r('app.float.top_bar_height')) - .width('100%') - } -} \ No newline at end of file diff --git a/features/home/src/main/ets/view/exampleTest.ets b/features/home/src/main/ets/view/exampleTest.ets deleted file mode 100644 index 644bc58..0000000 --- a/features/home/src/main/ets/view/exampleTest.ets +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { window } from '@kit.ArkUI'; - -@Component -export struct ExampleTest { - private mainWindowClass?: window.Window; - @StorageLink('currentWidthBreakpoint') currentWidthBreakpoint: string = 'lg'; - - // [Start example_updateWidthBp] - updateWidthBp(): void { - let mainWindow: window.WindowProperties = this.mainWindowClass!.getWindowProperties(); - let windowWidth: number = mainWindow.windowRect.width; - let windowWidthVp = this.getUIContext().px2vp(windowWidth); - let widthBp: string = ''; - if (windowWidthVp < 320) { - widthBp = 'xs'; - } else if (windowWidthVp >= 320 && windowWidthVp < 600) { - widthBp = 'sm'; - } else if (windowWidthVp >= 600 && windowWidthVp < 840) { - widthBp = 'md'; - } else if (windowWidthVp >= 840 && windowWidthVp < 1440) { - widthBp = 'lg'; - } else { - widthBp = 'xl'; - } - AppStorage.setOrCreate('currentWidthBreakpoint', widthBp); - } - // [End example_updateWidthBp] - - build() { - Column() { - // [Start example_text_test] - Text('Test') - .fontSize(this.currentWidthBreakpoint === 'lg' ? '16fp' : '14fp') - // [End example_text_test] - } - } -} \ No newline at end of file diff --git a/features/videoDetail/src/main/ets/view/VideoDetailChange.ets b/features/videoDetail/src/main/ets/view/VideoDetailChange.ets deleted file mode 100644 index 6e9df84..0000000 --- a/features/videoDetail/src/main/ets/view/VideoDetailChange.ets +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* -* 最佳实践: 一多交互事件开发实践,一多断点开发实践 -*/ - -import { KeyCode } from '@kit.InputKit'; -import { deviceInfo } from '@kit.BasicServicesKit'; -import { display, window } from '@kit.ArkUI'; -import { - AvPlayerUtil, - DeviceScreen, - Logger, - WindowUtil, - BreakpointConstants, - CommonConstants, - DisplayUtil, - VideoNavPathStack -} from '@ohos/commons'; -import { SelfComment } from './SelfComment'; -import { AllComments } from './AllComments'; -import { VideoDetailView } from './VideoDetailView'; -import { DetailConstants } from '../constants/DetailConstants'; - -@Component -export struct VideoDetail { - @StorageLink('currentWidthBreakpoint') currentWidthBreakpoint: string = BreakpointConstants.BREAKPOINT_LG; - @StorageLink('currentHeightBreakpoint') currentHeightBreakpoint: string = BreakpointConstants.BREAKPOINT_LG; - @StorageLink('windowWidth') windowWidth: number = 0; - @StorageLink('isHalfFolded') @Watch('onHalfFoldedChange') isHalfFolded: boolean = false; - @StorageLink('avplayerState') avplayerState: string = ''; - @StorageLink('isFullScreen') @Watch('onFullScreenChange') isFullScreen: boolean = false; - @Consume('pageInfo') pageInfo: VideoNavPathStack; - @State commentImgHeight: string = DetailConstants.INITIAL_COMMENT_IMAGE_HEIGHT; - @State commentImgWidth: string = DetailConstants.INITIAL_COMMENT_IMAGE_WIDTH; - @State relatedVideoHeight: number = DetailConstants.INITIAL_RELATED_VIDEO_HEIGHT; - @State videoHeight: number = DetailConstants.INITIAL_VIDEO_HEIGHT; - private avPlayerUtil?: AvPlayerUtil = AvPlayerUtil.getInstance(this.getUIContext()); - public screenHeight: number = 0; - private windowUtil?: WindowUtil = WindowUtil.getInstance(); - private mainWindow?: window.Window; - private onWindowSizeChange: (windowSize: window.Size) => void = (windowSize: window.Size) => { - if (this.pageInfo.getPageName() !== CommonConstants.PAGE_NAMES[1]) { - return; - } - if (((this.currentWidthBreakpoint === BreakpointConstants.BREAKPOINT_MD && this.currentHeightBreakpoint !== - BreakpointConstants.BREAKPOINT_SM) || this.currentWidthBreakpoint === BreakpointConstants.BREAKPOINT_LG) && - !this.isHalfFolded) { - this.windowUtil?.setMainWindowOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); - } - else if (this.currentWidthBreakpoint === BreakpointConstants.BREAKPOINT_MD && this.currentHeightBreakpoint === - BreakpointConstants.BREAKPOINT_SM) { - if (this.isFullScreen) { - this.windowUtil?.setMainWindowOrientation(window.Orientation.AUTO_ROTATION_LANDSCAPE_RESTRICTED); - } else { - this.windowUtil?.setMainWindowOrientation(window.Orientation.PORTRAIT); - } - } else if (this.currentWidthBreakpoint === BreakpointConstants.BREAKPOINT_SM && this.currentHeightBreakpoint === - BreakpointConstants.BREAKPOINT_LG) { - if (this.isFullScreen) { - this.windowUtil?.setMainWindowOrientation(window.Orientation.AUTO_ROTATION_LANDSCAPE_RESTRICTED); - } else { - this.windowUtil?.setMainWindowOrientation(window.Orientation.PORTRAIT); - } - } - }; - - private onHalfFoldedChange(): void { - if (this.isHalfFolded) { - this.windowUtil?.setMainWindowOrientation(window.Orientation.AUTO_ROTATION_LANDSCAPE_RESTRICTED); - } else { - if (this.currentWidthBreakpoint === BreakpointConstants.BREAKPOINT_MD && this.currentHeightBreakpoint === - BreakpointConstants.BREAKPOINT_MD) { - this.windowUtil?.setMainWindowOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); - } - } - } - - // [Start on_full_screen_change] - // [Start dd_on_full_screen_change] - // features/videoDetail/src/main/ets/view/VideoDetail.ets - private onFullScreenChange(): void { - // Large folding screen (X series) in unfolded state and tablet state, supporting rotation && large folding screen (X series) in hover state requires landscape display and does not support rotation. - if (((this.currentWidthBreakpoint === BreakpointConstants.BREAKPOINT_MD && this.currentHeightBreakpoint !== - BreakpointConstants.BREAKPOINT_SM) || this.currentWidthBreakpoint === BreakpointConstants.BREAKPOINT_LG) && - !this.isHalfFolded) { - this.windowUtil?.setMainWindowOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); - } - // Phone and large folding screen (X series) in portrait mode. - else if (this.currentWidthBreakpoint === BreakpointConstants.BREAKPOINT_SM && this.currentHeightBreakpoint === - BreakpointConstants.BREAKPOINT_LG) { - // In full-screen mode, the layout is displayed in landscape mode. Otherwise, the layout is displayed in portrait mode. - if (this.isFullScreen) { - this.windowUtil?.setMainWindowOrientation(window.Orientation.AUTO_ROTATION_LANDSCAPE_RESTRICTED); - } else { - this.windowUtil?.setMainWindowOrientation(window.Orientation.PORTRAIT); - } - } - // When the mobile phone and large folding screen (X series) are folded in landscape mode and the playback is not in full screen mode, the vertical display layout is displayed. - else if (this.currentWidthBreakpoint === BreakpointConstants.BREAKPOINT_MD && this.currentHeightBreakpoint === - BreakpointConstants.BREAKPOINT_SM && !this.isFullScreen) { - this.windowUtil?.setMainWindowOrientation(window.Orientation.PORTRAIT); - } - // The navigation bar is not hidden on a 2in1 device. - if (deviceInfo.deviceType !== '2in1') { - // The navigation bar is hidden in full-screen playback. Otherwise, the navigation bar is displayed. - if (this.isFullScreen) { - this.windowUtil!.disableWindowSystemBar(); - } else { - this.windowUtil!.enableWindowSystemBar(); - } - } - } - // [End dd_on_full_screen_change] - // [End on_full_screen_change] - - aboutToAppear() { - DisplayUtil.getFoldCreaseRegion(this.getUIContext()); - this.screenHeight = DeviceScreen.getDeviceHeight(); - this.mainWindow = this.windowUtil!.getMainWindow(); - this.mainWindow?.on('windowSizeChange', this.onWindowSizeChange); - if (this.currentWidthBreakpoint !== BreakpointConstants.BREAKPOINT_SM) { - this.windowUtil!.setMainWindowOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); - } - } - - async aboutToDisappear() { - this.isFullScreen = false; - this.avPlayerUtil?.offTimeUpdate(); - await this.avPlayerUtil?.release(); - - if (this.currentWidthBreakpoint === BreakpointConstants.BREAKPOINT_LG) { - this.windowUtil!.setMainWindowOrientation(window.Orientation.LANDSCAPE); - } else { - this.windowUtil!.setMainWindowOrientation(window.Orientation.PORTRAIT); - } - } - - build() { - NavDestination() { - GridRow({ - columns: { - sm: BreakpointConstants.GRID_ROW_COLUMNS[2], - md: BreakpointConstants.GRID_ROW_COLUMNS[0], - lg: BreakpointConstants.GRID_ROW_COLUMNS[0] - } - }) { - GridCol({ - span: { - sm: BreakpointConstants.GRID_COLUMN_SPANS[5], - md: BreakpointConstants.GRID_COLUMN_SPANS[0], - lg: BreakpointConstants.GRID_COLUMN_SPANS[0] - } - }) { - SideBarContainer() { - Column() { - // Sidebar area. - Scroll() { - AllComments({ commentImgHeight: $commentImgHeight, commentImgWidth: $commentImgWidth }) - .visibility(this.currentWidthBreakpoint === BreakpointConstants.BREAKPOINT_LG ? Visibility.Visible : - Visibility.None) - } - .align(Alignment.Top) - .scrollBar(BarState.Off) - .layoutWeight(1) - .width(CommonConstants.FULL_PERCENT) - .padding({ bottom: $r('app.float.side_scroll_padding') }) - - SelfComment() - .visibility(this.currentWidthBreakpoint === BreakpointConstants.BREAKPOINT_LG ? Visibility.Visible : - Visibility.None) - } - .justifyContent(FlexAlign.Start) - .height(CommonConstants.FULL_PERCENT) - .width(CommonConstants.FULL_PERCENT) - .backgroundColor(Color.White) - .onAreaChange((newValue: Area) => { - if (newValue.width !== 0) { - // Handling when the width of the sidebar changes. - let height: number = DetailConstants.COMMENT_IMAGE_MIN_HEIGHT_NUMBER + (Number(newValue.width) - - DetailConstants.SIDE_BAR_MIN_WIDTH_NUMBER) / - (this.getUIContext().px2vp(this.windowWidth) * DetailConstants.COMMENTS_AREA_PERCENT - - DetailConstants.SIDE_BAR_MIN_WIDTH_NUMBER) * (DetailConstants.COMMENT_IMAGE_MAX_HEIGHT_NUMBER - - DetailConstants.COMMENT_IMAGE_MIN_HEIGHT_NUMBER); - let width: number = DetailConstants.COMMENT_IMAGE_MIN_WIDTH_NUMBER + (Number(newValue.width) - - DetailConstants.SIDE_BAR_MIN_WIDTH_NUMBER) / - (this.getUIContext().px2vp(this.windowWidth) * DetailConstants.COMMENTS_AREA_PERCENT - - DetailConstants.SIDE_BAR_MIN_WIDTH_NUMBER) * (DetailConstants.COMMENT_IMAGE_MAX_WIDTH_NUMBER - - DetailConstants.COMMENT_IMAGE_MIN_WIDTH_NUMBER); - this.commentImgHeight = JSON.stringify(height); - this.commentImgWidth = JSON.stringify(width); - } - }) - - Column() { - // Content area. - VideoDetailView({ - screenHeight: this.screenHeight, - relatedVideoHeight: this.relatedVideoHeight, - videoHeight: this.videoHeight - }) - .layoutWeight(1) - SelfComment() - .visibility(this.currentWidthBreakpoint === BreakpointConstants.BREAKPOINT_LG || this.isFullScreen ? - Visibility.None : Visibility.Visible) - } - .height(CommonConstants.FULL_PERCENT) - .width(CommonConstants.FULL_PERCENT) - } - .showSideBar(this.currentWidthBreakpoint === BreakpointConstants.BREAKPOINT_LG && !this.isFullScreen ? true : - false) - .showControlButton(false) - .autoHide(false) - .sideBarPosition(SideBarPosition.End) - .sideBarWidth($r('app.float.side_bar_min_width')) - .minSideBarWidth($r('app.float.side_bar_min_width')) - .maxSideBarWidth(this.getUIContext().px2vp(this.windowWidth * DetailConstants.COMMENTS_AREA_PERCENT)) - } - .height(CommonConstants.FULL_PERCENT) - } - .width(CommonConstants.FULL_PERCENT) - .height(CommonConstants.FULL_PERCENT) - .onBreakpointChange((breakPoints) => { - if (breakPoints !== BreakpointConstants.BREAKPOINT_LG && - this.videoHeight < DetailConstants.INITIAL_VIDEO_HEIGHT) { - this.relatedVideoHeight = 0; - } else if (breakPoints === BreakpointConstants.BREAKPOINT_LG) { - this.relatedVideoHeight = DetailConstants.INITIAL_RELATED_VIDEO_HEIGHT; - } else { - Logger.info(`No specific function`); - } - }) - } - .hideTitleBar(true) - .onShown(() => { - if (this.avplayerState !== CommonConstants.AV_PLAYER_PLAYING_STATE) { - this.avPlayerUtil!.playerStateControl(); - } - if (canIUse('SystemCapability.Window.SessionManager')) { - if (this.currentWidthBreakpoint === BreakpointConstants.BREAKPOINT_MD && display.isFoldable()) { - this.isHalfFolded = false; - } - } - }) - .onKeyEvent((event?: KeyEvent) => { - //If the key type is pressed, the subsequent code will not be executed, and the specific key logic will be executed when released. - if (!event || event.type !== KeyType.Down) { - return; - } - // Space key controls pause/play. - if (event.keyCode === KeyCode.KEYCODE_SPACE) { - this.avPlayerUtil!.playerStateControl(); - } - //press ESC to exit full screen. - if (event.keyCode === KeyCode.KEYCODE_ESCAPE) { - this.windowUtil!.recover(); - } - //Right-click fast forward - if (event.keyCode === KeyCode.KEYCODE_DPAD_RIGHT) { - this.avPlayerUtil!.fastForward(); - } - //Left click to go back quickly - if (event.keyCode === KeyCode.KEYCODE_DPAD_LEFT) { - this.avPlayerUtil!.rewind(); - } - }) - } -} \ No newline at end of file diff --git a/products/phone/src/main/ets/entryability/EntryAbilityChange.ets b/products/phone/src/main/ets/entryability/EntryAbilityChange.ets deleted file mode 100644 index ef5b61e..0000000 --- a/products/phone/src/main/ets/entryability/EntryAbilityChange.ets +++ /dev/null @@ -1,33 +0,0 @@ -import { hilog } from "@kit.PerformanceAnalysisKit"; -import { BusinessError } from "@kit.BasicServicesKit"; -import { window } from "@kit.ArkUI"; -import { WindowUtil } from "@ohos/commons"; -import { UIAbility } from "@kit.AbilityKit"; - -// [Start dd_entryability_uicontext] -// [Start dd_entryability_default] -export default class EntryAbility extends UIAbility { - private windowUtil?: WindowUtil = WindowUtil.getInstance(); - private onWindowSizeChange: (windowSize: window.Size) => void = (windowSize: window.Size) => { - this.windowUtil!.updateHeightBp(); - this.windowUtil!.updateWidthBp(); - AppStorage.setOrCreate('windowWidth', windowSize.width); - }; - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - this.windowUtil?.setWindowStage(windowStage); - - windowStage.getMainWindow((err: BusinessError, data: window.Window) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to get the main window. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - this.windowUtil!.updateWidthBp(); - this.windowUtil!.updateHeightBp(); - data.on('windowSizeChange', this.onWindowSizeChange); - }) - } -} -// [End dd_entryability_default] -// [End dd_entryability_uicontext] \ No newline at end of file diff --git a/products/phone/src/main/ets/entryability/EntryAbilityNew.ets b/products/phone/src/main/ets/entryability/EntryAbilityNew.ets deleted file mode 100644 index cf67bd1..0000000 --- a/products/phone/src/main/ets/entryability/EntryAbilityNew.ets +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* -* 最佳实践: 平板开发实践,一多断点开发实践 -*/ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { display, window } from '@kit.ArkUI'; -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { CommonConstants, WindowUtil } from '@ohos/commons'; -import { BusinessError } from '@kit.BasicServicesKit'; - -// [Start dd_entryability] -export default class EntryAbility extends UIAbility { - private uiContext?: UIContext; - private onWindowSizeChange: (windowSize: window.Size) => void = (windowSize: window.Size) => { - let widthBp: WidthBreakpoint = this.uiContext!.getWindowWidthBreakpoint(); - AppStorage.setOrCreate('currentWidthBreakpoint', widthBp); - let heightBp: HeightBreakpoint = this.uiContext!.getWindowHeightBreakpoint(); - AppStorage.setOrCreate('currentHeightBreakpoint', heightBp); - }; - - onWindowStageCreate(windowStage: window.WindowStage): void { - // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - - windowStage.loadContent('pages/Index', (err) => { - if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); - // The system interface depends on UIContext and needs to be invoked after the page is loaded. It needs to be written in the loadContent callback function. - windowStage.getMainWindow().then((data: window.Window) => { - this.uiContext = data.getUIContext(); - let widthBp: WidthBreakpoint = this.uiContext.getWindowWidthBreakpoint(); - let heightBp: HeightBreakpoint = this.uiContext.getWindowHeightBreakpoint(); - AppStorage.setOrCreate('currentWidthBreakpoint', widthBp); - AppStorage.setOrCreate('currentHeightBreakpoint', heightBp); - data.on('windowSizeChange', this.onWindowSizeChange); - }).catch((err: BusinessError) => { - console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); - }); - }); - } -} -// [End dd_entryability] -- Gitee