@react-native-ohos/ting 1.2.4-rc.1

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.
Files changed (52) hide show
  1. package/LICENSE +20 -0
  2. package/README.OpenSource +11 -0
  3. package/README.md +14 -0
  4. package/harmony/ting/BuildProfile.ets +6 -0
  5. package/harmony/ting/build-profile.json5 +9 -0
  6. package/harmony/ting/hvigorfile.ts +2 -0
  7. package/harmony/ting/index.ets +7 -0
  8. package/harmony/ting/obfuscation-rules.txt +18 -0
  9. package/harmony/ting/oh-package.json5 +12 -0
  10. package/harmony/ting/src/main/cpp/CMakeLists.txt +7 -0
  11. package/harmony/ting/src/main/cpp/Ting.cpp +23 -0
  12. package/harmony/ting/src/main/cpp/Ting.h +18 -0
  13. package/harmony/ting/src/main/cpp/TingPackage.h +32 -0
  14. package/harmony/ting/src/main/ets/Logger.ets +64 -0
  15. package/harmony/ting/src/main/ets/TingPackage.ets +46 -0
  16. package/harmony/ting/src/main/ets/TingTurboModule.ets +514 -0
  17. package/harmony/ting/src/main/ets/Type.ets +133 -0
  18. package/harmony/ting/src/main/ets/generated/components/ts.ts +5 -0
  19. package/harmony/ting/src/main/ets/generated/index.ets +5 -0
  20. package/harmony/ting/src/main/ets/generated/ts.ts +6 -0
  21. package/harmony/ting/src/main/ets/generated/turboModules/Ting.ts +25 -0
  22. package/harmony/ting/src/main/ets/generated/turboModules/ts.ts +5 -0
  23. package/harmony/ting/src/main/module.json5 +7 -0
  24. package/harmony/ting/src/main/resources/base/element/color.json +8 -0
  25. package/harmony/ting/src/main/resources/base/element/string.json +16 -0
  26. package/harmony/ting/src/main/resources/base/profile/backup_config.json +3 -0
  27. package/harmony/ting/src/main/resources/base/profile/main_pages.json +5 -0
  28. package/harmony/ting/src/main/resources/en_US/element/string.json +16 -0
  29. package/harmony/ting/src/main/resources/zh_CN/element/string.json +16 -0
  30. package/harmony/ting.har +0 -0
  31. package/lib/commonjs/NativeTing.js +14 -0
  32. package/lib/commonjs/NativeTing.js.map +1 -0
  33. package/lib/commonjs/Type.js +2 -0
  34. package/lib/commonjs/Type.js.map +1 -0
  35. package/lib/commonjs/index.js +73 -0
  36. package/lib/commonjs/index.js.map +1 -0
  37. package/lib/module/NativeTing.js +9 -0
  38. package/lib/module/NativeTing.js.map +1 -0
  39. package/lib/module/Type.js +2 -0
  40. package/lib/module/Type.js.map +1 -0
  41. package/lib/module/index.js +47 -0
  42. package/lib/module/index.js.map +1 -0
  43. package/lib/typescript/NativeTing.d.ts +10 -0
  44. package/lib/typescript/NativeTing.d.ts.map +1 -0
  45. package/lib/typescript/Type.d.ts +98 -0
  46. package/lib/typescript/Type.d.ts.map +1 -0
  47. package/lib/typescript/index.d.ts +10 -0
  48. package/lib/typescript/index.d.ts.map +1 -0
  49. package/package.json +160 -0
  50. package/src/NativeTing.ts +17 -0
  51. package/src/Type.ts +108 -0
  52. package/src/index.tsx +64 -0
