diff --git a/LICENSE b/LICENSE deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/README.md b/README.md index ed693173db354c121af46e5126c3e36afea41393..0641e527622f2ef6f715a5c7e1a26098a6055bb0 100755 --- a/README.md +++ b/README.md @@ -39,10 +39,4 @@ 1. 本示例仅支持标准系统上运行,支持设备:华为手机。 2. HarmonyOS系统:HarmonyOS NEXT Developer Beta1及以上。 3. DevEco Studio版本:DevEco Studio NEXT Developer Beta1及以上。 -4. HarmonyOS SDK版本:HarmonyOS NEXT Developer Beta1 SDK及以上。 - -### 注意 - -运行时需设置引用所有HSP模块。点击Run > Edit Configurations,选择Deploy Multi Hap标签页,勾选Deploy Multi Hap Packages, 选择使用方模块(phone)和所有HSP模块,点击OK。单击Run > Run "模块名称"(如Run "phone")或![](screenshots/device/run.png)来启动应用/服务的编译构建。 - -![](screenshots/device/config.png) +4. HarmonyOS SDK版本:HarmonyOS NEXT Developer Beta1 SDK及以上。 \ No newline at end of file diff --git a/commons/base/BuildProfile.ets b/commons/base/BuildProfile.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a501e5ddee8ea6d28961648fc7dd314a5304bd4 --- /dev/null +++ b/commons/base/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/commons/base/hvigorfile.ts b/commons/base/hvigorfile.ts index 64fa6f97b15f9d477f14026c181352882b94a21b..436f2eeb38d8a2e8fbd7e864cca9ddfa86d16a98 100755 --- a/commons/base/hvigorfile.ts +++ b/commons/base/hvigorfile.ts @@ -1,6 +1,6 @@ -import { hspTasks } from '@ohos/hvigor-ohos-plugin'; +import { harTasks } from '@ohos/hvigor-ohos-plugin'; export default { - system: hspTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ } diff --git a/commons/base/src/main/ets/constants/BreakpointConstants.ets b/commons/base/src/main/ets/constants/BreakpointConstants.ets index 77a84a94b5e9c2de1b30b9ed72b6665978a7bc85..e1bc913b0ca8ad6fe965bca756a05bfd7fc57a0a 100755 --- a/commons/base/src/main/ets/constants/BreakpointConstants.ets +++ b/commons/base/src/main/ets/constants/BreakpointConstants.ets @@ -51,4 +51,8 @@ export class BreakpointConstants { * Large device width. */ static readonly LARGE_DEVICE_WIDTH: number = 840; + /** + * Breakpoints that represent large device types. + */ + static readonly BREAKPOINT_SCOPE: number[] = [0, 320, 600, 840]; } \ No newline at end of file diff --git a/commons/base/src/main/module.json5 b/commons/base/src/main/module.json5 index eb28b576e25a85f1c79c8b3cfedf1c28eaec24d9..169b18e9b265f521951c77c33ba87674aad045ec 100755 --- a/commons/base/src/main/module.json5 +++ b/commons/base/src/main/module.json5 @@ -1,13 +1,11 @@ { "module": { "name": "base", - "type": "shared", - "description": "$string:shared_desc", + "type": "har", "deviceTypes": [ "phone", "tablet", "2in1" - ], - "deliveryWithInstall": true, + ] } } \ No newline at end of file diff --git a/features/albumView/BuildProfile.ets b/features/albumView/BuildProfile.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a501e5ddee8ea6d28961648fc7dd314a5304bd4 --- /dev/null +++ b/features/albumView/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/features/albumView/Index.ets b/features/albumView/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..ddf5ef1395bdc8d31ba30d6118834b6bb3168108 --- /dev/null +++ b/features/albumView/Index.ets @@ -0,0 +1 @@ +export { AlbumView } from './src/main/ets/views/AlbumView'; \ No newline at end of file diff --git a/features/albumView/hvigorfile.ts b/features/albumView/hvigorfile.ts index 64fa6f97b15f9d477f14026c181352882b94a21b..436f2eeb38d8a2e8fbd7e864cca9ddfa86d16a98 100755 --- a/features/albumView/hvigorfile.ts +++ b/features/albumView/hvigorfile.ts @@ -1,6 +1,6 @@ -import { hspTasks } from '@ohos/hvigor-ohos-plugin'; +import { harTasks } from '@ohos/hvigor-ohos-plugin'; export default { - system: hspTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ } diff --git a/features/albumView/oh-package.json5 b/features/albumView/oh-package.json5 index 5dcf579f812cb85edbbc8a9c5710c48a24e3b09c..b86f0c7cbf5ac4ce148f9751ede51abe5873929f 100755 --- a/features/albumView/oh-package.json5 +++ b/features/albumView/oh-package.json5 @@ -1,6 +1,7 @@ { "license": "Apache-2.0", "devDependencies": {}, + "main": "Index.ets", "author": "", "name": "albumview", "description": "Please describe the basic information.", diff --git a/features/albumView/src/main/ets/pages/AlbumViewIndex.ets b/features/albumView/src/main/ets/views/AlbumView.ets old mode 100755 new mode 100644 similarity index 72% rename from features/albumView/src/main/ets/pages/AlbumViewIndex.ets rename to features/albumView/src/main/ets/views/AlbumView.ets index afa3b4a3f60822575d126cd0cde1326937cb7865..96a5667b24cfe35b11fa9e18f3828960018ea305 --- a/features/albumView/src/main/ets/pages/AlbumViewIndex.ets +++ b/features/albumView/src/main/ets/views/AlbumView.ets @@ -1,196 +1,198 @@ -/* - * 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 { router } from '@kit.ArkUI'; -import { SideColumn } from '../views/SideColumn'; -import { AlbumViewConstants, ImageData } from '../constants/AlbumViewConstants' -import { BaseConstants, BreakpointConstants } from '@ohos/commons'; -import { deviceInfo } from '@kit.BasicServicesKit'; - -// Grid unit. -const DEFAULT_GRID_TEMPLATE: string = '1fr'; -// Animate tiem. -const ANIMATE_TIME: number = 100; -// Max grid column. -const MAX_GRID_COLUMN = 16; -// Min grid column. -const MIN_GRID_COLUMN = 2; -// Finger number. -const FINGER_NUMBER = 2; -// Delay time -const DELAY = 70 -// Final delay time -const FINAL_DELAY = 100 - -@Entry -@Component -struct AlbumViewIndex { - @StorageLink('currentBreakpoint') currentBp: string = BreakpointConstants.BREAKPOINT_SM; - // Grid column num. - @State gridColumn: number = 3; - // Grid row num. - @State gridRow: number = 2; - // Save up setTimeOut - timeOutUpDemo: number = 0 - // Save down setTimeOut - timeOutDownDemo: number = 0 - - // Change the number of Grid columns based on the width of the Grid component. - getGridColumn(value: Length): number { - return Math.floor(2 * ((parseInt(JSON.stringify(value)) / 360) - 1) + 4); - } - - // PinchGesture up - up() { - if (!this.timeOutUpDemo) { - this.timeOutUpDemo = setTimeout(() => { - animateTo({ - duration: ANIMATE_TIME - }, () => { - if (this.gridColumn > MIN_GRID_COLUMN) { - this.gridColumn -= 1; - clearTimeout(this.timeOutUpDemo) - this.timeOutUpDemo = 0 - } - }) - }, DELAY) - } - setTimeout(() => { - this.timeOutUpDemo = 0 - }, FINAL_DELAY) - } - - // PinchGesture down - down() { - if (!this.timeOutDownDemo) { - this.timeOutDownDemo = setTimeout(() => { - animateTo({ - duration: ANIMATE_TIME - }, () => { - if (this.gridColumn < MAX_GRID_COLUMN) { - this.gridColumn += 1; - clearTimeout(this.timeOutDownDemo) - this.timeOutDownDemo = 0 - } - }) - - }, DELAY) - } - setTimeout(() => { - this.timeOutDownDemo = 0 - }, FINAL_DELAY) - - } - - @Builder - topRow() { - Column() { - Row() { - Button({ type: ButtonType.Circle, stateEffect: false }) { - Image($r('app.media.ic_public_back')) - .width(BaseConstants.DEFAULT_ICON_SIZE) - .height(BaseConstants.DEFAULT_ICON_SIZE) - .onClick(() => { - router.back() - }) - } - .width(BaseConstants.DEFAULT_ICON_SIZE) - .height(BaseConstants.DEFAULT_ICON_SIZE) - .backgroundColor(Color.White) - .margin({ right: $r('app.float.back_image_right') }) - - Text(AlbumViewConstants.DES_TEXT) - .fontSize(BaseConstants.FONT_SIZE_TWENTY) - .height($r('app.float.text_image_height')) - Blank() - - if (this.currentBp === BreakpointConstants.BREAKPOINT_LG) { - Button({ type: ButtonType.Circle, stateEffect: false }) { - Image($r('app.media.ic_gallery_material_select_checkbox')) - .width(BaseConstants.DEFAULT_ICON_SIZE) - .height(BaseConstants.DEFAULT_ICON_SIZE) - } - .width(BaseConstants.DEFAULT_ICON_SIZE) - .height(BaseConstants.DEFAULT_ICON_SIZE) - .backgroundColor(Color.White) - .margin({ right: $r('app.float.select_button_margin_right') }) - } - - Button({ type: ButtonType.Circle, stateEffect: false }) { - Image($r('app.media.ic_public_more')) - .width(BaseConstants.DEFAULT_ICON_SIZE) - .height(BaseConstants.DEFAULT_ICON_SIZE) - } - .width(BaseConstants.DEFAULT_ICON_SIZE) - .height(BaseConstants.DEFAULT_ICON_SIZE) - .backgroundColor(Color.White) - - } - .width(BaseConstants.FULL_WIDTH) - .height($r('app.float.tab_height')) - .backgroundColor(Color.White) - .padding({ - left: $r('app.float.tab_left'), - right: $r('app.float.tab_right'), - top: $r('app.float.tab_top'), - bottom: $r('app.float.tab_bottom') - }) - .visibility(Visibility.Visible) - } - } - - build() { - Flex() { - if (this.currentBp === BreakpointConstants.BREAKPOINT_LG) { - SideColumn() - .width($r('app.float.side_width')) - } - Flex({ direction: FlexDirection.Column }) { - this.topRow() - Flex() { - Grid() { - ForEach(AlbumViewConstants.IMAGE_LIST, (item: ImageData) => { - GridItem() { - Image(item.src) - .objectFit(ImageFit.Cover) - .autoResize(true) - .borderColor(item.selected ? Color.Blue : Color.White) - .borderWidth(1) - }.aspectRatio(1) - }, (item: ImageData, index: number) => index + JSON.stringify(item)) - } - .columnsTemplate(new Array(this.gridColumn).fill(DEFAULT_GRID_TEMPLATE).join(' ')) - - } - .onAreaChange((oldValue: Area, newValue: Area) => { - this.gridColumn = this.getGridColumn(newValue.width); - }) - .gesture(PinchGesture({ fingers: FINGER_NUMBER }).onActionUpdate((event: GestureEvent) => { - if (event.scale > 1) { - this.up() - } else { - this.down() - } - })) - } - } - .padding({ - top: deviceInfo.deviceType === BaseConstants.DEVICE_2IN1 ? $r('app.float.zero') : - $r('app.float.device_padding_top'), - bottom: deviceInfo.deviceType !== BaseConstants.DEVICE_2IN1 ? - $r('app.float.tab_content_pb') : $r('app.float.zero') - }) - } +/* + * 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 { SideColumn } from './SideColumn'; +import { AlbumViewConstants, ImageData } from '../constants/AlbumViewConstants' +import { BaseConstants, BreakpointConstants } from '@ohos/commons/'; +import { deviceInfo } from '@kit.BasicServicesKit'; + +// Grid unit. +const DEFAULT_GRID_TEMPLATE: string = '1fr'; +// Animate tiem. +const ANIMATE_TIME: number = 100; +// Max grid column. +const MAX_GRID_COLUMN = 16; +// Min grid column. +const MIN_GRID_COLUMN = 2; +// Finger number. +const FINGER_NUMBER = 2; +// Delay time +const DELAY = 70 +// Final delay time +const FINAL_DELAY = 100 + +@Component +export struct AlbumView { + @StorageLink('currentBreakpoint') currentBp: string = BreakpointConstants.BREAKPOINT_SM; + // Grid column num. + @State gridColumn: number = 3; + // Grid row num. + @State gridRow: number = 2; + @Consume('pageInfos') pageInfos: NavPathStack; + // Save up setTimeOut + timeOutUpDemo: number = 0 + // Save down setTimeOut + timeOutDownDemo: number = 0 + + // Change the number of Grid columns based on the width of the Grid component. + getGridColumn(value: Length): number { + return Math.floor(2 * ((parseInt(JSON.stringify(value)) / 360) - 1) + 4); + } + + // PinchGesture up + up() { + if (!this.timeOutUpDemo) { + this.timeOutUpDemo = setTimeout(() => { + animateTo({ + duration: ANIMATE_TIME + }, () => { + if (this.gridColumn > MIN_GRID_COLUMN) { + this.gridColumn -= 1; + clearTimeout(this.timeOutUpDemo) + this.timeOutUpDemo = 0 + } + }) + }, DELAY) + } + setTimeout(() => { + this.timeOutUpDemo = 0 + }, FINAL_DELAY) + } + + // PinchGesture down + down() { + if (!this.timeOutDownDemo) { + this.timeOutDownDemo = setTimeout(() => { + animateTo({ + duration: ANIMATE_TIME + }, () => { + if (this.gridColumn < MAX_GRID_COLUMN) { + this.gridColumn += 1; + clearTimeout(this.timeOutDownDemo) + this.timeOutDownDemo = 0 + } + }) + + }, DELAY) + } + setTimeout(() => { + this.timeOutDownDemo = 0 + }, FINAL_DELAY) + + } + + @Builder + topRow() { + Column() { + Row() { + Button({ type: ButtonType.Circle, stateEffect: false }) { + Image($r('app.media.ic_public_back')) + .width(BaseConstants.DEFAULT_ICON_SIZE) + .height(BaseConstants.DEFAULT_ICON_SIZE) + .onClick(() => { + this.pageInfos.pop(); + }) + } + .width(BaseConstants.DEFAULT_ICON_SIZE) + .height(BaseConstants.DEFAULT_ICON_SIZE) + .backgroundColor(Color.White) + .margin({ right: $r('app.float.back_image_right') }) + + Text(AlbumViewConstants.DES_TEXT) + .fontSize(BaseConstants.FONT_SIZE_TWENTY) + .height($r('app.float.text_image_height')) + Blank() + + if (this.currentBp === BreakpointConstants.BREAKPOINT_LG) { + Button({ type: ButtonType.Circle, stateEffect: false }) { + Image($r('app.media.ic_gallery_material_select_checkbox')) + .width(BaseConstants.DEFAULT_ICON_SIZE) + .height(BaseConstants.DEFAULT_ICON_SIZE) + } + .width(BaseConstants.DEFAULT_ICON_SIZE) + .height(BaseConstants.DEFAULT_ICON_SIZE) + .backgroundColor(Color.White) + .margin({ right: $r('app.float.select_button_margin_right') }) + } + + Button({ type: ButtonType.Circle, stateEffect: false }) { + Image($r('app.media.ic_public_more')) + .width(BaseConstants.DEFAULT_ICON_SIZE) + .height(BaseConstants.DEFAULT_ICON_SIZE) + } + .width(BaseConstants.DEFAULT_ICON_SIZE) + .height(BaseConstants.DEFAULT_ICON_SIZE) + .backgroundColor(Color.White) + + } + .width(BaseConstants.FULL_WIDTH) + .height($r('app.float.tab_height')) + .backgroundColor(Color.White) + .padding({ + left: $r('app.float.tab_left'), + right: $r('app.float.tab_right'), + top: $r('app.float.tab_top'), + bottom: $r('app.float.tab_bottom') + }) + .visibility(Visibility.Visible) + } + } + + build() { + NavDestination() { + Flex() { + if (this.currentBp === BreakpointConstants.BREAKPOINT_LG) { + SideColumn() + .width($r('app.float.side_width')) + } + Flex({ direction: FlexDirection.Column }) { + this.topRow() + Flex() { + Grid() { + ForEach(AlbumViewConstants.IMAGE_LIST, (item: ImageData) => { + GridItem() { + Image(item.src) + .objectFit(ImageFit.Cover) + .autoResize(true) + .borderColor(item.selected ? Color.Blue : Color.White) + .borderWidth(1) + }.aspectRatio(1) + }, (item: ImageData, index: number) => index + JSON.stringify(item)) + } + .columnsTemplate(new Array(this.gridColumn).fill(DEFAULT_GRID_TEMPLATE).join(' ')) + + } + .onAreaChange((oldValue: Area, newValue: Area) => { + this.gridColumn = this.getGridColumn(newValue.width); + }) + .gesture(PinchGesture({ fingers: FINGER_NUMBER }).onActionUpdate((event: GestureEvent) => { + if (event.scale > 1) { + this.up() + } else { + this.down() + } + })) + } + } + .padding({ + top: deviceInfo.deviceType === BaseConstants.DEVICE_2IN1 ? $r('app.float.zero') : + $r('app.float.device_padding_top'), + bottom: deviceInfo.deviceType !== BaseConstants.DEVICE_2IN1 ? + $r('app.float.tab_content_pb') : $r('app.float.zero') + }) + } + .hideTitleBar(true) + } } \ No newline at end of file diff --git a/features/albumView/src/main/module.json5 b/features/albumView/src/main/module.json5 index bc394f51efe044e6e95c8933a74286ecabba991e..eac6ce3d1321ceb4450c6d668f426625b9eb610b 100755 --- a/features/albumView/src/main/module.json5 +++ b/features/albumView/src/main/module.json5 @@ -1,14 +1,11 @@ { "module": { "name": "albumView", - "type": "shared", - "description": "$string:shared_desc", + "type": "har", "deviceTypes": [ "phone", "tablet", "2in1" - ], - "deliveryWithInstall": true, - "pages": "$profile:main_pages" + ] } } \ No newline at end of file diff --git a/features/albumView/src/main/resources/base/element/float.json b/features/albumView/src/main/resources/base/element/float.json index 403ec88d29e3000422745af3e89213a984dbcd8d..bcab1852f20f0d7481cf454c1d68364dba38f647 100755 --- a/features/albumView/src/main/resources/base/element/float.json +++ b/features/albumView/src/main/resources/base/element/float.json @@ -74,7 +74,7 @@ }, { "name": "search_height", - "value": "48vp" + "value": "52vp" }, { "name": "search_stack_right", diff --git a/features/albumView/src/main/resources/base/profile/main_pages.json b/features/albumView/src/main/resources/base/profile/main_pages.json deleted file mode 100755 index d2e397f3fd2c47afcbdcfa7d4de247e5b8f1efea..0000000000000000000000000000000000000000 --- a/features/albumView/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/AlbumViewIndex" - ] -} diff --git a/features/pictureEdit/BuildProfile.ets b/features/pictureEdit/BuildProfile.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a501e5ddee8ea6d28961648fc7dd314a5304bd4 --- /dev/null +++ b/features/pictureEdit/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/features/pictureEdit/Index.ets b/features/pictureEdit/Index.ets index f1d9b1dda939ae56aa34dc9b8e5fedd0d42aa47a..7221c0563b9f27334cd39c7807be74b8e3588bf0 100755 --- a/features/pictureEdit/Index.ets +++ b/features/pictureEdit/Index.ets @@ -13,4 +13,4 @@ * limitations under the License. */ -export { PictureEditIndex } from './src/main/ets/pages/PictureEditIndex' \ No newline at end of file +export { PictureEdit } from './src/main/ets/views/PictureEdit' \ No newline at end of file diff --git a/features/pictureEdit/hvigorfile.ts b/features/pictureEdit/hvigorfile.ts index 64fa6f97b15f9d477f14026c181352882b94a21b..436f2eeb38d8a2e8fbd7e864cca9ddfa86d16a98 100755 --- a/features/pictureEdit/hvigorfile.ts +++ b/features/pictureEdit/hvigorfile.ts @@ -1,6 +1,6 @@ -import { hspTasks } from '@ohos/hvigor-ohos-plugin'; +import { harTasks } from '@ohos/hvigor-ohos-plugin'; export default { - system: hspTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ } diff --git a/features/pictureEdit/src/main/ets/pages/PictureEditIndex.ets b/features/pictureEdit/src/main/ets/views/PictureEdit.ets old mode 100755 new mode 100644 similarity index 85% rename from features/pictureEdit/src/main/ets/pages/PictureEditIndex.ets rename to features/pictureEdit/src/main/ets/views/PictureEdit.ets index 0946e9bc6acd1909eae869a960f61d311d933dad..38d59db9f1cfd230bbb6d4c7f579ce2ea7bd49a1 --- a/features/pictureEdit/src/main/ets/pages/PictureEditIndex.ets +++ b/features/pictureEdit/src/main/ets/views/PictureEdit.ets @@ -1,235 +1,238 @@ -/* - * 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 { router } from '@kit.ArkUI'; -import { BaseConstants, BreakpointConstants } from '@ohos/commons'; -import PictureEditConstants from '../constants/PictureEditConstants'; -import { deviceInfo } from '@kit.BasicServicesKit'; - -interface ToolsAndName { - pic: Resource - pic_name: string -} - -interface PicAndName { - pic: Resource - pic_name: string - color_filter: number[] -} - -@Entry -@Component -export struct PictureEditIndex { - @StorageLink('currentBreakpoint') currentBp: string = BreakpointConstants.BREAKPOINT_MD; - @State outSetValueOne: number = 40; - @State windowDirection: boolean = true; - @State pictureWidth: string = BaseConstants.FULL_WIDTH; - - isColumnLayout(bp: string, direction: Boolean): Boolean { - if (bp === BreakpointConstants.BREAKPOINT_SM) { - this.pictureWidth = PictureEditConstants.PICTURE_WIDTH_SM; - return true; - } - if (bp === BreakpointConstants.BREAKPOINT_LG) { - this.pictureWidth = PictureEditConstants.PICTURE_WIDTH_LG; - return false; - } - if (direction) { - this.pictureWidth = PictureEditConstants.PICTURE_WIDTH_MD_ROW; - } else { - this.pictureWidth = PictureEditConstants.PICTURE_WIDTH_MD_COLUMN; - } - return !direction; - } - - @Builder - topBar() { - Row() { - Image($r('app.media.ic_public_back')) - .width(BaseConstants.DEFAULT_ICON_SIZE) - .height(BaseConstants.DEFAULT_ICON_SIZE) - .onClick(() => { - router.back(); - }) - .margin({ - left: $r('app.float.back_image_left'), - right: $r('app.float.back_image_right') - }) - - Text(PictureEditConstants.Edit_Text) - .fontSize(BaseConstants.FONT_SIZE_TWENTY) - .fontColor(Color.White) - Blank() - if (this.currentBp === BreakpointConstants.BREAKPOINT_MD) { - Image(this.windowDirection ? $r('app.media.change2') : $r('app.media.change')) - .width(BaseConstants.DEFAULT_ICON_SIZE) - .height(BaseConstants.DEFAULT_ICON_SIZE) - .margin({ right: $r('app.float.image_right') }) - .onClick(() => { - this.windowDirection = !this.windowDirection; - }) - } - Image($r('app.media.ic_add_2')) - .width(BaseConstants.DEFAULT_ICON_SIZE) - .height(BaseConstants.DEFAULT_ICON_SIZE) - .margin({ right: $r('app.float.image_right') }) - Image($r('app.media.ic_add_3')) - .width(BaseConstants.DEFAULT_ICON_SIZE) - .height(BaseConstants.DEFAULT_ICON_SIZE) - .margin({ right: $r('app.float.image_right') }) - - Image($r('app.media.ic_add_4')) - .width(BaseConstants.DEFAULT_ICON_SIZE) - .height(BaseConstants.DEFAULT_ICON_SIZE) - .margin({ right: $r('app.float.image_right') }) - - } - .alignItems(VerticalAlign.Center) - .height($r('app.float.row_height')) - .width(BaseConstants.FULL_WIDTH) - .backgroundColor(Color.Black) - } - - @Builder - centerPicture() { - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - Image($r("app.media.photo")) - .interpolation(ImageInterpolation.High) - .objectFit(ImageFit.Cover) - .autoResize(true) - .height(PictureEditConstants.PICTURE_HEIGHT) - .width(this.pictureWidth) - } - } - - @Builder - optionRegion() { - Flex({ - direction: this.isColumnLayout(this.currentBp, this.windowDirection) ? FlexDirection.Column : FlexDirection.Row - }) { - Flex() { - this.sliderBar() - } - .flexBasis(PictureEditConstants.SLIDER_FLEX_BASIS) - - this.filterWindows() - Flex({ justifyContent: FlexAlign.Center }) { - this.bottomBar() - } - .flexBasis(PictureEditConstants.BAR_FLEX_BASIS) - } - .height(this.isColumnLayout(this.currentBp, this.windowDirection) ? BaseConstants.FULL_HEIGHT : - PictureEditConstants.PICTURE_HALF_HEIGHT) - .padding($r('app.float.row_padding')) - } - - @Builder - sliderBar() { - Column() { - Slider({ - value: this.outSetValueOne, - min: 0, - max: 100, - style: SliderStyle.OutSet, - direction: this.isColumnLayout(this.currentBp, this.windowDirection) ? Axis.Horizontal : Axis.Vertical, - reverse: this.isColumnLayout(this.currentBp, this.windowDirection) ? false : true - }) - .blockColor(Color.White) - .selectedColor(Color.White) - .trackColor($r('app.color.track_color')) - .showTips(true) - .onChange((value: number) => { - this.outSetValueOne = value; - }) - } - } - - @Builder - filterWindows() { - List() { - ForEach(PictureEditConstants.filterAndName, (item: PicAndName) => { - ListItem() { - Stack() { - Image(item.pic) - .height($r('app.float.image_height')) - .aspectRatio(1) - .autoResize(true) - .colorFilter(item.color_filter) - .clip(true) - .borderRadius(PictureEditConstants.IMAGE_BORDER_RADIUS) - Text(item.pic_name) - .fontSize(BaseConstants.FONT_SIZE_TEN) - .fontColor($r('app.color.text_color')) - .margin({ left: $r('app.float.text_margin'), bottom: $r('app.float.text_margin') }) - } - .alignContent(Alignment.BottomStart) - } - },(item: PicAndName, index: number) => index + JSON.stringify(item)) - } - .listDirection(this.isColumnLayout(this.currentBp, this.windowDirection) ? Axis.Horizontal : Axis.Vertical) - } - - @Builder - bottomBar() { - Flex({ - justifyContent: this.isColumnLayout(this.currentBp, this.windowDirection) ? FlexAlign.SpaceAround : - FlexAlign.SpaceAround, - alignItems: ItemAlign.Center, - direction: this.isColumnLayout(this.currentBp, this.windowDirection) ? FlexDirection.Row : FlexDirection.Column, - }) { - - ForEach(PictureEditConstants.toolsAndName, (item: ToolsAndName) => { - Column() { - Image(item.pic) - .height(BaseConstants.DEFAULT_ICON_SIZE) - .autoResize(true) - .aspectRatio(1) - .margin({ bottom: $r('app.float.image_margin') }) - Text(item.pic_name) - .fontSize(BaseConstants.FONT_SIZE_TEN) - .fontColor($r('app.color.text_color')) - } - }, (item: ToolsAndName) => item.pic_name - ) - } - } - - build() { - Flex({ direction: FlexDirection.Column }) { - this.topBar() - Flex({ - direction: this.isColumnLayout(this.currentBp, this.windowDirection) ? FlexDirection.Column : FlexDirection.Row - }) { - Flex() { - this.centerPicture() - } - .flexShrink(1) - - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - this.optionRegion() - } - .flexBasis(PictureEditConstants.OPTION_FLEX_BASIS) - .height(BaseConstants.FULL_HEIGHT) - } - } - .backgroundColor(Color.Black) - .padding({ - top: deviceInfo.deviceType === BaseConstants.DEVICE_2IN1 ? $r('app.float.zero') : - $r('app.float.device_padding_top'), - bottom: deviceInfo.deviceType !== BaseConstants.DEVICE_2IN1 ? - $r('app.float.tab_content_pb') : $r('app.float.zero') - }) - } +/* + * 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 { BaseConstants, BreakpointConstants } from '@ohos/commons/'; +import PictureEditConstants from '../constants/PictureEditConstants'; +import { deviceInfo } from '@kit.BasicServicesKit'; + +interface ToolsAndName { + pic: Resource + pic_name: string +} + +interface PicAndName { + pic: Resource + pic_name: string + color_filter: number[] +} + +@Component +export struct PictureEdit { + @StorageLink('currentBreakpoint') currentBp: string = BreakpointConstants.BREAKPOINT_MD; + @State outSetValueOne: number = 40; + @State windowDirection: boolean = true; + @State pictureWidth: string = BaseConstants.FULL_WIDTH; + @Consume('pageInfos') pageInfos: NavPathStack; + + isColumnLayout(bp: string, direction: Boolean): Boolean { + if (bp === BreakpointConstants.BREAKPOINT_SM) { + this.pictureWidth = PictureEditConstants.PICTURE_WIDTH_SM; + return true; + } + if (bp === BreakpointConstants.BREAKPOINT_LG) { + this.pictureWidth = PictureEditConstants.PICTURE_WIDTH_LG; + return false; + } + if (direction) { + this.pictureWidth = PictureEditConstants.PICTURE_WIDTH_MD_ROW; + } else { + this.pictureWidth = PictureEditConstants.PICTURE_WIDTH_MD_COLUMN; + } + return !direction; + } + + @Builder + topBar() { + Row() { + Image($r('app.media.ic_public_back')) + .width(BaseConstants.DEFAULT_ICON_SIZE) + .height(BaseConstants.DEFAULT_ICON_SIZE) + .onClick(() => { + this.pageInfos.pop(); + }) + .margin({ + left: $r('app.float.back_image_left'), + right: $r('app.float.back_image_right') + }) + + Text(PictureEditConstants.Edit_Text) + .fontSize(BaseConstants.FONT_SIZE_TWENTY) + .fontColor(Color.White) + Blank() + if (this.currentBp === BreakpointConstants.BREAKPOINT_MD) { + Image(this.windowDirection ? $r('app.media.change2') : $r('app.media.change')) + .width(BaseConstants.DEFAULT_ICON_SIZE) + .height(BaseConstants.DEFAULT_ICON_SIZE) + .margin({ right: $r('app.float.image_right') }) + .onClick(() => { + this.windowDirection = !this.windowDirection; + }) + } + Image($r('app.media.ic_add_2')) + .width(BaseConstants.DEFAULT_ICON_SIZE) + .height(BaseConstants.DEFAULT_ICON_SIZE) + .margin({ right: $r('app.float.image_right') }) + Image($r('app.media.ic_add_3')) + .width(BaseConstants.DEFAULT_ICON_SIZE) + .height(BaseConstants.DEFAULT_ICON_SIZE) + .margin({ right: $r('app.float.image_right') }) + + Image($r('app.media.ic_add_4')) + .width(BaseConstants.DEFAULT_ICON_SIZE) + .height(BaseConstants.DEFAULT_ICON_SIZE) + .margin({ right: $r('app.float.image_right') }) + + } + .alignItems(VerticalAlign.Center) + .height($r('app.float.row_height')) + .width(BaseConstants.FULL_WIDTH) + .backgroundColor(Color.Black) + } + + @Builder + centerPicture() { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Image($r("app.media.photo")) + .interpolation(ImageInterpolation.High) + .objectFit(ImageFit.Cover) + .autoResize(true) + .height(PictureEditConstants.PICTURE_HEIGHT) + .width(this.pictureWidth) + } + } + + @Builder + optionRegion() { + Flex({ + direction: this.isColumnLayout(this.currentBp, this.windowDirection) ? FlexDirection.Column : FlexDirection.Row + }) { + Flex() { + this.sliderBar() + } + .flexBasis(PictureEditConstants.SLIDER_FLEX_BASIS) + + this.filterWindows() + Flex({ justifyContent: FlexAlign.Center }) { + this.bottomBar() + } + .flexBasis(PictureEditConstants.BAR_FLEX_BASIS) + } + .height(this.isColumnLayout(this.currentBp, this.windowDirection) ? BaseConstants.FULL_HEIGHT : + PictureEditConstants.PICTURE_HALF_HEIGHT) + .padding($r('app.float.row_padding')) + } + + @Builder + sliderBar() { + Column() { + Slider({ + value: this.outSetValueOne, + min: 0, + max: 100, + style: SliderStyle.OutSet, + direction: this.isColumnLayout(this.currentBp, this.windowDirection) ? Axis.Horizontal : Axis.Vertical, + reverse: this.isColumnLayout(this.currentBp, this.windowDirection) ? false : true + }) + .blockColor(Color.White) + .selectedColor(Color.White) + .trackColor($r('app.color.track_color')) + .showTips(true) + .onChange((value: number) => { + this.outSetValueOne = value; + }) + } + } + + @Builder + filterWindows() { + List() { + ForEach(PictureEditConstants.filterAndName, (item: PicAndName) => { + ListItem() { + Stack() { + Image(item.pic) + .height($r('app.float.image_height')) + .aspectRatio(1) + .autoResize(true) + .colorFilter(item.color_filter) + .clip(true) + .borderRadius(PictureEditConstants.IMAGE_BORDER_RADIUS) + Text(item.pic_name) + .fontSize(BaseConstants.FONT_SIZE_TEN) + .fontColor($r('app.color.text_color')) + .margin({ left: $r('app.float.text_margin'), bottom: $r('app.float.text_margin') }) + } + .alignContent(Alignment.BottomStart) + } + },(item: PicAndName, index: number) => index + JSON.stringify(item)) + } + .listDirection(this.isColumnLayout(this.currentBp, this.windowDirection) ? Axis.Horizontal : Axis.Vertical) + } + + @Builder + bottomBar() { + Flex({ + justifyContent: this.isColumnLayout(this.currentBp, this.windowDirection) ? FlexAlign.SpaceAround : + FlexAlign.SpaceAround, + alignItems: ItemAlign.Center, + direction: this.isColumnLayout(this.currentBp, this.windowDirection) ? FlexDirection.Row : FlexDirection.Column, + }) { + + ForEach(PictureEditConstants.toolsAndName, (item: ToolsAndName) => { + Column() { + Image(item.pic) + .height(BaseConstants.DEFAULT_ICON_SIZE) + .autoResize(true) + .aspectRatio(1) + .margin({ bottom: $r('app.float.image_margin') }) + Text(item.pic_name) + .fontSize(BaseConstants.FONT_SIZE_TEN) + .fontColor($r('app.color.text_color')) + } + }, (item: ToolsAndName) => item.pic_name + ) + } + } + + build() { + NavDestination(){ + Flex({ direction: FlexDirection.Column }) { + this.topBar() + Flex({ + direction: this.isColumnLayout(this.currentBp, this.windowDirection) ? FlexDirection.Column : FlexDirection.Row + }) { + Flex() { + this.centerPicture() + } + .flexShrink(1) + + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + this.optionRegion() + } + .flexBasis(PictureEditConstants.OPTION_FLEX_BASIS) + .height(BaseConstants.FULL_HEIGHT) + } + } + .backgroundColor(Color.Black) + .padding({ + top: deviceInfo.deviceType === BaseConstants.DEVICE_2IN1 ? $r('app.float.zero') : + $r('app.float.device_padding_top'), + bottom: deviceInfo.deviceType !== BaseConstants.DEVICE_2IN1 ? + $r('app.float.tab_content_pb') : $r('app.float.zero') + }) + } + .hideTitleBar(true) + + } } \ No newline at end of file diff --git a/features/pictureEdit/src/main/module.json5 b/features/pictureEdit/src/main/module.json5 index 0e115069cce3b9b75be1d5c16808fe151ddf5988..b67e5f8b02499ad07b21eefea12b084fd57975ba 100755 --- a/features/pictureEdit/src/main/module.json5 +++ b/features/pictureEdit/src/main/module.json5 @@ -1,14 +1,11 @@ { "module": { "name": "pictureEdit", - "type": "shared", - "description": "$string:shared_desc", + "type": "har", "deviceTypes": [ "phone", "tablet", "2in1" - ], - "deliveryWithInstall": true, - "pages": "$profile:main_pages" + ] } } \ No newline at end of file diff --git a/features/pictureEdit/src/main/resources/base/profile/main_pages.json b/features/pictureEdit/src/main/resources/base/profile/main_pages.json index bcf9c3a506e4f0ee56909c8b1f16d9bfd35c549e..f3ee419dbc6ab7a5ded7d3136ec5913e5f2b33d6 100755 --- a/features/pictureEdit/src/main/resources/base/profile/main_pages.json +++ b/features/pictureEdit/src/main/resources/base/profile/main_pages.json @@ -1,5 +1,2 @@ { - "src": [ - "pages/PictureEditIndex" - ] } diff --git a/features/pictureView/BuildProfile.ets b/features/pictureView/BuildProfile.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a501e5ddee8ea6d28961648fc7dd314a5304bd4 --- /dev/null +++ b/features/pictureView/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/features/pictureView/hvigorfile.ts b/features/pictureView/hvigorfile.ts index 64fa6f97b15f9d477f14026c181352882b94a21b..436f2eeb38d8a2e8fbd7e864cca9ddfa86d16a98 100755 --- a/features/pictureView/hvigorfile.ts +++ b/features/pictureView/hvigorfile.ts @@ -1,6 +1,6 @@ -import { hspTasks } from '@ohos/hvigor-ohos-plugin'; +import { harTasks } from '@ohos/hvigor-ohos-plugin'; export default { - system: hspTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ } diff --git a/features/pictureView/oh-package.json5 b/features/pictureView/oh-package.json5 index 157c2444a102e5ad021214777c74266eac549bcb..be4222943938243c84db70cb3fce7e89570b6f1d 100755 --- a/features/pictureView/oh-package.json5 +++ b/features/pictureView/oh-package.json5 @@ -7,6 +7,8 @@ "main": "Index.ets", "version": "1.0.0", "dependencies": { - "@ohos/commons": "file:../../commons/base" + "@ohos/commons": "file:../../commons/base", + "@ohos/album": "file:../../features/albumView", + "@ohos/pictureEdit": "file:../../features/pictureEdit" } } diff --git a/features/pictureView/src/main/ets/pages/PictureViewIndex.ets b/features/pictureView/src/main/ets/pages/PictureViewIndex.ets index 0fbe6aa21e5b06a9166e41c4a65b1e6c19000a97..8107b9029aac14796c6554df5071728c21795bd9 100755 --- a/features/pictureView/src/main/ets/pages/PictureViewIndex.ets +++ b/features/pictureView/src/main/ets/pages/PictureViewIndex.ets @@ -19,31 +19,52 @@ import { BottomBar } from '../view/BottomBar'; import { PreviewLists } from '../view/PreviewLists'; import { BaseConstants, BreakpointConstants } from '@ohos/commons'; import { deviceInfo } from '@kit.BasicServicesKit'; +import { AlbumView } from '@ohos/album'; +import { PictureEdit } from '@ohos/pictureEdit'; @Entry @Preview @Component export struct PictureViewIndex { @StorageLink('currentBreakpoint') currentBp: string = BreakpointConstants.BREAKPOINT_MD; - + @Provide('pageInfos') pageInfos: NavPathStack = new NavPathStack() + @Builder + PageMap(name: string) { + if (name === 'albumView') { + AlbumView() + } + if (name === 'pictureEdit') { + PictureEdit() + } + } build() { - Flex({ - direction: FlexDirection.Column, - alignItems: ItemAlign.Center - }) { - TopBar() - CenterPart() - .flexGrow(1) - PreviewLists() - if (this.currentBp !== BreakpointConstants.BREAKPOINT_LG) { - BottomBar() - } + Navigation(this.pageInfos) { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center + }) { + TopBar() + CenterPart() + .flexGrow(1) + PreviewLists() + if (this.currentBp !== BreakpointConstants.BREAKPOINT_LG) { + BottomBar() + } + } .padding({ + top: deviceInfo.deviceType === BaseConstants.DEVICE_2IN1 ? $r('app.float.zero') : + $r('app.float.device_padding_top'), + bottom: deviceInfo.deviceType !== BaseConstants.DEVICE_2IN1 ? + $r('app.float.tab_content_pb') : $r('app.float.zero') + }) } - .padding({ - top: deviceInfo.deviceType === BaseConstants.DEVICE_2IN1 ? $r('app.float.zero') : - $r('app.float.device_padding_top'), - bottom: deviceInfo.deviceType !== BaseConstants.DEVICE_2IN1 ? - $r('app.float.tab_content_pb') : $r('app.float.zero') - }) + .mode(NavigationMode.Stack) + .height(BaseConstants.FULL_HEIGHT) + .width(BaseConstants.FULL_WIDTH) + .navDestination(this.PageMap) + .hideTitleBar(true) + .hideToolBar(true) + .hideBackButton(true) + .titleMode(NavigationTitleMode.Mini) + } } \ No newline at end of file diff --git a/features/pictureView/src/main/ets/view/BottomBar.ets b/features/pictureView/src/main/ets/view/BottomBar.ets index f4916bdd21728c99460272ce51f5b49fbe7c64ee..f1e7b3fba30e4b361fda91ab2b2eb26154033b82 100755 --- a/features/pictureView/src/main/ets/view/BottomBar.ets +++ b/features/pictureView/src/main/ets/view/BottomBar.ets @@ -13,13 +13,13 @@ * limitations under the License. */ -import { router } from '@kit.ArkUI'; import PictureViewConstants, { ActionInterface } from '../constants/PictureViewConstants'; import { BaseConstants } from '@ohos/commons'; @Preview @Component export struct BottomBar { + @Consume('pageInfos') pageInfos: NavPathStack build() { Flex({ @@ -39,9 +39,7 @@ export struct BottomBar { } .onClick(() => { if (item.icon_name === PictureViewConstants.EDIT_ICON_NAME) { - router.pushUrl({ - url: '@bundle:com.example.multipicturebeautification/pictureEdit/ets/pages/PictureEditIndex' - }); + this.pageInfos.pushPath(new NavPathInfo('pictureEdit', [])); } }) .width(PictureViewConstants.ICON_LIST_WIDTH) diff --git a/features/pictureView/src/main/ets/view/TopBar.ets b/features/pictureView/src/main/ets/view/TopBar.ets index 510bbb22cc17bf5d3edb79d387b9580397ac1746..6c11666e8fcce124e8c35e6622c806c2d0820495 100755 --- a/features/pictureView/src/main/ets/view/TopBar.ets +++ b/features/pictureView/src/main/ets/view/TopBar.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -import { router } from '@kit.ArkUI'; import { BaseConstants, BreakpointConstants } from '@ohos/commons'; import PictureViewConstants, { ActionInterface } from '../constants/PictureViewConstants'; @@ -24,6 +23,7 @@ const SUBTITLE: string = '下午04:00 呼和浩特市'; @Component export struct TopBar { @StorageLink('currentBreakpoint') currentBp: string = BreakpointConstants.BREAKPOINT_MD; + @Consume('pageInfos') pageInfos: NavPathStack build() { Flex({ @@ -61,9 +61,7 @@ export struct TopBar { .width(BaseConstants.DEFAULT_ICON_SIZE) .autoResize(true) .onClick(() => { - router.pushUrl({ - url: '@bundle:com.example.multipicturebeautification/albumView/ets/pages/AlbumViewIndex', - }); + this.pageInfos.pushPath(new NavPathInfo('albumView', [])); }) Image($r('app.media.ic_public_detail')) .height(BaseConstants.DEFAULT_ICON_SIZE) @@ -77,9 +75,7 @@ export struct TopBar { .margin({ left: $r('app.float.detail_image_left') }) .onClick(() => { if (item.icon_name === PictureViewConstants.EDIT_ICON_NAME) { - router.pushUrl({ - url: '@bundle:com.example.multipicturebeautification/pictureEdit/ets/pages/PictureEditIndex', - }); + this.pageInfos.pushPath(new NavPathInfo('pictureEdit', [])); } }) }, (item: ActionInterface, index: number) => index + JSON.stringify(item)) diff --git a/features/pictureView/src/main/module.json5 b/features/pictureView/src/main/module.json5 index d4645c535cc461902f08f0448ce8de9200063339..d52852e2f74f7afadd98f707e643a05205d62790 100755 --- a/features/pictureView/src/main/module.json5 +++ b/features/pictureView/src/main/module.json5 @@ -1,14 +1,11 @@ { "module": { "name": "pictureView", - "type": "shared", - "description": "$string:shared_desc", + "type": "har", "deviceTypes": [ "phone", "tablet", "2in1" - ], - "deliveryWithInstall": true, - "pages": "$profile:main_pages" + ] } } \ No newline at end of file diff --git a/oh-package.json5 b/oh-package.json5 index 72c698ca8385bf9d1b670b29b23da2b9825e832a..37cacf653d9d583c8a18264832d29bdadf416794 100755 --- a/oh-package.json5 +++ b/oh-package.json5 @@ -2,8 +2,6 @@ "modelVersion": "5.0.0", "license": "", "devDependencies": { - "@ohos/hypium": "1.0.15", - }, "author": "", "name": "multipicturebeautification", diff --git a/product/phone/src/main/ets/pages/Index.ets b/product/phone/src/main/ets/pages/Index.ets index e920e6b517779b87c26f83e0d5d59da8fddb3823..872b200b90167fed44edf848f435afbc46907748 100755 --- a/product/phone/src/main/ets/pages/Index.ets +++ b/product/phone/src/main/ets/pages/Index.ets @@ -39,13 +39,9 @@ struct Index { } .width(BaseConstants.FULL_HEIGHT) .height(BaseConstants.FULL_HEIGHT) - } .height(BaseConstants.FULL_PERCENT) .width(BaseConstants.FULL_PERCENT) } - .onBreakpointChange((breakPoints) => { - this.currentBreakpoint = breakPoints; - }) } } \ No newline at end of file diff --git a/product/phone/src/main/ets/phoneability/PhoneAbility.ets b/product/phone/src/main/ets/phoneability/PhoneAbility.ets index 3224bdcf519358c26e1395121d1d59aaf774a849..839d7a536d244ec214f4feb4abcd2da6bf61459a 100755 --- a/product/phone/src/main/ets/phoneability/PhoneAbility.ets +++ b/product/phone/src/main/ets/phoneability/PhoneAbility.ets @@ -15,11 +15,12 @@ import { UIAbility, AbilityConstant, Want } from '@kit.AbilityKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; -import { window } from '@kit.ArkUI'; +import { display, window } from '@kit.ArkUI'; import { BusinessError, deviceInfo } from '@kit.BasicServicesKit'; -import { BaseConstants } from '@ohos/commons/Index'; +import { BaseConstants, BreakpointConstants } from '@ohos/commons/Index'; export default class PhoneAbility extends UIAbility { + private windowObj?: window.Window; onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); } @@ -33,6 +34,11 @@ export default class PhoneAbility extends UIAbility { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); windowStage.getMainWindow((err: BusinessError, data) => { + this.windowObj = data; + this.updateBreakpoint(this.windowObj.getWindowProperties().windowRect.width); + this.windowObj.on('windowSizeChange', (windowSize: window.Size) => { + this.updateBreakpoint(windowSize.width); + }) if (err.code) { hilog.info(0x0000, 'testTag', '%{public}s', 'getMainWindow failed'); return; @@ -50,6 +56,18 @@ export default class PhoneAbility extends UIAbility { hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); }); } + private updateBreakpoint(windowWidth: number) :void{ + let windowWidthVp = windowWidth / display.getDefaultDisplaySync().densityPixels; + let curBp: string = ''; + if (windowWidthVp < BreakpointConstants.BREAKPOINT_SCOPE[2]) { + curBp = BreakpointConstants.BREAKPOINT_SM; + } else if (windowWidthVp < BreakpointConstants.BREAKPOINT_SCOPE[3]) { + curBp = BreakpointConstants.BREAKPOINT_MD; + } else { + curBp = BreakpointConstants.BREAKPOINT_LG; + } + AppStorage.setOrCreate('currentBreakpoint', curBp); + } onWindowStageDestroy(): void { // Main window is destroyed, release UI related resources