react-native-live-widgets 0.0.0-stage → 1.1.0

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 (65) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE +21 -0
  3. package/README.md +367 -2
  4. package/android/build.gradle +49 -0
  5. package/android/src/main/AndroidManifest.xml +38 -0
  6. package/android/src/main/java/com/reactnativeliveactivity/bridge/LiveActivityModule.kt +441 -0
  7. package/android/src/main/java/com/reactnativeliveactivity/bridge/LiveActivityPackage.kt +17 -0
  8. package/android/src/main/java/com/reactnativeliveactivity/liveactivity/LiveActivityHeadlessTaskService.kt +24 -0
  9. package/android/src/main/java/com/reactnativeliveactivity/liveactivity/LiveActivityNotifier.kt +410 -0
  10. package/android/src/main/java/com/reactnativeliveactivity/liveactivity/LiveActivityReceiver.kt +67 -0
  11. package/android/src/main/java/com/reactnativeliveactivity/renderer/DynamicNodeRegistry.kt +64 -0
  12. package/android/src/main/java/com/reactnativeliveactivity/renderer/DynamicWidgetCanvasRenderer.kt +1223 -0
  13. package/android/src/main/java/com/reactnativeliveactivity/storage/DynamicWidgetImageCache.kt +120 -0
  14. package/android/src/main/java/com/reactnativeliveactivity/storage/DynamicWidgetStateStore.kt +281 -0
  15. package/android/src/main/java/com/reactnativeliveactivity/widgets/DynamicHomeScreenWidgetProvider.kt +229 -0
  16. package/android/src/main/res/layout/rn_live_widget_host.xml +113 -0
  17. package/android/src/main/res/xml/rn_live_widget_info.xml +14 -0
  18. package/app.plugin.js +114 -0
  19. package/assets/cross_platform_parity.png +0 -0
  20. package/assets/dashboard_features.png +0 -0
  21. package/assets/donate_qr.png +0 -0
  22. package/assets/dynamic_island_expanded.png +0 -0
  23. package/assets/home_widget_interactive.png +0 -0
  24. package/assets/lock_screen_live_activity.png +0 -0
  25. package/cli/setup.js +491 -0
  26. package/docs/EXPO-GUIDE-EN.md +405 -0
  27. package/docs/EXPO-GUIDE-VI.md +427 -0
  28. package/docs/GUIDE-EN.md +847 -0
  29. package/docs/GUIDE-VI.md +845 -0
  30. package/docs/widgets.md +52 -0
  31. package/ios/Bridge/LiveActivityModule.m +105 -0
  32. package/ios/Bridge/LiveActivityModule.swift +957 -0
  33. package/ios/Intents/DynamicWidgetActionIntent.swift +38 -0
  34. package/ios/Models/DynamicActivityAttributes.swift +22 -0
  35. package/ios/Models/DynamicLayoutModels.swift +243 -0
  36. package/ios/Renderer/ColorHexExtension.swift +49 -0
  37. package/ios/Renderer/DynamicNodeRegistry.swift +54 -0
  38. package/ios/Renderer/DynamicNodeView.swift +1060 -0
  39. package/ios/Storage/DynamicWidgetImageCache.swift +137 -0
  40. package/ios/Storage/DynamicWidgetStateStore.swift +162 -0
  41. package/ios/Widgets/DynamicHomeScreenWidget.swift +435 -0
  42. package/ios/Widgets/DynamicLiveActivityWidget.swift +79 -0
  43. package/lib/builder.d.ts +60 -0
  44. package/lib/builder.d.ts.map +1 -0
  45. package/lib/builder.js +292 -0
  46. package/lib/builder.js.map +1 -0
  47. package/lib/dispatcher.d.ts +16 -0
  48. package/lib/dispatcher.d.ts.map +1 -0
  49. package/lib/dispatcher.js +18 -0
  50. package/lib/dispatcher.js.map +1 -0
  51. package/lib/index.d.ts +199 -0
  52. package/lib/index.d.ts.map +1 -0
  53. package/lib/index.js +621 -0
  54. package/lib/index.js.map +1 -0
  55. package/lib/types.d.ts +489 -0
  56. package/lib/types.d.ts.map +1 -0
  57. package/lib/types.js +9 -0
  58. package/lib/types.js.map +1 -0
  59. package/package.json +85 -4
  60. package/react-native-live-widgets.podspec +38 -0
  61. package/src/builder.ts +409 -0
  62. package/src/dispatcher.ts +25 -0
  63. package/src/index.ts +689 -0
  64. package/src/react-native-env.d.ts +29 -0
  65. package/src/types.ts +595 -0
