@cordova-ohos/cordova-plugin-spinnerdialog 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,204 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+
191
+ Copyright (c) 2025 Huawei Device, Inc. Ltd. and <马弓手>.
192
+
193
+ Licensed under the Apache License, Version 2.0 (the "License");
194
+ you may not use this file except in compliance with the License.
195
+ You may obtain a copy of the License at
196
+
197
+ http://www.apache.org/licenses/LICENSE-2.0
198
+
199
+ Unless required by applicable law or agreed to in writing, software
200
+ distributed under the License is distributed on an "AS IS" BASIS,
201
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
+ See the License for the specific language governing permissions and
203
+ limitations under the License.
204
+
package/OAT.xml ADDED
@@ -0,0 +1,79 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- Copyright (c) 2021 Huawei Device Co., Ltd.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+
16
+ This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
17
+
18
+ -->
19
+
20
+ <configuration>
21
+ <oatconfig>
22
+ <licensefile></licensefile>
23
+ <policylist>
24
+ <policy name="projectPolicy" desc="">
25
+ <!--policyitem type="compatibility" name="GPL-2.0+" path="abc/.*" desc="Process that runs independently, invoked by the X process."/-->
26
+ <!--policyitem type="license" name="LGPL" path="abc/.*" desc="Dynamically linked by module X"/-->
27
+ <policyitem type="copyright" name="Copyright (c) 2025 Huawei Device, Inc. Ltd. and &lt;马弓手&gt;." path=".*" rule="may" group="defaultGroup" filefilter="copyrightPolicyFilter" desc="Developed by Huawei Device,Inc. Ltd. and &lt;马弓手&gt;"/>
28
+ </policy>
29
+ </policylist>
30
+ <filefilterlist>
31
+ <filefilter name="defaultFilter" desc="Files not to check">
32
+ <!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
33
+ <!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
34
+ <!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
35
+ </filefilter>
36
+ <filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
37
+ <!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
38
+ <!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
39
+ <!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
40
+ </filefilter>
41
+ <filefilter name="copyrightPolicyFilter" desc="Filters for copyright header policies">
42
+ <!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
43
+ <!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
44
+ <!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
45
+ </filefilter>
46
+ <filefilter name="licenseFileNamePolicyFilter" desc="Filters for LICENSE file policies">
47
+ <!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
48
+ <!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
49
+ <!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
50
+ </filefilter>
51
+ <filefilter name="readmeFileNamePolicyFilter" desc="Filters for README file policies">
52
+ <!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
53
+ <!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
54
+ <!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
55
+ </filefilter>
56
+ <filefilter name="readmeOpenSourcefileNamePolicyFilter" desc="Filters for README.OpenSource file policies">
57
+ <!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
58
+ <!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
59
+ <!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
60
+ </filefilter>
61
+ <filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
62
+ <!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
63
+ <!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
64
+ <!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
65
+ </filefilter>
66
+
67
+ </filefilterlist>
68
+ <licensematcherlist>
69
+ <!--licensematcher name="uvwxyz License" desc="If the scanning result is InvalidLicense, you can define matching rules here. Note that quotation marks must be escaped.">
70
+ <licensetext name="
71
+ uvwxyz license textA xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
72
+ " desc=""/>
73
+ <licensetext name="
74
+ uvwxyz license textB xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
75
+ " desc=""/>
76
+ </licensematcher-->
77
+ </licensematcherlist>
78
+ </oatconfig>
79
+ </configuration>
package/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # cordova-plugin-spinnerdialog
2
+
3
+
4
+ `cordova-plugin-spinnerdialog` 是一款为 Cordova 应用打造的轻量级加载对话框插件,支持在应用执行耗时操作(如网络请求、数据处理)时显示原生风格的加载指示器与提示文本,提升用户等待体验。插件适配多平台原生设计规范,支持自定义对话框样式、文字、遮罩层等属性,满足不同应用的视觉需求。
5
+
6
+
7
+ ## 1. 插件概述
8
+
9
+ 作为 Cordova 生态中加载交互类的常用插件,`cordova-plugin-spinnerdialog` 基于原生平台对话框能力开发,具备以下核心优势:
10
+
11
+ * **原生视觉体验**:遵循 Android(Material Design)、iOS(Human Interface Guidelines)、Windows 、OHOS平台原生设计规范,对话框风格与系统一致
12
+
13
+ * **高度可定制**:支持自定义提示文本、加载指示器样式(如圆形旋转、线性进度)、对话框背景色、文字颜色、遮罩层透明度等
14
+
15
+ * **轻量级设计**:插件体积小(仅几十 KB),无冗余依赖,集成后不影响应用启动速度与运行性能
16
+
17
+ * **灵活控制**:支持显示 / 隐藏对话框、更新提示文本、设置进度值(部分平台)等操作,满足复杂加载场景
18
+
19
+ * **跨平台统一**:统一多平台 API 调用方式,无需针对不同平台编写差异化代码
20
+
21
+ * **兼容性强**:支持低版本系统(Android 4.4+、iOS 9.0+、OHOS 5.0+),覆盖绝大多数移动设备
22
+
23
+ 该插件广泛应用于网络请求加载、文件上传下载、数据解析、页面初始化等耗时操作场景,是提升应用交互流畅度与用户体验的关键工具。
24
+
25
+ ## 2. 安装方式
26
+
27
+ ### 2.1 基础安全(推荐)
28
+
29
+ 在 Cordova 项目根目录执行以下命令,插件会自动处理各平台依赖与基础配置:
30
+
31
+
32
+ ```bash
33
+ # 安装hcordova
34
+ npm install -g hcordova
35
+
36
+ # 安装最新版本
37
+ hcordova plugin add cordova-plugin-spinnerdialog
38
+
39
+ # 安装指定版本
40
+ hcordova plugin add cordova-plugin-spinnerdialog@1.0.0 --platform ohos
41
+ ```
42
+
43
+ ### 3.2 从 GitCode 源码安装
44
+
45
+ 若需使用开发中的最新功能,可直接从 GitCode 仓库安装:
46
+
47
+ ```bash
48
+ hcordova plugin add https://gitcode.com/OpenHarmony-Cordova/cordova-plugin-spinnerdialog.git --platform ohos
49
+ ```
50
+
51
+ ### 3.4 卸载插件
52
+
53
+ 如需移除插件,执行以下命令即可清理相关配置与依赖:
54
+
55
+
56
+ ```bash
57
+ # 全平台卸载
58
+ hcordova plugin remove cordova-plugin-spinnerdialog
59
+
60
+ # 指定OHOS卸载
61
+ hcordova plugin remove cordova-plugin-spinnerdialog --platform ohos
62
+ ```
63
+
64
+
65
+ ## 4. API 文档
66
+
67
+ 插件通过全局对象 `window.plugins.spinnerDialog` 暴露所有 API,支持回调函数式调用(部分 API 无返回值)。所有 API 需在 `deviceready` 事件触发后调用,避免因原生接口未初始化导致的错误。
68
+
69
+ ### 4.1 显示对话框 API
70
+
71
+ ```js
72
+ //显示有标题有信息的spinner
73
+ window.plugins.spinnerDialog.show("title", "message", function(){
74
+ document.getElementById("spinner").innerHTML = "关闭成功";
75
+ });
76
+
77
+ //显示有标题spinner
78
+ window.plugins.spinnerDialog.show("title", null, function(){
79
+ document.getElementById("spinner").innerHTML = "关闭成功";
80
+ });
81
+
82
+ //显示spinner
83
+ window.plugins.spinnerDialog.show(null, null, function(){
84
+ document.getElementById("spinner").innerHTML = "关闭成功";
85
+ });
86
+ ```
87
+
88
+ ### 4.2 关闭对话框 API
89
+
90
+ ```js
91
+ window.plugins.spinnerDialog.hide();
92
+ ```
93
+
94
+ ## 许可证
95
+
96
+ 本插件基于 **Apache License** 开源,详见 [LICENSE](LICENSE) 文件。
97
+
98
+ ## 参考资源
99
+
100
+ * Android和iOS:[cordova-plugin-spinnerdialog 官方指南](https://www.npmjs.com/package/cordova-plugin-spinnerdialog)
101
+
102
+ * GitCode 仓库:[OpenHarmony-Cordova/cordova-plugin-spinnerdialog](https://gitcode.com/OpenHarmony-Cordova/cordova-plugin-spinnerdialog)
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@cordova-ohos/cordova-plugin-spinnerdialog",
3
+ "version": "1.3.2",
4
+ "description": "Cordova spinnerdialog Plugin",
5
+ "cordova": {
6
+ "id": "cordova-plugin-spinnerdialog",
7
+ "platforms": [
8
+ "ohos"
9
+ ]
10
+ },
11
+ "repository": "gitcode:OpenHarmony-Cordova/cordova-plugin-spinnerdialog",
12
+ "bugs": "https://gitcode.com/OpenHarmony-Cordova/cordova-plugin-spinnerdialog/issues",
13
+ "keywords": [
14
+ "cordova",
15
+ "spinnerdialog",
16
+ "ecosystem:cordova",
17
+ "cordova-openharmony"
18
+ ],
19
+ "engines": {
20
+ "cordovaDependencies": {
21
+ "1.3.2": {
22
+ "@cordova-ohos/ohos": ">=2.0.0",
23
+ "hcordova":">=1.0.0"
24
+ }
25
+ }
26
+ },
27
+ "author": " Huawei Device, Inc. Ltd. and <马弓手>",
28
+ "license": "Apache-2.0"
29
+ }
package/plugin.xml ADDED
@@ -0,0 +1,51 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ Copyright (c) 2025 Huawei Device, Inc. Ltd. and <马弓手>.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ -->
17
+ <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
18
+ id="cordova-plugin-spinnerdialog"
19
+ version="1.3.2">
20
+ <name>spinnerdialog</name>
21
+ <description>Cordova spinnerdialog Plugin</description>
22
+ <license>Apache 2.0</license>
23
+ <keywords>cordova,spinnerdialog</keywords>
24
+ <repo>https://gitcode.com/OpenHarmony-Cordova/cordova-plugin-spinnerdialog.git</repo>
25
+ <issue>https://gitcode.com/OpenHarmony-Cordova/cordova-plugin-spinnerdialog/issues</issue>
26
+
27
+ <engines>
28
+ <engine name="@cordova-ohos/ohos" version=">=2.0.0" />
29
+ </engines>
30
+
31
+ <platform name="ohos">
32
+ <config-file target="src/main/resources/rawfile/config.xml" parent="/*" modules-targets-name="default">
33
+ <feature name="SpinnerDialog">
34
+ <param name="android-package" value="SpinnerDialog"/>
35
+ </feature>
36
+ </config-file>
37
+
38
+ <CMakeLists target="src/main/cpp/CMakeLists.txt" modules-name="cordova">
39
+ <param target="add_library" value="SpinnerDialog/SpinnerDialog.cpp"/>
40
+ </CMakeLists>
41
+
42
+ <source-file type="h" src="src/main/cpp/SpinnerDialog/SpinnerDialog.h" target-dir="src/main/cpp/SpinnerDialog" modules-name="cordova"/>
43
+ <source-file type="cpp" src="src/main/cpp/SpinnerDialog/SpinnerDialog.cpp" target-dir="src/main/cpp/SpinnerDialog" modules-name="cordova"/>
44
+ <source-file type="ets" src="src/main/ets/components/SpinnerDialog/SpinnerDialog.ets" target-dir="src/main/ets/components/SpinnerDialog" modules-name="cordova" runtimeOnly="true"/>
45
+
46
+ <js-module src="www/spinner.js" name="SpinnerDialog" modules-targets-name="default">
47
+ <merges target="window.plugins.spinnerDialog" />
48
+ </js-module>
49
+
50
+ </platform>
51
+ </plugin>
@@ -0,0 +1,70 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device, Inc. Ltd. and <马弓手>.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #include "SpinnerDialog.h"
18
+ REGISTER_PLUGIN_CLASS(SpinnerDialog)
19
+
20
+ bool SpinnerDialog::execute(const std::string& action, cJSON* args, CallbackContext cbc)
21
+ {
22
+ if (action == "show") {
23
+ m_cbc = cbc;
24
+ std::string strTitle = "";
25
+ std::string strMessage = "";
26
+ bool isFixed = false;
27
+ if (cJSON_GetArraySize(args) > 0) {
28
+ if (cJSON_GetArrayItem(args, 0)->type == cJSON_String) {
29
+ strTitle = cJSON_GetArrayItem(args, 0)->valuestring;
30
+ }
31
+ }
32
+
33
+ if (cJSON_GetArraySize(args) > 1) {
34
+ if (cJSON_GetArrayItem(args, 1)->type == cJSON_String) {
35
+ strMessage = cJSON_GetArrayItem(args, 1)->valuestring;
36
+ }
37
+ }
38
+
39
+ if (cJSON_GetArraySize(args) > 2) {
40
+ if (cJSON_GetArrayItem(args, 2)->type == cJSON_True) {
41
+ isFixed = true;
42
+ }
43
+ }
44
+
45
+ cJSON* pJson = cJSON_CreateObject();
46
+ cJSON_AddStringToObject(pJson, "title", strTitle.c_str());
47
+ cJSON_AddStringToObject(pJson, "message", strMessage.c_str());
48
+ if (isFixed) {
49
+ cJSON_AddTrueToObject(pJson, "isFixed");
50
+ } else {
51
+ cJSON_AddFalseToObject(pJson, "isFixed");
52
+ }
53
+ char* pArg = cJSON_Print(pJson);
54
+ executeArkTs("./SpinnerDialog/SpinnerDialog/SpinnerDialog", 1, pArg, "SpinnerDialog", cbc);
55
+ }
56
+
57
+ if (action == "hide") {
58
+ executeArkTs("./SpinnerDialog/SpinnerDialog/SpinnerDialog", 0, "", "SpinnerDialog", cbc);
59
+ }
60
+ if (action == "onArKTsResult") {
61
+ return onArKTsResult(args);
62
+ }
63
+ return true;
64
+ }
65
+
66
+ bool SpinnerDialog::onArKTsResult(cJSON* args)
67
+ {
68
+ m_cbc.success();
69
+ return true;
70
+ }
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device, Inc. Ltd. and <马弓手>.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #ifndef MYAPPLICATION_SPINNERDIALOG_H
18
+ #define MYAPPLICATION_SPINNERDIALOG_H
19
+
20
+ #include "CordovaPlugin.h"
21
+
22
+ class SpinnerDialog : public CordovaPlugin {
23
+ CallbackContext m_cbc;
24
+ public:
25
+ SpinnerDialog() {
26
+ }
27
+ ~SpinnerDialog() {
28
+ }
29
+ bool execute(const std::string& action, cJSON* args, CallbackContext cbc) override;
30
+ bool onArKTsResult(cJSON* args);
31
+ };
32
+
33
+ #endif //MYAPPLICATION_SPINNERDIALOG_H
@@ -0,0 +1,257 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device, Inc. Ltd. and <马弓手>.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { MainPage } from "../MainPage";
18
+ import { ArkTsAttribute, cordovaWebTagToObjectGlobe, NativeAttribute } from "../PluginGlobal";
19
+ import { ComponentContent, promptAction } from "@kit.ArkUI";
20
+ import { BusinessError } from "@kit.BasicServicesKit";
21
+ import cordova from 'libcordova.so';
22
+ import { NormalizeError } from "../NormalizeError";
23
+
24
+ interface SpinnerAttribute {
25
+ title:string;
26
+ message:string;
27
+ isFixed:boolean;
28
+ }
29
+
30
+ export class PromptActionClass {
31
+ static ctx: UIContext;
32
+ static contentNode: ComponentContent<Object>;
33
+ static options: promptAction.BaseDialogOptions;
34
+ static cancelCallBack:()=>void=()=>{return;}
35
+
36
+ static setContext(context: UIContext) {
37
+ PromptActionClass.ctx = context;
38
+ }
39
+
40
+ static setContentNode(node: ComponentContent<Object>) {
41
+ PromptActionClass.contentNode = node;
42
+ }
43
+
44
+ static setOptions(options: promptAction.BaseDialogOptions) {
45
+ PromptActionClass.options = options;
46
+ }
47
+
48
+ static setCancelCallBack(cancelCallBack:()=>void) {
49
+ PromptActionClass.cancelCallBack = cancelCallBack;
50
+ }
51
+
52
+ static openDialog() {
53
+ if (PromptActionClass.contentNode !== null) {
54
+ PromptActionClass.ctx.getPromptAction().openCustomDialog(PromptActionClass.contentNode, PromptActionClass.options)
55
+ .then(() => {
56
+ console.info('OpenCustomDialog complete.')
57
+ })
58
+ .catch((error: BusinessError) => {
59
+ let message = (error as BusinessError).message;
60
+ let code = (error as BusinessError).code;
61
+ console.error(`OpenCustomDialog args error code is ${code}, message is ${message}`);
62
+ })
63
+ }
64
+ }
65
+
66
+ static closeDialog() {
67
+ if (PromptActionClass.contentNode !== null) {
68
+ PromptActionClass.ctx.getPromptAction().closeCustomDialog(PromptActionClass.contentNode)
69
+ .then(() => {
70
+ console.info('CloseCustomDialog complete.')
71
+ PromptActionClass.cancelCallBack();
72
+ })
73
+ .catch((error: BusinessError) => {
74
+ let message = (error as BusinessError).message;
75
+ let code = (error as BusinessError).code;
76
+ console.error(`CloseCustomDialog args error code is ${code}, message is ${message}`);
77
+ })
78
+ }
79
+ }
80
+
81
+ static updateDialog(options: promptAction.BaseDialogOptions) {
82
+ if (PromptActionClass.contentNode !== null) {
83
+ PromptActionClass.ctx.getPromptAction().updateCustomDialog(PromptActionClass.contentNode, options)
84
+ .then(() => {
85
+ console.info('UpdateCustomDialog complete.')
86
+ })
87
+ .catch((error: BusinessError) => {
88
+ let message = (error as BusinessError).message;
89
+ let code = (error as BusinessError).code;
90
+ console.error(`UpdateCustomDialog args error code is ${code}, message is ${message}`);
91
+ })
92
+ }
93
+ }
94
+ }
95
+
96
+
97
+ @Builder
98
+ function CustomSpinnerDialog() {
99
+ Column(){
100
+ Progress({ value: 0, total: 100, type: ProgressType.Ring })
101
+ .width(70).color(Color.Blue)
102
+ .style({ strokeWidth: 5, status: ProgressStatus.LOADING })
103
+ }.width('100%').height('100%').justifyContent(FlexAlign.Center).alignItems(HorizontalAlign.Center)
104
+ }
105
+
106
+ class Params {
107
+ title: string = "";
108
+ message:string = "";
109
+
110
+ constructor(title: string, message:string) {
111
+ this.title = title;
112
+ this.message = message;
113
+ }
114
+ }
115
+
116
+ @Builder
117
+ function CustomTitleMessageDialog(params:Params) {
118
+ Column(){
119
+ Row() {
120
+ Column() {
121
+ Progress({ value: 0, total: 100, type: ProgressType.Ring })
122
+ .width(60).color(Color.Blue)
123
+ .style({ strokeWidth: 8, status: ProgressStatus.LOADING })
124
+ }.width(70).margin({left:20})
125
+ Column() {
126
+ if(params.title != "") {
127
+ Text(params.title).fontSize(14)
128
+ }
129
+ if(params.message != "") {
130
+ Text(params.message).fontSize(12).margin({ top: 10})
131
+ }
132
+ }.layoutWeight(1).alignItems(HorizontalAlign.Start).margin({left:10})
133
+ }.width(250).height(90).backgroundColor("#ffffff")
134
+ }.width('100%').height('100%').justifyContent(FlexAlign.Center).alignItems(HorizontalAlign.Center)
135
+ }
136
+
137
+
138
+ export function SpinnerDialog(pageIndex:NativeAttribute) {
139
+ if(pageIndex.pageValue == 1) {
140
+ try{
141
+ if(!cordovaWebTagToObjectGlobe.hasKey(pageIndex.pageWebTag)) {
142
+ return;
143
+ }
144
+ let mainPage = cordovaWebTagToObjectGlobe.get(pageIndex.pageWebTag) as MainPage;
145
+ let spinnerAttr: SpinnerAttribute = JSON.parse(pageIndex.pageArgs) as SpinnerAttribute;
146
+ if (spinnerAttr.title == "" && spinnerAttr.message == "") {
147
+ let contentNode: ComponentContent<Object> = new ComponentContent(mainPage.getUIContext(), wrapBuilder(CustomSpinnerDialog));
148
+ PromptActionClass.setContext(mainPage.getUIContext());
149
+ PromptActionClass.setContentNode(contentNode);
150
+ PromptActionClass.setOptions({ alignment: DialogAlignment.Top, offset: { dx: 0, dy: 50 } });
151
+ if(spinnerAttr.isFixed) {
152
+ PromptActionClass.setCancelCallBack(() => {
153
+ let result: ArkTsAttribute = {content:"", result:[]};
154
+ cordova.onArkTsResult(JSON.stringify(result), pageIndex.pageObject, pageIndex.pageWebTag);
155
+ });
156
+ }
157
+ PromptActionClass.openDialog();
158
+ }
159
+
160
+ if (spinnerAttr.title != "" || spinnerAttr.message != "") {
161
+ let contentNode: ComponentContent<Object> = new ComponentContent(mainPage.getUIContext(), wrapBuilder(CustomTitleMessageDialog),new Params(spinnerAttr.title, spinnerAttr.message));
162
+ PromptActionClass.setContext(mainPage.getUIContext());
163
+ PromptActionClass.setContentNode(contentNode);
164
+ PromptActionClass.setOptions({ alignment: DialogAlignment.Top, offset: { dx: 0, dy: 50 } });
165
+ if(spinnerAttr.isFixed) {
166
+ PromptActionClass.setCancelCallBack(() => {
167
+ let result: ArkTsAttribute = {content:"", result:[]};
168
+ cordova.onArkTsResult(JSON.stringify(result), pageIndex.pageObject, pageIndex.pageWebTag);
169
+ });
170
+ }
171
+ PromptActionClass.openDialog();
172
+ }
173
+ } catch (error) {
174
+ const cordovaError = NormalizeError(error);
175
+ console.error(`Failed to SpinnerDialog. Cause code: ${cordovaError.code}, message: ${cordovaError.message}`);
176
+ }
177
+ }
178
+
179
+ if(pageIndex.pageValue == 0) {
180
+ PromptActionClass.closeDialog();
181
+ }
182
+ }
183
+
184
+ interface styling{
185
+ opacity?:number;
186
+ backgroundColor?:string;
187
+ textColor?:string;
188
+ textSize?:number;
189
+ cornerRadius?:number;
190
+ horizontalPadding?:number;
191
+ verticalPadding?:number;
192
+ width?:number;
193
+ height?:number;
194
+ }
195
+ interface toastInfo {
196
+ message?:string;
197
+ duration?:string;
198
+ position?:string;
199
+ addPixelsY?:number;
200
+ data?:ESObject;
201
+ styling?:styling;
202
+ }
203
+
204
+ @Builder
205
+ function CustomToastDialog(params:toastInfo) {
206
+ Column(){
207
+ Row() {
208
+ Text(params.message).width('100%').height('100%')
209
+ .fontColor(params?.styling?.textColor?params.styling.textColor:'#000000')
210
+ .fontSize(params.styling?.textSize?params.styling?.textSize:14)
211
+ .textAlign(TextAlign.Center)
212
+ }
213
+ .width(params.styling?.width?params.styling.width:150)
214
+ .height(params.styling?.height?params.styling.height:30)
215
+ .backgroundColor(params.styling?.backgroundColor?params.styling?.backgroundColor:'#ffffff')
216
+ .borderRadius(params.styling?.cornerRadius?params.styling?.cornerRadius:16)
217
+ .margin({top:params.addPixelsY,bottom:params.addPixelsY?params.addPixelsY+100:100})
218
+ .padding({top:params.styling?.verticalPadding?params.styling?.verticalPadding:0,left:params.styling?.horizontalPadding?params.styling?.horizontalPadding:0})
219
+ .justifyContent(FlexAlign.Center)
220
+ .alignItems(VerticalAlign.Center)
221
+ }.width('100%').height('100%')
222
+ .justifyContent(params.position=="top"?FlexAlign.Start:params.position=="bottom"?FlexAlign.End:FlexAlign.Center)
223
+ .alignItems(HorizontalAlign.Center)
224
+ }
225
+
226
+ //Toast显示和隐藏
227
+ export function ShowToast(pageIndex:NativeAttribute) {
228
+ if(pageIndex.pageValue == 1) {
229
+ try {
230
+ if(!cordovaWebTagToObjectGlobe.hasKey(pageIndex.pageWebTag)) {
231
+ return;
232
+ }
233
+ let mainPage = cordovaWebTagToObjectGlobe.get(pageIndex.pageWebTag) as MainPage;
234
+ let opt = JSON.parse(pageIndex.pageArgs) as toastInfo;
235
+ let contentNode: ComponentContent<Object> =
236
+ new ComponentContent(mainPage.getUIContext(), wrapBuilder(CustomToastDialog), opt);
237
+ PromptActionClass.setContext(mainPage.getUIContext());
238
+ PromptActionClass.setContentNode(contentNode);
239
+ PromptActionClass.setOptions({ alignment: DialogAlignment.Top, offset: { dx: 0, dy: 50 } });
240
+ PromptActionClass.openDialog();
241
+ PromptActionClass.setCancelCallBack(() => {
242
+ let result: ArkTsAttribute = { content: "Toast", result: [opt.data] };
243
+ cordova.onArkTsResult(JSON.stringify(result), pageIndex.pageObject, pageIndex.pageWebTag);
244
+ });
245
+ setTimeout(() => {
246
+ PromptActionClass.closeDialog();
247
+ }, opt?.duration == "short" ? 2000 : opt?.duration == "long" ? 5000 : 2000)
248
+ } catch (error) {
249
+ const cordovaError = NormalizeError(error);
250
+ console.error(`Failed to ShowToast. Cause code: ${cordovaError.code}, message: ${cordovaError.message}`);
251
+ }
252
+ }
253
+
254
+ if(pageIndex.pageValue == 0) {
255
+ PromptActionClass.closeDialog();
256
+ }
257
+ }
package/www/spinner.js ADDED
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device, Inc. Ltd. and <马弓手>.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ var exec = require('cordova/exec');
18
+
19
+ module.exports = {
20
+
21
+ show : function(title, message, cancelCallback) {
22
+ if (cancelCallback == true && typeof cancelCallback !== "function") {
23
+ cancelCallback = function () {};
24
+ }
25
+ cordova.exec(cancelCallback, null, 'SpinnerDialog', 'show', [ title, message, !!cancelCallback ]);
26
+ },
27
+
28
+
29
+ hide : function(success, fail) {
30
+ cordova.exec(success, fail, 'SpinnerDialog', 'hide', [ "","" ]);
31
+ }
32
+
33
+ };