149 lines
6.7 KiB
Diff
149 lines
6.7 KiB
Diff
diff --git a/build/Widgets.types.d.ts b/build/Widgets.types.d.ts
|
|
index 15e026868625ce20a3e359e5cc8e5c7e937c4650..f5cc83174ede4fb6e01cbce494f61e088eb4eed8 100644
|
|
--- a/build/Widgets.types.d.ts
|
|
+++ b/build/Widgets.types.d.ts
|
|
@@ -90,6 +90,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 2b4c044b597de7e0fab42dbc47af14d8bb521838..801f0aed65ea2659f221d477dd841787d9146c26 100644
|
|
--- a/ios/Widgets/Utils.swift
|
|
+++ b/ios/Widgets/Utils.swift
|
|
@@ -91,6 +91,10 @@ func getLiveActivityEnvironment(for environment: EnvironmentValues, in context:
|
|
"colorScheme": "\(environment.colorScheme)"
|
|
]
|
|
|
|
+ if #available(iOS 26.0, *) {
|
|
+ env["isLiquidGlassAvailable"] = true
|
|
+ }
|
|
+ env["widgetRenderingMode"] = environment.widgetRenderingMode.description
|
|
env["isLuminanceReduced"] = environment.isLuminanceReduced
|
|
env["isActivityFullscreen"] = environment.isActivityFullscreen
|
|
if #available(iOS 16.2, *) {
|
|
diff --git a/ios/Widgets/WidgetLiveActivity.swift b/ios/Widgets/WidgetLiveActivity.swift
|
|
index 24d4571a52d3ebe9d785b5d049d8e134a149d513..7051c23b17ac91552e5b5c54606c57086c0ebbea 100644
|
|
--- a/ios/Widgets/WidgetLiveActivity.swift
|
|
+++ b/ios/Widgets/WidgetLiveActivity.swift
|
|
@@ -20,53 +20,41 @@ struct LiveActivityAttributes: ActivityAttributes {
|
|
|
|
@available(iOS 16.1, *)
|
|
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)
|
|
@@ -79,11 +67,16 @@ public struct WidgetLiveActivity: Widget {
|
|
|
|
@available(iOS 16.1, *)
|
|
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 {
|
|
@@ -94,10 +87,17 @@ private struct LiveActivitySectionView: View {
|
|
|
|
@available(iOS 16.1, *)
|
|
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/src/Widgets.types.ts b/src/Widgets.types.ts
|
|
index fee5c7475b52218fa0e192a1d347dd32cb0fe1f8..1d3a097b45d8eb5d13e5cedd26f0414caa83a5d6 100644
|
|
--- a/src/Widgets.types.ts
|
|
+++ b/src/Widgets.types.ts
|
|
@@ -104,6 +104,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+
|