├── .gitignore ├── AppScope ├── app.json5 └── resources │ └── base │ ├── element │ └── string.json │ └── media │ └── app_icon.png ├── LICENSE ├── README.md ├── build-profile.json5 ├── china_area ├── .gitignore ├── BuildProfile.ets ├── CHANGELOG.md ├── Index.ets ├── LICENSE ├── README.md ├── build-profile.json5 ├── consumer-rules.txt ├── example │ └── README.md ├── hvigorfile.ts ├── obfuscation-rules.txt ├── oh-package.json5 └── src │ ├── main │ ├── ets │ │ ├── AreaEntity.ets │ │ └── AreaHelper.ets │ ├── module.json5 │ └── resources │ │ ├── base │ │ └── element │ │ │ └── string.json │ │ ├── en_US │ │ └── element │ │ │ └── string.json │ │ ├── rawfile │ │ └── area.json │ │ └── zh_CN │ │ └── element │ │ └── string.json │ ├── ohosTest │ ├── ets │ │ └── test │ │ │ ├── Ability.test.ets │ │ │ └── List.test.ets │ └── module.json5 │ └── test │ ├── List.test.ets │ └── LocalUnit.test.ets ├── entry ├── .gitignore ├── build-profile.json5 ├── hvigorfile.ts ├── libs │ └── harmony_utils.har ├── obfuscation-rules.txt ├── oh-package-lock.json5 ├── oh-package.json5 └── src │ ├── main │ ├── ets │ │ ├── abilitystage │ │ │ └── MyAbilityStage.ets │ │ ├── component │ │ │ ├── LabelButton.ets │ │ │ └── TitleBarView.ets │ │ ├── entity │ │ │ ├── DescribeBean.ets │ │ │ └── User.ets │ │ ├── entryability │ │ │ └── EntryAbility.ets │ │ ├── pages │ │ │ ├── Index.ets │ │ │ ├── crypto │ │ │ │ ├── AESPage.ets │ │ │ │ ├── DESPage.ets │ │ │ │ ├── ECDSAPage.ets │ │ │ │ ├── MD5Page.ets │ │ │ │ ├── RSAPage.ets │ │ │ │ ├── SHAPage.ets │ │ │ │ ├── SM2Page.ets │ │ │ │ ├── SM3Page.ets │ │ │ │ └── SM4Page.ets │ │ │ ├── index │ │ │ │ ├── DialogPage.ets │ │ │ │ ├── OtherPage.ets │ │ │ │ ├── RoomPage.ets │ │ │ │ ├── SpinKitPage.ets │ │ │ │ └── UtilsPage.ets │ │ │ ├── spinkit │ │ │ │ ├── SpinKit1.ets │ │ │ │ └── SpinKit2.ets │ │ │ └── utils │ │ │ │ ├── AppUtilPage.ets │ │ │ │ ├── ArrayUtilPage.ets │ │ │ │ ├── AssetUtilPage.ets │ │ │ │ ├── AuthUtilPage.ets │ │ │ │ ├── Base64UtilPage.ets │ │ │ │ ├── CacheUtilPage.ets │ │ │ │ ├── CharUtilPage.ets │ │ │ │ ├── ClickUtilPage.ets │ │ │ │ ├── CrashUtilPage.ets │ │ │ │ ├── DateUtilPage.ets │ │ │ │ ├── DeviceUtilPage.ets │ │ │ │ ├── DialogUtilPage.ets │ │ │ │ ├── DisplayUtilPage.ets │ │ │ │ ├── EmitterUtilPage.ets │ │ │ │ ├── FileUtilPage.ets │ │ │ │ ├── FormatUtilPage.ets │ │ │ │ ├── ImageUtilPage.ets │ │ │ │ ├── JSONUtilPage.ets │ │ │ │ ├── KeyboardUtilPage.ets │ │ │ │ ├── KvUtilPage.ets │ │ │ │ ├── LRUCacheUtilPage.ets │ │ │ │ ├── LocationUtilPage.ets │ │ │ │ ├── LogUtilPage.ets │ │ │ │ ├── NetworkUtilPage.ets │ │ │ │ ├── NotificationUtilPage.ets │ │ │ │ ├── NumberUtilPage.ets │ │ │ │ ├── ObjectUtilPage.ets │ │ │ │ ├── PasteboardUtilPage.ets │ │ │ │ ├── PermissionUtilPage.ets │ │ │ │ ├── PhotoHelperPage.ets │ │ │ │ ├── PickerUtilPage.ets │ │ │ │ ├── PreferencesUtilPage.ets │ │ │ │ ├── PreviewUtilPage.ets │ │ │ │ ├── RandomUtilPage.ets │ │ │ │ ├── RegexUtilPage.ets │ │ │ │ ├── ResUtilPage.ets │ │ │ │ ├── ScanUtilPage.ets │ │ │ │ ├── SnapshotUtilPage.ets │ │ │ │ ├── StrUtilPage.ets │ │ │ │ ├── TempUtilPage.ets │ │ │ │ ├── ToastUtilPage.ets │ │ │ │ └── WantUtilPage.ets │ │ └── utils │ │ │ ├── DrawerOptions.ets │ │ │ ├── MyCustomOptions.ets │ │ │ └── WindowUtil.ets │ ├── module.json5 │ └── resources │ │ ├── base │ │ ├── element │ │ │ ├── boolean.json │ │ │ ├── color.json │ │ │ ├── integer.json │ │ │ ├── plural.json │ │ │ ├── strarray.json │ │ │ └── string.json │ │ ├── media │ │ │ ├── background.png │ │ │ ├── foreground.png │ │ │ ├── ic_folder.png │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_round.png │ │ │ ├── icon_code.svg │ │ │ ├── icon_example.svg │ │ │ ├── icon_right.svg │ │ │ ├── icon_tab_dialog.svg │ │ │ ├── icon_tab_mine.svg │ │ │ ├── icon_tab_my.svg │ │ │ ├── icon_tab_other.svg │ │ │ ├── icon_tab_rcp.svg │ │ │ ├── icon_tab_room.svg │ │ │ ├── icon_tab_spin.svg │ │ │ ├── icon_tab_utils.svg │ │ │ ├── icon_tip_info.svg │ │ │ ├── icon_tip_ok.svg │ │ │ ├── icon_tip_warn.svg │ │ │ ├── icon_user.png │ │ │ ├── layered_image.json │ │ │ ├── startIcon.png │ │ │ ├── test_as1.jpg │ │ │ ├── test_as2.jpeg │ │ │ ├── test_as3.png │ │ │ ├── test_as4.png │ │ │ ├── test_as5.jpg │ │ │ └── wps_code.png │ │ └── profile │ │ │ └── main_pages.json │ │ ├── en_US │ │ └── element │ │ │ └── string.json │ │ ├── rawfile │ │ ├── MyFont.ttf │ │ ├── data.json │ │ ├── demo │ │ │ ├── demo.txt │ │ │ └── test.txt │ │ └── user.json │ │ └── zh_CN │ │ └── element │ │ └── string.json │ ├── ohosTest │ ├── ets │ │ ├── test │ │ │ ├── Ability.test.ets │ │ │ └── List.test.ets │ │ ├── testability │ │ │ ├── TestAbility.ets │ │ │ └── pages │ │ │ │ └── Index.ets │ │ └── testrunner │ │ │ └── OpenHarmonyTestRunner.ets │ ├── module.json5 │ └── resources │ │ └── base │ │ ├── element │ │ ├── color.json │ │ └── string.json │ │ ├── media │ │ └── icon.png │ │ └── profile │ │ └── test_pages.json │ └── test │ ├── List.test.ets │ └── LocalUnit.test.ets ├── harmony_dialog ├── .gitignore ├── BuildProfile.ets ├── CHANGELOG.md ├── Index.ets ├── LICENSE ├── README.md ├── build-profile.json5 ├── consumer-rules.txt ├── example │ └── README.md ├── hvigorfile.ts ├── obfuscation-rules.txt ├── oh-package-lock.json5 ├── oh-package.json5 └── src │ ├── main │ ├── ets │ │ ├── component │ │ │ ├── ActionSheetDialogView.ets │ │ │ ├── BottomSheetDialogView.ets │ │ │ ├── DatePickerDialogView.ets │ │ │ ├── LoadingProgressView.ets │ │ │ ├── LoadingView.ets │ │ │ ├── TextAreaDialogView.ets │ │ │ ├── TextInputDialogView.ets │ │ │ ├── TextPickerDialogView.ets │ │ │ ├── ToastTipView.ets │ │ │ └── ToastView.ets │ │ ├── dialog │ │ │ ├── BasePromptAction.ets │ │ │ ├── DialogBuilder.ets │ │ │ └── DialogHelper.ets │ │ ├── model │ │ │ ├── AlertOptions.ets │ │ │ ├── BottomSheetOptions.ets │ │ │ ├── ButtonOptions.ets │ │ │ ├── ConfirmOptions.ets │ │ │ ├── CustomContentOptions.ets │ │ │ ├── DateTimePickerOptions.ets │ │ │ ├── DialogConfig.ets │ │ │ ├── InputFilter.ets │ │ │ ├── LoadingOptions.ets │ │ │ ├── LoadingProgressOptions.ets │ │ │ ├── SelectOptions.ets │ │ │ ├── SheetOptions.ets │ │ │ ├── TextAreaOptions.ets │ │ │ ├── TextInputOptions.ets │ │ │ ├── TextPickerOptions.ets │ │ │ ├── TipsOptions.ets │ │ │ ├── ToastOptions.ets │ │ │ ├── ToastTipOptions.ets │ │ │ └── base │ │ │ │ ├── BaseContentOptions.ets │ │ │ │ ├── BaseDialogOptions.ets │ │ │ │ ├── BaseInputOptions.ets │ │ │ │ ├── BasePickerOptions.ets │ │ │ │ ├── DialogOptions.ets │ │ │ │ ├── HmDialogOptions.ets │ │ │ │ └── PromptActionArg.ets │ │ └── utils │ │ │ ├── AnimationHelper.ets │ │ │ ├── CacheHelper.ets │ │ │ ├── DateHelper.ets │ │ │ ├── Helper.ets │ │ │ ├── TextAreaModifier.ets │ │ │ ├── TextInputModifier.ets │ │ │ ├── TextPickerModifier.ets │ │ │ └── constraint.ets │ ├── module.json5 │ └── resources │ │ ├── base │ │ └── element │ │ │ ├── color.json │ │ │ └── string.json │ │ ├── en_US │ │ └── element │ │ │ └── string.json │ │ └── zh_CN │ │ └── element │ │ └── string.json │ ├── ohosTest │ ├── ets │ │ └── test │ │ │ ├── Ability.test.ets │ │ │ └── List.test.ets │ └── module.json5 │ └── test │ ├── List.test.ets │ └── LocalUnit.test.ets ├── harmony_utils ├── .gitignore ├── BuildProfile.ets ├── CHANGELOG.md ├── Index.ets ├── LICENSE ├── README.md ├── build-profile.json5 ├── consumer-rules.txt ├── example │ └── README.md ├── hvigorfile.ts ├── obfuscation-rules.txt ├── oh-package-lock.json5 ├── oh-package.json5 └── src │ ├── main │ ├── ets │ │ ├── action │ │ │ ├── DialogUtil.ets │ │ │ └── ToastUtil.ets │ │ ├── crypto │ │ │ ├── AES.ets │ │ │ ├── CryptoHelper.ets │ │ │ ├── CryptoUtil.ets │ │ │ ├── DES.ets │ │ │ ├── ECDSA.ets │ │ │ ├── MD5.ets │ │ │ ├── RSA.ets │ │ │ ├── SHA.ets │ │ │ ├── SM2.ets │ │ │ ├── SM3.ets │ │ │ ├── SM4.ets │ │ │ └── crypto.ets │ │ ├── entity │ │ │ ├── CameraOptions.ets │ │ │ ├── DialogConfig.ets │ │ │ ├── DialogOptions.ets │ │ │ ├── NotificationConfig.ets │ │ │ ├── NotificationOptions.ets │ │ │ ├── ToastConfig.ets │ │ │ ├── ToastOptions.ets │ │ │ ├── constraint.ets │ │ │ └── constranint.ts │ │ ├── photo │ │ │ └── PhotoHelper.ets │ │ └── utils │ │ │ ├── AppUtil.ets │ │ │ ├── ArrayUtil.ets │ │ │ ├── AssetUtil.ets │ │ │ ├── AuthUtil.ets │ │ │ ├── Base64Util.ets │ │ │ ├── CacheUtil.ets │ │ │ ├── CharUtil.ets │ │ │ ├── ClickUtil.ets │ │ │ ├── CrashUtil.ets │ │ │ ├── DateUtil.ets │ │ │ ├── DeviceUtil.ets │ │ │ ├── DisplayUtil.ets │ │ │ ├── EmitterUtil.ets │ │ │ ├── FileUtil.ets │ │ │ ├── FormatUtil.ets │ │ │ ├── GlobalContext.ets │ │ │ ├── ImageUtil.ets │ │ │ ├── JSONUtil.ets │ │ │ ├── KeyboardUtil.ets │ │ │ ├── KvUtil.ets │ │ │ ├── LRUCacheUtil.ets │ │ │ ├── LocationUtil.ets │ │ │ ├── LogUtil.ets │ │ │ ├── NetworkUtil.ets │ │ │ ├── NotificationUtil.ets │ │ │ ├── NumberUtil.ts │ │ │ ├── ObjectUtil.ts │ │ │ ├── PasteboardUtil.ets │ │ │ ├── PermissionUtil.ets │ │ │ ├── PickerUtil.ets │ │ │ ├── PreferencesUtil.ets │ │ │ ├── PreviewUtil.ets │ │ │ ├── RandomUtil.ets │ │ │ ├── RegexUtil.ets │ │ │ ├── ResUtil.ets │ │ │ ├── ScanUtil.ets │ │ │ ├── SnapshotUtil.ets │ │ │ ├── StrUtil.ets │ │ │ ├── TempUtil.ets │ │ │ └── WantUtil.ets │ ├── module.json5 │ └── resources │ │ ├── base │ │ └── element │ │ │ └── string.json │ │ ├── en_US │ │ └── element │ │ │ └── string.json │ │ └── zh_CN │ │ └── element │ │ └── string.json │ └── test │ ├── List.test.ets │ └── LocalUnit.test.ets ├── hvigor └── hvigor-config.json5 ├── hvigorfile.ts ├── oh-package-lock.json5 ├── oh-package.json5 └── spinkit ├── .gitignore ├── BuildProfile.ets ├── CHANGELOG.md ├── Index.ets ├── LICENSE ├── README.md ├── build-profile.json5 ├── consumer-rules.txt ├── example ├── GIF.gif └── README.md ├── hvigorfile.ts ├── obfuscation-rules.txt ├── oh-package.json5 └── src ├── main ├── ets │ ├── SpinType.ets │ └── components │ │ ├── SpinA.ets │ │ ├── SpinB.ets │ │ ├── SpinC.ets │ │ ├── SpinD.ets │ │ ├── SpinE.ets │ │ ├── SpinF.ets │ │ ├── SpinG.ets │ │ ├── SpinH.ets │ │ ├── SpinI.ets │ │ ├── SpinJ.ets │ │ ├── SpinK.ets │ │ ├── SpinKit.ets │ │ ├── SpinL.ets │ │ ├── SpinM.ets │ │ ├── SpinN.ets │ │ ├── SpinO.ets │ │ ├── SpinP.ets │ │ ├── SpinQ.ets │ │ ├── SpinR.ets │ │ └── SpinS.ets ├── module.json5 └── resources │ ├── base │ └── element │ │ └── string.json │ ├── en_US │ └── element │ │ └── string.json │ └── zh_CN │ └── element │ └── string.json ├── ohosTest ├── ets │ └── test │ │ ├── Ability.test.ets │ │ └── List.test.ets └── module.json5 └── test ├── List.test.ets └── LocalUnit.test.ets /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /oh_modules 3 | /local.properties 4 | /.idea 5 | **/build 6 | /.hvigor 7 | .cxx 8 | /.clangd 9 | /.clang-format 10 | /.clang-tidy 11 | **/.test 12 | /.appanalyzer -------------------------------------------------------------------------------- /AppScope/app.json5: -------------------------------------------------------------------------------- 1 | { 2 | "app": { 3 | "bundleName": "com.harmony.utils", 4 | "vendor": "桃花镇童长老", 5 | "versionCode": 1000001, 6 | "versionName": "1.0.1", 7 | "icon": "$media:app_icon", 8 | "label": "$string:app_name" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /AppScope/resources/base/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "app_name", 5 | "value": "鸿蒙宝典" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /AppScope/resources/base/media/app_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/AppScope/resources/base/media/app_icon.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 📚模块介 2 | 3 | [harmony-utils](https://gitee.com/tongyuyan/harmony-utils/tree/master/harmony_utils) 4 | 一款功能丰富且极易上手的HarmonyOS工具库,借助众多实用工具类,致力于助力开发者迅速构建鸿蒙应用。其封装的工具涵盖了APP、设备、屏幕、授权、通知、线程间通信、弹框、吐司、生物认证、用户首选项、拍照、相册、扫码、文件、日志,异常捕获、字符、字符串、数字、集合、日期、随机、base64、加密、解密、JSON等一系列的功能和操作,能够满足各种不同的开发需求。 5 | 6 | [harmony-dialog](https://gitee.com/tongyuyan/harmony-utils/tree/master/harmony_dialog) 7 | 一款极为简单易用的零侵入弹窗,仅需一行代码即可轻松实现,无论在何处都能够轻松弹出。其涵盖了 8 | AlertDialog、TipsDialog、ConfirmDialog、SelectDialog、CustomContentDialog、TextInputDialog、TextAreaDialog、BottomSheetDialog、ActionSheetDialog、TextPickerDialog、DatePickerDialog、CustomDialog、LoadingDialog、LoadingProgress、Toast、ToastTip 9 | 等多种类型,能够满足各种不同的弹窗开发需求。 10 | 11 | [SpinKit](https://gitee.com/tongyuyan/harmony-utils/tree/master/spinkit) 是一个适用于OpenHarmony/HarmonyOS的加载动画库。 12 | 13 | [china_area](https://gitee.com/tongyuyan/harmony-utils/tree/master/china_area) 中国区域数据,省市县三级数据。 14 | 15 | ## 🍎技术交流 16 | 17 | 鸿蒙技术交流QQ群:569512366 18 | 19 | ## 🌏开源协议 20 | 21 | 本项目基于 [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0.html) ,在拷贝和借鉴代码时,请大家务必注明出处。 22 | -------------------------------------------------------------------------------- /build-profile.json5: -------------------------------------------------------------------------------- 1 | { 2 | "app": { 3 | "signingConfigs": [ 4 | { 5 | "name": "default", 6 | "type": "HarmonyOS", 7 | "material": { 8 | "certpath": "C:\\Users\\Administrator\\.ohos\\config\\default_HarmonyUtils_CMdHBmfPiA_XUKbuKPjuQjwbq8ZkGKaaSQqm0yqzRtU=.cer", 9 | "storePassword": "0000001B0DF76E654FF6E5AB03118AEB4E05BAA17FB3C7BC6A7EB6FB862FA8106E73C3A30AF65C253EBFE1", 10 | "keyAlias": "debugKey", 11 | "keyPassword": "0000001BDD3881C32B33F7B558A167F1863D0990288E158FE871C792846E66C83B06A2F680B0F414D3557C", 12 | "profile": "C:\\Users\\Administrator\\.ohos\\config\\default_HarmonyUtils_CMdHBmfPiA_XUKbuKPjuQjwbq8ZkGKaaSQqm0yqzRtU=.p7b", 13 | "signAlg": "SHA256withECDSA", 14 | "storeFile": "C:\\Users\\Administrator\\.ohos\\config\\default_HarmonyUtils_CMdHBmfPiA_XUKbuKPjuQjwbq8ZkGKaaSQqm0yqzRtU=.p12" 15 | } 16 | } 17 | ], 18 | "products": [ 19 | { 20 | "name": "default", 21 | "signingConfig": "default", 22 | "compatibleSdkVersion": "5.0.0(12)", 23 | "runtimeOS": "HarmonyOS", 24 | "buildOption": { 25 | "strictMode": { 26 | "useNormalizedOHMUrl": false 27 | } 28 | } 29 | } 30 | ], 31 | "buildModeSet": [ 32 | { 33 | "name": "debug", 34 | }, 35 | { 36 | "name": "release" 37 | } 38 | ] 39 | }, 40 | "modules": [ 41 | { 42 | "name": "entry", 43 | "srcPath": "./entry", 44 | "targets": [ 45 | { 46 | "name": "default", 47 | "applyToProducts": [ 48 | "default" 49 | ] 50 | } 51 | ] 52 | }, 53 | { 54 | "name": "harmony_utils", 55 | "srcPath": "./harmony_utils" 56 | }, 57 | { 58 | "name": "harmony_dialog", 59 | "srcPath": "./harmony_dialog", 60 | }, 61 | { 62 | "name": "spinkit", 63 | "srcPath": "./spinkit", 64 | }, 65 | { 66 | "name": "china_area", 67 | "srcPath": "./china_area", 68 | } 69 | ] 70 | } -------------------------------------------------------------------------------- /china_area/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /oh_modules 3 | /.preview 4 | /build 5 | /.cxx 6 | /.test -------------------------------------------------------------------------------- /china_area/BuildProfile.ets: -------------------------------------------------------------------------------- 1 | /** 2 | * Use these variables when you tailor your ArkTS code. They must be of the const type. 3 | */ 4 | export const HAR_VERSION = '1.0.0'; 5 | export const BUILD_MODE_NAME = 'debug'; 6 | export const DEBUG = true; 7 | export const TARGET_NAME = 'default'; 8 | 9 | /** 10 | * BuildProfile Class is used only for compatibility purposes. 11 | */ 12 | export default class BuildProfile { 13 | static readonly HAR_VERSION = HAR_VERSION; 14 | static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; 15 | static readonly DEBUG = DEBUG; 16 | static readonly TARGET_NAME = TARGET_NAME; 17 | } -------------------------------------------------------------------------------- /china_area/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 版本记录 2 | 3 | ## 1.0.0 初版 4 | 1. 发布1.0.0初版。 -------------------------------------------------------------------------------- /china_area/Index.ets: -------------------------------------------------------------------------------- 1 | export { AreaHelper } from './src/main/ets/AreaHelper' 2 | 3 | export { AreaEntity } from './src/main/ets/AreaEntity' -------------------------------------------------------------------------------- /china_area/README.md: -------------------------------------------------------------------------------- 1 | # china_area 2 | 3 | ## 🏆简介 4 | 5 | [china_area](https://ohpm.openharmony.cn/#/cn/detail/@nutpi%2Fchina_area) 中国区域数据,省市县三级数据。 6 | 7 | ## 🌞下载安装 8 | 9 | `ohpm i @nutpi/china_area` 10 | OpenHarmony ohpm 11 | 环境配置等更多内容,请参考[如何安装 OpenHarmony ohpm 包](https://ohpm.openharmony.cn/#/cn/help/downloadandinstall) 12 | 13 | ## 📚AreaHelper 14 | 15 | | 方法 | 介绍 | 16 | |:-------------------------------------------|:--------------| 17 | | getAreaStrSync
getAreaStr | 获取省市县的JSON字符串 | 18 | | getAreaSync
getArea | 获取省市县的数据 | 19 | | getCityByNameSync
getCityByName | 根据省名获取下面的市 | 20 | | getDistrictByNameSync
getDistrictByName | 根据市名获取下面的区县 | 21 | 22 | ## 🍎贡献代码与技术交流 23 | 24 | 使用过程中发现任何问题都可以提 [Issue](https://gitee.com/tongyuyan/harmony-utils/issues)给我们; 25 | 当然,我们也非常欢迎你给我们发 [PR](https://gitee.com/tongyuyan/harmony-utils/pulls) 。 26 | 27 | [https://gitee.com/tongyuyan/harmony-utils](https://gitee.com/tongyuyan/harmony-utils) 28 | [https://github.com/787107497](https://github.com/787107497) 29 | 30 | 鸿蒙技术交流QQ群:569512366 31 | 32 | ## 🌏开源协议 33 | 34 | 本项目基于 [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0.html) ,在拷贝和借鉴代码时,请大家务必注明出处。 35 | -------------------------------------------------------------------------------- /china_area/build-profile.json5: -------------------------------------------------------------------------------- 1 | { 2 | "apiType": "stageMode", 3 | "buildOption": { 4 | }, 5 | "buildOptionSet": [ 6 | { 7 | "name": "release", 8 | "arkOptions": { 9 | "obfuscation": { 10 | "ruleOptions": { 11 | "enable": false, 12 | "files": [ 13 | "./obfuscation-rules.txt" 14 | ] 15 | }, 16 | "consumerFiles": [ 17 | "./consumer-rules.txt" 18 | ] 19 | } 20 | }, 21 | }, 22 | ], 23 | "targets": [ 24 | { 25 | "name": "default" 26 | }, 27 | { 28 | "name": "ohosTest" 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /china_area/consumer-rules.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/china_area/consumer-rules.txt -------------------------------------------------------------------------------- /china_area/example/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## 📚仓库主页 3 | https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils 4 | 5 | ## 📚源码地址 6 | https://gitee.com/tongyuyan/harmony-utils 7 | https://github.com/787107497 8 | 9 | ## 📚CSDN博客 10 | https://blog.csdn.net/qq_32922545 11 | 12 | ## 💖QQ交流群 13 | 569512366 14 | -------------------------------------------------------------------------------- /china_area/hvigorfile.ts: -------------------------------------------------------------------------------- 1 | import { harTasks } from '@ohos/hvigor-ohos-plugin'; 2 | 3 | export default { 4 | system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ 5 | plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ 6 | } 7 | -------------------------------------------------------------------------------- /china_area/obfuscation-rules.txt: -------------------------------------------------------------------------------- 1 | # Define project specific obfuscation rules here. 2 | # You can include the obfuscation configuration files in the current module's build-profile.json5. 3 | # 4 | # For more details, see 5 | # https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 6 | 7 | # Obfuscation options: 8 | # -disable-obfuscation: disable all obfuscations 9 | # -enable-property-obfuscation: obfuscate the property names 10 | # -enable-toplevel-obfuscation: obfuscate the names in the global scope 11 | # -compact: remove unnecessary blank spaces and all line feeds 12 | # -remove-log: remove all console.* statements 13 | # -print-namecache: print the name cache that contains the mapping from the old names to new names 14 | # -apply-namecache: reuse the given cache file 15 | 16 | # Keep options: 17 | # -keep-property-name: specifies property names that you want to keep 18 | # -keep-global-name: specifies names that you want to keep in the global scope 19 | 20 | -enable-property-obfuscation 21 | -enable-toplevel-obfuscation 22 | -enable-filename-obfuscation 23 | -enable-export-obfuscation -------------------------------------------------------------------------------- /china_area/oh-package.json5: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@nutpi/china_area", 3 | "version": "1.0.0", 4 | "description": "中国区域数据,省市县三级数据。", 5 | "author": "桃花镇童长老", 6 | "homepage": "https://gitee.com/tongyuyan", 7 | "repository": "https://gitee.com/tongyuyan/harmony-utils", 8 | "main": "Index.ets", 9 | "license": "Apache-2.0", 10 | "dependencies": {}, 11 | "devDependencies": {}, 12 | "dynamicDependencies": {}, 13 | "keywords": [ 14 | "中国区域数据", 15 | "省市县", 16 | "picker" 17 | ], 18 | "tags": [ 19 | "中国区域数据", 20 | "省市县", 21 | "picker" 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /china_area/src/main/ets/AreaEntity.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @nutpi/china_area 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | export interface AreaEntity { 16 | text: string; 17 | level: string; 18 | code: string; 19 | pcode: string; 20 | children: Array; 21 | } -------------------------------------------------------------------------------- /china_area/src/main/module.json5: -------------------------------------------------------------------------------- 1 | { 2 | "module": { 3 | "name": "china_area", 4 | "type": "har", 5 | "deviceTypes": [ 6 | "default", 7 | "tablet", 8 | "2in1" 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /china_area/src/main/resources/base/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "page_show", 5 | "value": "page from package" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /china_area/src/main/resources/en_US/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "page_show", 5 | "value": "page from package" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /china_area/src/main/resources/zh_CN/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "page_show", 5 | "value": "page from package" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /china_area/src/ohosTest/ets/test/Ability.test.ets: -------------------------------------------------------------------------------- 1 | import { hilog } from '@kit.PerformanceAnalysisKit'; 2 | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; 3 | 4 | export default function abilityTest() { 5 | describe('ActsAbilityTest', () => { 6 | // Defines a test suite. Two parameters are supported: test suite name and test suite function. 7 | beforeAll(() => { 8 | // Presets an action, which is performed only once before all test cases of the test suite start. 9 | // This API supports only one parameter: preset action function. 10 | }) 11 | beforeEach(() => { 12 | // Presets an action, which is performed before each unit test case starts. 13 | // The number of execution times is the same as the number of test cases defined by **it**. 14 | // This API supports only one parameter: preset action function. 15 | }) 16 | afterEach(() => { 17 | // Presets a clear action, which is performed after each unit test case ends. 18 | // The number of execution times is the same as the number of test cases defined by **it**. 19 | // This API supports only one parameter: clear action function. 20 | }) 21 | afterAll(() => { 22 | // Presets a clear action, which is performed after all test cases of the test suite end. 23 | // This API supports only one parameter: clear action function. 24 | }) 25 | it('assertContain', 0, () => { 26 | // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. 27 | hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); 28 | let a = 'abc'; 29 | let b = 'b'; 30 | // Defines a variety of assertion methods, which are used to declare expected boolean conditions. 31 | expect(a).assertContain(b); 32 | expect(a).assertEqual(a); 33 | }) 34 | }) 35 | } -------------------------------------------------------------------------------- /china_area/src/ohosTest/ets/test/List.test.ets: -------------------------------------------------------------------------------- 1 | import abilityTest from './Ability.test'; 2 | 3 | export default function testsuite() { 4 | abilityTest(); 5 | } -------------------------------------------------------------------------------- /china_area/src/ohosTest/module.json5: -------------------------------------------------------------------------------- 1 | { 2 | "module": { 3 | "name": "china_area_test", 4 | "type": "feature", 5 | "deviceTypes": [ 6 | "default", 7 | "tablet", 8 | "2in1" 9 | ], 10 | "deliveryWithInstall": true, 11 | "installationFree": false 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /china_area/src/test/List.test.ets: -------------------------------------------------------------------------------- 1 | import localUnitTest from './LocalUnit.test'; 2 | 3 | export default function testsuite() { 4 | localUnitTest(); 5 | } -------------------------------------------------------------------------------- /china_area/src/test/LocalUnit.test.ets: -------------------------------------------------------------------------------- 1 | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; 2 | 3 | export default function localUnitTest() { 4 | describe('localUnitTest', () => { 5 | // Defines a test suite. Two parameters are supported: test suite name and test suite function. 6 | beforeAll(() => { 7 | // Presets an action, which is performed only once before all test cases of the test suite start. 8 | // This API supports only one parameter: preset action function. 9 | }); 10 | beforeEach(() => { 11 | // Presets an action, which is performed before each unit test case starts. 12 | // The number of execution times is the same as the number of test cases defined by **it**. 13 | // This API supports only one parameter: preset action function. 14 | }); 15 | afterEach(() => { 16 | // Presets a clear action, which is performed after each unit test case ends. 17 | // The number of execution times is the same as the number of test cases defined by **it**. 18 | // This API supports only one parameter: clear action function. 19 | }); 20 | afterAll(() => { 21 | // Presets a clear action, which is performed after all test cases of the test suite end. 22 | // This API supports only one parameter: clear action function. 23 | }); 24 | it('assertContain', 0, () => { 25 | // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. 26 | let a = 'abc'; 27 | let b = 'b'; 28 | // Defines a variety of assertion methods, which are used to declare expected boolean conditions. 29 | expect(a).assertContain(b); 30 | expect(a).assertEqual(a); 31 | }); 32 | }); 33 | } -------------------------------------------------------------------------------- /entry/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /oh_modules 3 | /.preview 4 | /build 5 | /.cxx 6 | /.test -------------------------------------------------------------------------------- /entry/build-profile.json5: -------------------------------------------------------------------------------- 1 | { 2 | "apiType": "stageMode", 3 | "buildOption": { 4 | }, 5 | "buildOptionSet": [ 6 | { 7 | "name": "release", 8 | "arkOptions": { 9 | "obfuscation": { 10 | "ruleOptions": { 11 | "enable": true, 12 | "files": [ 13 | "./obfuscation-rules.txt" 14 | ] 15 | } 16 | } 17 | } 18 | }, 19 | ], 20 | "targets": [ 21 | { 22 | "name": "default" 23 | }, 24 | { 25 | "name": "ohosTest", 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /entry/hvigorfile.ts: -------------------------------------------------------------------------------- 1 | import { hapTasks } from '@ohos/hvigor-ohos-plugin'; 2 | 3 | export default { 4 | system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ 5 | plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ 6 | } 7 | -------------------------------------------------------------------------------- /entry/libs/harmony_utils.har: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/entry/libs/harmony_utils.har -------------------------------------------------------------------------------- /entry/obfuscation-rules.txt: -------------------------------------------------------------------------------- 1 | # Define project specific obfuscation rules here. 2 | # You can include the obfuscation configuration files in the current module's build-profile.json5. 3 | # 4 | # For more details, see 5 | # https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md 6 | 7 | # Obfuscation options: 8 | # -disable-obfuscation: disable all obfuscations 9 | # -enable-property-obfuscation: obfuscate the property names 10 | # -enable-toplevel-obfuscation: obfuscate the names in the global scope 11 | # -compact: remove unnecessary blank spaces and all line feeds 12 | # -remove-log: remove all console.* statements 13 | # -print-namecache: print the name cache that contains the mapping from the old names to new names 14 | # -apply-namecache: reuse the given cache file 15 | 16 | # Keep options: 17 | # -keep-property-name: specifies property names that you want to keep 18 | # -keep-global-name: specifies names that you want to keep in the global scope 19 | 20 | # ZsHx: 21 | #-enable-property-obfuscation 22 | #-enable-toplevel-obfuscation 23 | #-enable-filename-obfuscation 24 | #-enable-export-obfuscation 25 | -enable-property-obfuscation 26 | -enable-toplevel-obfuscation 27 | -enable-filename-obfuscation 28 | -enable-export-obfuscation -------------------------------------------------------------------------------- /entry/oh-package-lock.json5: -------------------------------------------------------------------------------- 1 | { 2 | "meta": { 3 | "stableOrder": true 4 | }, 5 | "lockfileVersion": 3, 6 | "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", 7 | "specifiers": { 8 | "@nutpi/china_area@../china_area": "@nutpi/china_area@../china_area", 9 | "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", 10 | "@pura/harmony-dialog@../harmony_dialog": "@pura/harmony-dialog@../harmony_dialog", 11 | "@pura/harmony-utils@../harmony_utils": "@pura/harmony-utils@../harmony_utils", 12 | "@pura/spinkit@../spinkit": "@pura/spinkit@../spinkit", 13 | "@pura/spinkit@^1.0.4": "@pura/spinkit@../spinkit", 14 | "class-transformer@^0.5.1": "class-transformer@0.5.1" 15 | }, 16 | "packages": { 17 | "@nutpi/china_area@../china_area": { 18 | "name": "@nutpi/china_area", 19 | "version": "1.0.0", 20 | "resolved": "../china_area", 21 | "registryType": "local" 22 | }, 23 | "@ohos/hamock@1.0.0": { 24 | "name": "@ohos/hamock", 25 | "version": "1.0.0", 26 | "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", 27 | "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hamock/-/hamock-1.0.0.har", 28 | "registryType": "ohpm" 29 | }, 30 | "@pura/harmony-dialog@../harmony_dialog": { 31 | "name": "@pura/harmony-dialog", 32 | "version": "1.0.9", 33 | "resolved": "../harmony_dialog", 34 | "registryType": "local", 35 | "dependencies": { 36 | "@pura/spinkit": "^1.0.4" 37 | } 38 | }, 39 | "@pura/harmony-utils@../harmony_utils": { 40 | "name": "@pura/harmony-utils", 41 | "version": "1.2.5", 42 | "resolved": "../harmony_utils", 43 | "registryType": "local", 44 | "dependencies": { 45 | "class-transformer": "^0.5.1" 46 | } 47 | }, 48 | "@pura/spinkit@../spinkit": { 49 | "name": "@pura/spinkit", 50 | "version": "1.0.4", 51 | "resolved": "../spinkit", 52 | "registryType": "local" 53 | }, 54 | "class-transformer@0.5.1": { 55 | "name": "class-transformer", 56 | "version": "0.5.1", 57 | "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==", 58 | "resolved": "https://ohpm.openharmony.cn/ohpm/class-transformer/-/class-transformer-0.5.1.tgz", 59 | "shasum": "24147d5dffd2a6cea930a3250a677addf96ab336", 60 | "registryType": "ohpm" 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /entry/oh-package.json5: -------------------------------------------------------------------------------- 1 | { 2 | "name": "entry", 3 | "version": "1.0.1", 4 | "description": "一款高效的OpenHarmony/HarmonyOS工具包", 5 | "main": "", 6 | "author": "", 7 | "license": "", 8 | "dependencies": { 9 | //版本号需根据hvigor及SDK的配套关系进行修改 10 | "@ohos/hamock": "1.0.0", 11 | //本地引用 12 | "@pura/harmony-utils": "file:../harmony_utils", 13 | "@pura/harmony-dialog": "file:../harmony_dialog", 14 | "@pura/spinkit": "file:../spinkit", 15 | "@nutpi/china_area": "file:../china_area", 16 | // "@pura/harmony-utils": "file:./libs/harmony_utils.har", 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /entry/src/main/ets/abilitystage/MyAbilityStage.ets: -------------------------------------------------------------------------------- 1 | import { AbilityStage, Want } from '@kit.AbilityKit'; 2 | import { CrashUtil } from '@pura/harmony-utils'; 3 | 4 | export default class MyAbilityStage extends AbilityStage { 5 | 6 | onCreate() { 7 | CrashUtil.enableAppRecovery(); 8 | 9 | let want: Want = { 10 | bundleName: 'com.harmony.utils', 11 | abilityName: 'EntryAbility' 12 | }; 13 | CrashUtil.setRestartWant(want) 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /entry/src/main/ets/component/LabelButton.ets: -------------------------------------------------------------------------------- 1 | @Component 2 | export struct LabelButton { 3 | @Prop label: string; 4 | @Prop content: string; 5 | @Prop num: number = 4; 6 | onClickAction?: (index: number) => void; 7 | 8 | build() { 9 | Column() { 10 | Text(this.label) 11 | .fontColor($r('app.color.color_main')) 12 | .fontWeight(FontWeight.Bold) 13 | .fontSize(24) 14 | .fontFamily('MyFont') 15 | .margin({ top: 10, left: 10, right: 10 }) 16 | Text(this.content ?? "") 17 | .fontColor('#666666') 18 | .fontSize(16) 19 | .fontFamily('MyFont') 20 | .margin({ top: 5, bottom: 16, left: 10, right: 10 }) 21 | Row() { 22 | Blank().layoutWeight(1) 23 | Button("案例一") 24 | .type(ButtonType.Capsule) 25 | .fontFamily('MyFont') 26 | .grayscale(0.1) 27 | .onClick(() => { 28 | if (this.onClickAction) { 29 | this.onClickAction(0); 30 | } 31 | }) 32 | Blank().layoutWeight(1) 33 | Button("案例二") 34 | .type(ButtonType.Capsule) 35 | .fontFamily('MyFont') 36 | .opacity(0.9) 37 | .onClick(() => { 38 | if (this.onClickAction) { 39 | this.onClickAction(1); 40 | } 41 | }) 42 | Blank().layoutWeight(1) 43 | Button("案例三") 44 | .type(ButtonType.Capsule) 45 | .fontFamily('MyFont') 46 | .opacity(0.9) 47 | .grayscale(0.1) 48 | .onClick(() => { 49 | if (this.onClickAction) { 50 | this.onClickAction(2); 51 | } 52 | }) 53 | .visibility(this.num >= 3 ? Visibility.Visible : Visibility.None) 54 | Blank().layoutWeight(1) 55 | .visibility(this.num >= 3 ? Visibility.Visible : Visibility.None) 56 | Button("案例四") 57 | .type(ButtonType.Capsule) 58 | .fontFamily('MyFont') 59 | .onClick(() => { 60 | if (this.onClickAction) { 61 | this.onClickAction(3); 62 | } 63 | }) 64 | .visibility(this.num >= 4 ? Visibility.Visible : Visibility.None) 65 | Blank().layoutWeight(1) 66 | .visibility(this.num >= 4 ? Visibility.Visible : Visibility.None) 67 | } 68 | .width('100%') 69 | } 70 | .width('95%') 71 | .backgroundColor(Color.White) 72 | .border({ width: 2, color: $r('app.color.color_line') }) 73 | .shadow(ShadowStyle.OUTER_DEFAULT_SM) 74 | .margin({ top: 12 }) 75 | .borderRadius(6) 76 | .padding({ top: 10, bottom: 12, left: 2, right: 2 }) 77 | } 78 | } -------------------------------------------------------------------------------- /entry/src/main/ets/component/TitleBarView.ets: -------------------------------------------------------------------------------- 1 | import { DescribeBean } from '../entity/DescribeBean' 2 | import { ComposeTitleBar } from '@kit.ArkUI' 3 | import { WantUtil } from '@pura/harmony-utils' 4 | 5 | @Component 6 | export struct TitleBarView { 7 | @Prop describe: DescribeBean 8 | 9 | build() { 10 | ComposeTitleBar({ 11 | title: this.describe.name, 12 | subtitle: this.describe.desc, 13 | menuItems: [{ 14 | value: $r('app.media.icon_example'), 15 | isEnabled: true, 16 | action: () => { 17 | WantUtil.toWebBrowser(this.describe.example ?? "https://gitee.com/tongyuyan/harmony-utils") 18 | } 19 | }, { 20 | value: $r('app.media.icon_code'), 21 | isEnabled: true, 22 | action: () => { 23 | WantUtil.toWebBrowser(this.describe.code ?? "https://gitee.com/tongyuyan/harmony-utils") 24 | } 25 | }] 26 | }) 27 | } 28 | } -------------------------------------------------------------------------------- /entry/src/main/ets/entity/DescribeBean.ets: -------------------------------------------------------------------------------- 1 | export class DescribeBean { 2 | name: string = ''; 3 | desc: string = ''; 4 | type: number = 0; //0-测试页面、1-util、2-crypto 5 | example: string = ''; //案例地址 6 | code: string = ''; //源代码地址 7 | url: string = ''; //url地址 8 | 9 | constructor(name: string, desc: string, type: number = 0) { 10 | this.name = name; 11 | this.desc = desc; 12 | this.type = type; 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /entry/src/main/ets/entity/User.ets: -------------------------------------------------------------------------------- 1 | import { LogUtil } from '@pura/harmony-utils'; 2 | 3 | export class User { 4 | id: string = 'No_1060701'; 5 | name: string = '张三'; 6 | age: number = 20; 7 | addr?: string = '乌市天山区'; 8 | work?: string = '工程师'; 9 | state?: string = ''; 10 | user?: User; 11 | url?: string; 12 | 13 | say(msg: string) { 14 | LogUtil.error(`我想吃:${msg}`); 15 | } 16 | 17 | print() { 18 | LogUtil.error("我是User对象~~~~~~"); 19 | } 20 | } -------------------------------------------------------------------------------- /entry/src/main/ets/entryability/EntryAbility.ets: -------------------------------------------------------------------------------- 1 | import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; 2 | import { hilog } from '@kit.PerformanceAnalysisKit'; 3 | import { font, window } from '@kit.ArkUI'; 4 | import { AppUtil } from '@pura/harmony-utils'; 5 | import { WindowUtil } from '../utils/WindowUtil'; 6 | import { DialogHelper } from '@pura/harmony-dialog'; 7 | 8 | export default class EntryAbility extends UIAbility { 9 | 10 | onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { 11 | AppUtil.init(this.context); 12 | DialogHelper.setDefaultConfig((config) => { 13 | config.uiAbilityContext = this.context; 14 | }) 15 | } 16 | 17 | 18 | onDestroy(): void { 19 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); 20 | } 21 | 22 | onWindowStageCreate(windowStage: window.WindowStage): void { 23 | WindowUtil.init(windowStage) 24 | windowStage.loadContent('pages/Index', (err) => { 25 | if (err.code) { 26 | hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); 27 | return; 28 | } 29 | font.registerFont({ 30 | familyName: 'MyFont', familySrc: $rawfile('MyFont.ttf') 31 | }) 32 | hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); 33 | }); 34 | 35 | } 36 | 37 | onWindowStageDestroy(): void { 38 | // Main window is destroyed, release UI related resources 39 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); 40 | } 41 | 42 | onForeground(): void { 43 | // Ability has brought to foreground 44 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); 45 | } 46 | 47 | onBackground(): void { 48 | // Ability has back to background 49 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); 50 | } 51 | 52 | //返回true表示UIAbility将会被移到后台不销毁,返回false表示UIAbility将正常销毁。 53 | onBackPressed(): boolean { 54 | return true; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /entry/src/main/ets/pages/Index.ets: -------------------------------------------------------------------------------- 1 | import { UtilsPage } from './index/UtilsPage'; 2 | import { DialogPage } from './index/DialogPage'; 3 | import { SpinKitPage } from './index/SpinKitPage'; 4 | import { OtherPage } from './index/OtherPage'; 5 | 6 | /** 7 | * 主页面 8 | */ 9 | @Entry 10 | @Component 11 | struct Index { 12 | private tabsController: TabsController = new TabsController(); 13 | @State index: number = 0; 14 | 15 | onBackPress(): boolean { 16 | return false; 17 | } 18 | 19 | build() { 20 | Tabs({ barPosition: BarPosition.End, index: this.index, controller: this.tabsController }) { 21 | TabContent() { 22 | UtilsPage() 23 | } 24 | .tabBar(this.tabBuilder(0, $r('app.media.icon_tab_utils'), "工具")) 25 | 26 | TabContent() { 27 | DialogPage() 28 | } 29 | .tabBar(this.tabBuilder(1, $r('app.media.icon_tab_dialog'), "弹框")) 30 | 31 | TabContent() { 32 | SpinKitPage() 33 | } 34 | .tabBar(this.tabBuilder(2, $r("app.media.icon_tab_spin"), "动画")) 35 | 36 | TabContent() { 37 | OtherPage() 38 | } 39 | .tabBar(this.tabBuilder(3, $r('app.media.icon_tab_mine'), "我的")) 40 | } 41 | .divider({ strokeWidth: 1, color: $r('app.color.color_line') }) 42 | .vertical(false) 43 | .barMode(BarMode.Fixed) 44 | .backgroundColor($r('app.color.main_background')) 45 | .fadingEdge(false) 46 | .barOverlap(false) 47 | .barBackgroundColor(Color.White) 48 | .width('100%') 49 | .height('100%') 50 | .onChange((index: number) => { //页面切换回调 51 | this.index = index; 52 | }) 53 | } 54 | 55 | /** 56 | * 57 | * @param index 58 | * @param icon 59 | * @param text 60 | */ 61 | @Builder 62 | tabBuilder(index: number, icon: string | Resource, text: string | Resource) { 63 | Column() { 64 | Image(icon) 65 | .width(26) 66 | .height(26) 67 | .objectFit(ImageFit.Auto) 68 | .fillColor(index == this.index ? Color.Brown : Color.Gray) 69 | Text(text) 70 | .fontSize(15) 71 | .fontColor(index == this.index ? Color.Brown : Color.Gray) 72 | .fontStyle(FontStyle.Normal) 73 | .margin({ top: 5 }) 74 | .fontFamily('MyFont') 75 | } 76 | .backgroundColor(Color.Transparent) 77 | .alignItems(HorizontalAlign.Center) 78 | .justifyContent(FlexAlign.Center) 79 | .alignSelf(ItemAlign.Center) 80 | } 81 | } -------------------------------------------------------------------------------- /entry/src/main/ets/pages/index/RoomPage.ets: -------------------------------------------------------------------------------- 1 | @Preview 2 | @Component 3 | export struct RoomPage { 4 | private scroller: Scroller = new Scroller(); 5 | 6 | build() { 7 | Column() { 8 | Text("艺术欣赏") 9 | .height(50) 10 | .width('100%') 11 | .backgroundColor(Color.White) 12 | .textAlign(TextAlign.Center) 13 | .fontWeight(FontWeight.Bold) 14 | .fontSize(24) 15 | Divider() 16 | Scroll(this.scroller) { 17 | Column() { 18 | Text("美女欣赏") 19 | .width("100%") 20 | .fontSize(18) 21 | .fontColor(Color.Pink) 22 | .fontStyle(FontStyle.Italic) 23 | .fontWeight(FontWeight.Bold) 24 | .textAlign(TextAlign.Center) 25 | .backgroundColor('#F0F0F0') 26 | .padding({ top: 12, bottom: 12 }) 27 | 28 | Image('https://photo.4305.net.cn/upload/image/20230319/6381486004561976509381023.jpg') 29 | .objectFit(ImageFit.Auto) 30 | .width('90%') 31 | .margin(10) 32 | Image($r('app.media.test_as4')) 33 | .objectFit(ImageFit.Auto) 34 | .width('90%') 35 | .margin(10) 36 | 37 | Text("油画与艺术欣赏") 38 | .width("100%") 39 | .fontStyle(FontStyle.Italic) 40 | .fontWeight(FontWeight.Bold) 41 | .fontColor(Color.Pink) 42 | .fontSize(20) 43 | .fontColor(Color.Black) 44 | .textAlign(TextAlign.Center) 45 | .backgroundColor('#F0F0F0') 46 | .padding({ top: 20, bottom: 15 }) 47 | .margin({ top: 30 }) 48 | 49 | Image('https://i.ebayimg.com/images/g/TqoAAOSwXBlmOfcs/s-l1600.webp') 50 | .objectFit(ImageFit.Auto) 51 | .width('100%') 52 | .margin({ top: 10, bottom: 10 }) 53 | Image('https://i.ebayimg.com/images/g/x9MAAOSwBERmuRqE/s-l1600.webp') 54 | .objectFit(ImageFit.Auto) 55 | .width('90%') 56 | .margin({ top: 10, bottom: 10 }) 57 | 58 | Blank().layoutWeight(1) 59 | } 60 | .width('100%') 61 | } 62 | .layoutWeight(1) 63 | .width('100%') 64 | .backgroundColor(Color.White) 65 | } 66 | .width("100%") 67 | .height("100%") 68 | } 69 | } -------------------------------------------------------------------------------- /entry/src/main/ets/pages/utils/AssetUtilPage.ets: -------------------------------------------------------------------------------- 1 | import { router } from '@kit.ArkUI'; 2 | import { DescribeBean } from '../../entity/DescribeBean'; 3 | import { MockSetup } from '@ohos/hamock'; 4 | import { AssetUtil, LogUtil, ToastUtil } from '@pura/harmony-utils'; 5 | import { TitleBarView } from '../../component/TitleBarView'; 6 | 7 | /** 8 | * 关键资产存储服务工具类 9 | */ 10 | @Entry 11 | @Component 12 | struct Index { 13 | private scroller: Scroller = new Scroller(); 14 | @State describe: DescribeBean = router.getParams() as DescribeBean; 15 | @State readonly rkey: string = "key_harmony" 16 | @State readonly skey: string = "key_harmony_sync" 17 | 18 | @MockSetup 19 | mock() { 20 | this.describe = new DescribeBean("AssetUtil", "关键资产存储服务工具类"); 21 | } 22 | 23 | 24 | build() { 25 | Column() { 26 | TitleBarView({ describe: this.describe }) 27 | Divider() 28 | Scroll(this.scroller) { 29 | Column() { 30 | Button("add") 31 | .btnStyle() 32 | .onClick(() => { 33 | AssetUtil.add(this.rkey, "我是异步知产X!") 34 | }) 35 | Button("get") 36 | .btnStyle() 37 | .onClick(async () => { 38 | let rStr = await AssetUtil.get(this.rkey) 39 | ToastUtil.showToast(`取值: ${rStr}`) 40 | LogUtil.error(`取值: ${rStr}`) 41 | }) 42 | Button("addSync") 43 | .btnStyle() 44 | .onClick(() => { 45 | AssetUtil.addSync(this.skey, "我是同步知产X!") 46 | }) 47 | Button("getSync") 48 | .btnStyle() 49 | .onClick(() => { 50 | let sStr = AssetUtil.getSync(this.skey) 51 | ToastUtil.showToast(`同步:${sStr}`) 52 | }) 53 | Button("remove") 54 | .btnStyle() 55 | .onClick(() => { 56 | AssetUtil.remove(this.rkey).then(() => { 57 | ToastUtil.showToast("移除成功!") 58 | }) 59 | }) 60 | Button("removeSync") 61 | .btnStyle() 62 | .onClick(() => { 63 | AssetUtil.removeSync(this.skey) 64 | ToastUtil.showToast("移除成功!!!") 65 | }) 66 | 67 | Text().layoutWeight(1) 68 | } 69 | .margin({ top: 5, bottom: 5 }) 70 | } 71 | .layoutWeight(1) 72 | } 73 | .width('100%') 74 | .height('100%') 75 | .justifyContent(FlexAlign.Start) 76 | .backgroundColor($r('app.color.main_background')) 77 | } 78 | } 79 | 80 | @Styles 81 | function btnStyle() { 82 | .width('90%') 83 | .margin({ top: 10, bottom: 5 }) 84 | } 85 | 86 | @Styles 87 | function textStyle() { 88 | .width('95%') 89 | .padding(10) 90 | .shadow(ShadowStyle.OUTER_DEFAULT_XS) 91 | .margin({ top: 5, bottom: 10 }) 92 | .backgroundColor(Color.White) 93 | .border({ 94 | width: 1, 95 | color: Color.Grey, 96 | radius: 10, 97 | style: BorderStyle.Dashed 98 | }) 99 | } -------------------------------------------------------------------------------- /entry/src/main/ets/pages/utils/CacheUtilPage.ets: -------------------------------------------------------------------------------- 1 | import { router } from '@kit.ArkUI'; 2 | import { MockSetup } from '@ohos/hamock'; 3 | import { CacheUtil, ToastUtil } from '@pura/harmony-utils'; 4 | import { TitleBarView } from '../../component/TitleBarView'; 5 | import { DescribeBean } from '../../entity/DescribeBean'; 6 | 7 | /** 8 | * "缓存工具类 9 | */ 10 | @Entry 11 | @Component 12 | struct Index { 13 | private scroller: Scroller = new Scroller(); 14 | @State describe: DescribeBean = router.getParams() as DescribeBean; 15 | 16 | @MockSetup 17 | mock() { 18 | this.describe = new DescribeBean("CacheUtil", "缓存工具类"); 19 | } 20 | 21 | build() { 22 | Column() { 23 | TitleBarView({ describe: this.describe }) 24 | Divider() 25 | Scroll(this.scroller) { 26 | Column() { 27 | Button("put()") 28 | .btnStyle() 29 | .onClick(() => { 30 | CacheUtil.put("pwd", "ABCD@12345") 31 | ToastUtil.showToast("缓存密码成功"); 32 | }) 33 | Button("get()") 34 | .btnStyle() 35 | .onClick(() => { 36 | let pwd = CacheUtil.get("pwd"); 37 | ToastUtil.showToast(`取值:${pwd}`); 38 | }) 39 | Button("has()") 40 | .btnStyle() 41 | .onClick(() => { 42 | let pwd = CacheUtil.has("pwd"); 43 | ToastUtil.showToast(`缓存是否存在:${pwd}`); 44 | }) 45 | Button("isEmpty()") 46 | .btnStyle() 47 | .onClick(() => { 48 | let blEmpty = CacheUtil.isEmpty(); 49 | ToastUtil.showToast(`缓存是否为空:${blEmpty}`); 50 | }) 51 | Button("clear()") 52 | .btnStyle() 53 | .onClick(() => { 54 | CacheUtil.clear(); 55 | ToastUtil.showToast(`清除缓存数据成功`); 56 | }) 57 | 58 | Blank().layoutWeight(1) 59 | } 60 | .margin({ top: 5, bottom: 5 }) 61 | } 62 | .layoutWeight(1) 63 | } 64 | .width('100%') 65 | .height('100%') 66 | .justifyContent(FlexAlign.Start) 67 | .backgroundColor($r('app.color.main_background')) 68 | } 69 | } 70 | 71 | 72 | @Styles 73 | function btnStyle() { 74 | .width('90%') 75 | .margin({ top: 10, bottom: 5 }) 76 | } 77 | 78 | @Styles 79 | function textStyle() { 80 | .width('95%') 81 | .padding(10) 82 | .shadow(ShadowStyle.OUTER_DEFAULT_XS) 83 | .margin({ top: 5, bottom: 10 }) 84 | .backgroundColor(Color.White) 85 | .border({ 86 | width: 1, 87 | color: Color.Grey, 88 | radius: 10, 89 | style: BorderStyle.Dashed 90 | }) 91 | } -------------------------------------------------------------------------------- /entry/src/main/ets/pages/utils/ClickUtilPage.ets: -------------------------------------------------------------------------------- 1 | import { router } from '@kit.ArkUI'; 2 | import { MockSetup } from '@ohos/hamock'; 3 | import { ClickUtil, ToastUtil } from '@pura/harmony-utils'; 4 | import { TitleBarView } from '../../component/TitleBarView'; 5 | import { DescribeBean } from '../../entity/DescribeBean'; 6 | 7 | /** 8 | * 节流、防抖 工具类(可用于点击事件,防止按钮被重复点击) 9 | */ 10 | @Entry 11 | @Component 12 | struct Index { 13 | private scroller: Scroller = new Scroller(); 14 | @State describe: DescribeBean = router.getParams() as DescribeBean; 15 | 16 | @MockSetup 17 | mock() { 18 | this.describe = new DescribeBean("ClickUtil", "节流、防抖 工具类(可用于点击事件,防止按钮被重复点击)"); 19 | } 20 | 21 | build() { 22 | Column() { 23 | TitleBarView({ describe: this.describe }) 24 | Divider() 25 | Scroll(this.scroller) { 26 | Column() { 27 | Button("throttle()") 28 | .btnStyle() 29 | .onClick(() => { 30 | ClickUtil.throttle(() => { 31 | ToastUtil.showToast("你好啊!X1"); 32 | }, 1200) 33 | }) 34 | Button("throttle()") 35 | .btnStyle() 36 | .onClick(() => { 37 | ClickUtil.throttle(() => { 38 | ToastUtil.showToast("你好啊!X2"); 39 | }) 40 | }) 41 | 42 | Button("debounce(),单点击") 43 | .btnStyle() 44 | .onClick(() => { 45 | ClickUtil.debounce(() => { 46 | ToastUtil.showToast("点了我!D1"); 47 | }, 1200) 48 | }) 49 | Button("debounce(),多点击事件") 50 | .btnStyle() 51 | .onClick(() => { 52 | ClickUtil.debounce(() => { 53 | ToastUtil.showToast("点了我!D2S"); 54 | }, 1200, "1000001") 55 | }) 56 | Button("debounce(),多点击事件") 57 | .btnStyle() 58 | .onClick(() => { 59 | ClickUtil.debounce(() => { 60 | ToastUtil.showToast("点了我!D3S"); 61 | }, 1200, "1000002") 62 | }) 63 | 64 | Blank().layoutWeight(1) 65 | } 66 | .margin({ top: 5, bottom: 5 }) 67 | } 68 | .layoutWeight(1) 69 | } 70 | .width('100%') 71 | .height('100%') 72 | .justifyContent(FlexAlign.Start) 73 | .backgroundColor($r('app.color.main_background')) 74 | } 75 | } 76 | 77 | 78 | @Styles 79 | function btnStyle() { 80 | .width('90%') 81 | .margin({ top: 10, bottom: 5 }) 82 | } 83 | 84 | @Styles 85 | function textStyle() { 86 | .width('95%') 87 | .padding(10) 88 | .shadow(ShadowStyle.OUTER_DEFAULT_XS) 89 | .margin({ top: 5, bottom: 10 }) 90 | .backgroundColor(Color.White) 91 | .border({ 92 | width: 1, 93 | color: Color.Grey, 94 | radius: 10, 95 | style: BorderStyle.Dashed 96 | }) 97 | } -------------------------------------------------------------------------------- /entry/src/main/ets/pages/utils/CrashUtilPage.ets: -------------------------------------------------------------------------------- 1 | import { router } from '@kit.ArkUI'; 2 | import { MockSetup } from '@ohos/hamock'; 3 | import { CrashUtil, FileUtil, StrUtil, ToastUtil } from '@pura/harmony-utils'; 4 | import { TitleBarView } from '../../component/TitleBarView'; 5 | import { DescribeBean } from '../../entity/DescribeBean'; 6 | 7 | /** 8 | * 全局异常捕获,崩溃日志收集 9 | */ 10 | @Entry 11 | @Component 12 | struct Index { 13 | private scroller: Scroller = new Scroller(); 14 | @State describe: DescribeBean = router.getParams() as DescribeBean; 15 | @State errorTxt: string = ''; 16 | 17 | @MockSetup 18 | mock() { 19 | this.describe = new DescribeBean("CrashUtil", "全局异常捕获,崩溃日志收集"); 20 | } 21 | 22 | build() { 23 | Column() { 24 | TitleBarView({ describe: this.describe }) 25 | Divider() 26 | Scroll(this.scroller) { 27 | Column() { 28 | Button("onError()") 29 | .btnStyle() 30 | .onClick(() => { 31 | CrashUtil.onError(); //注册错误观测器 32 | ToastUtil.showToast("注册错误观测器,成功") 33 | }) 34 | Button("offError()") 35 | .btnStyle() 36 | .onClick(() => { 37 | CrashUtil.offError(); //注销错误观测器 38 | ToastUtil.showToast("注销错误观测器,成功") 39 | }) 40 | Button("onExportErrorLog()") 41 | .btnStyle() 42 | .onClick(() => { 43 | CrashUtil.onExportErrorLog(); //导出错误日志文件 44 | }) 45 | Button("readErrorText") 46 | .btnStyle() 47 | .onClick(async () => { 48 | this.errorTxt = await CrashUtil.readErrorText(); //读取错误文件 49 | }) 50 | Button("制造异常") 51 | .btnStyle() 52 | .onClick(() => { 53 | let path = 'null'; 54 | FileUtil.openSync(path) 55 | }) 56 | Button("重启APP") 57 | .btnStyle() 58 | .onClick(() => { 59 | CrashUtil.restartApp(); 60 | }) 61 | Text(this.errorTxt) 62 | .visibility(StrUtil.isNotEmpty(this.errorTxt) ? Visibility.Visible : Visibility.None) 63 | .textStyle() 64 | 65 | Text('').layoutWeight(1) 66 | } 67 | .margin({ top: 5, bottom: 5 }) 68 | } 69 | 70 | .layoutWeight(1) 71 | } 72 | .width('100%') 73 | .height('100%') 74 | .justifyContent(FlexAlign.Start) 75 | .backgroundColor($r('app.color.main_background')) 76 | } 77 | } 78 | 79 | 80 | @Styles 81 | function btnStyle() { 82 | .width('90%') 83 | .margin({ top: 10, bottom: 5 }) 84 | } 85 | 86 | @Styles 87 | function textStyle() { 88 | .width('95%') 89 | .padding(10) 90 | .shadow(ShadowStyle.OUTER_DEFAULT_XS) 91 | .margin({ top: 5, bottom: 10 }) 92 | .backgroundColor(Color.White) 93 | .border({ width: 1, color: Color.Grey, radius: 10, style: BorderStyle.Dashed }) 94 | } -------------------------------------------------------------------------------- /entry/src/main/ets/pages/utils/KeyboardUtilPage.ets: -------------------------------------------------------------------------------- 1 | import { router } from '@kit.ArkUI'; 2 | import { MockSetup } from '@ohos/hamock'; 3 | import { KeyboardUtil, ToastUtil } from '@pura/harmony-utils'; 4 | import { TitleBarView } from '../../component/TitleBarView'; 5 | import { DescribeBean } from '../../entity/DescribeBean'; 6 | 7 | /** 8 | * 键盘工具类 9 | */ 10 | @Entry 11 | @Component 12 | struct Index { 13 | private scroller: Scroller = new Scroller(); 14 | private controller: TextInputController = new TextInputController() 15 | @State describe: DescribeBean = router.getParams() as DescribeBean; 16 | 17 | @MockSetup 18 | mock() { 19 | this.describe = new DescribeBean("KeyboardUtil", "键盘工具类"); 20 | } 21 | 22 | build() { 23 | Column() { 24 | TitleBarView({ describe: this.describe }) 25 | Divider() 26 | Scroll(this.scroller) { 27 | Column() { 28 | Button("show(),主动拉起键盘") 29 | .btnStyle() 30 | .onClick(() => { 31 | KeyboardUtil.show("id_input_1000"); 32 | }) 33 | 34 | Button("hide(),关闭键盘") 35 | .btnStyle() 36 | .onClick(() => { 37 | KeyboardUtil.hide(); 38 | }) 39 | Button("onKeyboardListener()") 40 | .btnStyle() 41 | .onClick(() => { 42 | KeyboardUtil.onKeyboardListener(1000, (show, height) => { 43 | if (show) { 44 | ToastUtil.showToast(`键盘显示,高度为:${height}`); 45 | } else { 46 | ToastUtil.showToast(`键盘已关闭!`); 47 | } 48 | }); 49 | }) 50 | Button("removeKeyboardListener()") 51 | .btnStyle() 52 | .onClick(() => { 53 | KeyboardUtil.removeKeyboardListener(1000); 54 | }) 55 | 56 | TextInput({ placeholder: '请输入', controller: this.controller }) 57 | .margin({ top: 30 }) 58 | .width('90%') 59 | .id("id_input_1000") 60 | 61 | Blank().layoutWeight(1) 62 | } 63 | .margin({ top: 5, bottom: 5 }) 64 | } 65 | .layoutWeight(1) 66 | } 67 | .width('100%') 68 | .height('100%') 69 | .justifyContent(FlexAlign.Start) 70 | .backgroundColor($r('app.color.main_background')) 71 | } 72 | } 73 | 74 | 75 | @Styles 76 | function btnStyle() { 77 | .width('90%') 78 | .margin({ top: 10, bottom: 5 }) 79 | } 80 | 81 | @Styles 82 | function textStyle() { 83 | .width('95%') 84 | .padding(10) 85 | .shadow(ShadowStyle.OUTER_DEFAULT_XS) 86 | .margin({ top: 5, bottom: 10 }) 87 | .backgroundColor(Color.White) 88 | .border({ 89 | width: 1, 90 | color: Color.Grey, 91 | radius: 10, 92 | style: BorderStyle.Dashed 93 | }) 94 | } -------------------------------------------------------------------------------- /entry/src/main/ets/pages/utils/TempUtilPage.ets: -------------------------------------------------------------------------------- 1 | import { router } from '@kit.ArkUI'; 2 | import { MockSetup } from '@ohos/hamock'; 3 | import { TempUtil, ToastUtil } from '@pura/harmony-utils'; 4 | import { TitleBarView } from '../../component/TitleBarView'; 5 | import { DescribeBean } from '../../entity/DescribeBean'; 6 | 7 | /** 8 | * 温度转换工具类,华氏度与摄氏度相互转换 9 | */ 10 | @Entry 11 | @Component 12 | struct Index { 13 | private scroller: Scroller = new Scroller(); 14 | @State describe: DescribeBean = router.getParams() as DescribeBean; 15 | 16 | @MockSetup 17 | mock() { 18 | this.describe = new DescribeBean("TempUtil", "温度转换工具类,华氏度与摄氏度相互转换"); 19 | } 20 | 21 | build() { 22 | Column() { 23 | TitleBarView({ describe: this.describe }) 24 | Divider() 25 | Scroll(this.scroller) { 26 | Column() { 27 | Button("F2C()") 28 | .btnStyle() 29 | .onClick(() => { 30 | let c = TempUtil.F2C(81.5) 31 | ToastUtil.showToast(`转换后的摄氏度:${c}`) 32 | }) 33 | Button("C2F()") 34 | .btnStyle() 35 | .onClick(() => { 36 | let f = TempUtil.C2F(27.5); 37 | ToastUtil.showToast(`转换后的华氏度${f}`) 38 | }) 39 | 40 | Text('').layoutWeight(1) 41 | } 42 | .margin({ top: 5, bottom: 5 }) 43 | } 44 | .layoutWeight(1) 45 | } 46 | .width('100%') 47 | .height('100%') 48 | .justifyContent(FlexAlign.Start) 49 | .backgroundColor($r('app.color.main_background')) 50 | } 51 | } 52 | 53 | 54 | @Styles 55 | function btnStyle() { 56 | .width('90%') 57 | .margin({ top: 10, bottom: 5 }) 58 | } 59 | 60 | @Styles 61 | function textStyle() { 62 | .width('95%') 63 | .padding(10) 64 | .shadow(ShadowStyle.OUTER_DEFAULT_XS) 65 | .margin({ top: 5, bottom: 10 }) 66 | .backgroundColor(Color.White) 67 | .border({ width: 1, color: Color.Grey, radius: 10, style: BorderStyle.Dashed }) 68 | } -------------------------------------------------------------------------------- /entry/src/main/ets/utils/DrawerOptions.ets: -------------------------------------------------------------------------------- 1 | import { BaseDialogOptions } from '@pura/harmony-dialog'; 2 | 3 | //自定义弹框 4 | export interface DrawerOptions extends BaseDialogOptions { 5 | width: number; //宽度 6 | msg: string; 7 | } -------------------------------------------------------------------------------- /entry/src/main/ets/utils/MyCustomOptions.ets: -------------------------------------------------------------------------------- 1 | import { BaseDialogOptions } from '@pura/harmony-dialog'; 2 | 3 | //自定义弹框 4 | export interface MyCustomOptions extends BaseDialogOptions { 5 | height: number; //高度 6 | msg: string; 7 | } -------------------------------------------------------------------------------- /entry/src/main/ets/utils/WindowUtil.ets: -------------------------------------------------------------------------------- 1 | import { display, window } from '@kit.ArkUI'; 2 | import { BusinessError } from '@kit.BasicServicesKit'; 3 | import { LogUtil } from '@pura/harmony-utils'; 4 | 5 | 6 | /** 7 | * 窗口工具类 8 | */ 9 | export class WindowUtil { 10 | private constructor() { 11 | } 12 | 13 | 14 | private static windowStage_: window.WindowStage 15 | 16 | static init(windowStage: window.WindowStage) { 17 | WindowUtil.windowStage_ = windowStage 18 | } 19 | 20 | /** 21 | * 缓存窗体,关闭时需要 22 | */ 23 | private static cacheWindow: window.Window; 24 | 25 | 26 | /** 27 | * 根据参数创建窗口 28 | */ 29 | static async createWindow(options: WinOptions): Promise { 30 | if (!options) { 31 | options = new WinOptions(); 32 | } 33 | if (!options.name) { 34 | options.name = 'utils001'; 35 | } 36 | if (options.windowType == undefined) { 37 | options.windowType = window.WindowType.TYPE_DIALOG; 38 | } 39 | if (!options.bgColor) { 40 | options.bgColor = '#33606266'; 41 | } 42 | try { 43 | //创建窗口 44 | // let windowClass = await window.createWindow({ 45 | // name: options.name, 46 | // windowType: options.windowType, 47 | // ctx: getContext() as common.UIAbilityContext 48 | // }); 49 | //创建窗口 50 | let windowClass = await WindowUtil.windowStage_.createSubWindow(options.name); 51 | WindowUtil.cacheWindow = windowClass; //将窗口缓存 52 | await windowClass.setUIContent(options.contentRouter); 53 | let d = display.getDefaultDisplaySync(); 54 | await windowClass.resize(d.width/2, d.height/2); 55 | windowClass.setWindowBackgroundColor(options.bgColor); 56 | await windowClass.showWindow(); 57 | } catch (err) { 58 | let error = err as BusinessError; 59 | LogUtil.error(`WindowUtil-createWindow-异常 ~ code: ${error.code} -·- message: ${error.message}`); 60 | } 61 | } 62 | 63 | 64 | //设置子窗口背景透明 65 | static setWindowBackgroundColor() { 66 | if (WindowUtil.cacheWindow) { 67 | WindowUtil.cacheWindow.setWindowBackgroundColor("#00000000") 68 | } 69 | } 70 | 71 | 72 | /** 73 | * 关闭窗口 74 | */ 75 | static async closeWindow(): Promise { 76 | if (WindowUtil.cacheWindow) { 77 | await WindowUtil.cacheWindow.destroyWindow(); 78 | } 79 | } 80 | } 81 | 82 | 83 | /** 84 | * 窗口参数 85 | */ 86 | class WinOptions { 87 | name?: string; //窗口名称 88 | windowType?: window.WindowType; //窗口类型 默认TYPE_DIALOG 89 | contentRouter: string = ''; //窗口要显示的路由,如:pages/index 90 | bgColor?: string; //窗口背景颜色 91 | callBack?: () => void; //回调函数 92 | } -------------------------------------------------------------------------------- /entry/src/main/resources/base/element/boolean.json: -------------------------------------------------------------------------------- 1 | { 2 | "boolean": [ 3 | { 4 | "name": "bl_debug", 5 | "value": true 6 | }, 7 | { 8 | "name": "bl_agree", 9 | "value": false 10 | }, 11 | { 12 | "name": "bl_big", 13 | "value": true 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /entry/src/main/resources/base/element/color.json: -------------------------------------------------------------------------------- 1 | { 2 | "color": [ 3 | { 4 | "name": "start_window_background", 5 | "value": "#FFFFFF" 6 | }, 7 | { 8 | "name": "main_background", 9 | "value": "#FAFAFA" 10 | }, 11 | { 12 | "name": "color_33", 13 | "value": "#333333" 14 | }, 15 | { 16 | "name": "color_66", 17 | "value": "#666666" 18 | }, 19 | { 20 | "name": "color_99", 21 | "value": "#999999" 22 | }, 23 | { 24 | "name": "color_cc", 25 | "value": "#cccccc" 26 | }, 27 | { 28 | "name": "color_dd", 29 | "value": "#dddddd" 30 | }, 31 | { 32 | "name": "color_ee", 33 | "value": "#eeeeee" 34 | }, 35 | { 36 | "name": "color_cancel", 37 | "value": "#0A59F7" 38 | }, 39 | { 40 | "name": "color_line", 41 | "value": "#ECECEC" 42 | }, 43 | { 44 | "name": "color_red", 45 | "value": "#FF0000" 46 | }, 47 | { 48 | "name": "color_main", 49 | "value": "#0A59F7" 50 | }, 51 | { 52 | "name": "color1", 53 | "value": "#D45100" 54 | }, 55 | { 56 | "name": "color2", 57 | "value": "#2A3D50" 58 | }, 59 | { 60 | "name": "color3", 61 | "value": "#00BA9B" 62 | }, 63 | { 64 | "name": "color4", 65 | "value": "#217DBA" 66 | }, 67 | { 68 | "name": "color5", 69 | "value": "#934EFF" 70 | }, 71 | { 72 | "name": "color6", 73 | "value": "#FEC95A" 74 | }, 75 | { 76 | "name": "color7", 77 | "value": "#DE5246" 78 | }, 79 | { 80 | "name": "color8", 81 | "value": "#17A05E" 82 | }, 83 | { 84 | "name": "color9", 85 | "value": "#0073FF" 86 | }, 87 | { 88 | "name": "color10", 89 | "value": "#934EFF" 90 | }, 91 | { 92 | "name": "color11", 93 | "value": "#4A70FF" 94 | }, 95 | { 96 | "name": "color12", 97 | "value": "#F46957" 98 | }, 99 | { 100 | "name": "color13", 101 | "value": "#4C8BF5" 102 | }, 103 | { 104 | "name": "color14", 105 | "value": "#7D8A8B" 106 | }, 107 | { 108 | "name": "color15", 109 | "value": "#54D562" 110 | } 111 | , 112 | { 113 | "name": "color66", 114 | "value": "#666666" 115 | } 116 | , 117 | { 118 | "name": "colorF0", 119 | "value": "#F0F0F0" 120 | } 121 | ] 122 | } -------------------------------------------------------------------------------- /entry/src/main/resources/base/element/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "integer": [ 3 | { 4 | "name": "count", 5 | "value": 109 6 | }, 7 | { 8 | "name": "age", 9 | "value": 18 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /entry/src/main/resources/base/element/plural.json: -------------------------------------------------------------------------------- 1 | { 2 | "plural": [ 3 | { 4 | "name": "eat_apple", 5 | "value": [{"quantity":"one","value":"%d apple"},{"quantity":"other","value":"%d apples"}] 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /entry/src/main/resources/base/element/strarray.json: -------------------------------------------------------------------------------- 1 | { 2 | "strarray": [ 3 | { 4 | "name": "font_size", 5 | "value": [ 6 | { 7 | "value": "mini" 8 | }, 9 | { 10 | "value": "small" 11 | }, 12 | { 13 | "value": "normal" 14 | }, 15 | { 16 | "value": "medium" 17 | } 18 | ] 19 | } 20 | ] 21 | } -------------------------------------------------------------------------------- /entry/src/main/resources/base/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "module_desc", 5 | "value": "一款功能丰富且极易上手的HarmonyOS工具库,借助众多实用工具类,致力于助力开发者迅速构建鸿蒙应用。其封装的工具涵盖了APP、设备、屏幕、授权、通知、线程间通信、弹框、吐司、生物认证、用户首选项、拍照、相册、扫码、文件、日志,异常捕获、字符、字符串、数字、集合、日期、随机、base64、加密、解密、JSON等一系列的功能和操作,能够满足各种不同的开发需求。" 6 | }, 7 | { 8 | "name": "EntryAbility_desc", 9 | "value": "一款功能丰富且极易上手的HarmonyOS工具库,借助众多实用工具类,致力于助力开发者迅速构建鸿蒙应用。其封装的工具涵盖了APP、设备、屏幕、授权、通知、线程间通信、弹框、吐司、生物认证、用户首选项、拍照、相册、扫码、文件、日志,异常捕获、字符、字符串、数字、集合、日期、随机、base64、加密、解密、JSON等一系列的功能和操作,能够满足各种不同的开发需求。" 10 | }, 11 | { 12 | "name": "spinKit", 13 | "value": "SpinKit" 14 | }, 15 | { 16 | "name": "spinKit_desc", 17 | "value": "一个适用于OpenHarmony/HarmonyOS的加载动画库。" 18 | }, 19 | { 20 | "name": "EntryAbility_label", 21 | "value": "鸿蒙宝典" 22 | }, 23 | { 24 | "name": "btn_sure", 25 | "value": "确定" 26 | }, 27 | { 28 | "name": "btn_cancel", 29 | "value": "取消" 30 | }, 31 | { 32 | "name": "btn_save", 33 | "value": "保存" 34 | }, 35 | { 36 | "name": "permission_APP_TRACKING_CONSENT", 37 | "value": "用于应用读取设备标识符" 38 | }, 39 | { 40 | "name": "permission_ACTIVITY_MOTION", 41 | "value": "用于应用读取用户的运动状态" 42 | }, 43 | { 44 | "name": "permission_LOCATION", 45 | "value": "用于应用获取设备位置信息" 46 | }, 47 | { 48 | "name": "permission_CAMERA", 49 | "value": "用于应用使用相机" 50 | }, 51 | { 52 | "name": "permission_READ_AUDIO", 53 | "value": "用于应用读取用户公共目录的音频文件" 54 | }, 55 | { 56 | "name": "permission_WRITE_AUDIO", 57 | "value": "用于应用读写用户公共目录的音频文件" 58 | }, 59 | { 60 | "name": "permission_READ_IMAGEVIDEO", 61 | "value": "用于应用读取公共目录的图片或视频文件" 62 | }, 63 | { 64 | "name": "permission_WRITE_IMAGEVIDEO", 65 | "value": "用于应用读写公共目录的图片或视频文件" 66 | }, 67 | { 68 | "name": "permission_READ_PASTEBOARD", 69 | "value": "用于应用读取剪贴板" 70 | }, 71 | { 72 | "name": "str_desc", 73 | "value": "张三%d岁,工资%d米" 74 | }, 75 | { 76 | "name": "str_num", 77 | "value": "360vpxx" 78 | } 79 | ] 80 | } -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/entry/src/main/resources/base/media/background.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/entry/src/main/resources/base/media/foreground.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/entry/src/main/resources/base/media/ic_folder.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/entry/src/main/resources/base/media/ic_launcher.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/entry/src/main/resources/base/media/ic_launcher_round.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/icon_code.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/icon_example.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/icon_right.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/icon_tab_dialog.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/icon_tab_mine.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/icon_tab_other.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/icon_tab_rcp.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/icon_tab_room.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/icon_tab_spin.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/icon_tip_info.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/icon_tip_ok.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/icon_tip_warn.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/icon_user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/entry/src/main/resources/base/media/icon_user.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/layered_image.json: -------------------------------------------------------------------------------- 1 | { 2 | "layered-image": 3 | { 4 | "background" : "$media:background", 5 | "foreground" : "$media:foreground" 6 | } 7 | } -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/startIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/entry/src/main/resources/base/media/startIcon.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/test_as1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/entry/src/main/resources/base/media/test_as1.jpg -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/test_as2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/entry/src/main/resources/base/media/test_as2.jpeg -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/test_as3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/entry/src/main/resources/base/media/test_as3.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/test_as4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/entry/src/main/resources/base/media/test_as4.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/test_as5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/entry/src/main/resources/base/media/test_as5.jpg -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/wps_code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/entry/src/main/resources/base/media/wps_code.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/profile/main_pages.json: -------------------------------------------------------------------------------- 1 | { 2 | "src": [ 3 | "pages/Index", 4 | "pages/utils/AppUtilPage", 5 | "pages/utils/DeviceUtilPage", 6 | "pages/utils/DisplayUtilPage", 7 | "pages/utils/PermissionUtilPage", 8 | "pages/utils/NotificationUtilPage", 9 | "pages/utils/EmitterUtilPage", 10 | "pages/utils/WantUtilPage", 11 | "pages/utils/AuthUtilPage", 12 | "pages/utils/KvUtilPage", 13 | "pages/utils/PreferencesUtilPage", 14 | "pages/utils/LRUCacheUtilPage", 15 | "pages/utils/CacheUtilPage", 16 | "pages/utils/FileUtilPage", 17 | "pages/utils/PickerUtilPage", 18 | "pages/utils/PhotoHelperPage", 19 | "pages/utils/ImageUtilPage", 20 | "pages/utils/SnapshotUtilPage", 21 | "pages/utils/PreviewUtilPage", 22 | "pages/utils/ScanUtilPage", 23 | "pages/utils/LocationUtilPage", 24 | "pages/utils/LogUtilPage", 25 | "pages/utils/ResUtilPage", 26 | "pages/utils/DateUtilPage", 27 | "pages/utils/StrUtilPage", 28 | "pages/utils/RegexUtilPage", 29 | "pages/utils/FormatUtilPage", 30 | "pages/utils/CharUtilPage", 31 | "pages/utils/NumberUtilPage", 32 | "pages/utils/ArrayUtilPage", 33 | "pages/utils/RandomUtilPage", 34 | "pages/utils/ObjectUtilPage", 35 | "pages/utils/Base64UtilPage", 36 | "pages/utils/JSONUtilPage", 37 | "pages/utils/ClickUtilPage", 38 | "pages/utils/CrashUtilPage", 39 | "pages/utils/KeyboardUtilPage", 40 | "pages/utils/PasteboardUtilPage", 41 | "pages/utils/NetworkUtilPage", 42 | "pages/utils/AssetUtilPage", 43 | "pages/utils/TempUtilPage", 44 | "pages/utils/DialogUtilPage", 45 | "pages/utils/ToastUtilPage", 46 | "pages/crypto/SM2Page", 47 | "pages/crypto/SM3Page", 48 | "pages/crypto/SM4Page", 49 | "pages/crypto/MD5Page", 50 | "pages/crypto/SHAPage", 51 | "pages/crypto/AESPage", 52 | "pages/crypto/DESPage", 53 | "pages/crypto/RSAPage", 54 | "pages/crypto/ECDSAPage", 55 | "pages/spinkit/SpinKit1", 56 | "pages/spinkit/SpinKit2" 57 | ], 58 | "window": { 59 | "designWidth": 750, 60 | "autoDesignWidth": false 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /entry/src/main/resources/en_US/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "module_desc", 5 | "value": "一款功能丰富且极易上手的HarmonyOS工具库,借助众多实用工具类,致力于助力开发者迅速构建鸿蒙应用。其封装的工具涵盖了APP、设备、屏幕、授权、通知、线程间通信、弹框、吐司、生物认证、用户首选项、拍照、相册、扫码、文件、日志,异常捕获、字符、字符串、数字、集合、日期、随机、base64、加密、解密、JSON等一系列的功能和操作,能够满足各种不同的开发需求。" 6 | }, 7 | { 8 | "name": "EntryAbility_desc", 9 | "value": "一款功能丰富且极易上手的HarmonyOS工具库,借助众多实用工具类,致力于助力开发者迅速构建鸿蒙应用。其封装的工具涵盖了APP、设备、屏幕、授权、通知、线程间通信、弹框、吐司、生物认证、用户首选项、拍照、相册、扫码、文件、日志,异常捕获、字符、字符串、数字、集合、日期、随机、base64、加密、解密、JSON等一系列的功能和操作,能够满足各种不同的开发需求。" 10 | }, 11 | { 12 | "name": "EntryAbility_label", 13 | "value": "鸿蒙宝典" 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /entry/src/main/resources/rawfile/MyFont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/entry/src/main/resources/rawfile/MyFont.ttf -------------------------------------------------------------------------------- /entry/src/main/resources/rawfile/demo/demo.txt: -------------------------------------------------------------------------------- 1 | harmony-utils 一款功能丰富且极易上手的HarmonyOS工具库,借助众多实用工具类,致力于助力开发者迅速构建鸿蒙应用。其封装的工具涵盖了APP、设备、屏幕、授权、通知、线程间通信、弹框、吐司、生物认证、用户首选项、拍照、相册、扫码、文件、日志,异常捕获、字符、字符串、数字、集合、日期、随机、base64、加密、解密、JSON等一系列的功能和操作,能够满足各种不同的开发需求。 -------------------------------------------------------------------------------- /entry/src/main/resources/rawfile/demo/test.txt: -------------------------------------------------------------------------------- 1 | harmony-utils 一款功能丰富且极易上手的HarmonyOS工具库。 -------------------------------------------------------------------------------- /entry/src/main/resources/rawfile/user.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "我的三方库中心仓", 4 | "url": "https://ohpm.openharmony.cn/#/cn/publisher/663b99a5788eb334c83d9cd5" 5 | }, 6 | { 7 | "name": "我的Gitee", 8 | "url": "https://gitee.com/tongyuyan/harmony-utils" 9 | }, 10 | { 11 | "name": "我的GitHub", 12 | "url": "https://github.com/787107497" 13 | }, 14 | { 15 | "name": "我的CSDN", 16 | "url": "https://blog.csdn.net/qq_32922545" 17 | }, 18 | { 19 | "name": "坚果派", 20 | "url": "https://www.nutpi.net/" 21 | } 22 | ] -------------------------------------------------------------------------------- /entry/src/main/resources/zh_CN/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "module_desc", 5 | "value": "一款功能丰富且极易上手的HarmonyOS工具库,借助众多实用工具类,致力于助力开发者迅速构建鸿蒙应用。其封装的工具涵盖了APP、设备、屏幕、授权、通知、线程间通信、弹框、吐司、生物认证、用户首选项、拍照、相册、扫码、文件、日志,异常捕获、字符、字符串、数字、集合、日期、随机、base64、加密、解密、JSON等一系列的功能和操作,能够满足各种不同的开发需求。" 6 | }, 7 | { 8 | "name": "EntryAbility_desc", 9 | "value": "一款功能丰富且极易上手的HarmonyOS工具库,借助众多实用工具类,致力于助力开发者迅速构建鸿蒙应用。其封装的工具涵盖了APP、设备、屏幕、授权、通知、线程间通信、弹框、吐司、生物认证、用户首选项、拍照、相册、扫码、文件、日志,异常捕获、字符、字符串、数字、集合、日期、随机、base64、加密、解密、JSON等一系列的功能和操作,能够满足各种不同的开发需求。" 10 | }, 11 | { 12 | "name": "EntryAbility_label", 13 | "value": "鸿蒙宝典" 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /entry/src/ohosTest/ets/test/Ability.test.ets: -------------------------------------------------------------------------------- 1 | import { hilog } from '@kit.PerformanceAnalysisKit'; 2 | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; 3 | 4 | export default function abilityTest() { 5 | describe('ActsAbilityTest', () => { 6 | // Defines a test suite. Two parameters are supported: test suite name and test suite function. 7 | beforeAll(() => { 8 | // Presets an action, which is performed only once before all test cases of the test suite start. 9 | // This API supports only one parameter: preset action function. 10 | }) 11 | beforeEach(() => { 12 | // Presets an action, which is performed before each unit test case starts. 13 | // The number of execution times is the same as the number of test cases defined by **it**. 14 | // This API supports only one parameter: preset action function. 15 | }) 16 | afterEach(() => { 17 | // Presets a clear action, which is performed after each unit test case ends. 18 | // The number of execution times is the same as the number of test cases defined by **it**. 19 | // This API supports only one parameter: clear action function. 20 | }) 21 | afterAll(() => { 22 | // Presets a clear action, which is performed after all test cases of the test suite end. 23 | // This API supports only one parameter: clear action function. 24 | }) 25 | it('assertContain', 0, () => { 26 | // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. 27 | hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); 28 | let a = 'abc'; 29 | let b = 'b'; 30 | // Defines a variety of assertion methods, which are used to declare expected boolean conditions. 31 | expect(a).assertContain(b); 32 | expect(a).assertEqual(a); 33 | }) 34 | }) 35 | } -------------------------------------------------------------------------------- /entry/src/ohosTest/ets/test/List.test.ets: -------------------------------------------------------------------------------- 1 | import abilityTest from './Ability.test'; 2 | 3 | export default function testsuite() { 4 | abilityTest(); 5 | } -------------------------------------------------------------------------------- /entry/src/ohosTest/ets/testability/TestAbility.ets: -------------------------------------------------------------------------------- 1 | import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; 2 | import { abilityDelegatorRegistry } from '@kit.TestKit'; 3 | import { hilog } from '@kit.PerformanceAnalysisKit'; 4 | import { window } from '@kit.ArkUI'; 5 | import { Hypium } from '@ohos/hypium'; 6 | import testsuite from '../test/List.test'; 7 | 8 | export default class TestAbility extends UIAbility { 9 | onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { 10 | hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate'); 11 | hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); 12 | hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? ''); 13 | let abilityDelegator: abilityDelegatorRegistry.AbilityDelegator; 14 | abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); 15 | let abilityDelegatorArguments: abilityDelegatorRegistry.AbilityDelegatorArgs; 16 | abilityDelegatorArguments = abilityDelegatorRegistry.getArguments(); 17 | hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); 18 | Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite); 19 | } 20 | 21 | onDestroy() { 22 | hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy'); 23 | } 24 | 25 | onWindowStageCreate(windowStage: window.WindowStage) { 26 | hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); 27 | windowStage.loadContent('testability/pages/Index', (err) => { 28 | if (err.code) { 29 | hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); 30 | return; 31 | } 32 | hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); 33 | }); 34 | } 35 | 36 | onWindowStageDestroy() { 37 | hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); 38 | } 39 | 40 | onForeground() { 41 | hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); 42 | } 43 | 44 | onBackground() { 45 | hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); 46 | } 47 | } -------------------------------------------------------------------------------- /entry/src/ohosTest/ets/testability/pages/Index.ets: -------------------------------------------------------------------------------- 1 | @Entry 2 | @Component 3 | struct Index { 4 | @State message: string = 'Hello World'; 5 | 6 | build() { 7 | Row() { 8 | Column() { 9 | Text(this.message) 10 | .fontSize(50) 11 | .fontWeight(FontWeight.Bold) 12 | } 13 | .width('100%') 14 | } 15 | .height('100%') 16 | } 17 | } -------------------------------------------------------------------------------- /entry/src/ohosTest/module.json5: -------------------------------------------------------------------------------- 1 | { 2 | "module": { 3 | "name": "entry_test", 4 | "type": "feature", 5 | "description": "$string:module_test_desc", 6 | "mainElement": "TestAbility", 7 | "deviceTypes": [ 8 | "phone", 9 | "tablet", 10 | "2in1" 11 | ], 12 | "deliveryWithInstall": true, 13 | "installationFree": false, 14 | "pages": "$profile:test_pages", 15 | "abilities": [ 16 | { 17 | "name": "TestAbility", 18 | "srcEntry": "./ets/testability/TestAbility.ets", 19 | "description": "$string:TestAbility_desc", 20 | "icon": "$media:icon", 21 | "label": "$string:TestAbility_label", 22 | "exported": true, 23 | "startWindowIcon": "$media:icon", 24 | "startWindowBackground": "$color:start_window_background", 25 | "skills": [ 26 | { 27 | "actions": [ 28 | "action.system.home" 29 | ], 30 | "entities": [ 31 | "entity.system.home" 32 | ] 33 | } 34 | ] 35 | } 36 | ] 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /entry/src/ohosTest/resources/base/element/color.json: -------------------------------------------------------------------------------- 1 | { 2 | "color": [ 3 | { 4 | "name": "start_window_background", 5 | "value": "#FFFFFF" 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /entry/src/ohosTest/resources/base/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "module_test_desc", 5 | "value": "test ability description" 6 | }, 7 | { 8 | "name": "TestAbility_desc", 9 | "value": "the test ability" 10 | }, 11 | { 12 | "name": "TestAbility_label", 13 | "value": "test label" 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /entry/src/ohosTest/resources/base/media/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/entry/src/ohosTest/resources/base/media/icon.png -------------------------------------------------------------------------------- /entry/src/ohosTest/resources/base/profile/test_pages.json: -------------------------------------------------------------------------------- 1 | { 2 | "src": [ 3 | "testability/pages/Index" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /entry/src/test/List.test.ets: -------------------------------------------------------------------------------- 1 | import localUnitTest from './LocalUnit.test'; 2 | 3 | export default function testsuite() { 4 | localUnitTest(); 5 | } -------------------------------------------------------------------------------- /entry/src/test/LocalUnit.test.ets: -------------------------------------------------------------------------------- 1 | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; 2 | 3 | export default function localUnitTest() { 4 | describe('localUnitTest',() => { 5 | // Defines a test suite. Two parameters are supported: test suite name and test suite function. 6 | beforeAll(() => { 7 | // Presets an action, which is performed only once before all test cases of the test suite start. 8 | // This API supports only one parameter: preset action function. 9 | }); 10 | beforeEach(() => { 11 | // Presets an action, which is performed before each unit test case starts. 12 | // The number of execution times is the same as the number of test cases defined by **it**. 13 | // This API supports only one parameter: preset action function. 14 | }); 15 | afterEach(() => { 16 | // Presets a clear action, which is performed after each unit test case ends. 17 | // The number of execution times is the same as the number of test cases defined by **it**. 18 | // This API supports only one parameter: clear action function. 19 | }); 20 | afterAll(() => { 21 | // Presets a clear action, which is performed after all test cases of the test suite end. 22 | // This API supports only one parameter: clear action function. 23 | }); 24 | it('assertContain', 0, () => { 25 | // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. 26 | let a = 'abc'; 27 | let b = 'b'; 28 | // Defines a variety of assertion methods, which are used to declare expected boolean conditions. 29 | expect(a).assertContain(b); 30 | expect(a).assertEqual(a); 31 | }); 32 | }); 33 | } -------------------------------------------------------------------------------- /harmony_dialog/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /oh_modules 3 | /.preview 4 | /build 5 | /.cxx 6 | /.test -------------------------------------------------------------------------------- /harmony_dialog/BuildProfile.ets: -------------------------------------------------------------------------------- 1 | /** 2 | * Use these variables when you tailor your ArkTS code. They must be of the const type. 3 | */ 4 | export const HAR_VERSION = '1.0.9'; 5 | export const BUILD_MODE_NAME = 'debug'; 6 | export const DEBUG = true; 7 | export const TARGET_NAME = 'default'; 8 | 9 | /** 10 | * BuildProfile Class is used only for compatibility purposes. 11 | */ 12 | export default class BuildProfile { 13 | static readonly HAR_VERSION = HAR_VERSION; 14 | static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; 15 | static readonly DEBUG = DEBUG; 16 | static readonly TARGET_NAME = TARGET_NAME; 17 | } -------------------------------------------------------------------------------- /harmony_dialog/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 版本记录 2 | 3 | ## 1.0.9 4 | 1. 优化部分弹框的最大宽度。 5 | 2. 优化ToastTip部分参数配置。 6 | 3. 优化ToastTip新增支持水平布局,参数alignment。 7 | 8 | 9 | ## 1.0.8 10 | 1. 新增日期选择器弹框,showDatePickerDialog。 11 | 2. BottomSheetOptions 支持 cancelFontColor/cancelFontWeight 属性,用于自定义【取消】字体样式。 12 | 3. 加载弹框,修改为可传入dialogId; 并废弃closeLoading()、isShowLoading()、getLoadingDialogId()方法。 13 | 4. DialogConfig的uiContext改为uiAbilityContext,并且类型为common.UIAbilityContext;所以后面需要在UIAbility的onCreate方法里初始化uiAbilityContext。 14 | 15 | ```typescript 16 | //1.0.8版本适配指南: 17 | 18 | DialogHelper.setDefaultConfig((config) => { 19 | config.uiContext = this.context 20 | }) 21 | //改为 22 | DialogHelper.setDefaultConfig((config) => { 23 | config.uiAbilityContext = this.context 24 | }) 25 | 26 | DialogHelper.closeLoading(); 27 | //改为 28 | DialogHelper.closeDialog("xxx"); 29 | ``` 30 | 31 | ## 1.0.7 32 | 1. 修复部分弹框,buttons设置按钮颜色不生效。 33 | 2. 优化BottomSheetDialog和ActionSheetDialog的展示。 34 | 3. 新增参数maxHeight,设置弹窗高度默认最大值;很多弹框都是自适应高度,谨慎设置该值。 35 | 4. 新增加载弹框方法isShowLoading()、getLoadingDialogId()。 36 | 5. 输入类弹框新增参数defaultFocus;设置弹框默认获得焦点,打开弹窗同时弹出输入法。 37 | 6. 新增选择器弹框,showTextPickerDialog。 38 | 39 | ## 1.0.6 40 | 1. 优化弹框关闭可能出现的异常。 41 | 42 | ## 1.0.5 43 | 1. 优化代码。 44 | 2. 输入弹框添加maxLength、controller、inputFilter参数。 45 | 1、maxLength:文本的最大输入字符数。 46 | 2、controller:TextInputController,输入控制器。 47 | 3、inputFilter:InputFilter,通过正则表达式设置输入过滤器。 48 | 49 | ## 1.0.4 50 | 1. 优化代码。 51 | 2. showLoading,Loading弹框内置SpinKit,支持20多种动画。 52 | 53 | ## 1.0.3 54 | 1. 优化吐司(Toast)支持backCancel。 55 | 2. 优化showCustomContentDialog等的多按钮参数buttons?: Array。 56 | 57 | ## 1.0.2 58 | 1. 在代码里添加开源协议。 59 | 2. 优化代码。 60 | 3. 优化弹框宽度,弹框默认宽度为calc(100% - 32vp)。 61 | 4. 添加 maxWidth,优化在大屏上的显示效果。 62 | 63 | ## 1.0.1 64 | 1. 优化代码。 65 | 2. 优化有子窗口的情况下,弹框异常显示的问题。 66 | 67 | ## 1.0.0 初版 68 | 1. 发布1.0.0初版。 -------------------------------------------------------------------------------- /harmony_dialog/Index.ets: -------------------------------------------------------------------------------- 1 | 2 | export { DialogHelper } from './src/main/ets/dialog/DialogHelper' 3 | 4 | export { AnimationHelper } from './src/main/ets/utils/AnimationHelper'; 5 | 6 | export * from './src/main/ets/utils/constraint'; 7 | 8 | export { DialogConfig } from './src/main/ets/model/DialogConfig'; 9 | 10 | export { BaseDialogOptions } from './src/main/ets/model/base/BaseDialogOptions'; 11 | 12 | export { DialogOptions } from './src/main/ets/model/base/DialogOptions'; 13 | 14 | export { AlertOptions } from './src/main/ets/model/AlertOptions'; 15 | 16 | export { ConfirmOptions } from './src/main/ets/model/ConfirmOptions'; 17 | 18 | export { TipsOptions } from './src/main/ets/model/TipsOptions'; 19 | 20 | export { SelectOptions } from './src/main/ets/model/SelectOptions'; 21 | 22 | export { CustomContentOptions } from './src/main/ets/model/CustomContentOptions'; 23 | 24 | export { TextInputOptions } from './src/main/ets/model/TextInputOptions'; 25 | 26 | export { TextAreaOptions } from './src/main/ets/model/TextAreaOptions'; 27 | 28 | export { BottomSheetOptions } from './src/main/ets/model/BottomSheetOptions'; 29 | 30 | export { DateTimePickerOptions } from './src/main/ets/model/DateTimePickerOptions'; 31 | 32 | export { LoadingOptions } from './src/main/ets/model/LoadingOptions'; 33 | 34 | export { LoadingProgressOptions } from './src/main/ets/model/LoadingProgressOptions'; 35 | 36 | export { ToastOptions } from './src/main/ets/model/ToastOptions'; 37 | 38 | export { ToastTipOptions } from './src/main/ets/model/ToastTipOptions'; 39 | 40 | export { ButtonOptions } from './src/main/ets/model/ButtonOptions'; 41 | 42 | export { SheetOptions } from './src/main/ets/model/SheetOptions'; 43 | 44 | export { SpinType, SpinKit } from '@pura/spinkit'; -------------------------------------------------------------------------------- /harmony_dialog/build-profile.json5: -------------------------------------------------------------------------------- 1 | { 2 | "apiType": "stageMode", 3 | "buildOption": { 4 | }, 5 | "buildOptionSet": [ 6 | { 7 | "name": "release", 8 | "arkOptions": { 9 | "obfuscation": { 10 | "ruleOptions": { 11 | "enable": false, 12 | "files": [ 13 | "./obfuscation-rules.txt" 14 | ] 15 | }, 16 | "consumerFiles": [ 17 | "./consumer-rules.txt" 18 | ] 19 | } 20 | }, 21 | }, 22 | ], 23 | "targets": [ 24 | { 25 | "name": "default" 26 | }, 27 | { 28 | "name": "ohosTest" 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /harmony_dialog/consumer-rules.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/harmony_dialog/consumer-rules.txt -------------------------------------------------------------------------------- /harmony_dialog/example/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## 📚仓库主页 3 | https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 4 | 5 | ## 📚源码地址 6 | https://gitee.com/tongyuyan/harmony-utils 7 | https://github.com/787107497 8 | 9 | ## 📚CSDN博客 10 | https://blog.csdn.net/qq_32922545 11 | 12 | ## 💖QQ交流群 13 | 569512366 14 | -------------------------------------------------------------------------------- /harmony_dialog/hvigorfile.ts: -------------------------------------------------------------------------------- 1 | import { harTasks } from '@ohos/hvigor-ohos-plugin'; 2 | 3 | export default { 4 | system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ 5 | plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ 6 | } 7 | -------------------------------------------------------------------------------- /harmony_dialog/obfuscation-rules.txt: -------------------------------------------------------------------------------- 1 | # Define project specific obfuscation rules here. 2 | # You can include the obfuscation configuration files in the current module's build-profile.json5. 3 | # 4 | # For more details, see 5 | # https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 6 | 7 | # Obfuscation options: 8 | # -disable-obfuscation: disable all obfuscations 9 | # -enable-property-obfuscation: obfuscate the property names 10 | # -enable-toplevel-obfuscation: obfuscate the names in the global scope 11 | # -compact: remove unnecessary blank spaces and all line feeds 12 | # -remove-log: remove all console.* statements 13 | # -print-namecache: print the name cache that contains the mapping from the old names to new names 14 | # -apply-namecache: reuse the given cache file 15 | 16 | # Keep options: 17 | # -keep-property-name: specifies property names that you want to keep 18 | # -keep-global-name: specifies names that you want to keep in the global scope 19 | 20 | # ZsHx: 21 | #-enable-property-obfuscation 22 | #-enable-toplevel-obfuscation 23 | #-enable-filename-obfuscation 24 | #-enable-export-obfuscation -------------------------------------------------------------------------------- /harmony_dialog/oh-package-lock.json5: -------------------------------------------------------------------------------- 1 | { 2 | "meta": { 3 | "stableOrder": true 4 | }, 5 | "lockfileVersion": 3, 6 | "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", 7 | "specifiers": { 8 | "@pura/spinkit@^1.0.4": "@pura/spinkit@../spinkit" 9 | }, 10 | "packages": { 11 | "@pura/spinkit@../spinkit": { 12 | "name": "@pura/spinkit", 13 | "version": "1.0.4", 14 | "resolved": "../spinkit", 15 | "registryType": "local" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /harmony_dialog/oh-package.json5: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@pura/harmony-dialog", 3 | "version": "1.0.9", 4 | "description": "一款极为简单易用的零侵入弹窗,仅需一行代码即可轻松实现,无论在何处都能够轻松弹出。其涵盖了 AlertDialog、TipsDialog、ConfirmDialog、SelectDialog、CustomContentDialog、TextInputDialog、TextAreaDialog、BottomSheetDialog、ActionSheetDialog、TextPickerDialog、DatePickerDialog、CustomDialog、LoadingDialog、LoadingProgress、Toast、ToastTip 等多种类型,能够满足各种不同的弹窗开发需求。", 5 | "author": "桃花镇童长老", 6 | "homepage": "https://gitee.com/tongyuyan", 7 | "repository": "https://gitee.com/tongyuyan/harmony-utils", 8 | "main": "Index.ets", 9 | "license": "Apache-2.0", 10 | "dependencies": { 11 | "@pura/spinkit": "^1.0.4" 12 | }, 13 | "devDependencies": {}, 14 | "dynamicDependencies": {}, 15 | "keywords": [ 16 | "弹框", 17 | "加载", 18 | "日期", 19 | "吐司", 20 | "dialog", 21 | "loading", 22 | "progress", 23 | "toast", 24 | "picker" 25 | ], 26 | "tags": [ 27 | "弹框", 28 | "加载", 29 | "日期", 30 | "吐司", 31 | "dialog", 32 | "loading", 33 | "progress", 34 | "toast", 35 | "picker" 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/component/LoadingView.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | import { SpinKit } from '@pura/spinkit'; 19 | import { LoadingOptions } from '../model/LoadingOptions'; 20 | import { Helper } from '../utils/Helper'; 21 | 22 | /** 23 | * TODO Loading组件 24 | * author: 桃花镇童长老ᥫ᭡ 25 | * since: 2024/08/01 26 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 27 | * github: https://github.com/787107497 28 | * gitee: https://gitee.com/tongyuyan/harmony-utils 29 | * QQ交流群: 569512366 30 | */ 31 | @Component 32 | export default struct LoadingView { 33 | @Prop options: LoadingOptions; 34 | @State content: string = ''; 35 | 36 | aboutToAppear(): void { 37 | if (this.options.content) { 38 | this.content = Helper.getResourceStr(this.options.content) ?? ""; 39 | } 40 | } 41 | 42 | build() { 43 | Column() { 44 | SpinKit({ 45 | spinType: this.options.loadType, 46 | spinSize: this.options.loadSize, 47 | spinColor: this.options.loadColor 48 | }) 49 | Text(this.options.content) 50 | .textAlign(TextAlign.Center) 51 | .margin({ top: this.options.marginTop }) 52 | .fontSize(this.options.fontSize) 53 | .fontColor(this.options.fontColor) 54 | .visibility(this.content.length > 0 ? Visibility.Visible : Visibility.None) 55 | } 56 | .justifyContent(FlexAlign.Center) 57 | .alignItems(HorizontalAlign.Center) 58 | .margin(12) 59 | .constraintSize({ minWidth: 100, minHeight: 100 }) 60 | .padding(this.options.padding) 61 | .backgroundColor(this.options.backgroundColor) 62 | .borderRadius(this.options.borderRadius) 63 | .shadow(ShadowStyle.OUTER_DEFAULT_SM) 64 | } 65 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/component/ToastTipView.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | import { Orientation } from '../../../../Index'; 19 | import { ToastTipOptions } from '../model/ToastTipOptions'; 20 | 21 | /** 22 | * TODO Toast组件 23 | * author: 桃花镇童长老ᥫ᭡ 24 | * since: 2024/08/01 25 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 26 | * github: https://github.com/787107497 27 | * gitee: https://gitee.com/tongyuyan/harmony-utils 28 | * QQ交流群: 569512366 29 | */ 30 | @Component 31 | export default struct ToastTipView { 32 | @Prop options: ToastTipOptions; 33 | 34 | build() { 35 | if (this.options.orientation == Orientation.VERTICAL) { 36 | Column({ space: this.options.margin ?? 10 }) { 37 | Image(this.options.imageRes) 38 | .size(this.options.imageSize) 39 | .fillColor(this.options.fontColor) 40 | .margin(2) 41 | Text(this.options.message) 42 | .fontColor(this.options.fontColor) 43 | .fontSize(this.options.fontSize) 44 | } 45 | .margin(12) 46 | .padding(20) 47 | .justifyContent(FlexAlign.Center) 48 | .alignItems(HorizontalAlign.Center) 49 | .align(Alignment.Center) 50 | .alignSelf(ItemAlign.Center) 51 | .constraintSize({ minWidth: 120 }) 52 | .backgroundColor(this.options.backgroundColor) 53 | .borderRadius(this.options.borderRadius) 54 | .shadow(ShadowStyle.OUTER_DEFAULT_SM) 55 | } else { 56 | Row({ space: this.options.margin ?? 10 }) { 57 | Image(this.options.imageRes) 58 | .size(this.options.imageSize) 59 | .fillColor(this.options.fontColor) 60 | .margin({ right: 2 }) 61 | Text(this.options.message) 62 | .fontColor(this.options.fontColor) 63 | .fontSize(this.options.fontSize) 64 | } 65 | .margin(12) 66 | .padding(20) 67 | .justifyContent(FlexAlign.Center) 68 | .alignItems(VerticalAlign.Center) 69 | .align(Alignment.Center) 70 | .alignSelf(ItemAlign.Center) 71 | .constraintSize({ minWidth: 120 }) 72 | .backgroundColor(this.options.backgroundColor) 73 | .borderRadius(this.options.borderRadius) 74 | .shadow(ShadowStyle.OUTER_DEFAULT_SM) 75 | } 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/component/ToastView.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | import { ToastOptions } from '../model/ToastOptions'; 19 | 20 | /** 21 | * TODO Toast组件 22 | * author: 桃花镇童长老ᥫ᭡ 23 | * since: 2024/08/01 24 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 25 | * github: https://github.com/787107497 26 | * gitee: https://gitee.com/tongyuyan/harmony-utils 27 | * QQ交流群: 569512366 28 | */ 29 | @Component 30 | export default struct ToastView { 31 | @Prop options: ToastOptions; 32 | 33 | build() { 34 | Column() { 35 | Text(this.options.message) 36 | .fontColor(this.options.fontColor) 37 | .fontSize(this.options.fontSize) 38 | .padding({ left: 10, right: 10 }) 39 | } 40 | .justifyContent(FlexAlign.Center) 41 | .alignItems(HorizontalAlign.Center) 42 | .align(Alignment.Center) 43 | .alignSelf(ItemAlign.Center) 44 | .constraintSize({ minWidth: 90 }) 45 | .margin({ left: 15, right: 15 }) 46 | .padding(this.options.padding) 47 | .backgroundColor(this.options.backgroundColor) 48 | .borderRadius(this.options.borderRadius) 49 | .shadow(ShadowStyle.OUTER_DEFAULT_SM) 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/AlertOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | import { HmDialogOptions } from './base/HmDialogOptions'; 19 | 20 | /** 21 | * TODO 操作确认类弹出框,参数类 22 | * author: 桃花镇童长老ᥫ᭡ 23 | * since: 2024/08/18 24 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 25 | * github: https://github.com/787107497 26 | * gitee: https://gitee.com/tongyuyan/harmony-utils 27 | * CSDN: https://blog.csdn.net/qq_32922545 28 | * QQ交流群: 569512366 29 | */ 30 | export interface AlertOptions extends HmDialogOptions { 31 | 32 | primaryTitle?: ResourceStr; //确认框一级标题。 33 | secondaryTitle?: ResourceStr; //确认框二级标题。 34 | 35 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/BottomSheetOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | import { BaseDialogOptions } from './base/BaseDialogOptions'; 19 | import { SheetOptions } from '../model/SheetOptions'; 20 | import { ActionCallBack } from '../utils/constraint'; 21 | 22 | /** 23 | * TODO BottomSheet弹框,参数类 24 | * author: 桃花镇童长老ᥫ᭡ 25 | * since: 2024/08/18 26 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 27 | * github: https://github.com/787107497 28 | * gitee: https://gitee.com/tongyuyan/harmony-utils 29 | * CSDN: https://blog.csdn.net/qq_32922545 30 | * QQ交流群: 569512366 31 | */ 32 | export interface BottomSheetOptions extends BaseDialogOptions { 33 | 34 | title?: ResourceStr; //弹框标题 35 | titleFontColor?: ResourceColor; //弹框标题的字体颜色。 36 | cancelValue?: ResourceStr; //取消按钮 37 | cancelFontColor?: ResourceColor; //取消按钮的字体颜色。 38 | cancelFontWeight?: FontWeight; //取消按钮的字体粗细。 39 | sheets: Array | Array; //BottomSheet弹出框操作区按钮。 40 | onAction: ActionCallBack; //按钮的CallBack事件。 41 | 42 | actionCancel?: boolean; //点击操作按钮时,是否关闭弹窗。false表示不关闭弹窗。默认值:true。 43 | height?: Dimension | Length; //设置弹窗的高度;很多弹框都是自适应高度,谨慎设置该值。 44 | width?: Dimension | Length; //设置弹窗的宽度,弹窗宽度默认值:'calc(100% - 32vp)'。 45 | maxHeight?: Dimension | Length; //设置弹窗高度默认最大值;很多弹框都是自适应高度,谨慎设置该值。 46 | maxWidth?: Length; //弹窗宽度默认最大值:360vp。 47 | backgroundColor?: ResourceColor; //弹窗背板颜色。默认值:Color.White 48 | backgroundBlurStyle?: BlurStyle; //弹窗背板模糊材质。默认值:BlurStyle.COMPONENT_ULTRA_THICK 49 | cornerRadius?: Length; //设置背板的圆角半径。可分别设置4个圆角的半径,默认15。 50 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/ButtonOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | 19 | /** 20 | * TODO Dialog按钮参数类 21 | * author: 桃花镇童长老ᥫ᭡ 22 | * since: 2024/08/18 23 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 24 | * github: https://github.com/787107497 25 | * gitee: https://gitee.com/tongyuyan/harmony-utils 26 | * CSDN: https://blog.csdn.net/qq_32922545 27 | * QQ交流群: 569512366 28 | */ 29 | export class ButtonOptions { 30 | value: ResourceStr = ''; //按钮的内容。 31 | fontColor?: ResourceColor; //按钮的字体颜色。 32 | action?: VoidCallback; //按钮的点击事件,大多数按钮不需要实现这个点击事件 33 | background?: ResourceColor; //按钮的背景。 34 | buttonStyle?: ButtonStyleMode; //按钮的样式。默认值:2in1设备为ButtonStyleMode.NORMAL,其他设备为ButtonStyleMode.TEXTUAL。 35 | role?: ButtonRole; //按钮的角色。默认值:ButtonRole.NORMAL。 36 | } 37 | -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/ConfirmOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | import { HmDialogOptions } from './base/HmDialogOptions'; 19 | 20 | /** 21 | * TODO 信息确认类弹出框,参数类 22 | * author: 桃花镇童长老ᥫ᭡ 23 | * since: 2024/08/18 24 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 25 | * github: https://github.com/787107497 26 | * gitee: https://gitee.com/tongyuyan/harmony-utils 27 | * CSDN: https://blog.csdn.net/qq_32922545 28 | * QQ交流群: 569512366 29 | */ 30 | export interface ConfirmOptions extends HmDialogOptions { 31 | 32 | checkTips: ResourceStr; //checkbox的提示内容。 33 | isChecked?: boolean; //@Prop-value为true时,表示checkbox已选中,value为false时,表示未选中。默认值:false 34 | onCheckedChange: Callback; //checkbox的选中状态改变事件。 35 | 36 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/CustomContentOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | import { ActionStrCallBack } from '../utils/constraint'; 19 | import { BaseContentOptions } from './base/BaseContentOptions'; 20 | import { ButtonOptions } from './ButtonOptions'; 21 | 22 | /** 23 | * TODO 自定义内容区弹出框,参数类 24 | * author: 桃花镇童长老ᥫ᭡ 25 | * since: 2024/08/18 26 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 27 | * github: https://github.com/787107497 28 | * gitee: https://gitee.com/tongyuyan/harmony-utils 29 | * CSDN: https://blog.csdn.net/qq_32922545 30 | * QQ交流群: 569512366 31 | */ 32 | export interface CustomContentOptions extends BaseContentOptions { 33 | 34 | buttons?: Array; //弹出框操作区按钮,最多支持4个按钮。 35 | onAction?: ActionStrCallBack; //按钮的CallBack事件。 36 | 37 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/DateTimePickerOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | 19 | import { ActionDateCallBack, DateType } from '../utils/constraint'; 20 | import { BasePickerOptions } from './base/BasePickerOptions'; 21 | 22 | 23 | /** 24 | * TODO 弹窗工具类,DatePicker参数类 25 | * author: 桃花镇童长老ᥫ᭡ 26 | * since: 2024/08/18 27 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 28 | * github: https://github.com/787107497 29 | * gitee: https://gitee.com/tongyuyan/harmony-utils 30 | * CSDN: https://blog.csdn.net/qq_32922545 31 | * QQ交流群: 569512366 32 | */ 33 | export interface DateTimePickerOptions extends BasePickerOptions { 34 | 35 | dateType: DateType; //选择的日期类型 36 | selected?: Date; // 选中日期,不传默认当前日期 37 | start?: Date; //开始日期(1900-01-01 00:00:00) 38 | end?: Date; //结束日期(2199-12-31 23:59:59) 39 | 40 | onAction: ActionDateCallBack; //按钮的CallBack事件。 41 | 42 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/InputFilter.ets: -------------------------------------------------------------------------------- 1 | /** 2 | * 通过正则表达式设置输入过滤器。匹配表达式的输入允许显示,不匹配的输入将被过滤。仅支持单个字符匹配,不支持字符串匹配。 3 | */ 4 | export interface InputFilter { 5 | value: ResourceStr; //正则表达式。 6 | error?: (value: string) => void; //正则匹配失败时,返回被过滤的内容。 7 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/LoadingOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | import { SpinType } from '@pura/spinkit'; 19 | import { BaseDialogOptions } from './base/BaseDialogOptions'; 20 | 21 | 22 | /** 23 | * TODO 加载框,参数类 24 | * author: 桃花镇童长老ᥫ᭡ 25 | * since: 2024/08/18 26 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 27 | * github: https://github.com/787107497 28 | * gitee: https://gitee.com/tongyuyan/harmony-utils 29 | * CSDN: https://blog.csdn.net/qq_32922545 30 | * QQ交流群: 569512366 31 | */ 32 | export interface LoadingOptions extends BaseDialogOptions { 33 | 34 | loadType?: SpinType //动画类型 35 | loadSize?: number; //加载动画或进度条的大小 36 | loadColor?: ResourceColor; //加载动画的颜色 37 | content?: ResourceStr; //加载动画的提示文字 38 | fontSize?: number | string | Resource; //加载动画的文字大小 39 | fontColor?: ResourceColor; //加载动画的文字颜色 40 | backgroundColor?: ResourceColor; //加载动画背景颜色,建议八位色值前两位为透明度 41 | borderRadius?: Length | BorderRadiuses; //加载动画背景圆角 42 | marginTop?: number | string | Resource //文字与动画的间距 43 | padding?: Padding | Length //padding 44 | 45 | } 46 | -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/LoadingProgressOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | import { LoadingOptions } from './LoadingOptions'; 19 | 20 | 21 | /** 22 | * TODO 进度加载框,参数类 23 | * author: 桃花镇童长老ᥫ᭡ 24 | * since: 2024/08/18 25 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 26 | * github: https://github.com/787107497 27 | * gitee: https://gitee.com/tongyuyan/harmony-utils 28 | * CSDN: https://blog.csdn.net/qq_32922545 29 | * QQ交流群: 569512366 30 | */ 31 | export interface LoadingProgressOptions extends LoadingOptions { 32 | 33 | progress: number //设置当前进度值。设置小于0的数值时置为0,设置大于total的数值时置为total。非法数值不生效。 34 | 35 | } 36 | -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/SelectOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | import { DialogOptions } from './base/DialogOptions'; 19 | import { ButtonOptions } from '../model/ButtonOptions'; 20 | import { ActionStrCallBack, NumberCalBack } from '../utils/constraint'; 21 | 22 | 23 | /** 24 | * TODO 选择类弹出框,参数类 25 | * author: 桃花镇童长老ᥫ᭡ 26 | * since: 2024/08/18 27 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 28 | * github: https://github.com/787107497 29 | * gitee: https://gitee.com/tongyuyan/harmony-utils 30 | * CSDN: https://blog.csdn.net/qq_32922545 31 | * QQ交流群: 569512366 32 | */ 33 | export interface SelectOptions extends DialogOptions { 34 | 35 | content?: ResourceStr; //弹框内容。 36 | confirm?: ButtonOptions | ResourceStr; //选择弹出框底部按钮。 37 | radioContent: Array | Array; //选择弹出框的子项内容列表,每个选择项支持设置文本和选中的回调事件。 38 | onCheckedChanged: NumberCalBack; //选择回调 39 | onAction: ActionStrCallBack; //按钮的CallBack事件。 40 | 41 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/SheetOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | 19 | /** 20 | * TODO BottomSheetDialog按钮参数类 21 | * author: 桃花镇童长老ᥫ᭡ 22 | * since: 2024/08/18 23 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 24 | * github: https://github.com/787107497 25 | * gitee: https://gitee.com/tongyuyan/harmony-utils 26 | * CSDN: https://blog.csdn.net/qq_32922545 27 | * QQ交流群: 569512366 28 | */ 29 | export class SheetOptions { 30 | value: ResourceStr = ''; //按钮的内容。 31 | fontColor?: ResourceColor; //按钮的字体颜色。 32 | fontSize?: number | string | Resource; //按钮的文字大小,,默认16。 33 | } 34 | -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/TextAreaOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | import { TextAlignment } from '../utils/constraint'; 19 | import { BaseInputOptions } from './base/BaseInputOptions'; 20 | 21 | /** 22 | * TODO 输入弹出框,参数类 23 | * author: 桃花镇童长老ᥫ᭡ 24 | * since: 2024/08/18 25 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 26 | * github: https://github.com/787107497 27 | * gitee: https://gitee.com/tongyuyan/harmony-utils 28 | * CSDN: https://blog.csdn.net/qq_32922545 29 | * QQ交流群: 569512366 30 | */ 31 | export interface TextAreaOptions extends BaseInputOptions { 32 | 33 | inputType?: TextAreaType; //输入框类型。默认值:TextAreaType.Normal 34 | 35 | inputLineHeight?: number | string | Resource; //行高 36 | textAlign?: TextAlign; //输入框TextAlign 37 | align?: TextAlignment; //输入框Align 38 | 39 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/TextInputOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | import { BaseInputOptions } from './base/BaseInputOptions'; 19 | 20 | /** 21 | * TODO 输入弹出框,参数类 22 | * author: 桃花镇童长老ᥫ᭡ 23 | * since: 2024/08/18 24 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 25 | * github: https://github.com/787107497 26 | * gitee: https://gitee.com/tongyuyan/harmony-utils 27 | * CSDN: https://blog.csdn.net/qq_32922545 28 | * QQ交流群: 569512366 29 | */ 30 | export interface TextInputOptions extends BaseInputOptions { 31 | 32 | inputType?: InputType; //输入框类型。默认值:InputType.Normal 33 | 34 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/TextPickerOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | 19 | import { ActionValueCallBack } from '../utils/constraint'; 20 | import { BasePickerOptions } from './base/BasePickerOptions'; 21 | 22 | 23 | /** 24 | * TODO 弹窗工具类,TextPicker参数类 25 | * author: 桃花镇童长老ᥫ᭡ 26 | * since: 2024/08/18 27 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 28 | * github: https://github.com/787107497 29 | * gitee: https://gitee.com/tongyuyan/harmony-utils 30 | * CSDN: https://blog.csdn.net/qq_32922545 31 | * QQ交流群: 569512366 32 | */ 33 | export interface TextPickerOptions extends BasePickerOptions { 34 | 35 | value?: string | string[]; //选中 36 | range: string[] | string[][] | Resource | TextPickerRangeContent[] | TextCascadePickerRangeContent[]; 37 | onChange?: (value: string | string[], index: number | number[]) => void; //滑动选中TextPicker文本内容后,触发该回调。 38 | // selected?: number | number[]; 39 | onAction: ActionValueCallBack; //按钮的CallBack事件。 40 | 41 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/TipsOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | import { HmDialogOptions } from './base/HmDialogOptions'; 19 | 20 | /** 21 | * TODO 提示弹出框,即为带图形确认框,参数类 22 | * author: 桃花镇童长老ᥫ᭡ 23 | * since: 2024/08/18 24 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 25 | * github: https://github.com/787107497 26 | * gitee: https://gitee.com/tongyuyan/harmony-utils 27 | * CSDN: https://blog.csdn.net/qq_32922545 28 | * QQ交流群: 569512366 29 | */ 30 | export interface TipsOptions extends HmDialogOptions { 31 | 32 | imageRes?: ResourceStr | PixelMap; //展示的图片。 33 | imageSize?: SizeOptions; //自定义图片尺寸。默认值:64*64vp 34 | checkTips?: ResourceStr; //checkbox的提示内容。 35 | isChecked?: boolean; //@Prop-value为true时,表示checkbox已选中,value为false时,表示未选中。默认值:false 36 | onCheckedChange?: Callback; //checkbox的选中状态改变事件。 37 | 38 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/ToastOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | import { BaseDialogOptions } from './base/BaseDialogOptions'; 19 | 20 | /** 21 | * TODO Toast基本参数类 22 | * author: 桃花镇童长老ᥫ᭡ 23 | * since: 2024/08/18 24 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 25 | * github: https://github.com/787107497 26 | * gitee: https://gitee.com/tongyuyan/harmony-utils 27 | * CSDN: https://blog.csdn.net/qq_32922545 28 | * QQ交流群: 569512366 29 | */ 30 | export interface ToastOptions extends BaseDialogOptions { 31 | 32 | message?: string | Resource; //吐司内容 33 | duration?: number; //显示时长(1500ms-10000ms) 34 | fontSize?: number | string | Resource; //文字大小 35 | fontColor?: ResourceColor; //文字颜色 36 | backgroundColor?: ResourceColor; //背景颜色,建议八位色值前两位为透明度 37 | borderRadius?: Length | BorderRadiuses; //背景圆角 38 | padding?: Padding | Length; //Padding 39 | 40 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/ToastTipOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | import { Orientation } from '../utils/constraint'; 19 | import { ToastOptions } from './ToastOptions'; 20 | 21 | /** 22 | * TODO ToastTip基本参数类 23 | * author: 桃花镇童长老ᥫ᭡ 24 | * since: 2024/08/18 25 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 26 | * github: https://github.com/787107497 27 | * gitee: https://gitee.com/tongyuyan/harmony-utils 28 | * CSDN: https://blog.csdn.net/qq_32922545 29 | * QQ交流群: 569512366 30 | */ 31 | export interface ToastTipOptions extends ToastOptions { 32 | 33 | message: string | Resource; //吐司内容 34 | imageRes: ResourceStr | PixelMap; //展示的图片。 35 | imageSize?: SizeOptions; //自定义图片尺寸。默认值:64*64vp 36 | orientation?: Orientation; //吐司布局方向,默认垂直。设置该值时,请重新设置imageSize和margin。 37 | margin?: number; //吐司的图片与文字间距。 38 | 39 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/base/BaseContentOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | import { DialogOptions } from './DialogOptions'; 19 | 20 | /** 21 | * TODO 自定义内容区弹出框,参数类 22 | * author: 桃花镇童长老ᥫ᭡ 23 | * since: 2024/08/18 24 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 25 | * github: https://github.com/787107497 26 | * gitee: https://gitee.com/tongyuyan/harmony-utils 27 | * CSDN: https://blog.csdn.net/qq_32922545 28 | * QQ交流群: 569512366 29 | */ 30 | export interface BaseContentOptions extends DialogOptions { 31 | 32 | primaryTitle?: ResourceStr; //弹出框标题。 33 | secondaryTitle?: ResourceStr; //弹出框辅助文本。 34 | 35 | contentBuilder: () => void; //弹出框内容。 36 | localizedContentAreaPadding?: LocalizedPadding; //弹出框内容区内边距。 37 | contentAreaPadding?: Padding; //弹出框内容区内边距。设置了localizedContentAreaPadding属性时该属性不生效。 38 | 39 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/base/BaseDialogOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | import { ActionCallBack, ActionDateCallBack, ActionStrCallBack, ActionValueCallBack } from '../../utils/constraint'; 19 | 20 | 21 | /** 22 | * TODO 弹窗工具类,Base参数类 23 | * author: 桃花镇童长老ᥫ᭡ 24 | * since: 2024/08/18 25 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 26 | * github: https://github.com/787107497 27 | * gitee: https://gitee.com/tongyuyan/harmony-utils 28 | * CSDN: https://blog.csdn.net/qq_32922545 29 | * QQ交流群: 569512366 30 | */ 31 | export interface BaseDialogOptions { 32 | uiContext?: UIContext; //UIContext上下文 33 | backCancel?: boolean; //点击返回键或手势返回时,是否关闭弹窗;实现onWillDismiss函数时,该参数不起作用。true表示关闭弹窗。false表示不关闭弹窗。默认值:true。 34 | onAction?: ActionCallBack | ActionStrCallBack | ActionValueCallBack | ActionDateCallBack; //按钮的CallBack事件。 35 | 36 | dialogId?: string; //弹框id,具有唯一性 37 | alignment?: DialogAlignment; //弹窗的对齐方式。 38 | offset?: Offset; //弹窗相对alignment所在位置的偏移量。默认值:{ dx: 0, dy: 0 } 39 | maskRect?: Rectangle; //弹窗遮蔽层区域,在遮蔽层区域内的事件不透传,在遮蔽层区域外的事件透传。 40 | maskColor?: ResourceColor; //自定义蒙层颜色。默认值 0x33000000 41 | isModal?: boolean; //弹窗是否为模态窗口,模态窗口有蒙层,非模态窗口无蒙层。默认值:true,此时弹窗有蒙层。 42 | showInSubWindow?: boolean; //某弹框需要显示在主窗口之外时,是否在子窗口显示此弹窗。 43 | autoCancel?: boolean; //点击遮障层时,是否关闭弹窗,true表示关闭弹窗。false表示不关闭弹窗。默认值:true 44 | transition?: TransitionEffect; //设置弹窗显示和退出的过渡效果。 45 | onWillAppear?: VoidCallback; //弹窗显示动效前的事件回调。 46 | onWillDisappear?: VoidCallback; //弹窗退出动效前的事件回调。 47 | onDidAppear?: VoidCallback; //弹窗弹出时的事件回调。 48 | onDidDisappear?: VoidCallback; //弹窗消失时的事件回调。 49 | onWillDismiss?: Callback; //交互式关闭回调函数。 50 | 51 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/base/BaseInputOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | import { ActionStrCallBack, StringCalBack } from '../../utils/constraint'; 19 | import { DialogOptions } from './DialogOptions'; 20 | import { ButtonOptions } from '../ButtonOptions'; 21 | import { InputFilter } from '../InputFilter'; 22 | 23 | /** 24 | * TODO Base输入弹出框,参数类 25 | * author: 桃花镇童长老ᥫ᭡ 26 | * since: 2024/08/18 27 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 28 | * github: https://github.com/787107497 29 | * gitee: https://gitee.com/tongyuyan/harmony-utils 30 | * CSDN: https://blog.csdn.net/qq_32922545 31 | * QQ交流群: 569512366 32 | */ 33 | export interface BaseInputOptions extends DialogOptions { 34 | 35 | primaryTitle?: ResourceStr; //弹出框标题。 36 | secondaryTitle?: ResourceStr; //弹出框辅助文本。 37 | buttons?: Array; //弹出框操作区按钮,最多支持4个按钮。 38 | localizedContentAreaPadding?: LocalizedPadding; //弹出框内容区内边距。 39 | contentAreaPadding?: Padding; //弹出框内容区内边距。设置了localizedContentAreaPadding属性时该属性不生效。 40 | 41 | text: string; //设置输入框当前的文本内容。 42 | fontColor?: ResourceColor; //字体颜色 43 | fontSize?: Length; //字体大小 44 | placeholder?: ResourceStr; //设置无输入时的提示文本。 45 | placeholderColor ?: ResourceColor //设置placeholder文本颜色。 46 | inputBackgroundColor?: ResourceColor; //输入框背景 47 | inputBorder?: BorderOptions; //输入框Border 48 | inputHeight?: Length; //输入框高度 49 | 50 | defaultFocus?: boolean //设置弹框默认获得焦点,打开弹窗同时弹出输入法 51 | maxLength?: number; //文本的最大输入字符数。 默认值:Infinity,可以无限输入。 52 | controller?: TextInputController; //TextInput组件的控制器 53 | inputFilter?: InputFilter; //通过正则表达式设置输入过滤器。 54 | 55 | onChange?: StringCalBack; 56 | onAction: ActionStrCallBack; //按钮的CallBack事件。 57 | 58 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/base/BasePickerOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | 19 | import { BaseDialogOptions } from './BaseDialogOptions'; 20 | import { ButtonOptions } from '../ButtonOptions'; 21 | 22 | 23 | /** 24 | * TODO 弹窗工具类,Picker参数类 25 | * author: 桃花镇童长老ᥫ᭡ 26 | * since: 2024/08/18 27 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 28 | * github: https://github.com/787107497 29 | * gitee: https://gitee.com/tongyuyan/harmony-utils 30 | * CSDN: https://blog.csdn.net/qq_32922545 31 | * QQ交流群: 569512366 32 | */ 33 | export interface BasePickerOptions extends BaseDialogOptions { 34 | 35 | title?: ResourceStr; //弹框标题 36 | titleFontColor?: ResourceColor; //弹框标题的字体颜色。 37 | titleBackground?: ResourceColor; //头部背景颜色 38 | primaryButton?: ButtonOptions | ResourceStr; //弹框左侧按钮。 39 | secondaryButton?: ButtonOptions | ResourceStr; //弹框右侧按钮。 40 | 41 | actionCancel?: boolean; //点击操作按钮时,是否关闭弹窗。false表示不关闭弹窗。默认值:true。 42 | width?: Dimension | Length; //设置弹窗的宽度,弹窗宽度默认值:'100%'。 43 | maxWidth?: Length; //弹窗宽度默认最大值:360vp。 44 | backgroundColor?: ResourceColor; //弹窗背板颜色。默认值:Color.White 45 | backgroundBlurStyle?: BlurStyle; //弹窗背板模糊材质。默认值:BlurStyle.COMPONENT_ULTRA_THICK 46 | cornerRadius?: Length; //设置背板的圆角半径。可分别设置4个圆角的半径,默认15。 47 | 48 | textStyle?: PickerTextStyle; //设置所有选项中除了最上、最下及选中项以外的文本颜色、字号、字体粗细。 49 | selectedTextStyle?: PickerTextStyle; //设置选中项的文本颜色、字号、字体粗细。 50 | disappearTextStyle?: PickerTextStyle; //设置所有选项中最上和最下两个选项的文本颜色、字号、字体粗细。 51 | divider?: DividerOptions | null; //设置分割线样式,不设置该属性则按“默认值”展示分割线。 52 | canLoop?: boolean; //设置是否可循环滚动。 53 | 54 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/base/DialogOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | import { ActionCallBack, ActionStrCallBack } from '../../utils/constraint'; 19 | import { BaseDialogOptions } from './BaseDialogOptions'; 20 | 21 | 22 | /** 23 | * TODO 弹窗工具类,Base参数类 24 | * author: 桃花镇童长老ᥫ᭡ 25 | * since: 2024/08/18 26 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 27 | * github: https://github.com/787107497 28 | * gitee: https://gitee.com/tongyuyan/harmony-utils 29 | * CSDN: https://blog.csdn.net/qq_32922545 30 | * QQ交流群: 569512366 31 | */ 32 | export interface DialogOptions extends BaseDialogOptions { 33 | title?: ResourceStr; //弹框标题 34 | actionCancel?: boolean; //点击操作按钮时,是否关闭弹窗。false表示不关闭弹窗。默认值:true。 35 | onAction?: ActionCallBack | ActionStrCallBack; //按钮的CallBack事件。 36 | 37 | height?: Dimension | Length; //设置弹窗的高度;很多弹框都是自适应高度,谨慎设置该值。 38 | width?: Dimension | Length; //设置弹窗的宽度,弹窗宽度默认值:'calc(100% - 32vp)'、100%。 39 | maxHeight?: Dimension | Length; //设置弹窗高度默认最大值;很多弹框都是自适应高度,谨慎设置该值。 40 | maxWidth?: Length; //弹窗宽度默认最大值:360vp。 41 | backgroundColor?: ResourceColor; //弹窗背板颜色。默认值:Color.White 42 | backgroundBlurStyle?: BlurStyle; //弹窗背板模糊材质。默认值:BlurStyle.COMPONENT_ULTRA_THICK 43 | cornerRadius?: Length | BorderRadiuses | LocalizedBorderRadiuses; //设置背板的圆角半径。可分别设置4个圆角的半径。 44 | borderWidth?: Dimension | EdgeWidths | LocalizedEdgeWidths; //可分别设置4个边框宽度。默认值:0。 45 | borderColor?: ResourceColor | EdgeColors | LocalizedEdgeColors; //设置弹窗背板的边框颜色。默认值:Color.Black。 46 | borderStyle?: BorderStyle | EdgeStyles; //设置弹窗背板的边框样式。默认值:BorderStyle.Solid。 47 | theme?: Theme | CustomTheme; //主题信息,可以是CustomTheme或从onWillApplyTheme中获取的Theme实例。 48 | 49 | } 50 | -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/base/HmDialogOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | import { DialogOptions } from './DialogOptions'; 19 | import { ButtonOptions } from '../ButtonOptions'; 20 | import { ActionCallBack } from '../../utils/constraint'; 21 | 22 | /** 23 | * TODO 确认弹出框,Base参数类 24 | * author: 桃花镇童长老ᥫ᭡ 25 | * since: 2024/08/18 26 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 27 | * github: https://github.com/787107497 28 | * gitee: https://gitee.com/tongyuyan/harmony-utils 29 | * CSDN: https://blog.csdn.net/qq_32922545 30 | * QQ交流群: 569512366 31 | */ 32 | export interface HmDialogOptions extends DialogOptions { 33 | 34 | content?: ResourceStr; //弹框内容。 35 | primaryButton?: ButtonOptions | ResourceStr; //弹框左侧按钮。 36 | secondaryButton?: ButtonOptions | ResourceStr; //弹框右侧按钮。 37 | onAction: ActionCallBack; //按钮的CallBack事件。 38 | 39 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/model/base/PromptActionArg.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | 19 | /** 20 | * TODO PromptAction基类的参数 21 | * author: 桃花镇童长老ᥫ᭡ 22 | * since: 2024/08/01 23 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 24 | * github: https://github.com/787107497 25 | * gitee: https://gitee.com/tongyuyan/harmony-utils 26 | * QQ交流群: 569512366 27 | */ 28 | export interface PromptActionArg { 29 | dialogId: string; 30 | uiContext: UIContext; 31 | componentContent: ComponentContent; 32 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/utils/CacheHelper.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-utils 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils 16 | */ 17 | 18 | 19 | import { util } from '@kit.ArkTS'; 20 | 21 | /** 22 | * TODO LRUCache缓存工具类 23 | * author: 桃花镇童长老ᥫ᭡ 24 | * since: 2024/05/01 25 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils 26 | * github: https://github.com/787107497 27 | * gitee: https://gitee.com/tongyuyan/harmony-utils 28 | * CSDN: https://blog.csdn.net/qq_32922545 29 | * QQ交流群: 569512366 30 | */ 31 | export class CacheHelper { 32 | private static lruCache: util.LRUCache = new util.LRUCache(64); 33 | static readonly CACHE_LABEL: string = "dialog_cache_" //缓存key的头部字符串。 34 | 35 | /** 36 | * 获取key对应的缓存 37 | */ 38 | public static get(key: string): T { 39 | return CacheHelper.lruCache.get(key) as T; 40 | } 41 | 42 | 43 | /** 44 | * 添加缓存到lruCache中 45 | */ 46 | public static put(key: string, value: Object) { 47 | CacheHelper.lruCache.put(key, value); 48 | } 49 | 50 | 51 | /** 52 | * 删除key对应的缓存 53 | */ 54 | public static remove(key: string) { 55 | CacheHelper.lruCache.remove(key); 56 | } 57 | 58 | 59 | /** 60 | * 判断是否包含key对应的缓存 61 | */ 62 | public static has(key: string): boolean { 63 | return CacheHelper.lruCache.contains(key); 64 | } 65 | 66 | 67 | /** 68 | * 判断lruCache缓存是否为空 69 | * @returns 70 | */ 71 | public static isEmpty(): boolean { 72 | return CacheHelper.lruCache.isEmpty(); 73 | } 74 | 75 | 76 | /** 77 | * 获取当前缓冲区的容量。 78 | * @returns 79 | */ 80 | public static getCapacity(): number { 81 | console.error(JSON.stringify(CacheHelper.lruCache, null, 2)); 82 | return CacheHelper.lruCache.getCapacity(); 83 | } 84 | 85 | 86 | /** 87 | * 重新设置lruCache的容量 88 | * @param newCapacity 89 | */ 90 | public static updateCapacity(newCapacity: number) { 91 | CacheHelper.lruCache.updateCapacity(newCapacity); 92 | } 93 | 94 | 95 | /** 96 | * 清除缓存数据,并重置lruCache的大小 97 | */ 98 | public static clear() { 99 | CacheHelper.lruCache.clear(); 100 | CacheHelper.lruCache.updateCapacity(64); 101 | } 102 | 103 | 104 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/utils/TextAreaModifier.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | 19 | import { InputFilter } from '../model/InputFilter'; 20 | 21 | 22 | /** 23 | * 给TextArea 设置过滤器 24 | */ 25 | export class TextAreaModifier implements AttributeModifier { 26 | inputFilter?: InputFilter; //通过正则表达式设置输入过滤器。 27 | 28 | applyNormalAttribute(instance: TextAreaAttribute): void { 29 | if (this.inputFilter) { 30 | instance.inputFilter(this.inputFilter.value, this.inputFilter.error); 31 | } 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/utils/TextInputModifier.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | 19 | import { InputFilter } from '../model/InputFilter'; 20 | 21 | 22 | /** 23 | * 给TextInput 设置过滤器 24 | */ 25 | export class TextInputModifier implements AttributeModifier { 26 | inputFilter?: InputFilter; //通过正则表达式设置输入过滤器。 27 | 28 | applyNormalAttribute(instance: TextInputAttribute): void { 29 | if (this.inputFilter) { 30 | instance.inputFilter(this.inputFilter.value, this.inputFilter.error); 31 | } 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/utils/TextPickerModifier.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-dialog 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog 16 | */ 17 | 18 | 19 | /** 20 | * 给TextPicker 设置样式 21 | */ 22 | export class TextPickerModifier implements AttributeModifier { 23 | 24 | textStyle?: PickerTextStyle; //设置所有选项中除了最上、最下及选中项以外的文本颜色、字号、字体粗细。 25 | selectedTextStyle?: PickerTextStyle; //设置选中项的文本颜色、字号、字体粗细。 26 | disappearTextStyle?: PickerTextStyle; //设置所有选项中最上和最下两个选项的文本颜色、字号、字体粗细。 27 | divider?: DividerOptions | null; //设置分割线样式,不设置该属性则按“默认值”展示分割线。 28 | canLoop?: boolean; //设置是否可循环滚动。 29 | 30 | applyNormalAttribute(instance: TextPickerAttribute): void { 31 | if (this.disappearTextStyle) { 32 | instance.disappearTextStyle(this.disappearTextStyle) 33 | } 34 | if (this.textStyle) { 35 | instance.textStyle(this.textStyle) 36 | } 37 | if (this.selectedTextStyle) { 38 | instance.selectedTextStyle(this.selectedTextStyle) 39 | } 40 | if (this.divider) { 41 | instance.divider(this.divider) 42 | } 43 | instance.canLoop(this.canLoop) 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/ets/utils/constraint.ets: -------------------------------------------------------------------------------- 1 | //number类型Callback 2 | export declare type NumberCalBack = (index: number) => void; 3 | 4 | 5 | //string类型Callback 6 | export declare type StringCalBack = (content: string) => void; 7 | 8 | 9 | /** 10 | * 弹框操作按钮Callback 11 | * action: 12 | * 1、当action小于0时,对应弹框操作按钮的Action,类型为DialogAction。 13 | * 2、当action大于等于0时,对选的是选项索引值。 14 | * dialogId: 对应弹框的id。 15 | * value: string 弹框内容回调,如输入框的输入内容。 16 | * value: string | string[] picker选中值 17 | * date: Date 选中日期 18 | */ 19 | export declare type ActionCallBack = (action: number, dialogId: string) => void; 20 | export declare type ActionStrCallBack = (action: number, dialogId: string, value: string) => void; 21 | export declare type ActionValueCallBack = (action: number, dialogId: string, value: string | string[]) => void; 22 | export declare type ActionDateCallBack = (action: number, dialogId: string, date: Date) => void; 23 | 24 | //多行文本输入弹框Align 25 | export enum TextAlignment { Top, Center, Bottom } 26 | 27 | 28 | //弹框按钮的Action类型(从左往右,最多四个按钮) 29 | export enum DialogAction { 30 | ONE = -1, //第一个按钮 - 取消。 31 | TWO = -2, //第二个按钮 - 确定。 32 | THREE = -3, //第三个按钮。 33 | FOUR = -4, //第四个按钮。 34 | FIVE = -5, //第五个按钮。 35 | SIX = -6, //第六个按钮。 36 | CANCEL = ONE, //第一个按钮 - 取消。 37 | SURE = TWO, //第二个按钮 - 确定。 38 | } 39 | 40 | //选择日期类型 41 | export enum DateType { 42 | YmdHms, //年月日时分秒 43 | YmdHm, //年月日时分 44 | YmdH, //年月日时 45 | Ymd, //年月日 46 | Ym, //年月 47 | Y, //年 48 | Hms, //时分秒 49 | Hm, //时分 50 | Ms //分秒 51 | } 52 | 53 | export enum Orientation { 54 | VERTICAL, //垂直 55 | HORIZONTAL //水平 56 | } 57 | -------------------------------------------------------------------------------- /harmony_dialog/src/main/module.json5: -------------------------------------------------------------------------------- 1 | { 2 | "module": { 3 | "name": "harmony_dialog", 4 | "type": "har", 5 | "deviceTypes": [ 6 | "default", 7 | "tablet", 8 | "2in1" 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /harmony_dialog/src/main/resources/base/element/color.json: -------------------------------------------------------------------------------- 1 | { 2 | "color": [ 3 | { 4 | "name": "color_harmony_dialog_33", 5 | "value": "#333333" 6 | }, 7 | { 8 | "name": "color_harmony_dialog_66", 9 | "value": "#666666" 10 | }, 11 | { 12 | "name": "color_harmony_dialog_99", 13 | "value": "#999999" 14 | }, 15 | { 16 | "name": "color_harmony_dialog_line", 17 | "value": "#EEEEEE" 18 | }, 19 | { 20 | "name": "color_harmony_dialog_cancel", 21 | "value": "#0A59F7" 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /harmony_dialog/src/main/resources/base/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "page_show", 5 | "value": "page from package" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /harmony_dialog/src/main/resources/en_US/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "page_show", 5 | "value": "page from package" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /harmony_dialog/src/main/resources/zh_CN/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "page_show", 5 | "value": "page from package" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /harmony_dialog/src/ohosTest/ets/test/Ability.test.ets: -------------------------------------------------------------------------------- 1 | import { hilog } from '@kit.PerformanceAnalysisKit'; 2 | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; 3 | 4 | export default function abilityTest() { 5 | describe('ActsAbilityTest', () => { 6 | // Defines a test suite. Two parameters are supported: test suite name and test suite function. 7 | beforeAll(() => { 8 | // Presets an action, which is performed only once before all test cases of the test suite start. 9 | // This API supports only one parameter: preset action function. 10 | }) 11 | beforeEach(() => { 12 | // Presets an action, which is performed before each unit test case starts. 13 | // The number of execution times is the same as the number of test cases defined by **it**. 14 | // This API supports only one parameter: preset action function. 15 | }) 16 | afterEach(() => { 17 | // Presets a clear action, which is performed after each unit test case ends. 18 | // The number of execution times is the same as the number of test cases defined by **it**. 19 | // This API supports only one parameter: clear action function. 20 | }) 21 | afterAll(() => { 22 | // Presets a clear action, which is performed after all test cases of the test suite end. 23 | // This API supports only one parameter: clear action function. 24 | }) 25 | it('assertContain', 0, () => { 26 | // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. 27 | hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); 28 | let a = 'abc'; 29 | let b = 'b'; 30 | // Defines a variety of assertion methods, which are used to declare expected boolean conditions. 31 | expect(a).assertContain(b); 32 | expect(a).assertEqual(a); 33 | }) 34 | }) 35 | } -------------------------------------------------------------------------------- /harmony_dialog/src/ohosTest/ets/test/List.test.ets: -------------------------------------------------------------------------------- 1 | import abilityTest from './Ability.test'; 2 | 3 | export default function testsuite() { 4 | abilityTest(); 5 | } -------------------------------------------------------------------------------- /harmony_dialog/src/ohosTest/module.json5: -------------------------------------------------------------------------------- 1 | { 2 | "module": { 3 | "name": "harmony_dialog_test", 4 | "type": "feature", 5 | "deviceTypes": [ 6 | "default", 7 | "tablet", 8 | "2in1" 9 | ], 10 | "deliveryWithInstall": true, 11 | "installationFree": false 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /harmony_dialog/src/test/List.test.ets: -------------------------------------------------------------------------------- 1 | import localUnitTest from './LocalUnit.test'; 2 | 3 | export default function testsuite() { 4 | localUnitTest(); 5 | } -------------------------------------------------------------------------------- /harmony_dialog/src/test/LocalUnit.test.ets: -------------------------------------------------------------------------------- 1 | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; 2 | 3 | export default function localUnitTest() { 4 | describe('localUnitTest', () => { 5 | // Defines a test suite. Two parameters are supported: test suite name and test suite function. 6 | beforeAll(() => { 7 | // Presets an action, which is performed only once before all test cases of the test suite start. 8 | // This API supports only one parameter: preset action function. 9 | }); 10 | beforeEach(() => { 11 | // Presets an action, which is performed before each unit test case starts. 12 | // The number of execution times is the same as the number of test cases defined by **it**. 13 | // This API supports only one parameter: preset action function. 14 | }); 15 | afterEach(() => { 16 | // Presets a clear action, which is performed after each unit test case ends. 17 | // The number of execution times is the same as the number of test cases defined by **it**. 18 | // This API supports only one parameter: clear action function. 19 | }); 20 | afterAll(() => { 21 | // Presets a clear action, which is performed after all test cases of the test suite end. 22 | // This API supports only one parameter: clear action function. 23 | }); 24 | it('assertContain', 0, () => { 25 | // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. 26 | let a = 'abc'; 27 | let b = 'b'; 28 | // Defines a variety of assertion methods, which are used to declare expected boolean conditions. 29 | expect(a).assertContain(b); 30 | expect(a).assertEqual(a); 31 | }); 32 | }); 33 | } -------------------------------------------------------------------------------- /harmony_utils/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /oh_modules 3 | /.preview 4 | /build 5 | /.cxx 6 | /.test -------------------------------------------------------------------------------- /harmony_utils/BuildProfile.ets: -------------------------------------------------------------------------------- 1 | /** 2 | * Use these variables when you tailor your ArkTS code. They must be of the const type. 3 | */ 4 | export const HAR_VERSION = '1.2.5'; 5 | export const BUILD_MODE_NAME = 'debug'; 6 | export const DEBUG = true; 7 | export const TARGET_NAME = 'default'; 8 | 9 | /** 10 | * BuildProfile Class is used only for compatibility purposes. 11 | */ 12 | export default class BuildProfile { 13 | static readonly HAR_VERSION = HAR_VERSION; 14 | static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; 15 | static readonly DEBUG = DEBUG; 16 | static readonly TARGET_NAME = TARGET_NAME; 17 | } -------------------------------------------------------------------------------- /harmony_utils/build-profile.json5: -------------------------------------------------------------------------------- 1 | { 2 | "apiType": "stageMode", 3 | "buildOption": { 4 | }, 5 | "buildOptionSet": [ 6 | { 7 | "name": "release", 8 | "arkOptions": { 9 | "obfuscation": { 10 | "ruleOptions": { 11 | "enable": false, 12 | "files": [ 13 | "./obfuscation-rules.txt" 14 | ] 15 | }, 16 | "consumerFiles": [ 17 | "./consumer-rules.txt" 18 | ] 19 | } 20 | }, 21 | }, 22 | ], 23 | "targets": [ 24 | { 25 | "name": "default" 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /harmony_utils/consumer-rules.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/harmony_utils/consumer-rules.txt -------------------------------------------------------------------------------- /harmony_utils/example/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## 📚仓库主页 3 | https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils 4 | 5 | ## 📚源码地址 6 | https://gitee.com/tongyuyan/harmony-utils 7 | https://github.com/787107497 8 | 9 | ## 📚CSDN博客 10 | https://blog.csdn.net/qq_32922545 11 | 12 | ## 💖QQ交流群 13 | 569512366 14 | -------------------------------------------------------------------------------- /harmony_utils/hvigorfile.ts: -------------------------------------------------------------------------------- 1 | import { harTasks } from '@ohos/hvigor-ohos-plugin'; 2 | 3 | export default { 4 | system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ 5 | plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ 6 | } 7 | -------------------------------------------------------------------------------- /harmony_utils/obfuscation-rules.txt: -------------------------------------------------------------------------------- 1 | # Define project specific obfuscation rules here. 2 | # You can include the obfuscation configuration files in the current module's build-profile.json5. 3 | # 4 | # For more details, see 5 | # https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 6 | 7 | # Obfuscation options: 8 | # -disable-obfuscation: disable all obfuscations 9 | # -enable-property-obfuscation: obfuscate the property names 10 | # -enable-toplevel-obfuscation: obfuscate the names in the global scope 11 | # -compact: remove unnecessary blank spaces and all line feeds 12 | # -remove-log: remove all console.* statements 13 | # -print-namecache: print the name cache that contains the mapping from the old names to new names 14 | # -apply-namecache: reuse the given cache file 15 | 16 | # Keep options: 17 | # -keep-property-name: specifies property names that you want to keep 18 | # -keep-global-name: specifies names that you want to keep in the global scope 19 | 20 | # ZsHx: 21 | #-enable-property-obfuscation 22 | #-enable-toplevel-obfuscation 23 | #-enable-filename-obfuscation 24 | #-enable-export-obfuscation -------------------------------------------------------------------------------- /harmony_utils/oh-package-lock.json5: -------------------------------------------------------------------------------- 1 | { 2 | "meta": { 3 | "stableOrder": true 4 | }, 5 | "lockfileVersion": 3, 6 | "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", 7 | "specifiers": { 8 | "class-transformer@^0.5.1": "class-transformer@0.5.1" 9 | }, 10 | "packages": { 11 | "class-transformer@0.5.1": { 12 | "name": "class-transformer", 13 | "version": "0.5.1", 14 | "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==", 15 | "resolved": "https://ohpm.openharmony.cn/ohpm/class-transformer/-/class-transformer-0.5.1.tgz", 16 | "shasum": "24147d5dffd2a6cea930a3250a677addf96ab336", 17 | "registryType": "ohpm" 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /harmony_utils/oh-package.json5: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@pura/harmony-utils", 3 | "version": "1.2.5", 4 | "description": "一款功能丰富且极易上手的HarmonyOS工具库,借助众多实用工具类,致力于助力开发者迅速构建鸿蒙应用。其封装的工具涵盖了APP、设备、屏幕、授权、通知、线程间通信、弹框、吐司、生物认证、用户首选项、拍照、相册、扫码、文件、日志,异常捕获、字符、字符串、数字、集合、日期、随机、base64、加密、解密、JSON等一系列的功能和操作,能够满足各种不同的开发需求。", 5 | "author": "桃花镇童长老", 6 | "homepage": "https://gitee.com/tongyuyan", 7 | "repository": "https://gitee.com/tongyuyan/harmony-utils", 8 | "main": "Index.ets", 9 | "license": "Apache-2.0", 10 | "dependencies": { 11 | "class-transformer": "^0.5.1" 12 | }, 13 | "devDependencies": {}, 14 | "dynamicDependencies": {}, 15 | "keywords": [ 16 | "工具类", 17 | "加解密", 18 | "字符串", 19 | "日期", 20 | "图片", 21 | "文件", 22 | "弹框", 23 | "通知", 24 | "授权", 25 | "picker" 26 | ], 27 | "tags": [ 28 | "工具类", 29 | "加解密", 30 | "字符串", 31 | "日期", 32 | "图片", 33 | "文件", 34 | "弹框", 35 | "通知", 36 | "授权", 37 | "picker" 38 | ] 39 | } -------------------------------------------------------------------------------- /harmony_utils/src/main/ets/crypto/crypto.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-utils 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils 16 | */ 17 | 18 | 19 | /** 20 | * TODO 类型约束 21 | * author: 桃花镇童长老ᥫ᭡ 22 | * since: 2024/07/01 23 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils 24 | * github: https://github.com/787107497 25 | * gitee: https://gitee.com/tongyuyan/harmony-utils 26 | * CSDN: https://blog.csdn.net/qq_32922545 27 | * QQ交流群: 569512366 28 | */ 29 | export declare namespace crypto { 30 | 31 | type BhuCoding = 'base64' | 'hex' | 'utf8' | 'utf-8'; 32 | type BhCoding = 'base64' | 'hex'; 33 | 34 | type SHA = 'SHA1' | 'SHA224' | 'SHA256' | 'SHA384' | 'SHA512'; //密钥类型,字符串参数 35 | 36 | type RSA_AlG = 'RSA512|PRIMES_2' | 'RSA768|PRIMES_2' | 'RSA1024|PRIMES_2' | 'RSA1024|PRIMES_3' 37 | | 'RSA2048|PRIMES_2'| 'RSA2048|PRIMES_3'| 'RSA3072|PRIMES_2'| 'RSA3072|PRIMES_2' 38 | | 'RSA4096|PRIMES_2'| 'RSA4096|PRIMES_3'| 'RSA4096|PRIMES_4' 39 | | 'RSA8192|PRIMES_2'| 'RSA8192|PRIMES_3'| 'RSA8192|PRIMES_4'| 'RSA8192|PRIMES_5'; //RSA密钥规格,字符串参数 40 | type RSA_TRAN_SOME = 'RSA|NoPadding' | 'RSA512|NoPadding' | 'RSA768|NoPadding' | 'RSA1024|NoPadding' 41 | | 'RSA2048|NoPadding' | 'RSA3072|NoPadding' | 'RSA4096|NoPadding' | 'RSA8192|NoPadding' 42 | | 'RSA|PKCS1' | 'RSA512|PKCS1' | 'RSA768|PKCS1' | 'RSA1024|PKCS1' 43 | | 'RSA2048|PKCS1' | 'RSA3072|PKCS1' | 'RSA4096|PKCS1' | 'RSA8192|PKCS1' 44 | | 'RSA2048|PKCS1_OAEP|SHA256|MGF1_SHA256' | 'RSA1024|PKCS1_OAEP|SHA256|MGF1_SHA256'; //RSA加解密规格,字符串参数 45 | type RSA_TRAN = RSA_TRAN_SOME | string; 46 | 47 | 48 | } -------------------------------------------------------------------------------- /harmony_utils/src/main/ets/entity/CameraOptions.ets: -------------------------------------------------------------------------------- 1 | import { camera, cameraPicker } from "@kit.CameraKit"; 2 | 3 | /** 4 | * 相机参数类 5 | */ 6 | export class CameraOptions { 7 | mediaTypes: Array = [cameraPicker.PickerMediaType.PHOTO, cameraPicker.PickerMediaType.VIDEO]; //媒体类型。 8 | cameraPosition: camera.CameraPosition = camera.CameraPosition.CAMERA_POSITION_BACK; //相机的位置。 9 | saveUri?: string; //保存配置信息的uri。 10 | videoDuration?: number; //录制的最大时长。 11 | } -------------------------------------------------------------------------------- /harmony_utils/src/main/ets/entity/ToastConfig.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-utils 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils 16 | */ 17 | 18 | 19 | import { promptAction } from '@kit.ArkUI'; 20 | 21 | /** 22 | * TODO Toast默认样式参数 23 | * author: 桃花镇童长老ᥫ᭡ 24 | * since: 2024/08/18 25 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils 26 | * github: https://github.com/787107497 27 | * gitee: https://gitee.com/tongyuyan/harmony-utils 28 | * CSDN: https://blog.csdn.net/qq_32922545 29 | * QQ交流群: 569512366 30 | */ 31 | export class ToastConfig { 32 | showMode: promptAction.ToastShowMode = promptAction.ToastShowMode.DEFAULT; //是否显示在应用之上。 33 | alignment: Alignment = Alignment.Center; //对齐方式。默认值:undefined,默认底部偏上位置。 34 | offset: Offset = { dx: 0, dy: 0 } //在对齐方式上的偏移。 默认值:{dx:0, dy:0},默认没有偏移。 35 | duration: number = 2000; //显示时长(1500ms-10000ms) 36 | duration_short: number = 1500; //显示时长(1500ms) 37 | duration_long: number = 10000; //显示时长(10000ms) 38 | } -------------------------------------------------------------------------------- /harmony_utils/src/main/ets/entity/ToastOptions.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-utils 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils 16 | */ 17 | 18 | 19 | import { promptAction } from '@kit.ArkUI'; 20 | 21 | /** 22 | * TODO Toast基本参数类 23 | * author: 桃花镇童长老ᥫ᭡ 24 | * since: 2024/08/18 25 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils 26 | * github: https://github.com/787107497 27 | * gitee: https://gitee.com/tongyuyan/harmony-utils 28 | * CSDN: https://blog.csdn.net/qq_32922545 29 | * QQ交流群: 569512366 30 | */ 31 | export class ToastOptions { 32 | duration?: number; //显示时长(1500ms-10000ms) 33 | bottom?: string | number; //距离屏幕底部的位置 34 | showMode?: promptAction.ToastShowMode; //是否显示在应用之上 35 | alignment?: Alignment; //对齐方式。默认值:undefined,默认底部偏上位置。 36 | offset?: Offset //在对齐方式上的偏移。 默认值:{dx:0, dy:0},默认没有偏移。 37 | } -------------------------------------------------------------------------------- /harmony_utils/src/main/ets/entity/constraint.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-utils 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils 16 | */ 17 | 18 | 19 | /** 20 | * 弹框操作按钮Callback 21 | * action: 22 | * 1、当action小于0时,对应弹框操作按钮的Action,类型为DialogAction。 23 | * 2、当action大于等于0时,对选的是选项索引值。 24 | */ 25 | export declare type ActionCallBack = (action: number) => void; 26 | 27 | 28 | //弹框按钮的Action类型(从左往右,最多四个按钮) 29 | export enum DialogAction { 30 | ONE = -1, //第一个按钮 - 取消。 31 | TWO = -2, //第二个按钮 - 确定。 32 | THREE = -3, //第三个按钮。 33 | FOUR = -4, //第四个按钮。 34 | FIVE = -5, //第五个按钮。 35 | SIX = -6 //第六个按钮。 36 | } -------------------------------------------------------------------------------- /harmony_utils/src/main/ets/entity/constranint.ts: -------------------------------------------------------------------------------- 1 | import { ArrayList, HashMap } from "@kit.ArkTS"; 2 | 3 | 4 | export type CommonSingleType = Object | String | Number | Boolean | null | undefined; //通用单个联合类型 5 | export type CommonAllType = CommonSingleType | Array | ArrayList | HashMap; //通用所有联合类型 -------------------------------------------------------------------------------- /harmony_utils/src/main/ets/utils/CacheUtil.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-utils 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils 16 | */ 17 | 18 | 19 | /** 20 | * TODO 缓存工具类 21 | * author: 桃花镇童长老ᥫ᭡ 22 | * since: 2024/05/01 23 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils 24 | * github: https://github.com/787107497 25 | * gitee: https://gitee.com/tongyuyan/harmony-utils 26 | * CSDN: https://blog.csdn.net/qq_32922545 27 | * QQ交流群: 569512366 28 | */ 29 | export class CacheUtil { 30 | private static cache: Record = {}; //私有缓存对象 31 | 32 | 33 | /** 34 | * 将数据存入缓存中 35 | * @param key 存入key 36 | * @param value 存入数据 37 | */ 38 | static put(key: string, value: T): void { 39 | CacheUtil.cache[key] = value as Object; 40 | } 41 | 42 | 43 | /** 44 | * 获取缓存中的数据 45 | * @param key 存入的key 46 | * @returns 47 | */ 48 | static get(key: string): T { 49 | return CacheUtil.cache[key] as T; 50 | } 51 | 52 | 53 | /** 54 | * 缓存中的数据是否存在 55 | * @param key 存入的key 56 | * @returns 57 | */ 58 | static has(key: string): boolean { 59 | let keys = Object.keys(CacheUtil.cache); 60 | return keys.indexOf(key) >= 0 61 | } 62 | 63 | /** 64 | * 判断缓存是否为空 65 | * @returns 66 | */ 67 | static isEmpty(): boolean { 68 | let keys = Object.keys(CacheUtil.cache); 69 | return keys.length <= 0; 70 | } 71 | 72 | /** 73 | * 清除缓存数据 74 | */ 75 | static clear(): void { 76 | CacheUtil.cache = {}; 77 | } 78 | 79 | 80 | } 81 | -------------------------------------------------------------------------------- /harmony_utils/src/main/ets/utils/GlobalContext.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-utils 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils 16 | */ 17 | 18 | // 单例对象 GlobalContext.ts 19 | export class GlobalContext { 20 | 21 | private constructor() {} 22 | 23 | 24 | private static instance: GlobalContext; 25 | private _objects = new Map(); 26 | 27 | 28 | public static getContext(): GlobalContext { 29 | if (!GlobalContext.instance) { 30 | GlobalContext.instance = new GlobalContext(); 31 | } 32 | return GlobalContext.instance; 33 | } 34 | 35 | 36 | public getObject(key: string): Object | undefined { 37 | return this._objects.get(key); 38 | } 39 | 40 | public setObject(key: string, objectClass: Object): void { 41 | this._objects.set(key, objectClass); 42 | } 43 | 44 | 45 | /** 46 | * 将数据存入缓存中 47 | */ 48 | public put(key: string, value: Object): void { 49 | this._objects.set(key, value); 50 | } 51 | 52 | /** 53 | * 获取缓存中的数据 54 | */ 55 | public get(key: string): T { 56 | return this._objects.get(key) as T; 57 | } 58 | 59 | 60 | /** 61 | * 缓存中的数据是否存在 62 | */ 63 | public has(key: string): boolean { 64 | return this._objects.has(key); 65 | } 66 | 67 | 68 | /** 69 | * 移除缓存 70 | */ 71 | public remove(key: string) { 72 | this._objects.delete(key); 73 | } 74 | 75 | /** 76 | * 清除缓存数据 77 | */ 78 | public clear() { 79 | return this._objects.clear(); 80 | } 81 | 82 | 83 | } -------------------------------------------------------------------------------- /harmony_utils/src/main/ets/utils/NumberUtil.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-utils 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils 16 | */ 17 | 18 | 19 | /** 20 | * TODO number工具类 21 | * author: 桃花镇童长老ᥫ᭡ 22 | * since: 2024/05/01 23 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils 24 | * github: https://github.com/787107497 25 | * gitee: https://gitee.com/tongyuyan/harmony-utils 26 | * CSDN: https://blog.csdn.net/qq_32922545 27 | * QQ交流群: 569512366 28 | */ 29 | export class NumberUtil { 30 | 31 | 32 | /** 33 | * 判断是否是数值 34 | * @param value 需要判断的参数 35 | */ 36 | static isNumber(value: any): boolean { 37 | return typeof (value) === "number" && !isNaN(value); 38 | } 39 | 40 | 41 | /** 42 | * 将字符串转换为整数。 43 | * @param value 44 | * @param defaultValue 45 | * @returns 46 | */ 47 | static toInt(value: string, defaultValue: number = 0): number { 48 | try { 49 | const parsedValue = parseInt(value); 50 | if (isNaN(parsedValue)) { 51 | return defaultValue; 52 | } 53 | return parsedValue; 54 | } catch (e) { 55 | return defaultValue 56 | } 57 | } 58 | 59 | 60 | /** 61 | * 将字符串转换为浮点数。 62 | * @param value 63 | * @param defaultValue 64 | * @returns 65 | */ 66 | static toFloat(value: string, defaultValue: number = 0): number { 67 | try { 68 | const parsedValue = parseFloat(value); 69 | if (isNaN(parsedValue)) { 70 | return defaultValue; 71 | } 72 | return parsedValue; 73 | } catch (e) { 74 | return defaultValue 75 | } 76 | } 77 | 78 | 79 | } -------------------------------------------------------------------------------- /harmony_utils/src/main/ets/utils/TempUtil.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/harmony-utils 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils 16 | */ 17 | 18 | 19 | /** 20 | * TODO 温度转换工具类,华氏度与摄氏度相互转换 21 | * author: 桃花镇童长老ᥫ᭡ 22 | * since: 2024/05/01 23 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils 24 | * github: https://github.com/787107497 25 | * gitee: https://gitee.com/tongyuyan/harmony-utils 26 | * CSDN: https://blog.csdn.net/qq_32922545 27 | * QQ交流群: 569512366 28 | */ 29 | export class TempUtil { 30 | 31 | 32 | /** 33 | * 华氏度转摄氏度 34 | * @param f 华氏度 35 | * @return 摄氏度 36 | */ 37 | static F2C(f: number): number { 38 | return (f - 32) * (5 / 9) 39 | } 40 | 41 | /** 42 | * 摄氏度转华氏度 43 | * @param c 摄氏度 44 | * @return 华氏度 45 | */ 46 | static C2F(c: number): number { 47 | return c * (9 / 5) + 32 48 | } 49 | 50 | } -------------------------------------------------------------------------------- /harmony_utils/src/main/module.json5: -------------------------------------------------------------------------------- 1 | { 2 | "module": { 3 | "name": "harmony_utils", 4 | "type": "har", 5 | "deviceTypes": [ 6 | "default", 7 | "tablet", 8 | "2in1" 9 | ], 10 | "requestPermissions": [ 11 | { 12 | "name": "ohos.permission.GET_BUNDLE_INFO" //允许查询应用的基本信息。 13 | }, 14 | { 15 | "name": "ohos.permission.STORE_PERSISTENT_DATA" //允许应用存储持久化的数据,该数据直到设备恢复出厂设置或重装系统才会被清除 16 | }, 17 | { 18 | "name": "ohos.permission.PRIVACY_WINDOW" //允许应用将窗口设置为隐私窗口,禁止截屏录屏 19 | } 20 | ] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /harmony_utils/src/main/resources/base/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "lib_name", 5 | "value": "harmony-utils" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /harmony_utils/src/main/resources/en_US/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "lib_name", 5 | "value": "harmony-utils" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /harmony_utils/src/main/resources/zh_CN/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "lib_name", 5 | "value": "harmony-utils" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /harmony_utils/src/test/List.test.ets: -------------------------------------------------------------------------------- 1 | import localUnitTest from './LocalUnit.test'; 2 | 3 | export default function testsuite() { 4 | localUnitTest(); 5 | } -------------------------------------------------------------------------------- /harmony_utils/src/test/LocalUnit.test.ets: -------------------------------------------------------------------------------- 1 | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; 2 | 3 | export default function localUnitTest() { 4 | describe('localUnitTest',() => { 5 | // Defines a test suite. Two parameters are supported: test suite name and test suite function. 6 | beforeAll(() => { 7 | // Presets an action, which is performed only once before all test cases of the test suite start. 8 | // This API supports only one parameter: preset action function. 9 | }); 10 | beforeEach(() => { 11 | // Presets an action, which is performed before each unit test case starts. 12 | // The number of execution times is the same as the number of test cases defined by **it**. 13 | // This API supports only one parameter: preset action function. 14 | }); 15 | afterEach(() => { 16 | // Presets a clear action, which is performed after each unit test case ends. 17 | // The number of execution times is the same as the number of test cases defined by **it**. 18 | // This API supports only one parameter: clear action function. 19 | }); 20 | afterAll(() => { 21 | // Presets a clear action, which is performed after all test cases of the test suite end. 22 | // This API supports only one parameter: clear action function. 23 | }); 24 | it('assertContain', 0, () => { 25 | // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. 26 | let a = 'abc'; 27 | let b = 'b'; 28 | // Defines a variety of assertion methods, which are used to declare expected boolean conditions. 29 | expect(a).assertContain(b); 30 | expect(a).assertEqual(a); 31 | }); 32 | }); 33 | } -------------------------------------------------------------------------------- /hvigor/hvigor-config.json5: -------------------------------------------------------------------------------- 1 | { 2 | "modelVersion": "5.0.0", 3 | "dependencies": { 4 | }, 5 | "execution": { 6 | // "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */ 7 | // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ 8 | // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ 9 | // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ 10 | // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ 11 | }, 12 | "logging": { 13 | // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ 14 | }, 15 | "debugging": { 16 | // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ 17 | }, 18 | "nodeOptions": { 19 | // "maxOldSpaceSize": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */ 20 | } 21 | } -------------------------------------------------------------------------------- /hvigorfile.ts: -------------------------------------------------------------------------------- 1 | import { appTasks } from '@ohos/hvigor-ohos-plugin'; 2 | 3 | export default { 4 | system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ 5 | plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ 6 | } 7 | -------------------------------------------------------------------------------- /oh-package-lock.json5: -------------------------------------------------------------------------------- 1 | { 2 | "meta": { 3 | "stableOrder": true 4 | }, 5 | "lockfileVersion": 3, 6 | "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", 7 | "specifiers": { 8 | "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", 9 | "@ohos/hypium@1.0.16": "@ohos/hypium@1.0.16", 10 | "class-transformer@^0.5.1": "class-transformer@0.5.1" 11 | }, 12 | "packages": { 13 | "@ohos/hamock@1.0.0": { 14 | "name": "@ohos/hamock", 15 | "version": "1.0.0", 16 | "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", 17 | "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hamock/-/hamock-1.0.0.har", 18 | "registryType": "ohpm" 19 | }, 20 | "@ohos/hypium@1.0.16": { 21 | "name": "@ohos/hypium", 22 | "version": "1.0.16", 23 | "integrity": "sha512-PC3jpwKERg68V+4dmKU+SLjNps9i5JcQH57rQriaTsh62NBgVZs4SceMmNOtrIOyldbEJ5mXSwoZwiG/nkRmTw==", 24 | "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.16.har", 25 | "registryType": "ohpm" 26 | }, 27 | "class-transformer@0.5.1": { 28 | "name": "class-transformer", 29 | "version": "0.5.1", 30 | "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==", 31 | "resolved": "https://ohpm.openharmony.cn/ohpm/class-transformer/-/class-transformer-0.5.1.tgz", 32 | "shasum": "24147d5dffd2a6cea930a3250a677addf96ab336", 33 | "registryType": "ohpm" 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /oh-package.json5: -------------------------------------------------------------------------------- 1 | { 2 | "modelVersion": "5.0.0", 3 | "name": "harmony-utils", 4 | "version": "1.0.6", 5 | "description": "一款高效的HarmonyOS工具包,封装了常用工具类,提供一系列简单易用的方法。帮助开发者快速构建鸿蒙应用。", 6 | "main": "", 7 | "author": "", 8 | "license": "", 9 | "dependencies": { 10 | "class-transformer": "^0.5.1", 11 | }, 12 | "devDependencies": { 13 | "@ohos/hypium": "1.0.16", 14 | "@ohos/hamock": "1.0.0" 15 | }, 16 | "dynamicDependencies": {} 17 | } -------------------------------------------------------------------------------- /spinkit/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /oh_modules 3 | /.preview 4 | /build 5 | /.cxx 6 | /.test -------------------------------------------------------------------------------- /spinkit/BuildProfile.ets: -------------------------------------------------------------------------------- 1 | /** 2 | * Use these variables when you tailor your ArkTS code. They must be of the const type. 3 | */ 4 | export const HAR_VERSION = '1.0.4'; 5 | export const BUILD_MODE_NAME = 'debug'; 6 | export const DEBUG = true; 7 | export const TARGET_NAME = 'default'; 8 | 9 | /** 10 | * BuildProfile Class is used only for compatibility purposes. 11 | */ 12 | export default class BuildProfile { 13 | static readonly HAR_VERSION = HAR_VERSION; 14 | static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; 15 | static readonly DEBUG = DEBUG; 16 | static readonly TARGET_NAME = TARGET_NAME; 17 | } -------------------------------------------------------------------------------- /spinkit/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 版本记录 2 | 3 | ## 1.0.4 4 | 1.加载弹框,迁移到harmony-dialog,本库将专注于动画,以后只扩展动画。 5 | 6 | ## 1.0.3 7 | 1.解决有子窗口时,加载框可能显示异常的问题。 8 | 9 | ## 1.0.2 10 | 1.基于harmony-dialog重构加载框,解决加载框在一些情况下不显示的Bug。 11 | 12 | ## 1.0.1 13 | 1. 修复在UIAbility设置全局统一样式,导致加载框不显示。 14 | 2. 添加自定义加载框方法,showCustomLoading()。 15 | 16 | ## 1.0.0 初版 17 | 1. 发布1.0.0 初版。 -------------------------------------------------------------------------------- /spinkit/Index.ets: -------------------------------------------------------------------------------- 1 | export { SpinKit } from './src/main/ets/components/SpinKit'; 2 | 3 | export { SpinType } from './src/main/ets/SpinType'; 4 | -------------------------------------------------------------------------------- /spinkit/README.md: -------------------------------------------------------------------------------- 1 | # SpinKit(API12) 2 | 3 | -------------------------------------------------------------------------------- 4 | 5 | ## 🏆简介与推荐 6 | 7 | [SpinKit](https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fspinkit) 8 | 是一个适用于OpenHarmony/HarmonyOS的加载动画库。 9 | 10 | [harmony-utils](https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils) 11 | 一款功能丰富且极易上手的HarmonyOS工具库,借助众多实用工具类,致力于助力开发者迅速构建鸿蒙应用。 12 | 13 | [harmony-dialog](https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog) 14 | 一款极为简单易用的零侵入弹窗,仅需一行代码即可轻松实现,无论在何处都能够轻松弹出。 15 | 16 | ## 📚下载安装 17 | 18 | `ohpm i @pura/spinkit` 19 | 20 | OpenHarmony ohpm 21 | 环境配置等更多内容,请参考[如何安装 OpenHarmony ohpm 包](https://ohpm.openharmony.cn/#/cn/help/downloadandinstall) 22 | 23 | ## 📚效果图 24 | 25 | 效果图略有卡顿,请运行源码或添加依赖,查看效果。 26 | ![QQ群:569512366](example/GIF.gif) 27 | 28 | ## 📚SpinKit组件 29 | 30 | | 属性 | 介绍 | 31 | |:----------|:-----------| 32 | | spinType | 动画的类型 | 33 | | spinSize | 动画的大小,默认60 | 34 | | spinColor | 动画的颜色,默认白色 | 35 | 36 | ``` 37 | SpinKit() 38 | 39 | SpinKit({ spinType: SpinType.spinA }) 40 | 41 | SpinKit({ spinType: SpinType.spinH }) 42 | 43 | SpinKit({ 44 | spinType: SpinType.spinA, 45 | spinColor: Color.Pink, 46 | spinSize: 70 47 | }) 48 | ``` 49 | 50 | ## 加载弹框请移步 [harmony-dialog](https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog) 51 | 52 | ## 💖沟通与交流🙏 53 | 54 | 使用过程中发现任何问题都可以提 [Issue](https://gitee.com/tongyuyan/harmony-utils/issues)给我们; 55 | 当然,我们也非常欢迎你给我们发 [PR](https://gitee.com/tongyuyan/harmony-utils/pulls) 。 56 | 57 | [https://gitee.com/tongyuyan/harmony-utils](https://gitee.com/tongyuyan/harmony-utils) 58 | [https://github.com/787107497](https://github.com/787107497) 59 | 60 | QQ群:569512366 61 | 62 | ## 🌞友情推荐 63 | 64 | #### [《ArkUI实战》](https://www.arkui.club)深入浅出介绍鸿蒙应用开发,帮助数百万开发者学习鸿蒙与仓颉。 65 | 66 | ## 🌏开源协议 67 | 68 | 本项目基于 [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0.html) ,在拷贝和借鉴代码时,请大家务必注明出处。 69 | 70 | -------------------------------------------------------------------------------- /spinkit/build-profile.json5: -------------------------------------------------------------------------------- 1 | { 2 | "apiType": "stageMode", 3 | "buildOption": { 4 | }, 5 | "buildOptionSet": [ 6 | { 7 | "name": "release", 8 | "arkOptions": { 9 | "obfuscation": { 10 | "ruleOptions": { 11 | "enable": false, 12 | "files": [ 13 | "./obfuscation-rules.txt" 14 | ] 15 | }, 16 | "consumerFiles": [ 17 | "./consumer-rules.txt" 18 | ] 19 | } 20 | }, 21 | }, 22 | ], 23 | "targets": [ 24 | { 25 | "name": "default" 26 | }, 27 | { 28 | "name": "ohosTest" 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /spinkit/consumer-rules.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/spinkit/consumer-rules.txt -------------------------------------------------------------------------------- /spinkit/example/GIF.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/787107497/harmony-utils/794249b6ea9dbb5ebf0b9a0cd3306a5af9b7d31b/spinkit/example/GIF.gif -------------------------------------------------------------------------------- /spinkit/example/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## 📚仓库主页 3 | https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils 4 | 5 | ## 📚源码地址 6 | https://gitee.com/tongyuyan/harmony-utils 7 | https://github.com/787107497 8 | 9 | ## 📚CSDN博客 10 | https://blog.csdn.net/qq_32922545 11 | 12 | ## 💖QQ交流群 13 | 569512366 14 | -------------------------------------------------------------------------------- /spinkit/hvigorfile.ts: -------------------------------------------------------------------------------- 1 | import { harTasks } from '@ohos/hvigor-ohos-plugin'; 2 | 3 | export default { 4 | system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ 5 | plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ 6 | } 7 | -------------------------------------------------------------------------------- /spinkit/obfuscation-rules.txt: -------------------------------------------------------------------------------- 1 | # Define project specific obfuscation rules here. 2 | # You can include the obfuscation configuration files in the current module's build-profile.json5. 3 | # 4 | # For more details, see 5 | # https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 6 | 7 | # Obfuscation options: 8 | # -disable-obfuscation: disable all obfuscations 9 | # -enable-property-obfuscation: obfuscate the property names 10 | # -enable-toplevel-obfuscation: obfuscate the names in the global scope 11 | # -compact: remove unnecessary blank spaces and all line feeds 12 | # -remove-log: remove all console.* statements 13 | # -print-namecache: print the name cache that contains the mapping from the old names to new names 14 | # -apply-namecache: reuse the given cache file 15 | 16 | # Keep options: 17 | # -keep-property-name: specifies property names that you want to keep 18 | # -keep-global-name: specifies names that you want to keep in the global scope 19 | 20 | -enable-property-obfuscation 21 | -enable-toplevel-obfuscation 22 | -enable-filename-obfuscation 23 | -enable-export-obfuscation -------------------------------------------------------------------------------- /spinkit/oh-package.json5: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@pura/spinkit", 3 | "version": "1.0.4", 4 | "description": "SpinKit是一个适用于OpenHarmony的加载动画库", 5 | "author": "tongyuyan", 6 | "homepage": "https://gitee.com/tongyuyan", 7 | "repository": "https://gitee.com/tongyuyan/harmony-utils", 8 | "license": "Apache-2.0", 9 | "main": "Index.ets", 10 | "dependencies": {}, 11 | "keywords": [ 12 | "动画", 13 | "加载动画", 14 | "SpinKit", 15 | "加载框", 16 | "弹框", 17 | "OpenHarmony", 18 | "HarmonyOS", 19 | ], 20 | "tags": [ 21 | "SpinKit", 22 | "动画", 23 | "加载动画", 24 | "加载框", 25 | "弹框", 26 | "OpenHarmony", 27 | "HarmonyOS" 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /spinkit/src/main/ets/SpinType.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/spinkit 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fspinkit 16 | */ 17 | 18 | 19 | /** 20 | * TODO Spin类型 21 | * author: 桃花镇童长老 22 | * since: 2024/05/01 23 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fspinkit 24 | * github: https://github.com/787107497 25 | * gitee: https://gitee.com/tongyuyan/spinkit 26 | * QQ交流群: 569512366 27 | */ 28 | export enum SpinType { 29 | spinA, 30 | spinB, 31 | spinC, 32 | spinD, 33 | spinE, 34 | spinF, 35 | spinG, 36 | spinH, 37 | spinI, 38 | spinJ, 39 | spinK, 40 | spinL, 41 | spinM, 42 | spinN, 43 | spinO, 44 | spinP, 45 | spinQ, 46 | spinR, 47 | spinS, 48 | spinT, 49 | spinU, 50 | spinV, 51 | spinW, 52 | spinX, 53 | spinY, 54 | spinZ 55 | } -------------------------------------------------------------------------------- /spinkit/src/main/ets/components/SpinA.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/spinkit 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fspinkit 16 | */ 17 | 18 | 19 | /** 20 | * TODO SpinKit动画组件 21 | * author: 桃花镇童长老 22 | * since: 2024/05/01 23 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fspinkit 24 | * github: https://github.com/787107497 25 | * gitee: https://gitee.com/tongyuyan/spinkit 26 | * QQ交流群: 569512366 27 | */ 28 | @Component 29 | export struct SpinA { 30 | @State spinSize: number = 60; 31 | @State spinColor: ResourceColor = Color.White; 32 | @State x: number = 0; 33 | @State y: number = 0; 34 | @State angle: number = 0; 35 | 36 | build() { 37 | Canvas() 38 | .width(this.spinSize) 39 | .height(this.spinSize) 40 | .backgroundColor(this.spinColor) 41 | .renderFit(RenderFit.CENTER) 42 | .shadow(ShadowStyle.OUTER_DEFAULT_XS) 43 | .rotate({ perspective: this.spinSize, x: this.x, y: this.y, angle: this.angle }) 44 | .onAppear(() => { 45 | this.getUIContext().keyframeAnimateTo({ iterations: -1, delay: 0 }, [ 46 | { 47 | duration: 600, 48 | curve: Curve.EaseInOut, 49 | event: () => { 50 | this.angle = 180 51 | this.x = this.spinSize/2 52 | this.y = 0 53 | } 54 | }, 55 | { 56 | duration: 0, 57 | curve: Curve.EaseInOut, 58 | event: () => { 59 | this.angle = 0 60 | } 61 | }, 62 | { 63 | duration: 600, 64 | curve: Curve.EaseInOut, 65 | event: () => { 66 | this.angle = 180 67 | this.x = 0 68 | this.y = this.spinSize/2 69 | } 70 | } 71 | ]) 72 | }) 73 | } 74 | } -------------------------------------------------------------------------------- /spinkit/src/main/ets/components/SpinB.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/spinkit 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fspinkit 16 | */ 17 | 18 | 19 | /** 20 | * TODO SpinKit动画组件 21 | * author: 桃花镇童长老 22 | * since: 2024/05/01 23 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fspinkit 24 | * github: https://github.com/787107497 25 | * gitee: https://gitee.com/tongyuyan/spinkit 26 | * QQ交流群: 569512366 27 | */ 28 | @Component 29 | export struct SpinB { 30 | @State spinSize: number = 60; 31 | @State spinColor: ResourceColor = Color.White; 32 | @State scale1: number = 0; 33 | @State scale2: number = 1; 34 | 35 | build() { 36 | Stack() { 37 | Canvas() 38 | .scale({ x: this.scale1, y: this.scale1 }) 39 | .bounceStyle() 40 | Canvas() 41 | .scale({ x: this.scale2, y: this.scale2 }) 42 | .bounceStyle() 43 | } 44 | .width(this.spinSize) 45 | .height(this.spinSize) 46 | .onAppear(() => { 47 | this.getUIContext().keyframeAnimateTo({ iterations: -1, delay: 0 }, [ 48 | { 49 | duration: 1000, 50 | curve: Curve.EaseInOut, 51 | event: () => { 52 | this.scale1 = 1; 53 | this.scale2 = 0; 54 | } 55 | }, 56 | { 57 | duration: 1000, 58 | curve: Curve.EaseInOut, 59 | event: () => { 60 | this.scale1 = 0; 61 | this.scale2 = 1; 62 | } 63 | } 64 | ]); 65 | }) 66 | } 67 | 68 | @Styles 69 | bounceStyle() { 70 | .width('100%') 71 | .height('100%') 72 | .opacity(0.6) 73 | .borderRadius(this.spinSize) 74 | .backgroundColor(this.spinColor) 75 | } 76 | } -------------------------------------------------------------------------------- /spinkit/src/main/ets/components/SpinE.ets: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 桃花镇童长老 @pura/spinkit 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fspinkit 16 | */ 17 | 18 | 19 | /** 20 | * TODO SpinKit动画组件 21 | * author: 桃花镇童长老 22 | * since: 2024/05/01 23 | * 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fspinkit 24 | * github: https://github.com/787107497 25 | * gitee: https://gitee.com/tongyuyan/spinkit 26 | * QQ交流群: 569512366 27 | */ 28 | @Component 29 | export struct SpinE { 30 | @State spinSize: number = 60; 31 | @State spinColor: ResourceColor = Color.White; 32 | @State scale1: number = 1; 33 | @State opacity1: number = 1; 34 | 35 | build() { 36 | Canvas() 37 | .width(this.spinSize) 38 | .height(this.spinSize) 39 | .borderRadius(this.spinSize) 40 | .backgroundColor(this.spinColor) 41 | .renderFit(RenderFit.CENTER) 42 | .scale({ x: this.scale1, y: this.scale1 }) 43 | .opacity(this.opacity1) 44 | .onAppear(() => { 45 | this.getUIContext().keyframeAnimateTo({ iterations: -1, delay: 0 }, [ 46 | { 47 | duration: 0, 48 | curve: Curve.EaseInOut, 49 | event: () => { 50 | this.scale1 = 0 51 | this.opacity1 = 1 52 | } 53 | }, 54 | { 55 | duration: 1000, 56 | curve: Curve.EaseInOut, 57 | event: () => { 58 | this.scale1 = 1.0 59 | this.opacity1 = 0.01 60 | } 61 | } 62 | ]) 63 | }) 64 | } 65 | } -------------------------------------------------------------------------------- /spinkit/src/main/module.json5: -------------------------------------------------------------------------------- 1 | { 2 | "module": { 3 | "name": "spinkit", 4 | "type": "har", 5 | "deviceTypes": [ 6 | "default", 7 | "tablet", 8 | "2in1" 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /spinkit/src/main/resources/base/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "page_show", 5 | "value": "page from package" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /spinkit/src/main/resources/en_US/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "page_show", 5 | "value": "page from package" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /spinkit/src/main/resources/zh_CN/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "page_show", 5 | "value": "page from package" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /spinkit/src/ohosTest/ets/test/Ability.test.ets: -------------------------------------------------------------------------------- 1 | import { hilog } from '@kit.PerformanceAnalysisKit'; 2 | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; 3 | 4 | export default function abilityTest() { 5 | describe('ActsAbilityTest', () => { 6 | // Defines a test suite. Two parameters are supported: test suite name and test suite function. 7 | beforeAll(() => { 8 | // Presets an action, which is performed only once before all test cases of the test suite start. 9 | // This API supports only one parameter: preset action function. 10 | }) 11 | beforeEach(() => { 12 | // Presets an action, which is performed before each unit test case starts. 13 | // The number of execution times is the same as the number of test cases defined by **it**. 14 | // This API supports only one parameter: preset action function. 15 | }) 16 | afterEach(() => { 17 | // Presets a clear action, which is performed after each unit test case ends. 18 | // The number of execution times is the same as the number of test cases defined by **it**. 19 | // This API supports only one parameter: clear action function. 20 | }) 21 | afterAll(() => { 22 | // Presets a clear action, which is performed after all test cases of the test suite end. 23 | // This API supports only one parameter: clear action function. 24 | }) 25 | it('assertContain', 0, () => { 26 | // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. 27 | hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); 28 | let a = 'abc'; 29 | let b = 'b'; 30 | // Defines a variety of assertion methods, which are used to declare expected boolean conditions. 31 | expect(a).assertContain(b); 32 | expect(a).assertEqual(a); 33 | }) 34 | }) 35 | } -------------------------------------------------------------------------------- /spinkit/src/ohosTest/ets/test/List.test.ets: -------------------------------------------------------------------------------- 1 | import abilityTest from './Ability.test'; 2 | 3 | export default function testsuite() { 4 | abilityTest(); 5 | } -------------------------------------------------------------------------------- /spinkit/src/ohosTest/module.json5: -------------------------------------------------------------------------------- 1 | { 2 | "module": { 3 | "name": "spinkit_test", 4 | "type": "feature", 5 | "deviceTypes": [ 6 | "default", 7 | "tablet", 8 | "2in1" 9 | ], 10 | "deliveryWithInstall": true, 11 | "installationFree": false 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spinkit/src/test/List.test.ets: -------------------------------------------------------------------------------- 1 | import localUnitTest from './LocalUnit.test'; 2 | 3 | export default function testsuite() { 4 | localUnitTest(); 5 | } -------------------------------------------------------------------------------- /spinkit/src/test/LocalUnit.test.ets: -------------------------------------------------------------------------------- 1 | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; 2 | 3 | export default function localUnitTest() { 4 | describe('localUnitTest', () => { 5 | // Defines a test suite. Two parameters are supported: test suite name and test suite function. 6 | beforeAll(() => { 7 | // Presets an action, which is performed only once before all test cases of the test suite start. 8 | // This API supports only one parameter: preset action function. 9 | }); 10 | beforeEach(() => { 11 | // Presets an action, which is performed before each unit test case starts. 12 | // The number of execution times is the same as the number of test cases defined by **it**. 13 | // This API supports only one parameter: preset action function. 14 | }); 15 | afterEach(() => { 16 | // Presets a clear action, which is performed after each unit test case ends. 17 | // The number of execution times is the same as the number of test cases defined by **it**. 18 | // This API supports only one parameter: clear action function. 19 | }); 20 | afterAll(() => { 21 | // Presets a clear action, which is performed after all test cases of the test suite end. 22 | // This API supports only one parameter: clear action function. 23 | }); 24 | it('assertContain', 0, () => { 25 | // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. 26 | let a = 'abc'; 27 | let b = 'b'; 28 | // Defines a variety of assertion methods, which are used to declare expected boolean conditions. 29 | expect(a).assertContain(b); 30 | expect(a).assertEqual(a); 31 | }); 32 | }); 33 | } --------------------------------------------------------------------------------