package/src/Type.ts ADDED
@@ -0,0 +1,108 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ export interface Icon {
8
+ size?: number;
9
+ uri?: string | number;
10
+ tintColor?: string;
11
+ }
12
+
13
+ export interface ToastOptions {
14
+ title?: string;
15
+ message?: string;
16
+ titleColor?: string;
17
+ messageColor?: string;
18
+ /**
19
+ * Defaults to `done`.
20
+ */
21
+ preset?: 'done' | 'error' | 'none' | 'spinner';
22
+ /**
23
+ * Duration in seconds.
24
+ */
25
+ duration?: number;
26
+ haptic?: 'success' | 'warning' | 'error' | 'none';
27
+ /**
28
+ * Defaults to `true`.
29
+ */
30
+ shouldDismissByDrag?: boolean;
31
+ /**
32
+ * Change the presentation side.
33
+ * Defaults to `top`.
34
+ */
35
+ position?: 'top' | 'bottom';
36
+ /**
37
+ * backgroundColor for toastView
38
+ * Defaults to `null`.
39
+ */
40
+ backgroundColor?: string;
41
+
42
+ /**
43
+ * custom icon
44
+ * Defaults to `null`.
45
+ */
46
+ icon?: Icon;
47
+
48
+ /**
49
+ * progress color for spinner preset
50
+ * @platform android
51
+ */
52
+ progressColor?: string;
53
+ }
54
+
55
+ export interface AlertOptions {
56
+ title?: string;
57
+ message?: string;
58
+ titleColor?: string;
59
+ messageColor?: string;
60
+ /**
61
+ * Defaults to `done`.
62
+ */
63
+ preset?: 'done' | 'error' | 'none' | 'spinner';
64
+ /**
65
+ * Duration in seconds.
66
+ * Defaults to 3.
67
+ */
68
+ duration?: number;
69
+ /**
70
+ * @platform ios
71
+ */
72
+ haptic?: 'success' | 'warning' | 'error' | 'none';
73
+ /**
74
+ * Defaults to `true`.
75
+ */
76
+ shouldDismissByTap?: boolean;
77
+ /**
78
+ * backgroundColor for alertView
79
+ * Defaults to `null`.
80
+ */
81
+ backgroundColor?: string;
82
+ /**
83
+ * borderRadius for alertView
84
+ * Defaults to `24`.
85
+ */
86
+ borderRadius?: number;
87
+ /**
88
+ * blur for backdrop
89
+ * @platform android
90
+ */
91
+ blurBackdrop?: number;
92
+ /**
93
+ * @platform android
94
+ * 0 -> 1
95
+ * Defaults to 0.
96
+ */
97
+ backdropOpacity?: number;
98
+ /**
99
+ * custom icon
100
+ */
101
+ icon?: Icon;
102
+
103
+ /**
104
+ * progress color for spinner preset
105
+ * @platform android
106
+ */
107
+ progressColor?: string;
108
+ }
package/src/index.tsx ADDED
@@ -0,0 +1,64 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import { NativeModules, Platform, Image } from 'react-native';
8
+ import type { AlertOptions, ToastOptions } from './Type';
9
+ export * from './Type';
10
+
11
+ const LINKING_ERROR =
12
+ `The package 'ting' doesn't seem to be linked. Make sure: \n\n` +
13
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
14
+ '- You rebuilt the app after installing the package\n'
15
+
16
+ // @ts-expect-error
17
+ const isTurboModuleEnabled = global.__turboModuleProxy != null;
18
+
19
+ const TingModule = isTurboModuleEnabled
20
+ ? require('./NativeTing').default
21
+ : NativeModules.Ting;
22
+
23
+ const Ting = TingModule
24
+ ? TingModule
25
+ : new Proxy(
26
+ {},
27
+ {
28
+ get() {
29
+ throw new Error(LINKING_ERROR);
30
+ },
31
+ }
32
+ );
33
+
34
+ const convertIconFile = (options: ToastOptions | AlertOptions): void => {
35
+ const iconURI = options?.icon?.uri;
36
+ if (options?.icon) {
37
+ if (typeof iconURI === 'number') {
38
+ options.icon.uri = Image.resolveAssetSource(iconURI).uri;
39
+ }
40
+ }
41
+ };
42
+
43
+ export function toast(options: ToastOptions): void {
44
+ convertIconFile(options);
45
+ Ting.toast(options);
46
+ }
47
+
48
+ export function alert(options: AlertOptions): void {
49
+ convertIconFile(options);
50
+ Ting.alert(options);
51
+ }
52
+
53
+ export function dismissAlert(): void {
54
+ Ting.dismissAlert();
55
+ }
56
+
57
+ export function setup(options: {
58
+ alert?: AlertOptions;
59
+ toast?: ToastOptions;
60
+ }): void {
61
+ convertIconFile(options?.alert as AlertOptions);
62
+ convertIconFile(options?.toast as ToastOptions);
63
+ return Ting.setup(options);
64
+ }