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
3 changes: 2 additions & 1 deletion Example/SharedExample/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import OpenSwiftUI
#else
import SwiftUI
#endif
import Foundation

struct ContentView: View {
var body: some View {
RepeatAnimationExample()
AsyncImageExample()
}
}
19 changes: 19 additions & 0 deletions Example/SharedExample/View/Image/AsyncImageExample.swift
Original file line number Diff line number Diff line change
@@ -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"))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
}
}
}
3 changes: 1 addition & 2 deletions Sources/OpenSwiftUICore/View/Image/CGImageProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading