From f62aaebaf0285f04ffe5567f2b8f20180439c376 Mon Sep 17 00:00:00 2001 From: Kyle Date: Sun, 18 Jan 2026 01:57:04 +0800 Subject: [PATCH 1/2] Add AsyncImageExample --- Example/SharedExample/ContentView.swift | 3 ++- .../View/Image/AsyncImageExample.swift | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 Example/SharedExample/View/Image/AsyncImageExample.swift diff --git a/Example/SharedExample/ContentView.swift b/Example/SharedExample/ContentView.swift index ca60dd7fd..239fe31f8 100644 --- a/Example/SharedExample/ContentView.swift +++ b/Example/SharedExample/ContentView.swift @@ -10,9 +10,10 @@ import OpenSwiftUI #else import SwiftUI #endif +import Foundation struct ContentView: View { var body: some View { - RepeatAnimationExample() + AsyncImageExample() } } diff --git a/Example/SharedExample/View/Image/AsyncImageExample.swift b/Example/SharedExample/View/Image/AsyncImageExample.swift new file mode 100644 index 000000000..51e519ed4 --- /dev/null +++ b/Example/SharedExample/View/Image/AsyncImageExample.swift @@ -0,0 +1,19 @@ +// +// AsyncImageExample.swift +// Example +// +// Created by Kyle on 1/18/26. +// + +#if OPENSWIFTUI +import OpenSwiftUI +#else +import SwiftUI +#endif +import Foundation + +struct AsyncImageExample: View { + var body: some View { + AsyncImage(url: URL(string: "https://picsum.photos/200")) + } +} From 6a5221837745852db65f16196002d7ca81c50fde Mon Sep 17 00:00:00 2001 From: Kyle Date: Sun, 18 Jan 2026 23:54:00 +0800 Subject: [PATCH 2/2] Update Image+redacted --- .../EnvironmentKeys/RedactionReasons.swift | 35 +++++++++++++++---- .../View/Image/CGImageProvider.swift | 3 +- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/Sources/OpenSwiftUICore/Data/EnvironmentKeys/RedactionReasons.swift b/Sources/OpenSwiftUICore/Data/EnvironmentKeys/RedactionReasons.swift index 42a0090e3..dc2be4797 100644 --- a/Sources/OpenSwiftUICore/Data/EnvironmentKeys/RedactionReasons.swift +++ b/Sources/OpenSwiftUICore/Data/EnvironmentKeys/RedactionReasons.swift @@ -3,10 +3,11 @@ // OpenSwiftUICore // // Audited for 6.5.4 -// Status: Blocked by Image +// Status: Complete // ID: 18671928047E57F039DC339288B6FAFB (SwiftUICore) import OpenAttributeGraphShims +import OpenCoreGraphicsShims // MARK: - RedactionReasons @@ -161,16 +162,38 @@ extension _ViewInputs { } } -// MARK: - Image + redacted [TODO] +// MARK: - Image + redacted extension GraphicsImage { package mutating func redact(in environment: EnvironmentValues) { - _openSwiftUIUnimplementedFailure() + let color = Color.foreground.resolve(in: environment) + contents = .color(color.multiplyingOpacity(by: 0.16)) } } extension Image { - package static let redacted: Image = { - _openSwiftUIUnimplementedFailure() - }() + package static let redacted: Image = Image(RedactedImageProvider()) + + private struct RedactedImageProvider: ImageProvider { + func resolve(in context: ImageResolutionContext) -> Image.Resolved { + let color = Color.foreground.resolve(in: context.environment) + let image = GraphicsImage( + contents: .color(color.multiplyingOpacity(by: 0.16)), + scale: 1.0, + unrotatedPixelSize: CGSize(width: 1, height: 1), + orientation: .up, + isTemplate: false, + resizingInfo: .resizable + ) + return Image.Resolved( + image: image, + decorative: true, + label: nil + ) + } + + func resolveNamedImage(in context: ImageResolutionContext) -> Image.NamedResolved? { + nil + } + } } diff --git a/Sources/OpenSwiftUICore/View/Image/CGImageProvider.swift b/Sources/OpenSwiftUICore/View/Image/CGImageProvider.swift index 845c2c8f2..54d580506 100644 --- a/Sources/OpenSwiftUICore/View/Image/CGImageProvider.swift +++ b/Sources/OpenSwiftUICore/View/Image/CGImageProvider.swift @@ -84,8 +84,7 @@ private struct CGImageProvider: ImageProvider { ) graphicsImage.allowedDynamicRange = context.effectiveAllowedDynamicRange(for: graphicsImage) if context.environment.shouldRedactContent { - let color = Color.foreground.resolve(in: context.environment) - graphicsImage.contents = .color(color.multiplyingOpacity(by: 0.16)) + graphicsImage.redact(in: context.environment) } return Image.Resolved( image: graphicsImage,