@@ -0,0 +1,113 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+ android:id="@+id/rn_widget_root"
4
+ android:layout_width="match_parent"
5
+ android:layout_height="match_parent">
6
+
7
+ <!-- Lớp Canvas vẽ toàn bộ cây giao diện UI.VStack / HStack / Progress / Image / Text / Timer -->
8
+ <ImageView
9
+ android:id="@+id/rn_widget_canvas"
10
+ android:layout_width="match_parent"
11
+ android:layout_height="match_parent"
12
+ android:scaleType="fitCenter"
13
+ android:contentDescription="Live Widget Content" />
14
+
15
+ <!-- Lớp vùng bấm tương tác (Interactive Hit Zones) cho các UI.Button trên Widget -->
16
+ <LinearLayout
17
+ android:layout_width="match_parent"
18
+ android:layout_height="match_parent"
19
+ android:orientation="vertical"
20
+ android:weightSum="100">
21
+
22
+ <!-- Hàng trên cùng (dành cho thanh Tab Bar chuyển trang: page:shift, page:todo, page:okr, page:next) -->
23
+ <LinearLayout
24
+ android:id="@+id/rn_widget_row_top"
25
+ android:layout_width="match_parent"
26
+ android:layout_height="0dp"
27
+ android:layout_weight="22"
28
+ android:orientation="horizontal">
29
+
30
+ <TextView
31
+ android:id="@+id/rn_hit_top_1"
32
+ android:layout_width="0dp"
33
+ android:layout_height="match_parent"
34
+ android:layout_weight="1"
35
+ android:background="@android:color/transparent" />
36
+
37
+ <TextView
38
+ android:id="@+id/rn_hit_top_2"
39
+ android:layout_width="0dp"
40
+ android:layout_height="match_parent"
41
+ android:layout_weight="1"
42
+ android:background="@android:color/transparent" />
43
+
44
+ <TextView
45
+ android:id="@+id/rn_hit_top_3"
46
+ android:layout_width="0dp"
47
+ android:layout_height="match_parent"
48
+ android:layout_weight="1"
49
+ android:background="@android:color/transparent" />
50
+
51
+ <TextView
52
+ android:id="@+id/rn_hit_top_4"
53
+ android:layout_width="0dp"
54
+ android:layout_height="match_parent"
55
+ android:layout_weight="1"
56
+ android:background="@android:color/transparent" />
57
+ </LinearLayout>
58
+
59
+ <!-- Vùng giữa (dành cho danh sách các nút bấm / Todo items: toggle:todo_1, toggle:todo_2, toggle:todo_3) -->
60
+ <LinearLayout
61
+ android:id="@+id/rn_widget_row_mid"
62
+ android:layout_width="match_parent"
63
+ android:layout_height="0dp"
64
+ android:layout_weight="58"
65
+ android:orientation="vertical">
66
+
67
+ <TextView
68
+ android:id="@+id/rn_hit_mid_1"
69
+ android:layout_width="match_parent"
70
+ android:layout_height="0dp"
71
+ android:layout_weight="1"
72
+ android:background="@android:color/transparent" />
73
+
74
+ <TextView
75
+ android:id="@+id/rn_hit_mid_2"
76
+ android:layout_width="match_parent"
77
+ android:layout_height="0dp"
78
+ android:layout_weight="1"
79
+ android:background="@android:color/transparent" />
80
+
81
+ <TextView
82
+ android:id="@+id/rn_hit_mid_3"
83
+ android:layout_width="match_parent"
84
+ android:layout_height="0dp"
85
+ android:layout_weight="1"
86
+ android:background="@android:color/transparent" />
87
+ </LinearLayout>
88
+
89
+ <!-- Hàng dưới cùng (dành cho nút Refresh API ngầm / Điều hướng: refresh, page:prev, page:next) -->
90
+ <LinearLayout
91
+ android:id="@+id/rn_widget_row_bottom"
92
+ android:layout_width="match_parent"
93
+ android:layout_height="0dp"
94
+ android:layout_weight="20"
95
+ android:orientation="horizontal">
96
+
97
+ <TextView
98
+ android:id="@+id/rn_hit_bot_1"
99
+ android:layout_width="0dp"
100
+ android:layout_height="match_parent"
101
+ android:layout_weight="1"
102
+ android:background="@android:color/transparent" />
103
+
104
+ <TextView
105
+ android:id="@+id/rn_hit_bot_2"
106
+ android:layout_width="0dp"
107
+ android:layout_height="match_parent"
108
+ android:layout_weight="1"
109
+ android:background="@android:color/transparent" />
110
+ </LinearLayout>
111
+ </LinearLayout>
112
+ </FrameLayout>
113
+
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
3
+ android:minWidth="250dp"
4
+ android:minHeight="180dp"
5
+ android:targetCellWidth="4"
6
+ android:targetCellHeight="3"
7
+ android:minResizeWidth="140dp"
8
+ android:minResizeHeight="110dp"
9
+ android:maxResizeWidth="520dp"
10
+ android:maxResizeHeight="520dp"
11
+ android:updatePeriodMillis="900000"
12
+ android:initialLayout="@layout/rn_live_widget_host"
13
+ android:resizeMode="horizontal|vertical"
14
+ android:widgetCategory="home_screen" />
package/app.plugin.js ADDED
@@ -0,0 +1,114 @@
1
+ const path = require('path');
2
+ const fs = require('fs');
3
+
4
+ /**
5
+ * Expo Config Plugin for react-native-live-widgets
6
+ *
7
+ * Automatically configures:
8
+ * 1. iOS Info.plist: NSSupportsLiveActivities = YES, NSSupportsLiveActivitiesFrequentUpdates = YES
9
+ * 2. iOS Entitlements: com.apple.security.application-groups = [appGroup]
10
+ * 3. Android AndroidManifest.xml: POST_NOTIFICATIONS, FOREGROUND_SERVICE permissions
11
+ */
12
+
13
+ let withLiveWidgets;
14
+
15
+ try {
16
+ const {
17
+ withInfoPlist,
18
+ withEntitlementsPlist,
19
+ withAndroidManifest,
20
+ createRunOncePlugin,
21
+ } = require('@expo/config-plugins');
22
+
23
+ const pkg = require('./package.json');
24
+
25
+ /**
26
+ * Configures iOS Info.plist to enable Live Activities support
27
+ */
28
+ const withLiveWidgetsInfoPlist = (config, options = {}) => {
29
+ return withInfoPlist(config, (plistConfig) => {
30
+ const enableLiveActivities =
31
+ options.enableLiveActivities !== undefined ? options.enableLiveActivities : true;
32
+ const frequentUpdates =
33
+ options.frequentUpdates !== undefined ? options.frequentUpdates : true;
34
+
35
+ plistConfig.modResults.NSSupportsLiveActivities = enableLiveActivities;
36
+ if (frequentUpdates) {
37
+ plistConfig.modResults.NSSupportsLiveActivitiesFrequentUpdates = true;
38
+ }
39
+
40
+ return plistConfig;
41
+ });
42
+ };
43
+
44
+ /**
45
+ * Configures iOS Entitlements for App Groups shared storage
46
+ */
47
+ const withLiveWidgetsEntitlements = (config, options = {}) => {
48
+ return withEntitlementsPlist(config, (entitlementsConfig) => {
49
+ if (options.appGroup) {
50
+ const existingGroups =
51
+ entitlementsConfig.modResults['com.apple.security.application-groups'] || [];
52
+ const groups = Array.isArray(existingGroups) ? [...existingGroups] : [existingGroups];
53
+
54
+ if (!groups.includes(options.appGroup)) {
55
+ groups.push(options.appGroup);
56
+ }
57
+
58
+ entitlementsConfig.modResults['com.apple.security.application-groups'] = groups;
59
+ }
60
+ return entitlementsConfig;
61
+ });
62
+ };
63
+
64
+ /**
65
+ * Configures Android Manifest permissions for Notifications & Background Service
66
+ */
67
+ const withLiveWidgetsAndroidManifest = (config, _options = {}) => {
68
+ return withAndroidManifest(config, (manifestConfig) => {
69
+ const manifest = manifestConfig.modResults.manifest;
70
+
71
+ if (!manifest['uses-permission']) {
72
+ manifest['uses-permission'] = [];
73
+ }
74
+
75
+ const permissions = [
76
+ 'android.permission.INTERNET',
77
+ 'android.permission.POST_NOTIFICATIONS',
78
+ 'android.permission.FOREGROUND_SERVICE',
79
+ ];
80
+
81
+ for (const permission of permissions) {
82
+ const hasPermission = manifest['uses-permission'].some(
83
+ (p) => p.$?.['android:name'] === permission
84
+ );
85
+ if (!hasPermission) {
86
+ manifest['uses-permission'].push({
87
+ $: { 'android:name': permission },
88
+ });
89
+ }
90
+ }
91
+
92
+ return manifestConfig;
93
+ });
94
+ };
95
+
96
+ /**
97
+ * Main Expo Config Plugin composite function
98
+ */
99
+ const plugin = (config, options = {}) => {
100
+ config = withLiveWidgetsInfoPlist(config, options);
101
+ config = withLiveWidgetsEntitlements(config, options);
102
+ config = withLiveWidgetsAndroidManifest(config, options);
103
+ return config;
104
+ };
105
+
106
+ withLiveWidgets = createRunOncePlugin(plugin, pkg.name, pkg.version);
107
+ } catch (_error) {
108
+ // Fallback for non-Expo / bare React Native environments where @expo/config-plugins is absent
109
+ withLiveWidgets = function (config) {
110
+ return config;
111
+ };
112
+ }
113
+
114
+ module.exports = withLiveWidgets;
Binary file
Binary file
Binary file