Skip to content

Add ShadowEffect support#779

Merged
Kyle-Ye merged 2 commits intomainfrom
feature/shadow_effect
Feb 8, 2026
Merged

Add ShadowEffect support#779
Kyle-Ye merged 2 commits intomainfrom
feature/shadow_effect

Conversation

@Kyle-Ye
Copy link
Collaborator

@Kyle-Ye Kyle-Ye commented Feb 8, 2026

Summary

  • Add _ShadowEffect as an EnvironmentalModifier with _Resolved inner type conforming to RendererEffect
  • Add View.shadow(color:radius:x:y:) view modifier
  • Add shadow effect UI snapshot tests
  • Enable previously disabled clip shape tests

Add _ShadowEffect as an EnvironmentalModifier with a _Resolved inner
type conforming to RendererEffect. Includes View.shadow(color:radius:x:y:)
convenience modifier.
@augmentcode
Copy link

augmentcode bot commented Feb 8, 2026

🤖 Augment PR Summary

Summary: This PR adds view-level shadow support to OpenSwiftUI by introducing a dedicated shadow renderer effect and exposing a SwiftUI-compatible shadow modifier.

Changes:

  • Adds _ShadowEffect as an EnvironmentalModifier that resolves into a RendererEffect applying GraphicsFilter.shadow.
  • Introduces View.shadow(color:radius:x:y:) with the expected defaults for color and offset.
  • Adds UI snapshot tests covering default shadows, custom colors, and offsets.
  • Re-enables previously disabled clip-shape renderer snapshot tests.
  • Removes an outdated TestingHost note related to key-window hierarchy snapshots.

Technical Notes: Shadow styling is resolved via Color.resolve(in:) and emitted into the display list as a shadow filter effect.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 3 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

}

@available(OpenSwiftUI_v4_0, *)
public static var _requiresMainThread: Bool {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EnvironmentalModifier._requiresMainThread is available starting OpenSwiftUI_v3_0, but this override is only available from OpenSwiftUI_v4_0, so on v3 the default true may still apply and prevent async updates. Also, the instance _requiresMainThread property doesn’t appear to be referenced elsewhere, so it might be dead/unintentional.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

public struct _Resolved: RendererEffect {
package var style: ResolvedShadowStyle

public typealias AnimatableData = AnimatablePair<AnimatablePair<Float, AnimatablePair<Float, AnimatablePair<Float, Float>>>, AnimatablePair<CGFloat, CGSize.AnimatableData>>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_Resolved.AnimatableData is spelled out explicitly rather than using ResolvedShadowStyle.AnimatableData, which tightly couples this effect to the current internal shape of Color.Resolved.AnimatableData. If that underlying type changes, animations could break or this could stop compiling even though ResolvedShadowStyle still conforms to Animatable.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@inlinable
nonisolated public func shadow(
color: Color = Color(.sRGBLinear, white: 0, opacity: 0.33),
radius: CGFloat,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The public shadow(... radius:) API forwards radius directly into ResolvedShadowStyle, but ResolvedShadowStyle.insets assumes radius is non-negative (it multiplies by -2.8). If callers pass a negative radius, this can produce unexpected insets/rendering, so it may be worth guarding or documenting the valid range.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@codecov
Copy link

codecov bot commented Feb 8, 2026

Codecov Report

❌ Patch coverage is 0% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 26.20%. Comparing base (7408fcf) to head (5e0445c).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...iftUICore/Render/RendererEffect/ShadowEffect.swift 0.00% 28 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #779       +/-   ##
===========================================
+ Coverage   13.14%   26.20%   +13.06%     
===========================================
  Files         619      650       +31     
  Lines       36745    40232     +3487     
===========================================
+ Hits         4829    10542     +5713     
+ Misses      31916    29690     -2226     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Kyle-Ye Kyle-Ye merged commit 72e5678 into main Feb 8, 2026
11 of 13 checks passed
@Kyle-Ye Kyle-Ye deleted the feature/shadow_effect branch February 8, 2026 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant