163 lines
7.0 KiB
Diff
163 lines
7.0 KiB
Diff
diff --git a/build/Widgets.types.d.ts b/build/Widgets.types.d.ts
|
|
index c9f4dfe..dc0792e 100644
|
|
--- a/build/Widgets.types.d.ts
|
|
+++ b/build/Widgets.types.d.ts
|
|
@@ -93,6 +93,10 @@ export type LiveActivityEnvironment = {
|
|
* The color scheme of the activity's environment.
|
|
*/
|
|
colorScheme: 'light' | 'dark';
|
|
+ /** The rendering mode supplied by WidgetKit for this presentation. */
|
|
+ widgetRenderingMode?: WidgetRenderingMode;
|
|
+ /** Whether the presentation OS supports Liquid Glass. @platform iOS 26+ */
|
|
+ isLiquidGlassAvailable?: boolean;
|
|
/**
|
|
* Whether the activity is displayed in a context with reduced luminance.
|
|
* @platform iOS 16+
|
|
diff --git a/ios/Widgets/Utils.swift b/ios/Widgets/Utils.swift
|
|
index 76b2199..6cb52c3 100644
|
|
--- a/ios/Widgets/Utils.swift
|
|
+++ b/ios/Widgets/Utils.swift
|
|
@@ -125,6 +125,10 @@ func getLiveActivityEnvironment(for environment: EnvironmentValues, in context:
|
|
"isStale": context.isStale
|
|
]
|
|
|
|
+ if #available(iOS 26.0, *) {
|
|
+ env["isLiquidGlassAvailable"] = true
|
|
+ }
|
|
+ env["widgetRenderingMode"] = environment.widgetRenderingMode.description
|
|
if #available(iOS 18.0, *) {
|
|
env["isActivityUpdateReduced"] = environment.isActivityUpdateReduced
|
|
env["activityFamily"] = "\(environment.activityFamily)"
|
|
diff --git a/ios/Widgets/WidgetLiveActivity.swift b/ios/Widgets/WidgetLiveActivity.swift
|
|
index 4d135c4..dae4744 100644
|
|
--- a/ios/Widgets/WidgetLiveActivity.swift
|
|
+++ b/ios/Widgets/WidgetLiveActivity.swift
|
|
@@ -19,53 +19,41 @@ struct LiveActivityAttributes: ActivityAttributes {
|
|
}
|
|
|
|
public struct WidgetLiveActivity: Widget {
|
|
- @Environment(\.self) var env
|
|
-
|
|
let widgetContext: AppContext = AppContext()
|
|
|
|
public init() {}
|
|
|
|
public var body: some WidgetConfiguration {
|
|
ActivityConfiguration(for: LiveActivityAttributes.self) { context in
|
|
- let nodes = getLiveActivityNodes(
|
|
- forName: context.state.name,
|
|
- props: context.state.props,
|
|
- environment: getLiveActivityEnvironment(for: env, in: context)
|
|
- )
|
|
// Only apply widgetURL when the activity has one: a hierarchy with more than one
|
|
// widgetURL modifier is undefined behavior, and layouts can set their own through
|
|
// the widgetURL modifier from @expo/ui.
|
|
- let banner = LiveActivityBannerView(context: context, nodes: nodes)
|
|
+ let banner = LiveActivityBannerView(context: context)
|
|
if let url = context.attributes.url.flatMap(URL.init(string:)) {
|
|
banner.widgetURL(url)
|
|
} else {
|
|
banner
|
|
}
|
|
} dynamicIsland: { context in
|
|
- let nodes = getLiveActivityNodes(
|
|
- forName: context.state.name,
|
|
- props: context.state.props,
|
|
- environment: getLiveActivityEnvironment(for: env, in: context)
|
|
- )
|
|
let island = DynamicIsland {
|
|
DynamicIslandExpandedRegion(.center) {
|
|
- LiveActivitySectionView(context: context, nodes: nodes, sectionName: "expandedCenter")
|
|
+ LiveActivitySectionView(context: context, sectionName: "expandedCenter")
|
|
}
|
|
DynamicIslandExpandedRegion(.leading) {
|
|
- LiveActivitySectionView(context: context, nodes: nodes, sectionName: "expandedLeading")
|
|
+ LiveActivitySectionView(context: context, sectionName: "expandedLeading")
|
|
}
|
|
DynamicIslandExpandedRegion(.trailing) {
|
|
- LiveActivitySectionView(context: context, nodes: nodes, sectionName: "expandedTrailing")
|
|
+ LiveActivitySectionView(context: context, sectionName: "expandedTrailing")
|
|
}
|
|
DynamicIslandExpandedRegion(.bottom) {
|
|
- LiveActivitySectionView(context: context, nodes: nodes, sectionName: "expandedBottom")
|
|
+ LiveActivitySectionView(context: context, sectionName: "expandedBottom")
|
|
}
|
|
} compactLeading: {
|
|
- LiveActivitySectionView(context: context, nodes: nodes, sectionName: "compactLeading")
|
|
+ LiveActivitySectionView(context: context, sectionName: "compactLeading")
|
|
} compactTrailing: {
|
|
- LiveActivitySectionView(context: context, nodes: nodes, sectionName: "compactTrailing")
|
|
+ LiveActivitySectionView(context: context, sectionName: "compactTrailing")
|
|
} minimal: {
|
|
- LiveActivitySectionView(context: context, nodes: nodes, sectionName: "minimal")
|
|
+ LiveActivitySectionView(context: context, sectionName: "minimal")
|
|
}
|
|
if let url = context.attributes.url.flatMap(URL.init(string:)) {
|
|
return island.widgetURL(url)
|
|
@@ -77,11 +65,16 @@ public struct WidgetLiveActivity: Widget {
|
|
}
|
|
|
|
private struct LiveActivitySectionView: View {
|
|
+ @Environment(\.self) var env
|
|
let context: ActivityViewContext<LiveActivityAttributes>
|
|
- let nodes: [String: Any]
|
|
let sectionName: String
|
|
|
|
var body: some View {
|
|
+ let nodes = getLiveActivityNodes(
|
|
+ forName: context.state.name,
|
|
+ props: context.state.props,
|
|
+ environment: getLiveActivityEnvironment(for: env, in: context)
|
|
+ )
|
|
if let node = nodes[sectionName] as? [String: Any] {
|
|
WidgetsDynamicView(name: context.activityID, kind: .liveActivity, node: node)
|
|
} else {
|
|
@@ -91,10 +84,17 @@ private struct LiveActivitySectionView: View {
|
|
}
|
|
|
|
private struct LiveActivityBannerView: View {
|
|
+ // Read inside the rendered view: Widget-level values do not include the
|
|
+ // presentation's color scheme, rendering mode, or reduced-luminance state.
|
|
+ @Environment(\.self) var env
|
|
var context: ActivityViewContext<LiveActivityAttributes>
|
|
- let nodes: [String: Any]
|
|
|
|
var body: some View {
|
|
+ let nodes = getLiveActivityNodes(
|
|
+ forName: context.state.name,
|
|
+ props: context.state.props,
|
|
+ environment: getLiveActivityEnvironment(for: env, in: context)
|
|
+ )
|
|
if #available(iOS 18.0, *) {
|
|
LiveActivityBanner(context: context, nodes: nodes)
|
|
} else if let node = nodes["banner"] as? [String: Any] {
|
|
diff --git a/scripts/build-layout-registry.mjs b/scripts/build-layout-registry.mjs
|
|
index d52a60e..fa9bd77 100644
|
|
--- a/scripts/build-layout-registry.mjs
|
|
+++ b/scripts/build-layout-registry.mjs
|
|
@@ -154,6 +154,8 @@ function createLayoutRegistry(expectedWidgets, capturedLayouts) {
|
|
return registry;
|
|
}
|
|
|
|
-if (process.argv[1] && path.resolve(process.argv[1]) === __filename) {
|
|
+// Compare real paths: pnpm exposes the package through a symlink, so the
|
|
+// invoked path and import.meta.url differ while naming the same file.
|
|
+if (process.argv[1] && fs.realpathSync(path.resolve(process.argv[1])) === fs.realpathSync(__filename)) {
|
|
await main();
|
|
}
|
|
diff --git a/src/Widgets.types.ts b/src/Widgets.types.ts
|
|
index 0770613..924fa00 100644
|
|
--- a/src/Widgets.types.ts
|
|
+++ b/src/Widgets.types.ts
|
|
@@ -107,6 +107,10 @@ export type LiveActivityEnvironment = {
|
|
* The color scheme of the activity's environment.
|
|
*/
|
|
colorScheme: 'light' | 'dark';
|
|
+ /** The rendering mode supplied by WidgetKit for this presentation. */
|
|
+ widgetRenderingMode?: WidgetRenderingMode;
|
|
+ /** Whether the presentation OS supports Liquid Glass. @platform iOS 26+ */
|
|
+ isLiquidGlassAvailable?: boolean;
|
|
/**
|
|
* Whether the activity is displayed in a context with reduced luminance.
|
|
* @platform iOS 16+
|