diff --git a/windowpiplibrary/Index.ets b/windowpiplibrary/Index.ets index 128520f228b4d96ca55f593e8509dba91ca2935c..5560b178d1fee63aa07d8739b7e96edc9f88a449 100644 --- a/windowpiplibrary/Index.ets +++ b/windowpiplibrary/Index.ets @@ -1,3 +1,3 @@ -export { WindowPipComponent } from './src/main/ets/component/WindowPipComponent'; +export { VideoPlayComponent } from './src/main/ets/component/VideoPlayComponent'; export { WindowPipController } from './src/main/ets/WindowPipController'; diff --git a/windowpiplibrary/src/main/ets/component/WindowPipComponent.ets b/windowpiplibrary/src/main/ets/component/WindowPipComponent.ets deleted file mode 100644 index 227704e9a21e67cd7f089893ce753fd5c2555fcd..0000000000000000000000000000000000000000 --- a/windowpiplibrary/src/main/ets/component/WindowPipComponent.ets +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2024 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 { VideoPlayComponent } from './VideoPlayComponent'; -import { ImageWidthTitle } from './ImageWidthTitle'; -import { CommonConstants } from '../constants/CommonConstants'; -import { BreakpointTypeEnum } from '../utils/BreakpointSystem'; - -@Component -export struct WindowPipComponent { - @StorageLink(CommonConstants.KEY_PREFIX_BREAKPOINT) curBp: string = BreakpointTypeEnum.SM; - @Provide(CommonConstants.KEY_PREFIX_SYSTEM_PAGE_INFO) pageInfos: NavPathStack = new NavPathStack(); - private navigationId: string = 'navId'; - private videoList: Array = [ - $r('app.string.video1'), $r('app.string.video2'), $r('app.string.video3'), - $r('app.string.video4'), $r('app.string.video5'), $r('app.string.video6'), - $r('app.string.video7'), $r('app.string.video8'), $r('app.string.video9'), - $r('app.string.video10'), $r('app.string.video11'), $r('app.string.video12'), - $r('app.string.video13'), $r('app.string.video14'), $r('app.string.video15') - ]; - - @Builder - PageMap(name: string) { - if (name === CommonConstants.NAV_DESTINATION_NAME) { - VideoPlayComponent({ navigationId: this.navigationId }) - } - } - - aboutToAppear(): void { - this.getUIContext().getHostContext()!.eventHub.emit('onStateChange', true); - this.pageInfos?.pushPath({ name: CommonConstants.NAV_DESTINATION_NAME }, { launchMode: 3, animated: false }); - } - - build() { - Navigation(this.pageInfos) { - Column() { - Row() { - Text($r('app.string.pip_effect')) - .fontSize($r('sys.float.Title_L')) - .fontWeight(FontWeight.Bold) - .fontColor($r('sys.color.font_primary')) - } - .width('100%') - .height(40) - .margin({ - top: 84, - bottom: $r('sys.float.padding_level12') - }) - - Grid() { - ForEach(this.videoList, (item: Resource, index: number) => { - GridItem() { - ImageWidthTitle({ titleResource: item, pageInfos: this.pageInfos }) - } - .padding({ - bottom: this.videoList.length - 1 === index ? $r('sys.float.padding_level8') : - $r('sys.float.padding_level0') - }) - }, (item: Resource) => item.id.toString()) - } - .width(CommonConstants.FULL_PERCENT) - .layoutWeight(1) - .columnsTemplate(this.curBp === 'sm' ? CommonConstants.COLUMNS_TEMPLATE_SM : - this.curBp === 'md' ? CommonConstants.COLUMNS_TEMPLATE_MD : CommonConstants.COLUMNS_TEMPLATE_LG) - .columnsGap(this.curBp === 'lg' ? $r('sys.float.padding_level8') : $r('sys.float.padding_level6')) - .rowsGap(this.curBp === 'lg' ? $r('sys.float.padding_level8') : $r('sys.float.padding_level6')) - .scrollBar(BarState.Off) - } - .width(CommonConstants.FULL_PERCENT) - .padding({ - top: this.curBp === 'lg' ? $r('sys.float.padding_level8') : $r('sys.float.padding_level6'), - right: this.curBp === 'lg' ? $r('sys.float.padding_level8') : $r('sys.float.padding_level6'), - left: this.curBp === 'lg' ? $r('sys.float.padding_level8') : $r('sys.float.padding_level6') - }) - } - .title($r('app.string.pip_effect')) - .titleMode(NavigationTitleMode.Full) - .hideTitleBar(true) - .navDestination(this.PageMap) - .mode(NavigationMode.Stack) - .hideBackButton(true) - .backgroundColor($r('sys.color.background_secondary')) - .size({ width: CommonConstants.NAV_DESTINATION_WIDTH, height: CommonConstants.NAV_DESTINATION_HEIGHT }) - .id(this.navigationId) - } -} \ No newline at end of file diff --git a/windowpiplibrary/src/main/ets/constants/CommonConstants.ets b/windowpiplibrary/src/main/ets/constants/CommonConstants.ets index 9569d461471a8dc90b49768edd19503a5e7731a6..69ddccaee5994510f3ced0a281ff9e1b0da5a31f 100644 --- a/windowpiplibrary/src/main/ets/constants/CommonConstants.ets +++ b/windowpiplibrary/src/main/ets/constants/CommonConstants.ets @@ -152,10 +152,10 @@ export class CommonConstants { * AppStorage key prefix. */ public static readonly KEY_PREFIX: string = 'WindowPip'; - public static readonly KEY_PREFIX_BREAKPOINT: string = CommonConstants.KEY_PREFIX + 'WindowPipCurrentBreakpoint'; - public static readonly KEY_PREFIX_NAVIGATOR_BAR_HEIGHT: string = CommonConstants.KEY_PREFIX + 'WindowPipNavigatorBarHeight'; - public static readonly KEY_PREFIX_STATUS_BAR_HEIGHT: string = CommonConstants.KEY_PREFIX + 'WindowPipStatusBarHeight'; - public static readonly KEY_PREFIX_SYSTEM_COLOR_MODE: string = CommonConstants.KEY_PREFIX + 'WindowPipSystemColorMode'; - public static readonly KEY_PREFIX_SYSTEM_UICONTEXT: string = CommonConstants.KEY_PREFIX + 'WindowPipUIContext'; - public static readonly KEY_PREFIX_SYSTEM_PAGE_INFO: string = CommonConstants.KEY_PREFIX + 'WindowPipPageInfos'; + public static readonly KEY_PREFIX_BREAKPOINT: string = CommonConstants.KEY_PREFIX + 'CurrentBreakpoint'; + public static readonly KEY_PREFIX_NAVIGATOR_BAR_HEIGHT: string = CommonConstants.KEY_PREFIX + 'NavigatorBarHeight'; + public static readonly KEY_PREFIX_STATUS_BAR_HEIGHT: string = CommonConstants.KEY_PREFIX + 'StatusBarHeight'; + public static readonly KEY_PREFIX_SYSTEM_COLOR_MODE: string = CommonConstants.KEY_PREFIX + 'SystemColorMode'; + public static readonly KEY_PREFIX_SYSTEM_UICONTEXT: string = CommonConstants.KEY_PREFIX + 'UIContext'; + public static readonly KEY_PREFIX_SYSTEM_PAGE_INFO: string = CommonConstants.KEY_PREFIX + 'PageInfos'; } diff --git a/windowpiplibrary/src/main/ets/utils/BreakpointSystem.ets b/windowpiplibrary/src/main/ets/utils/BreakpointSystem.ets index fc714de8bbed9a5962588691f65d6cd0617113de..f04e2f98d92b9609fba20521b0d413314e1d50ac 100644 --- a/windowpiplibrary/src/main/ets/utils/BreakpointSystem.ets +++ b/windowpiplibrary/src/main/ets/utils/BreakpointSystem.ets @@ -72,7 +72,7 @@ export class BreakpointType { export class BreakpointSystem { private static instance: BreakpointSystem; private currentBreakpoint: BreakpointTypeEnum = BreakpointTypeEnum.MD; - private uiContext: UIContext = AppStorage.get(CommonConstants.KEY_PREFIX_BREAKPOINT) as UIContext; + private uiContext: UIContext = AppStorage.get(CommonConstants.KEY_PREFIX_SYSTEM_UICONTEXT) as UIContext; private constructor() { } diff --git a/windowpipsample/src/main/ets/pages/Index.ets b/windowpipsample/src/main/ets/pages/Index.ets index 04dab4966cb805bfa3244499df3fc40ce7ed9ca1..03d2286d90f74279b277fc4c61c46eb99eb1ba59 100644 --- a/windowpipsample/src/main/ets/pages/Index.ets +++ b/windowpipsample/src/main/ets/pages/Index.ets @@ -13,15 +13,14 @@ * limitations under the License. */ -import { WindowPipComponent } from '@ohos_sample/windowpiplibrary'; - +import { VideoPlayComponent } from '@ohos_sample/windowpiplibrary'; @Entry @Component struct WindowPip { build() { Stack() { - WindowPipComponent() + VideoPlayComponent() } } } \ No newline at end of file