Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<EnvironmentVariables>
<EnvironmentVariable
key = "SWIFTUI_PRINT_TREE"
value = "1"
isEnabled = "NO">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "OpenSwiftUIRelease"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@
<EnvironmentVariable
key = "SWIFTUI_PRINT_TREE"
value = "1"
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "OPENSWIFTUI_PRINT_TREE"
value = "1"
isEnabled = "YES">
isEnabled = "NO">
Copy link

Choose a reason for hiding this comment

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

The codebase reads OPENSWIFTUI_PRINT_TREE (e.g. DisplayListViewRenderer/DisplayListViewUpdater), but this scheme now defines SWIFTUI_PRINT_TREE, so enabling it won’t trigger tree printing. Consider aligning the environment variable key (or providing both) so the scheme matches runtime behavior.

Severity: low

Other Locations
  • Example/Example.xcodeproj/xcshareddata/xcschemes/OSUI_Example.xcscheme:70
  • Example/Example.xcodeproj/xcshareddata/xcschemes/SUI_Example.xcscheme:70
  • Example/Example.xcodeproj/xcshareddata/xcschemes/SUI_HostingExample.xcscheme:57

Fix This in Augment

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

</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<EnvironmentVariables>
<EnvironmentVariable
key = ""
value = ""
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "OpenSwiftUIRelease"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<EnvironmentVariables>
<EnvironmentVariable
key = "SWIFTUI_PRINT_TREE"
value = "1"
isEnabled = "NO">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "SwiftUIRelease"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,17 @@
<EnvironmentVariable
key = "SWIFTUI_PRINT_TREE"
value = "1"
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "OPENSWIFTUI_PRINT_TREE"
value = "1"
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
key = "AG_PRINT_CYCLES"
value = "2"
isEnabled = "YES">
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
key = "AG_TRAP_CYCLES"
value = "1"
isEnabled = "YES">
isEnabled = "NO">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
Expand Down
20 changes: 19 additions & 1 deletion Example/OpenSwiftUIUITests/Shape/ShapeUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ struct ShapeUITests {
struct ContentView: View {
var body: some View {
Rectangle()
.fill(Color.red)
.frame(width: 100, height: 100, alignment: .center)
}
}
openSwiftUIAssertSnapshot(of: ContentView())
Expand All @@ -23,8 +25,24 @@ struct ShapeUITests {
struct ContentView: View {
var body: some View {
Circle()
.fill(Color.red)
.frame(width: 100, height: 100, alignment: .center)
}
}
openSwiftUIAssertSnapshot(of: ContentView())
// FIXME
openSwiftUIAssertSnapshot(of: ContentView(), perceptualPrecision: 0.8)
}

@Test
func shadow() {
struct ContentView: View {
var body: some View {
Circle()
.fill(Color.red.shadow(.drop(color: .blue,radius: 5, x: 10, y: 10)))
.frame(width: 100, height: 100, alignment: .center)
}
}
// FIXME
openSwiftUIAssertSnapshot(of: ContentView(), perceptualPrecision: 0.8)
}
}
57 changes: 57 additions & 0 deletions Sources/OpenSwiftUICore/Shape/ShapeStyle/ShadowStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public import Foundation

// MARK: - ShadowStyle

/// A style to use when rendering shadows.
@available(OpenSwiftUI_v4_0, *)
public struct ShadowStyle: Equatable, Sendable {
package struct Kind: OptionSet {
Expand Down Expand Up @@ -64,6 +65,20 @@ public struct ShadowStyle: Equatable, Sendable {
@_spi(Private)
public static let inner: ShadowStyle = .inner(radius: 0)

/// Creates a custom drop shadow style.
///
/// Drop shadows draw behind the source content by blurring,
/// tinting and offsetting its per-pixel alpha values.
///
/// - Parameters:
/// - color: The shadow's color.
/// - radius: The shadow's size.
/// - x: A horizontal offset you use to position the shadow
/// relative to this view.
/// - y: A vertical offset you use to position the shadow
/// relative to this view.
///
/// - Returns: A new shadow style.
public static func drop(
color: Color = .init(.sRGBLinear, white: 0, opacity: 0.33),
radius: CGFloat,
Expand All @@ -76,6 +91,20 @@ public struct ShadowStyle: Equatable, Sendable {
)
}

/// Creates a custom inner shadow style.
///
/// Inner shadows draw on top of the source content by blurring,
/// tinting, inverting and offsetting its per-pixel alpha values.
///
/// - Parameters:
/// - color: The shadow's color.
/// - radius: The shadow's size.
/// - x: A horizontal offset you use to position the shadow
/// relative to this view.
/// - y: A vertical offset you use to position the shadow
/// relative to this view.
///
/// - Returns: A new shadow style.
public static func inner(
color: Color = .init(.sRGBLinear, white: 0, opacity: 0.55),
radius: CGFloat,
Expand Down Expand Up @@ -151,6 +180,17 @@ extension ShadowStyle {

@available(OpenSwiftUI_v4_0, *)
extension ShapeStyle {

/// Applies the specified shadow effect to the shape style.
///
/// For example, you can create a rectangle that adds a drop shadow to
/// the ``ShapeStyle/red`` shape style.
///
/// Rectangle().fill(.red.shadow(.drop(radius: 2, y: 3)))
///
/// - Parameter style: The shadow style to apply.
///
/// - Returns: A new shape style that uses the specified shadow style.
@inlinable
public func shadow(_ style: ShadowStyle) -> some ShapeStyle {
return _ShadowShapeStyle(style: self, shadowStyle: style)
Expand All @@ -159,6 +199,23 @@ extension ShapeStyle {

@available(OpenSwiftUI_v4_0, *)
extension ShapeStyle where Self == AnyShapeStyle {

/// Returns a shape style that applies the specified shadow style to the
/// current style.
///
/// In most contexts the current style is the foreground, but not always.
/// For example, when setting the value of the background style, that
/// becomes the current implicit style.
///
/// The following example creates a circle filled with the current
/// foreground style that uses an inner shadow:
///
/// Circle().fill(.shadow(.inner(radius: 1, y: 1)))
///
/// - Parameter style: The shadow style to apply.
///
/// - Returns: A new shape style based on the current style that uses the
/// specified shadow style.
@_alwaysEmitIntoClient
public static func shadow(_ style: ShadowStyle) -> some ShapeStyle {
return _ShadowShapeStyle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ package struct _ShapeStyle_RenderedShape {
default:
_openSwiftUIUnimplementedFailure()
}
// FIXME
for effect in style.effects {
guard case let .shadow(shadow) = effect.kind else {
continue
}
addEffect(.filter(.shadow(shadow)))
}
_openSwiftUIUnimplementedWarning()
}

Expand Down
Loading