|
| 1 | +diff --git a/build/Widgets.types.d.ts b/build/Widgets.types.d.ts |
| 2 | +index 15e026868625ce20a3e359e5cc8e5c7e937c4650..f5cc83174ede4fb6e01cbce494f61e088eb4eed8 100644 |
| 3 | +--- a/build/Widgets.types.d.ts |
| 4 | ++++ b/build/Widgets.types.d.ts |
| 5 | +@@ -90,6 +90,10 @@ export type LiveActivityEnvironment = { |
| 6 | + * The color scheme of the activity's environment. |
| 7 | + */ |
| 8 | + colorScheme: 'light' | 'dark'; |
| 9 | ++ /** The rendering mode supplied by WidgetKit for this presentation. */ |
| 10 | ++ widgetRenderingMode?: WidgetRenderingMode; |
| 11 | ++ /** Whether the presentation OS supports Liquid Glass. @platform iOS 26+ */ |
| 12 | ++ isLiquidGlassAvailable?: boolean; |
| 13 | + /** |
| 14 | + * Whether the activity is displayed in a context with reduced luminance. |
| 15 | + * @platform iOS 16+ |
| 16 | +diff --git a/ios/Widgets/Utils.swift b/ios/Widgets/Utils.swift |
| 17 | +index 2b4c044b597de7e0fab42dbc47af14d8bb521838..801f0aed65ea2659f221d477dd841787d9146c26 100644 |
| 18 | +--- a/ios/Widgets/Utils.swift |
| 19 | ++++ b/ios/Widgets/Utils.swift |
| 20 | +@@ -91,6 +91,10 @@ func getLiveActivityEnvironment(for environment: EnvironmentValues, in context: |
| 21 | + "colorScheme": "\(environment.colorScheme)" |
| 22 | + ] |
| 23 | + |
| 24 | ++ if #available(iOS 26.0, *) { |
| 25 | ++ env["isLiquidGlassAvailable"] = true |
| 26 | ++ } |
| 27 | ++ env["widgetRenderingMode"] = environment.widgetRenderingMode.description |
| 28 | + env["isLuminanceReduced"] = environment.isLuminanceReduced |
| 29 | + env["isActivityFullscreen"] = environment.isActivityFullscreen |
| 30 | + if #available(iOS 16.2, *) { |
| 31 | +diff --git a/ios/Widgets/WidgetLiveActivity.swift b/ios/Widgets/WidgetLiveActivity.swift |
| 32 | +index 24d4571a52d3ebe9d785b5d049d8e134a149d513..7051c23b17ac91552e5b5c54606c57086c0ebbea 100644 |
| 33 | +--- a/ios/Widgets/WidgetLiveActivity.swift |
| 34 | ++++ b/ios/Widgets/WidgetLiveActivity.swift |
| 35 | +@@ -20,53 +20,41 @@ struct LiveActivityAttributes: ActivityAttributes { |
| 36 | + |
| 37 | + @available(iOS 16.1, *) |
| 38 | + public struct WidgetLiveActivity: Widget { |
| 39 | +- @Environment(\.self) var env |
| 40 | +- |
| 41 | + let widgetContext: AppContext = AppContext() |
| 42 | + |
| 43 | + public init() {} |
| 44 | + |
| 45 | + public var body: some WidgetConfiguration { |
| 46 | + ActivityConfiguration(for: LiveActivityAttributes.self) { context in |
| 47 | +- let nodes = getLiveActivityNodes( |
| 48 | +- forName: context.state.name, |
| 49 | +- props: context.state.props, |
| 50 | +- environment: getLiveActivityEnvironment(for: env, in: context) |
| 51 | +- ) |
| 52 | + // Only apply widgetURL when the activity has one: a hierarchy with more than one |
| 53 | + // widgetURL modifier is undefined behavior, and layouts can set their own through |
| 54 | + // the widgetURL modifier from @expo/ui. |
| 55 | +- let banner = LiveActivityBannerView(context: context, nodes: nodes) |
| 56 | ++ let banner = LiveActivityBannerView(context: context) |
| 57 | + if let url = context.attributes.url.flatMap(URL.init(string:)) { |
| 58 | + banner.widgetURL(url) |
| 59 | + } else { |
| 60 | + banner |
| 61 | + } |
| 62 | + } dynamicIsland: { context in |
| 63 | +- let nodes = getLiveActivityNodes( |
| 64 | +- forName: context.state.name, |
| 65 | +- props: context.state.props, |
| 66 | +- environment: getLiveActivityEnvironment(for: env, in: context) |
| 67 | +- ) |
| 68 | + let island = DynamicIsland { |
| 69 | + DynamicIslandExpandedRegion(.center) { |
| 70 | +- LiveActivitySectionView(context: context, nodes: nodes, sectionName: "expandedCenter") |
| 71 | ++ LiveActivitySectionView(context: context, sectionName: "expandedCenter") |
| 72 | + } |
| 73 | + DynamicIslandExpandedRegion(.leading) { |
| 74 | +- LiveActivitySectionView(context: context, nodes: nodes, sectionName: "expandedLeading") |
| 75 | ++ LiveActivitySectionView(context: context, sectionName: "expandedLeading") |
| 76 | + } |
| 77 | + DynamicIslandExpandedRegion(.trailing) { |
| 78 | +- LiveActivitySectionView(context: context, nodes: nodes, sectionName: "expandedTrailing") |
| 79 | ++ LiveActivitySectionView(context: context, sectionName: "expandedTrailing") |
| 80 | + } |
| 81 | + DynamicIslandExpandedRegion(.bottom) { |
| 82 | +- LiveActivitySectionView(context: context, nodes: nodes, sectionName: "expandedBottom") |
| 83 | ++ LiveActivitySectionView(context: context, sectionName: "expandedBottom") |
| 84 | + } |
| 85 | + } compactLeading: { |
| 86 | +- LiveActivitySectionView(context: context, nodes: nodes, sectionName: "compactLeading") |
| 87 | ++ LiveActivitySectionView(context: context, sectionName: "compactLeading") |
| 88 | + } compactTrailing: { |
| 89 | +- LiveActivitySectionView(context: context, nodes: nodes, sectionName: "compactTrailing") |
| 90 | ++ LiveActivitySectionView(context: context, sectionName: "compactTrailing") |
| 91 | + } minimal: { |
| 92 | +- LiveActivitySectionView(context: context, nodes: nodes, sectionName: "minimal") |
| 93 | ++ LiveActivitySectionView(context: context, sectionName: "minimal") |
| 94 | + } |
| 95 | + if let url = context.attributes.url.flatMap(URL.init(string:)) { |
| 96 | + return island.widgetURL(url) |
| 97 | +@@ -79,11 +67,16 @@ public struct WidgetLiveActivity: Widget { |
| 98 | + |
| 99 | + @available(iOS 16.1, *) |
| 100 | + private struct LiveActivitySectionView: View { |
| 101 | ++ @Environment(\.self) var env |
| 102 | + let context: ActivityViewContext<LiveActivityAttributes> |
| 103 | +- let nodes: [String: Any] |
| 104 | + let sectionName: String |
| 105 | + |
| 106 | + var body: some View { |
| 107 | ++ let nodes = getLiveActivityNodes( |
| 108 | ++ forName: context.state.name, |
| 109 | ++ props: context.state.props, |
| 110 | ++ environment: getLiveActivityEnvironment(for: env, in: context) |
| 111 | ++ ) |
| 112 | + if let node = nodes[sectionName] as? [String: Any] { |
| 113 | + WidgetsDynamicView(name: context.activityID, kind: .liveActivity, node: node) |
| 114 | + } else { |
| 115 | +@@ -94,10 +87,17 @@ private struct LiveActivitySectionView: View { |
| 116 | + |
| 117 | + @available(iOS 16.1, *) |
| 118 | + private struct LiveActivityBannerView: View { |
| 119 | ++ // Read inside the rendered view: Widget-level values do not include the |
| 120 | ++ // presentation's color scheme, rendering mode, or reduced-luminance state. |
| 121 | ++ @Environment(\.self) var env |
| 122 | + var context: ActivityViewContext<LiveActivityAttributes> |
| 123 | +- let nodes: [String: Any] |
| 124 | + |
| 125 | + var body: some View { |
| 126 | ++ let nodes = getLiveActivityNodes( |
| 127 | ++ forName: context.state.name, |
| 128 | ++ props: context.state.props, |
| 129 | ++ environment: getLiveActivityEnvironment(for: env, in: context) |
| 130 | ++ ) |
| 131 | + if #available(iOS 18.0, *) { |
| 132 | + LiveActivityBanner(context: context, nodes: nodes) |
| 133 | + } else if let node = nodes["banner"] as? [String: Any] { |
| 134 | +diff --git a/src/Widgets.types.ts b/src/Widgets.types.ts |
| 135 | +index fee5c7475b52218fa0e192a1d347dd32cb0fe1f8..1d3a097b45d8eb5d13e5cedd26f0414caa83a5d6 100644 |
| 136 | +--- a/src/Widgets.types.ts |
| 137 | ++++ b/src/Widgets.types.ts |
| 138 | +@@ -104,6 +104,10 @@ export type LiveActivityEnvironment = { |
| 139 | + * The color scheme of the activity's environment. |
| 140 | + */ |
| 141 | + colorScheme: 'light' | 'dark'; |
| 142 | ++ /** The rendering mode supplied by WidgetKit for this presentation. */ |
| 143 | ++ widgetRenderingMode?: WidgetRenderingMode; |
| 144 | ++ /** Whether the presentation OS supports Liquid Glass. @platform iOS 26+ */ |
| 145 | ++ isLiquidGlassAvailable?: boolean; |
| 146 | + /** |
| 147 | + * Whether the activity is displayed in a context with reduced luminance. |
| 148 | + * @platform iOS 16+ |
0 commit comments