react-native-live-widgets 0.0.0-stage → 1.0.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.
- package/CHANGELOG.md +13 -0
- package/LICENSE +21 -0
- package/README.md +221 -2
- package/android/build.gradle +49 -0
- package/android/src/main/AndroidManifest.xml +38 -0
- package/android/src/main/java/com/reactnativeliveactivity/bridge/LiveActivityModule.kt +440 -0
- package/android/src/main/java/com/reactnativeliveactivity/bridge/LiveActivityPackage.kt +17 -0
- package/android/src/main/java/com/reactnativeliveactivity/liveactivity/LiveActivityHeadlessTaskService.kt +24 -0
- package/android/src/main/java/com/reactnativeliveactivity/liveactivity/LiveActivityNotifier.kt +410 -0
- package/android/src/main/java/com/reactnativeliveactivity/liveactivity/LiveActivityReceiver.kt +67 -0
- package/android/src/main/java/com/reactnativeliveactivity/renderer/DynamicNodeRegistry.kt +64 -0
- package/android/src/main/java/com/reactnativeliveactivity/renderer/DynamicWidgetCanvasRenderer.kt +1223 -0
- package/android/src/main/java/com/reactnativeliveactivity/storage/DynamicWidgetImageCache.kt +120 -0
- package/android/src/main/java/com/reactnativeliveactivity/storage/DynamicWidgetStateStore.kt +281 -0
- package/android/src/main/java/com/reactnativeliveactivity/widgets/DynamicHomeScreenWidgetProvider.kt +229 -0
- package/android/src/main/res/layout/rn_live_widget_host.xml +113 -0
- package/android/src/main/res/xml/rn_live_widget_info.xml +14 -0
- package/assets/dashboard_features.png +0 -0
- package/assets/dynamic_island_expanded.png +0 -0
- package/assets/home_widget_interactive.png +0 -0
- package/assets/lock_screen_live_activity.png +0 -0
- package/cli/setup.js +94 -0
- package/docs/GUIDE-EN.md +804 -0
- package/docs/GUIDE-VI.md +802 -0
- package/docs/widgets.md +52 -0
- package/ios/Bridge/LiveActivityModule.m +105 -0
- package/ios/Bridge/LiveActivityModule.swift +957 -0
- package/ios/Intents/DynamicWidgetActionIntent.swift +38 -0
- package/ios/Models/DynamicActivityAttributes.swift +22 -0
- package/ios/Models/DynamicLayoutModels.swift +243 -0
- package/ios/Renderer/ColorHexExtension.swift +49 -0
- package/ios/Renderer/DynamicNodeRegistry.swift +54 -0
- package/ios/Renderer/DynamicNodeView.swift +1060 -0
- package/ios/Storage/DynamicWidgetImageCache.swift +137 -0
- package/ios/Storage/DynamicWidgetStateStore.swift +162 -0
- package/ios/Widgets/DynamicHomeScreenWidget.swift +435 -0
- package/ios/Widgets/DynamicLiveActivityWidget.swift +79 -0
- package/lib/builder.d.ts +60 -0
- package/lib/builder.d.ts.map +1 -0
- package/lib/builder.js +296 -0
- package/lib/builder.js.map +1 -0
- package/lib/dispatcher.d.ts +16 -0
- package/lib/dispatcher.d.ts.map +1 -0
- package/lib/dispatcher.js +23 -0
- package/lib/dispatcher.js.map +1 -0
- package/lib/index.d.ts +199 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +634 -0
- package/lib/index.js.map +1 -0
- package/lib/types.d.ts +489 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +10 -0
- package/lib/types.js.map +1 -0
- package/package.json +68 -4
- package/react-native-live-widgets.podspec +38 -0
- package/src/builder.ts +409 -0
- package/src/dispatcher.ts +25 -0
- package/src/index.ts +681 -0
- package/src/types.ts +595 -0
package/docs/widgets.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Home Screen Widgets & Interactive Multi-Page Guide (`Widget.*`)
|
|
2
|
+
|
|
3
|
+
> 🌐 Full Guides: [English (`GUIDE-EN.md`)](./GUIDE-EN.md) | [Tiếng Việt (`GUIDE-VI.md`)](./GUIDE-VI.md)
|
|
4
|
+
|
|
5
|
+
This document focuses on building **Home Screen Widgets (`small`, `medium`, `large`)** with **multi-page navigation**, **interactive checklists**, **remote URL/Base64 images**, and **autonomous background API synchronization** on both iOS and Android.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Setting Dynamic Widget Layouts (`Widget.setLayout`)
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { Widget, UI } from 'react-native-live-widgets';
|
|
13
|
+
|
|
14
|
+
await Widget.setLayout('main', {
|
|
15
|
+
initialPage: 'overview',
|
|
16
|
+
small: smallNode,
|
|
17
|
+
medium: mediumNode,
|
|
18
|
+
large: largeNode,
|
|
19
|
+
pages: {
|
|
20
|
+
overview: { small: smallNode, medium: mediumNode, large: largeNode },
|
|
21
|
+
tasks: { small: tasksSmallNode, medium: tasksMediumNode, large: tasksLargeNode },
|
|
22
|
+
stats: { small: statsSmallNode, medium: statsMediumNode, large: statsLargeNode },
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 2. Interactive Widget Actions (`UI.Button`)
|
|
30
|
+
|
|
31
|
+
| `actionId` Format | Behavior on iOS (`AppIntents`) & Android (`PendingIntent`) |
|
|
32
|
+
|---|---|
|
|
33
|
+
| `'page:<page_id>'` | Switches the widget to `<page_id>` in-place without launching the app |
|
|
34
|
+
| `'page:next'` / `'page:prev'` | Cycles to the next or previous page defined in `pages` |
|
|
35
|
+
| `'toggle:<item_key>'` | Toggles checklist state (`true` / `false`) and updates any `UI.Text` with `strikethroughWhenToggled: '<item_key>'` |
|
|
36
|
+
| `'refresh'` | Immediately executes the background HTTP call configured via `Widget.setRemoteConfig` |
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 3. Autonomous Background API Sync (`Widget.setRemoteConfig`)
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
await Widget.setRemoteConfig({
|
|
44
|
+
url: 'https://api.example.com/v1/widget-data',
|
|
45
|
+
method: 'GET',
|
|
46
|
+
headers: { Authorization: 'Bearer <token>' },
|
|
47
|
+
intervalMinutes: 15,
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Any `UI.Text` containing `{{fieldName}}` or `{{_lastSyncTime}}` will be automatically populated from the JSON response even when the app is killed.
|
|
52
|
+
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
#import <React/RCTEventEmitter.h>
|
|
3
|
+
|
|
4
|
+
@interface RCT_EXTERN_MODULE(LiveActivityModule, RCTEventEmitter)
|
|
5
|
+
|
|
6
|
+
RCT_EXTERN_METHOD(start:(NSString *)activityId
|
|
7
|
+
payloadJson:(NSString *)payloadJson
|
|
8
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
9
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
10
|
+
|
|
11
|
+
RCT_EXTERN_METHOD(update:(NSString *)activityId
|
|
12
|
+
payloadJson:(NSString *)payloadJson
|
|
13
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
14
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
15
|
+
|
|
16
|
+
RCT_EXTERN_METHOD(end:(NSString *)activityId
|
|
17
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
18
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
19
|
+
|
|
20
|
+
RCT_EXTERN_METHOD(endWithOptions:(NSString *)activityId
|
|
21
|
+
options:(nullable NSDictionary *)options
|
|
22
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
23
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
24
|
+
|
|
25
|
+
RCT_EXTERN_METHOD(endAll:(RCTPromiseResolveBlock)resolve
|
|
26
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
27
|
+
|
|
28
|
+
RCT_EXTERN_METHOD(getPushToStartToken:(RCTPromiseResolveBlock)resolve
|
|
29
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
30
|
+
|
|
31
|
+
RCT_EXTERN_METHOD(registerForPushNotifications:(RCTPromiseResolveBlock)resolve
|
|
32
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
33
|
+
|
|
34
|
+
RCT_EXTERN_METHOD(getDevicePushToken:(RCTPromiseResolveBlock)resolve
|
|
35
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
36
|
+
|
|
37
|
+
RCT_EXTERN_METHOD(getActivityPushToken:(NSString *)activityId
|
|
38
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
39
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
40
|
+
|
|
41
|
+
RCT_EXTERN_METHOD(getAllPushTokens:(NSString *)activityId
|
|
42
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
43
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
44
|
+
|
|
45
|
+
RCT_EXTERN_METHOD(reloadAllWidgets:(RCTPromiseResolveBlock)resolve
|
|
46
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
47
|
+
|
|
48
|
+
RCT_EXTERN_METHOD(reloadWidget:(NSString *)kind
|
|
49
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
50
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
51
|
+
|
|
52
|
+
RCT_EXTERN_METHOD(requestPinWidget:(RCTPromiseResolveBlock)resolve
|
|
53
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
54
|
+
|
|
55
|
+
RCT_EXTERN_METHOD(isRequestPinWidgetSupported:(RCTPromiseResolveBlock)resolve
|
|
56
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
57
|
+
|
|
58
|
+
RCT_EXTERN_METHOD(setSharedItem:(NSString *)key
|
|
59
|
+
value:(NSString *)value
|
|
60
|
+
appGroup:(NSString *)appGroup
|
|
61
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
62
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
63
|
+
|
|
64
|
+
RCT_EXTERN_METHOD(getSharedItem:(NSString *)key
|
|
65
|
+
appGroup:(NSString *)appGroup
|
|
66
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
67
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
68
|
+
|
|
69
|
+
RCT_EXTERN_METHOD(removeSharedItem:(NSString *)key
|
|
70
|
+
appGroup:(NSString *)appGroup
|
|
71
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
72
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
73
|
+
|
|
74
|
+
RCT_EXTERN_METHOD(clearSharedItems:(NSString *)appGroup
|
|
75
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
76
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
77
|
+
|
|
78
|
+
RCT_EXTERN_METHOD(playAudio:(NSString *)urlString
|
|
79
|
+
metadata:(nullable NSDictionary *)metadata
|
|
80
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
81
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
82
|
+
|
|
83
|
+
RCT_EXTERN_METHOD(pauseAudio:(RCTPromiseResolveBlock)resolve
|
|
84
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
85
|
+
|
|
86
|
+
RCT_EXTERN_METHOD(resumeAudio:(RCTPromiseResolveBlock)resolve
|
|
87
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
88
|
+
|
|
89
|
+
RCT_EXTERN_METHOD(stopAudio:(RCTPromiseResolveBlock)resolve
|
|
90
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
91
|
+
|
|
92
|
+
RCT_EXTERN_METHOD(getAudioStatus:(RCTPromiseResolveBlock)resolve
|
|
93
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
94
|
+
|
|
95
|
+
RCT_EXTERN_METHOD(getActiveActivities:(RCTPromiseResolveBlock)resolve
|
|
96
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
97
|
+
|
|
98
|
+
RCT_EXTERN_METHOD(areActivitiesEnabled:(RCTPromiseResolveBlock)resolve
|
|
99
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
100
|
+
|
|
101
|
+
RCT_EXTERN_METHOD(areFrequentPushesEnabled:(RCTPromiseResolveBlock)resolve
|
|
102
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
103
|
+
|
|
104
|
+
@end
|
|
105
|
+
|