diff --git a/AppScope/app.json5 b/AppScope/app.json5 index 782c962c737a0fe8b549a1ce5a1e4c0b69a4ff7a..98d982b9e5aaf06ae759b40e3541afa12daa27e9 100644 --- a/AppScope/app.json5 +++ b/AppScope/app.json5 @@ -3,7 +3,7 @@ "bundleName": "com.example.roundimageview", "vendor": "example", "versionCode": 1000003, - "versionName": "2.0.1", + "versionName": "2.0.1-rc.0", "icon": "$media:app_icon", "label": "$string:app_name", "distributedNotificationEnabled": true diff --git a/CHANGELOG.md b/CHANGELOG.md index 60a5d4005dae5345a1561ea95caa87f1380e479f..7f7fec4f48ac6f7119367ab107b5c19d146b4f99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 2.0.1-rc.0 +- RoundedImageName.Model类 + 1.新增setContext(context:common.UIAbilityContext)接口,在hsp场景下需要传入正确的context才能保证后续获取资源代码正常运行,对于非HSP场景无影响可以不传。 + 2.新增getContext()接口,多用于自定义组件内部,开发者也可以用该方法判断当前context是否传入。 +- 项目名称和核心模块名称相同,三方库核心模块更名为library +- hsp的默认library依赖更名为sharedlibrary + ## 2.0.1 - ArkTs语法适配 - 接口使用方式变更:GlobalContext替代globalThis diff --git a/OAT.xml b/OAT.xml index ad4acd23c869d2a036ade95c8704003ff4074494..f3a925d53fd7a26d8332fac338f9b2fc830ad09c 100644 --- a/OAT.xml +++ b/OAT.xml @@ -45,6 +45,12 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index b52b27ee6111849b293f309b3f3dc4e1ce9055b1..9ad088462a7e8bd59fb60c373d26956c8484a607 100644 --- a/README.md +++ b/README.md @@ -113,23 +113,37 @@ OpenHarmony ohpm 环境配置等更多内容,请参考[如何安装 OpenHarmon `let data: RoundedImageView.Model = new RoundedImageView.Model();` 1. 设置图片路径 `data.setImageSrc(src: string | Resource | ArrayBuffer)` + 2. 设置图片类型 `data.setSrcType(srcType: SrcType)` + 3. 设置图片缩放类型 `data.setScaleType(scaleType: ScaleType)` + 4. 设置图片的重复样式 `data.setTileModeXY(value: TileMode)` + 5. 设置角半径 `data.setCornerRadius(cornerRadius: number)` + 6. 设置图片显示的宽度 `data.setWidth(width: number)` + 7. 设置图片显示的高度 `data.setHeight(height: number)` + 8. 设置边框线宽 `data.setBorderWidth(borderWidth: number)` + 9. 设置背景颜色 `data.setBackgroundColor(value: string | CanvasGradient | CanvasPattern)` +10. 设置当前场景上下文context + + `data.setContext(context:common.UIAbilityContext)` + + + ## 约束与限制 在下述版本验证通过: @@ -140,7 +154,7 @@ OpenHarmony ohpm 环境配置等更多内容,请参考[如何安装 OpenHarmon ``` |---- RoundedImageView | |---- entry # 示例代码文件夹 -| |---- RoundedImageView # RoundedImageView库文件夹 +| |---- library # RoundedImageView库文件夹 | |---- src | |---- main | |---- ets @@ -164,4 +178,3 @@ OpenHarmony ohpm 环境配置等更多内容,请参考[如何安装 OpenHarmon 本项目基于 [Apache License 2.0](https://gitee.com/openharmony-sig/RoundedImageView/blob/master/LICENSE) ,请自由地享受和参与开源。 - diff --git a/build-profile.json5 b/build-profile.json5 index 416203c8d8248a6c21dad6e3e8cf6f91d495b483..618cbd82ba3cb97e20647737de2ca1c2c28d2e02 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -24,8 +24,20 @@ ] }, { - "name": "RoundedImageView", - "srcPath": "./RoundedImageView" + "name": "library", + "srcPath": "./library" + }, + { + "name": "sharedlibrary", + "srcPath": "./sharedlibrary", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] } ] } \ No newline at end of file diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 index cf9f48985f3daf123b949a666dbc753e624fbd62..6f6e44da92a7c8abb6a1dea8a364794499d7e1cb 100644 --- a/entry/oh-package.json5 +++ b/entry/oh-package.json5 @@ -4,8 +4,8 @@ "name": "entry", "description": "example description", "repository": {}, - "version": "2.0.1", + "version": "2.0.1-rc.0", "dependencies": { - "@ohos/roundedimageview": "file:../RoundedImageView" + "@ohos/roundedimageview": "file:../library" } -} +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 67f6a25ee1adc7ed297e44e0537b05260d10ff5a..9c11447cacb1f825f9f493dc2df2da5a9bb581f7 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -16,6 +16,7 @@ import { PictureItem } from './PictureItem' import { TypeCustomDialog } from './TypeCustomDialog' import { RoundedImageView,RoundedImageName, ScaleType, TileMode, SrcType, FileUtils, GlobalContext } from '@ohos/roundedimageview' +import router from '@ohos.router' @Entry @Component @@ -853,6 +854,13 @@ struct Index { build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Button('测试HSP场景').margin({top:10,bottom:10}) + .onClick(()=>{ + router.pushUrl({url:'@bundle:com.example.roundimageview/sharedlibrary/ets/pages/Index'}) + .then(()=>{ + console.log('push page suceess') + }) + }) Column() { Column() { Image($r('app.media.down')).width(30).height(30).position({ x: -30, y: 5 }).onClick(() => { diff --git a/RoundedImageView/.gitignore b/library/.gitignore similarity index 100% rename from RoundedImageView/.gitignore rename to library/.gitignore diff --git a/RoundedImageView/build-profile.json5 b/library/build-profile.json5 similarity index 100% rename from RoundedImageView/build-profile.json5 rename to library/build-profile.json5 diff --git a/RoundedImageView/hvigorfile.ts b/library/hvigorfile.ts similarity index 100% rename from RoundedImageView/hvigorfile.ts rename to library/hvigorfile.ts diff --git a/RoundedImageView/index.ets b/library/index.ets similarity index 100% rename from RoundedImageView/index.ets rename to library/index.ets diff --git a/RoundedImageView/oh-package.json5 b/library/oh-package.json5 similarity index 88% rename from RoundedImageView/oh-package.json5 rename to library/oh-package.json5 index ec4ae81156ba3aa49c9485c415ecc9db44b289f3..142e4e10297ceb140b695a24a9102c25b6d691aa 100644 --- a/RoundedImageView/oh-package.json5 +++ b/library/oh-package.json5 @@ -12,8 +12,8 @@ "description": "RoundedImageView支持许多附加功能,包括椭圆、圆角矩形、ScaleTypes 和 TileModes", "main": "index.ets", "repository": "https://gitee.com/openharmony-sig/RoundedImageView", - "version": "2.0.1", + "version": "2.0.1-rc.0", "dependencies": { - "@ohos/svg": "2.0.0" + "@ohos/svg": "2.1.1-rc.4" } -} +} \ No newline at end of file diff --git a/RoundedImageView/src/main/ets/components/DownloadUtils.ts b/library/src/main/ets/components/DownloadUtils.ts similarity index 100% rename from RoundedImageView/src/main/ets/components/DownloadUtils.ts rename to library/src/main/ets/components/DownloadUtils.ts diff --git a/RoundedImageView/src/main/ets/components/FileUtils.ts b/library/src/main/ets/components/FileUtils.ts similarity index 100% rename from RoundedImageView/src/main/ets/components/FileUtils.ts rename to library/src/main/ets/components/FileUtils.ts diff --git a/RoundedImageView/src/main/ets/components/GlobalContext.ts b/library/src/main/ets/components/GlobalContext.ts similarity index 100% rename from RoundedImageView/src/main/ets/components/GlobalContext.ts rename to library/src/main/ets/components/GlobalContext.ts diff --git a/RoundedImageView/src/main/ets/components/PixelMapUtils.ts b/library/src/main/ets/components/PixelMapUtils.ts similarity index 90% rename from RoundedImageView/src/main/ets/components/PixelMapUtils.ts rename to library/src/main/ets/components/PixelMapUtils.ts index 6af1b5f14d71afd37a550cb5aa0abd33ad84d0dd..f7bf839d7fd3a60f78676c755eb42dd850c8f721 100644 --- a/RoundedImageView/src/main/ets/components/PixelMapUtils.ts +++ b/library/src/main/ets/components/PixelMapUtils.ts @@ -18,10 +18,15 @@ import image from '@ohos.multimedia.image'; import SrcType from './SrcType'; import DownloadUtils from './DownloadUtils'; import { GlobalContext } from './GlobalContext'; +import common from '@ohos.app.ability.common'; class PixelMapUtils { - public static createPixelMap(src: string | Resource | ArrayBuffer, srcType: SrcType | null, callback: (pixelMap: image.PixelMap, width: number, height: number, error?: Error) => void): void { - let context:Context = GlobalContext.getContext().getObject("context") as Context + public static createPixelMap(src: string | Resource | ArrayBuffer, srcType: SrcType | null, callback: (pixelMap: image.PixelMap, width: number, height: number, error?: Error) => void,context?:common.UIAbilityContext): void { + if(context != undefined) { + + }else{ + context = GlobalContext.getContext().getObject("context") as common.UIAbilityContext + } switch (srcType) { case SrcType.MEDIA: //media相关数据 context.resourceManager.getMediaContent(src.id, (error, value) => { diff --git a/RoundedImageView/src/main/ets/components/RoundedImageView.ets b/library/src/main/ets/components/RoundedImageView.ets similarity index 97% rename from RoundedImageView/src/main/ets/components/RoundedImageView.ets rename to library/src/main/ets/components/RoundedImageView.ets index 30cea36799feeda6856c2eab9ac018b89767e8fb..c32f63994872910c27efa153b1d32fb844823772 100644 --- a/RoundedImageView/src/main/ets/components/RoundedImageView.ets +++ b/library/src/main/ets/components/RoundedImageView.ets @@ -19,6 +19,7 @@ import ScaleType from './ScaleType'; import TileMode from './TileMode'; import SrcType from './SrcType'; import { GlobalContext } from './GlobalContext'; +import common from '@ohos.app.ability.common'; @Component @@ -202,8 +203,13 @@ export struct RoundedImageView { this.context.restore() } - private getSvgData(callback: (svgData: Uint8Array) => void) { - let context:Context = GlobalContext.getContext().getObject("context") as Context + private getSvgData(callback: (svgData: Uint8Array) => void,context?:common.UIAbilityContext) { + + if(context != undefined) { + + }else{ + context = GlobalContext.getContext().getObject("context") as common.UIAbilityContext + } switch (this.model.srcType) { case SrcType.MEDIA: @@ -245,7 +251,7 @@ export struct RoundedImageView { this.context.stroke() }) }) - }) + }, this.model.getContext()) return } PixelMapUtils.createPixelMap(this.model.src, this.model.srcType, (pixelMap, width, height, error) => { @@ -268,7 +274,7 @@ export struct RoundedImageView { this.setRect() this.context.stroke() } - }) + },this.model.getContext()) } private async drawOvals() { @@ -295,7 +301,7 @@ export struct RoundedImageView { this.context.stroke() }) }) - }) + }, this.model.getContext()) return } PixelMapUtils.createPixelMap(this.model.src, this.model.srcType, (pixelMap, width, height, error) => { @@ -318,7 +324,7 @@ export struct RoundedImageView { this.setOval() this.context.stroke() } - }) + },this.model.getContext()) } private drawColors() { @@ -458,8 +464,19 @@ export namespace RoundedImageName { padding: number = 0; colorWidth: number = 0; colorHeight: number = 0; + context:common.UIAbilityContext|undefined = undefined constructor() { + + } + + setContext(context:common.UIAbilityContext){ + this.context = context; + return this; + } + + getContext(){ + return this.context; } setImageSrc(src: string | ArrayBuffer | Resource): Model { diff --git a/RoundedImageView/src/main/ets/components/ScaleType.ts b/library/src/main/ets/components/ScaleType.ts similarity index 100% rename from RoundedImageView/src/main/ets/components/ScaleType.ts rename to library/src/main/ets/components/ScaleType.ts diff --git a/RoundedImageView/src/main/ets/components/SrcType.ts b/library/src/main/ets/components/SrcType.ts similarity index 100% rename from RoundedImageView/src/main/ets/components/SrcType.ts rename to library/src/main/ets/components/SrcType.ts diff --git a/RoundedImageView/src/main/ets/components/TileMode.ts b/library/src/main/ets/components/TileMode.ts similarity index 100% rename from RoundedImageView/src/main/ets/components/TileMode.ts rename to library/src/main/ets/components/TileMode.ts diff --git a/RoundedImageView/src/main/module.json5 b/library/src/main/module.json5 similarity index 74% rename from RoundedImageView/src/main/module.json5 rename to library/src/main/module.json5 index 657c11aaa1343e6e9eb4cbc71cc8d464fa5e914a..0204bcbe104d49753055cfe84e63bf81a404cf62 100644 --- a/RoundedImageView/src/main/module.json5 +++ b/library/src/main/module.json5 @@ -1,10 +1,10 @@ { "module": { - "name": "RoundedImageView", + "name": "library", "type": "har", "deviceTypes": [ "default", "tablet" ] } -} +} \ No newline at end of file diff --git a/RoundedImageView/src/main/resources/base/element/string.json b/library/src/main/resources/base/element/string.json similarity index 100% rename from RoundedImageView/src/main/resources/base/element/string.json rename to library/src/main/resources/base/element/string.json diff --git a/RoundedImageView/src/main/resources/en_US/element/string.json b/library/src/main/resources/en_US/element/string.json similarity index 100% rename from RoundedImageView/src/main/resources/en_US/element/string.json rename to library/src/main/resources/en_US/element/string.json diff --git a/RoundedImageView/src/main/resources/zh_CN/element/string.json b/library/src/main/resources/zh_CN/element/string.json similarity index 100% rename from RoundedImageView/src/main/resources/zh_CN/element/string.json rename to library/src/main/resources/zh_CN/element/string.json diff --git a/oh-package.json5 b/oh-package.json5 index aed62c9e2b2e2f89d4c138129c06da1ec83e8a54..a0f062cb6e1bd9496b6eb07fda3cbcf8df907ff8 100644 --- a/oh-package.json5 +++ b/oh-package.json5 @@ -6,6 +6,6 @@ "name": "roundimageview", "description": "example description", "repository": {}, - "version": "2.0.1", + "version": "2.0.1-rc.0", "dependencies": {} } diff --git a/sharedlibrary/.gitignore b/sharedlibrary/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/sharedlibrary/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/sharedlibrary/build-profile.json5 b/sharedlibrary/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..befa10141dfc5999e35f60a36a9f948e664732b1 --- /dev/null +++ b/sharedlibrary/build-profile.json5 @@ -0,0 +1,10 @@ +{ + "apiType": 'stageMode', + "buildOption": { + }, + "targets": [ + { + "name": "default" + } + ] +} \ No newline at end of file diff --git a/sharedlibrary/hvigorfile.ts b/sharedlibrary/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..0e65ea8582bf16134695dfefbdc93d4cda460e84 --- /dev/null +++ b/sharedlibrary/hvigorfile.ts @@ -0,0 +1,2 @@ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +module.exports = require('@ohos/hvigor-ohos-plugin').hspTasks diff --git a/sharedlibrary/oh-package.json5 b/sharedlibrary/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9d8b43ac36fab47dd57098ee9dbda9962eb2f368 --- /dev/null +++ b/sharedlibrary/oh-package.json5 @@ -0,0 +1,11 @@ +{ + "name": "sharedlibrary", + "version": "2.0.1-rc.0", + "description": "Please describe the basic information.", + "main": "./src/main/ets/Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": { + "@ohos/roundedimageview": "file:../library" + } +} \ No newline at end of file diff --git a/sharedlibrary/src/main/ets/Index.ets b/sharedlibrary/src/main/ets/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a5ed91e4fdb6c8fd98b4315ee6f12199ba6e07be --- /dev/null +++ b/sharedlibrary/src/main/ets/Index.ets @@ -0,0 +1,16 @@ +/* + * 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. + */ + +// 只做相关接口测试这里不需要暴露接口 \ No newline at end of file diff --git a/sharedlibrary/src/main/ets/pages/Index.ets b/sharedlibrary/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..757170eee6b3d41c0e6a5fd42ab10cf8659bced5 --- /dev/null +++ b/sharedlibrary/src/main/ets/pages/Index.ets @@ -0,0 +1,936 @@ +/* + * Copyright (C) 2022 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 { PictureItem } from './PictureItem' +import { TypeCustomDialog } from './TypeCustomDialog' +import { RoundedImageView,RoundedImageName, ScaleType, TileMode, SrcType, FileUtils, GlobalContext } from '@ohos/roundedimageview' +import common from '@ohos.app.ability.common' +import display from '@ohos.display' + +@Entry +@Component +struct Index { + private picIdxArr: number [] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + private colorIdxArr: number [] = [0, 1, 2, 3, 4, 5, 6] + private uiWidth: number = px2vp(display.getDefaultDisplaySync().width * 0.9) + private uiHeight: number = px2vp(500) + + private uriFolder: string = getContext(this).filesDir + "/" + "uriFolder" + private uriFile: string = this.uriFolder + "/" + "photo1.jpg" + private viewModels: RoundedImageName.Model [] = []; + private scroller: Scroller = new Scroller() + private dialogController: CustomDialogController = new CustomDialogController({ + alignment: DialogAlignment.Top, + builder: TypeCustomDialog({ typeValue: $typeValue }), + autoCancel: true + }) + private rectPictureItems: PictureItem [] = [ + { + src: $r('app.media.photo1'), + srcType: SrcType.MEDIA, + isSvg: false, + primaryTitle: 'Tufa at night', + secondTitle: 'Mono Lake, CA', + scaleTypeName: 'CENTER', + scaleType: ScaleType.CENTER, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: $r('app.media.photo2'), + srcType: SrcType.MEDIA, + isSvg: false, + primaryTitle: 'Starry night', + secondTitle: 'Lake Powell, AZ', + scaleTypeName: 'CENTER_CROP', + scaleType: ScaleType.CENTER_CROP, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor:'', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: $r('app.media.photo3'), + srcType: SrcType.MEDIA, + isSvg: false, + primaryTitle: 'Racetrack playa', + secondTitle: 'Death Valley, CA', + scaleTypeName: 'CENTER_INSIDE', + scaleType: ScaleType.CENTER_INSIDE, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: $r('app.media.photo4'), + srcType: SrcType.MEDIA, + isSvg: false, + primaryTitle: 'Napali coast', + secondTitle: 'Kauai, HI', + scaleTypeName: 'FIT_CENTER', + scaleType: ScaleType.FIT_CENTER, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: $r('app.media.photo5'), + srcType: SrcType.MEDIA, + isSvg: false, + primaryTitle: 'Delicate Arch', + secondTitle: 'Arches, UT', + scaleTypeName: 'FIT_END', + scaleType: ScaleType.FIT_END, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: $r('app.media.photo6'), + srcType: SrcType.MEDIA, + isSvg: false, + primaryTitle: 'Sierra sunset', + secondTitle: 'Lone Pine, CA', + scaleTypeName: 'FIT_START', + scaleType: ScaleType.FIT_START, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: $r('app.media.photo7'), + srcType: SrcType.MEDIA, + isSvg: false, + primaryTitle: 'Majestic', + secondTitle: 'Grand Teton, WY', + scaleTypeName: 'FIT_XY', + scaleType: ScaleType.FIT_XY, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: $r('app.media.black_white_tile'), + srcType: SrcType.MEDIA, + isSvg: false, + primaryTitle: 'TileMode', + secondTitle: 'REPEAT', + scaleTypeName: 'FIT_XY', + scaleType: ScaleType.FIT_XY, + tileMode: TileMode.REPEAT, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: $r('app.media.black_white_tile'), + srcType: SrcType.MEDIA, + isSvg: false, + primaryTitle: 'TileMode', + secondTitle: 'CLAMP', + scaleTypeName: 'FIT_XY', + scaleType: ScaleType.FIT_XY, + tileMode: TileMode.CLAMP, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: $r('app.media.black_white_tile'), + srcType: SrcType.MEDIA, + isSvg: false, + primaryTitle: 'TileMode', + secondTitle: 'MIRROR', + scaleTypeName: 'FIT_XY', + scaleType: ScaleType.FIT_XY, + tileMode: TileMode.MIRROR, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + } + ] + private ovalPictureItems: PictureItem [] = [ + { + src: 'photo1.jpg', + srcType: SrcType.RAWFILE, + isSvg: false, + primaryTitle: 'Tufa at night', + secondTitle: 'Mono Lake, CA', + scaleTypeName: 'CENTER', + scaleType: ScaleType.CENTER, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 0, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: 'photo2.jpg', + srcType: SrcType.RAWFILE, + isSvg: false, + primaryTitle: 'Starry night', + secondTitle: 'Lake Powell, AZ', + scaleTypeName: 'CENTER_CROP', + scaleType: ScaleType.CENTER_CROP, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 0, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: 'photo3.jpg', + srcType: SrcType.RAWFILE, + isSvg: false, + primaryTitle: 'Racetrack playa', + secondTitle: 'Death Valley, CA', + scaleTypeName: 'CENTER_INSIDE', + scaleType: ScaleType.CENTER_INSIDE, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 0, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: 'photo4.jpg', + srcType: SrcType.RAWFILE, + isSvg: false, + primaryTitle: 'Napali coast', + secondTitle: 'Kauai, HI', + scaleTypeName: 'FIT_CENTER', + scaleType: ScaleType.FIT_CENTER, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 0, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: 'photo5.jpg', + srcType: SrcType.RAWFILE, + isSvg: false, + primaryTitle: 'Delicate Arch', + secondTitle: 'Arches, UT', + scaleTypeName: 'FIT_END', + scaleType: ScaleType.FIT_END, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 0, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: 'photo6.jpg', + srcType: SrcType.RAWFILE, + isSvg: false, + primaryTitle: 'Sierra sunset', + secondTitle: 'Lone Pine, CA', + scaleTypeName: 'FIT_START', + scaleType: ScaleType.FIT_START, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 0, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: 'photo7.jpg', + srcType: SrcType.RAWFILE, + isSvg: false, + primaryTitle: 'Majestic', + secondTitle: 'Grand Teton, WY', + scaleTypeName: 'FIT_XY', + scaleType: ScaleType.FIT_XY, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 0, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: 'black_white_tile.jpg', + srcType: SrcType.RAWFILE, + isSvg: false, + primaryTitle: 'TileMode', + secondTitle: 'REPEAT', + scaleTypeName: 'FIT_XY', + scaleType: ScaleType.FIT_XY, + tileMode: TileMode.REPEAT, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 0, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: 'black_white_tile.jpg', + srcType: SrcType.RAWFILE, + isSvg: false, + primaryTitle: 'TileMode', + secondTitle: 'CLAMP', + scaleTypeName: 'FIT_XY', + scaleType: ScaleType.FIT_XY, + tileMode: TileMode.CLAMP, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 0, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: 'black_white_tile.jpg', + srcType: SrcType.RAWFILE, + isSvg: false, + primaryTitle: 'TileMode', + secondTitle: 'MIRROR', + scaleTypeName: 'FIT_XY', + scaleType: ScaleType.FIT_XY, + tileMode: TileMode.MIRROR, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 0, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + } + ] + private colorItems: PictureItem [] = [ + { + src: '', + srcType: null, + isSvg: false, + primaryTitle: 'Color', + secondTitle: '', + scaleTypeName: 'CENTER', + scaleType: ScaleType.CENTER, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '#AAAAAA', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: '', + srcType: null, + isSvg: false, + primaryTitle: 'Color', + secondTitle: '', + scaleTypeName: 'CENTER_CROP', + scaleType: ScaleType.CENTER_CROP, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '#FF8800', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: '', + srcType: null, + isSvg: false, + primaryTitle: 'Color', + secondTitle: '', + scaleTypeName: 'CENTER_INSIDE', + scaleType: ScaleType.CENTER_INSIDE, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '#FAFAFA', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: '', + srcType: null, + isSvg: false, + primaryTitle: 'Color', + secondTitle: '', + scaleTypeName: 'FIT_CENTER', + scaleType: ScaleType.FIT_CENTER, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '#669900', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: '', + srcType: null, + isSvg: false, + primaryTitle: 'Color', + secondTitle: '', + scaleTypeName: 'FIT_END', + scaleType: ScaleType.FIT_END, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '#CC0000', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: '', + srcType: null, + isSvg: false, + primaryTitle: 'Color', + secondTitle: '', + scaleTypeName: 'FIT_START', + scaleType: ScaleType.FIT_START, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '#AA66CC', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: '', + srcType: null, + isSvg: false, + primaryTitle: 'Color', + secondTitle: '', + scaleTypeName: 'FIT_XY', + scaleType: ScaleType.FIT_XY, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '#FFFFFF', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + ] + private backgroundColorItems: PictureItem [] = [ + { + src: 'https://hbimg.huabanimg.com/0ef60041445edcfd6b38d20e19024b2cd9281dcc3525a4-Vy8fYO_fw658/format/webp', + srcType: SrcType.URL, + isSvg: false, + primaryTitle: 'Tufa at night', + secondTitle: 'Mono Lake, CA', + scaleTypeName: 'CENTER', + scaleType: ScaleType.CENTER, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '#55AA66', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 30 + }, + { + src: 'https://hbimg.huabanimg.com/0ef60041445edcfd6b38d20e19024b2cd9281dcc3525a4-Vy8fYO_fw658/format/webp', + srcType: SrcType.URL, + isSvg: false, + primaryTitle: 'Starry night', + secondTitle: 'Lake Powell, AZ', + scaleTypeName: 'CENTER_CROP', + scaleType: ScaleType.CENTER_CROP, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '#55AA66', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 30 + }, + { + src: this.uriFile, + srcType: SrcType.URI, + isSvg: false, + primaryTitle: 'Racetrack playa', + secondTitle: 'Death Valley, CA', + scaleTypeName: 'CENTER_INSIDE', + scaleType: ScaleType.CENTER_INSIDE, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '#55AA66', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 30 + }, + { + src: this.uriFile, + srcType: SrcType.URI, + isSvg: false, + primaryTitle: 'Napali coast', + secondTitle: 'Kauai, HI', + scaleTypeName: 'FIT_CENTER', + scaleType: ScaleType.FIT_CENTER, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '#55AA66', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 30 + }, + { + src: $r('app.media.photo5'), + srcType: SrcType.MEDIA, + isSvg: false, + primaryTitle: 'Delicate Arch', + secondTitle: 'Arches, UT', + scaleTypeName: 'FIT_END', + scaleType: ScaleType.FIT_END, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '#55AA66', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 30 + }, + { + src: $r('app.media.photo6'), + srcType: SrcType.MEDIA, + isSvg: false, + primaryTitle: 'Sierra sunset', + secondTitle: 'Lone Pine, CA', + scaleTypeName: 'FIT_START', + scaleType: ScaleType.FIT_START, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '#55AA66', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 30 + }, + { + src: $r('app.media.photo7'), + srcType: SrcType.MEDIA, + isSvg: false, + primaryTitle: 'Majestic', + secondTitle: 'Grand Teton, WY', + scaleTypeName: 'FIT_XY', + scaleType: ScaleType.FIT_XY, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '#55AA66', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 30 + }, + { + src: $r('app.media.black_white_tile'), + srcType: SrcType.MEDIA, + isSvg: false, + primaryTitle: 'TileMode', + secondTitle: 'REPEAT', + scaleTypeName: 'FIT_XY', + scaleType: ScaleType.FIT_XY, + tileMode: TileMode.REPEAT, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '#55AA66', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 30 + }, + { + src: $r('app.media.black_white_tile'), + srcType: SrcType.MEDIA, + isSvg: false, + primaryTitle: 'TileMode', + secondTitle: 'CLAMP', + scaleTypeName: 'FIT_XY', + scaleType: ScaleType.FIT_XY, + tileMode: TileMode.CLAMP, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '#55AA66', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 30 + }, + { + src: $r('app.media.black_white_tile'), + srcType: SrcType.MEDIA, + isSvg: false, + primaryTitle: 'TileMode', + secondTitle: 'MIRROR', + scaleTypeName: 'FIT_XY', + scaleType: ScaleType.FIT_XY, + tileMode: TileMode.MIRROR, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '#55AA66', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 30 + } + ] + private svgItems: PictureItem [] = [ + { + src: $r('app.media.ic_svg'), + srcType: SrcType.MEDIA, + isSvg: true, + primaryTitle: 'SVG', + secondTitle: '', + scaleTypeName: 'CENTER', + scaleType: ScaleType.CENTER, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: $r('app.media.ic_svg'), + srcType: SrcType.MEDIA, + isSvg: true, + primaryTitle: 'SVG', + secondTitle: '', + scaleTypeName: 'CENTER_CROP', + scaleType: ScaleType.CENTER_CROP, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: $r('app.media.ic_svg'), + srcType: SrcType.MEDIA, + isSvg: true, + primaryTitle: 'SVG', + secondTitle: '', + scaleTypeName: 'CENTER_INSIDE', + scaleType: ScaleType.CENTER_INSIDE, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: 'ic_svg.svg', + srcType: SrcType.RAWFILE, + isSvg: true, + primaryTitle: 'SVG', + secondTitle: '', + scaleTypeName: 'FIT_CENTER', + scaleType: ScaleType.FIT_CENTER, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: 'ic_svg.svg', + srcType: SrcType.RAWFILE, + isSvg: true, + primaryTitle: 'SVG', + secondTitle: '', + scaleTypeName: 'FIT_END', + scaleType: ScaleType.FIT_END, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: 'ic_svg.svg', + srcType: SrcType.RAWFILE, + isSvg: true, + primaryTitle: 'SVG', + secondTitle: '', + scaleTypeName: 'FIT_START', + scaleType: ScaleType.FIT_START, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + { + src: 'ic_svg.svg', + srcType: SrcType.RAWFILE, + isSvg: true, + primaryTitle: 'SVG', + secondTitle: '', + scaleTypeName: 'FIT_XY', + scaleType: ScaleType.FIT_XY, + tileMode: null, + uiWidth: this.uiWidth, + uiHeight: this.uiHeight, + backgroundColor: '', + cornerRadius: 25, + borderWidth: 10, + borderColor: '#317AF7', + padding: 0 + }, + ] + @State @Watch("typeValueChanged") typeValue: string = 'Bitmap' + + aboutToAppear() { + this.initViewModels() + this.typeValueChanged() + this.initUri() + } + + private initViewModels(): void { + let viewModelsLength = Math.max(this.picIdxArr.length, this.colorIdxArr.length) + for (let index = 0; index < viewModelsLength; index++) { + this.viewModels.push(new RoundedImageName.Model) + } + } + + private typeValueChanged(): void { + if (this.typeValue == 'Bitmap') { + this.updateViewModels(this.rectPictureItems) + } else if (this.typeValue == 'Ovals') { + this.updateViewModels(this.ovalPictureItems) + } else if (this.typeValue == 'Color') { + this.updateViewModels(this.colorItems) + } else if (this.typeValue == 'Background') { + this.updateViewModels(this.backgroundColorItems) + } else if (this.typeValue == 'SVG') { + this.updateViewModels(this.svgItems) + } + this.scroller.scrollTo({ xOffset: 0, yOffset: 0, animation: { duration: 2000, curve: Curve.Ease } }) + } + + + private updateViewModels(pictureItem: PictureItem[]) { + pictureItem.forEach((val, idx) => { + this.viewModels[idx] + .setImageSrc(pictureItem[idx].src) + .setBackgroundColor(pictureItem[idx].backgroundColor) + .setSrcType(pictureItem[idx].srcType) + .setIsSvg(pictureItem[idx].isSvg) + .setTypeValue(this.typeValue) + .setUiWidth(pictureItem[idx].uiWidth) + .setUiHeight(pictureItem[idx].uiHeight) + .setScaleType(pictureItem[idx].scaleType) + .setTileModeXY(pictureItem[idx].tileMode) + .setCornerRadius(pictureItem[idx].cornerRadius) + .setBorderWidth(pictureItem[idx].borderWidth) + .setBorderColor(pictureItem[idx].borderColor) + .setPadding(pictureItem[idx].padding) + .setColorWidth(this.uiHeight) + .setColorHeight(this.uiHeight) + .setContext(getContext(this).createModuleContext('sharedlibrary') as common.UIAbilityContext) + }); + } + + private initUri() { + FileUtils.getInstance().createFolder(this.uriFolder); + (getContext(this).createModuleContext('sharedlibrary') as common.UIAbilityContext).resourceManager.getMedia($r('app.media.photo1').id, (error: Error, value: Uint8Array) => { + FileUtils.getInstance().writePic(this.uriFile, value.buffer) + }) + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Column() { + Image($r('app.media.down')).width(30).height(30).position({ x: -30, y: 5 }).onClick(() => { + this.dialogController.open() + }) + Text(' select:' + this.typeValue).fontSize(30) + }.margin(15) + + Scroll(this.scroller) { + List({ space: 10, initialIndex: 0 }) { + if (this.typeValue == 'Bitmap') { + ForEach(this.picIdxArr, (item:number) => { + ListItem() { + this.ViewItem(this.viewModels[item], this.rectPictureItems[item]) + }.editable(false) + }, (item:string) => item) + } else if (this.typeValue == 'Ovals') { + ForEach(this.picIdxArr, (item:number) => { + ListItem() { + this.ViewItem(this.viewModels[item], this.ovalPictureItems[item]) + }.editable(false) + }, (item:string) => item) + } else if (this.typeValue == 'Color') { + ForEach(this.colorIdxArr, (item:number) => { + ListItem() { + this.ViewItem(this.viewModels[item], this.colorItems[item]) + }.editable(false) + }, (item:string) => item) + } else if (this.typeValue == 'Background') { + ForEach(this.picIdxArr, (item:number) => { + ListItem() { + this.ViewItem(this.viewModels[item], this.backgroundColorItems[item]) + }.editable(false) + }, (item:string) => item) + } else if (this.typeValue == 'SVG') { + ForEach(this.colorIdxArr, (item:number) => { + ListItem() { + this.ViewItem(this.viewModels[item], this.svgItems[item]) + }.editable(false) + }, (item:string) => item) + } + } + } + .scrollable(ScrollDirection.Vertical).scrollBar(BarState.Off) + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 20, bottom: 100 }) + } + } + + @Builder ViewItem(roundedImageViewModel: RoundedImageName.Model, pictureItem: PictureItem) { + Column({ space: 5 }) { + RoundedImageView({ model: roundedImageViewModel }) + Column() { + Text(pictureItem.primaryTitle) + .size({ height: 35 }) + .fontColor(0xFAFAFA) + .backgroundColor(0x7f000000) + .fontSize(18) + .position({ x: 20, y: 40 }) + Text(pictureItem.secondTitle) + .size({ height: 20 }) + .fontColor(0xFAFAFA) + .backgroundColor(0x7f000000) + .fontSize(16) + .position({ x: 20, y: 90 }) + Text(pictureItem.scaleTypeName) + .size({ height: 20 }) + .fontColor(0xFAFAFA) + .backgroundColor(0x7f000000) + .fontSize(14) + .position({ x: 20, y: 120 }) + } + }.width('100%') + } +} diff --git a/sharedlibrary/src/main/ets/pages/PictureItem.ets b/sharedlibrary/src/main/ets/pages/PictureItem.ets new file mode 100644 index 0000000000000000000000000000000000000000..fe48f81e9573c6e3a8b6b581f54d63811e351edd --- /dev/null +++ b/sharedlibrary/src/main/ets/pages/PictureItem.ets @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2022 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 { ScaleType, TileMode, SrcType } from '@ohos/roundedimageview' + + +export interface PictureItem { + src: string | Resource | ArrayBuffer + srcType: SrcType | null + isSvg: boolean + primaryTitle: string + secondTitle: string + scaleTypeName: string + scaleType: ScaleType + tileMode: TileMode | null + uiWidth: number + uiHeight: number + backgroundColor: string | CanvasGradient | CanvasPattern + cornerRadius: number + borderWidth: number + borderColor: string | CanvasGradient | CanvasPattern + padding: number +} diff --git a/sharedlibrary/src/main/ets/pages/TypeCustomDialog.ets b/sharedlibrary/src/main/ets/pages/TypeCustomDialog.ets new file mode 100644 index 0000000000000000000000000000000000000000..ae9cd9c8f897a7d2095599d74e07614edff442b3 --- /dev/null +++ b/sharedlibrary/src/main/ets/pages/TypeCustomDialog.ets @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2022 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. + */ + +@CustomDialog +export struct TypeCustomDialog { + private controller?: CustomDialogController + private typeArr: string[] = ['Bitmap', 'Ovals', 'Color', 'Background', 'SVG'] + @Link private typeValue: string + + build() { + Row() { + Scroll() { + List({ space: 10, initialIndex: 0 }) { + ForEach(this.typeArr, (item:string) => { + ListItem() { + Text(item) + .width('100%') + .height(20) + .fontSize(20) + .textAlign(TextAlign.Start) + .backgroundColor(0xFFFFFF) + .onClick(() => { + this.typeValue = item + this.controller?.close(); + }) + } + }, (item:string) => item) + }.backgroundColor(Color.White).width(200).padding(20) + } + } + } +} \ No newline at end of file diff --git a/sharedlibrary/src/main/module.json5 b/sharedlibrary/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7e3769959a06db7987e58f44f6b437dc8264a554 --- /dev/null +++ b/sharedlibrary/src/main/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "sharedlibrary", + "type": "shared", + "description": "$string:shared_desc", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "pages": "$profile:main_pages" + } +} \ No newline at end of file diff --git a/sharedlibrary/src/main/resources/base/element/color.json b/sharedlibrary/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..1bbc9aa9617e97c45440e1d3d66afc1154837012 --- /dev/null +++ b/sharedlibrary/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/sharedlibrary/src/main/resources/base/element/string.json b/sharedlibrary/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..98e1d8a84b3d8539ea33e79fe2ac593a05d23bb4 --- /dev/null +++ b/sharedlibrary/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "shared_desc", + "value": "description" + } + ] +} \ No newline at end of file diff --git a/sharedlibrary/src/main/resources/base/media/black_white_tile.jpg b/sharedlibrary/src/main/resources/base/media/black_white_tile.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9628a1566a0576e601e17ae5b492a5c000233b2d Binary files /dev/null and b/sharedlibrary/src/main/resources/base/media/black_white_tile.jpg differ diff --git a/sharedlibrary/src/main/resources/base/media/down.png b/sharedlibrary/src/main/resources/base/media/down.png new file mode 100644 index 0000000000000000000000000000000000000000..01411cd6e6f535960cf4af719d3f82a1d909c4a4 Binary files /dev/null and b/sharedlibrary/src/main/resources/base/media/down.png differ diff --git a/sharedlibrary/src/main/resources/base/media/ic_svg.svg b/sharedlibrary/src/main/resources/base/media/ic_svg.svg new file mode 100644 index 0000000000000000000000000000000000000000..a82bbdf1df215c815bd78c63dea1d36bfceb4aa0 --- /dev/null +++ b/sharedlibrary/src/main/resources/base/media/ic_svg.svg @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sharedlibrary/src/main/resources/base/media/icon.png b/sharedlibrary/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/sharedlibrary/src/main/resources/base/media/icon.png differ diff --git a/sharedlibrary/src/main/resources/base/media/photo1.jpg b/sharedlibrary/src/main/resources/base/media/photo1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..407d55c451f47507bb8a468871cfb9535f4d7d0c Binary files /dev/null and b/sharedlibrary/src/main/resources/base/media/photo1.jpg differ diff --git a/sharedlibrary/src/main/resources/base/media/photo2.jpg b/sharedlibrary/src/main/resources/base/media/photo2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..4ab6485132ba728d756641846cea9486f7d731c9 Binary files /dev/null and b/sharedlibrary/src/main/resources/base/media/photo2.jpg differ diff --git a/sharedlibrary/src/main/resources/base/media/photo3.jpg b/sharedlibrary/src/main/resources/base/media/photo3.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c259fddf09fa4a27955b2a69b1cab632a857a2c9 Binary files /dev/null and b/sharedlibrary/src/main/resources/base/media/photo3.jpg differ diff --git a/sharedlibrary/src/main/resources/base/media/photo4.jpg b/sharedlibrary/src/main/resources/base/media/photo4.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c3a086e591cde291b215cc360bab86fd25122f7a Binary files /dev/null and b/sharedlibrary/src/main/resources/base/media/photo4.jpg differ diff --git a/sharedlibrary/src/main/resources/base/media/photo5.jpg b/sharedlibrary/src/main/resources/base/media/photo5.jpg new file mode 100644 index 0000000000000000000000000000000000000000..7eb134e01be4f5475e115c0f7b024efb3b71e5b3 Binary files /dev/null and b/sharedlibrary/src/main/resources/base/media/photo5.jpg differ diff --git a/sharedlibrary/src/main/resources/base/media/photo6.jpg b/sharedlibrary/src/main/resources/base/media/photo6.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a8c859d095e79bf96cfea09066659143259fe82e Binary files /dev/null and b/sharedlibrary/src/main/resources/base/media/photo6.jpg differ diff --git a/sharedlibrary/src/main/resources/base/media/photo7.jpg b/sharedlibrary/src/main/resources/base/media/photo7.jpg new file mode 100644 index 0000000000000000000000000000000000000000..47cfe1c856ce0b9b9f7fbe9ae236d528e21337a3 Binary files /dev/null and b/sharedlibrary/src/main/resources/base/media/photo7.jpg differ diff --git a/sharedlibrary/src/main/resources/base/media/setting.jpeg b/sharedlibrary/src/main/resources/base/media/setting.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..57e67dd49d39ad64ef090f59db3db9dfe6632106 Binary files /dev/null and b/sharedlibrary/src/main/resources/base/media/setting.jpeg differ diff --git a/sharedlibrary/src/main/resources/base/profile/main_pages.json b/sharedlibrary/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/sharedlibrary/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/sharedlibrary/src/main/resources/rawfile/black_white_tile.jpg b/sharedlibrary/src/main/resources/rawfile/black_white_tile.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9628a1566a0576e601e17ae5b492a5c000233b2d Binary files /dev/null and b/sharedlibrary/src/main/resources/rawfile/black_white_tile.jpg differ diff --git a/sharedlibrary/src/main/resources/rawfile/ic_svg.svg b/sharedlibrary/src/main/resources/rawfile/ic_svg.svg new file mode 100644 index 0000000000000000000000000000000000000000..a82bbdf1df215c815bd78c63dea1d36bfceb4aa0 --- /dev/null +++ b/sharedlibrary/src/main/resources/rawfile/ic_svg.svg @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sharedlibrary/src/main/resources/rawfile/photo1.jpg b/sharedlibrary/src/main/resources/rawfile/photo1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..407d55c451f47507bb8a468871cfb9535f4d7d0c Binary files /dev/null and b/sharedlibrary/src/main/resources/rawfile/photo1.jpg differ diff --git a/sharedlibrary/src/main/resources/rawfile/photo2.jpg b/sharedlibrary/src/main/resources/rawfile/photo2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..4ab6485132ba728d756641846cea9486f7d731c9 Binary files /dev/null and b/sharedlibrary/src/main/resources/rawfile/photo2.jpg differ diff --git a/sharedlibrary/src/main/resources/rawfile/photo3.jpg b/sharedlibrary/src/main/resources/rawfile/photo3.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c259fddf09fa4a27955b2a69b1cab632a857a2c9 Binary files /dev/null and b/sharedlibrary/src/main/resources/rawfile/photo3.jpg differ diff --git a/sharedlibrary/src/main/resources/rawfile/photo4.jpg b/sharedlibrary/src/main/resources/rawfile/photo4.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c3a086e591cde291b215cc360bab86fd25122f7a Binary files /dev/null and b/sharedlibrary/src/main/resources/rawfile/photo4.jpg differ diff --git a/sharedlibrary/src/main/resources/rawfile/photo5.jpg b/sharedlibrary/src/main/resources/rawfile/photo5.jpg new file mode 100644 index 0000000000000000000000000000000000000000..7eb134e01be4f5475e115c0f7b024efb3b71e5b3 Binary files /dev/null and b/sharedlibrary/src/main/resources/rawfile/photo5.jpg differ diff --git a/sharedlibrary/src/main/resources/rawfile/photo6.jpg b/sharedlibrary/src/main/resources/rawfile/photo6.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a8c859d095e79bf96cfea09066659143259fe82e Binary files /dev/null and b/sharedlibrary/src/main/resources/rawfile/photo6.jpg differ diff --git a/sharedlibrary/src/main/resources/rawfile/photo7.jpg b/sharedlibrary/src/main/resources/rawfile/photo7.jpg new file mode 100644 index 0000000000000000000000000000000000000000..47cfe1c856ce0b9b9f7fbe9ae236d528e21337a3 Binary files /dev/null and b/sharedlibrary/src/main/resources/rawfile/photo7.jpg differ