From f022e6b959bdf8d9e0f77dfced45cae0097dd1ea Mon Sep 17 00:00:00 2001 From: Kyle Date: Sat, 17 May 2025 16:45:30 +0800 Subject: [PATCH] Update Private API for CoreAnimation --- .../Render/UIKit/UIViewPlatformViewDefinition.swift | 6 +++--- .../Shims/CoreAnimation/CoreAnimation_Private.h | 4 +--- .../Shims/CoreAnimation/CoreAnimation_Private.m | 11 +++-------- .../Shims/CoreAnimationPrivateTests.swift | 12 ++++++++---- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Sources/OpenSwiftUI/Integration/Render/UIKit/UIViewPlatformViewDefinition.swift b/Sources/OpenSwiftUI/Integration/Render/UIKit/UIViewPlatformViewDefinition.swift index 8fca851b..699efd7b 100644 --- a/Sources/OpenSwiftUI/Integration/Render/UIKit/UIViewPlatformViewDefinition.swift +++ b/Sources/OpenSwiftUI/Integration/Render/UIKit/UIViewPlatformViewDefinition.swift @@ -43,12 +43,12 @@ final class UIViewPlatformViewDefinition: PlatformViewDefinition, @unchecked Sen view.layer.anchorPoint = .zero switch kind { case .color, .image, .shape: - view.layer.setAllowsEdgeAntialiasing(true) + view.layer.allowsEdgeAntialiasing = true break case .geometry, .projection, .affine3D, .mask, .platformEffect: let layer = view.layer - layer.setAllowsGroupOpacity(false) - layer.setAllowsGroupBlending(false) + layer.allowsGroupOpacity = false + layer.allowsGroupBlending = false break default: break diff --git a/Sources/OpenSwiftUI_SPI/Shims/CoreAnimation/CoreAnimation_Private.h b/Sources/OpenSwiftUI_SPI/Shims/CoreAnimation/CoreAnimation_Private.h index 1b7c7027..d849e6c5 100644 --- a/Sources/OpenSwiftUI_SPI/Shims/CoreAnimation/CoreAnimation_Private.h +++ b/Sources/OpenSwiftUI_SPI/Shims/CoreAnimation/CoreAnimation_Private.h @@ -15,9 +15,7 @@ OPENSWIFTUI_ASSUME_NONNULL_BEGIN @interface CALayer (OpenSwiftUI_SPI) @property (nonatomic, assign, readonly) BOOL hasBeenCommitted_openswiftui_safe_wrapper OPENSWIFTUI_SWIFT_NAME(hasBeenCommitted); -- (void)setAllowsEdgeAntialiasing_openswiftui_safe_wrapper:(BOOL)allows OPENSWIFTUI_SWIFT_NAME(setAllowsEdgeAntialiasing(_:)); -- (void)setAllowsGroupOpacity_openswiftui_safe_wrapper:(BOOL)allows OPENSWIFTUI_SWIFT_NAME(setAllowsGroupOpacity(_:)); -- (void)setAllowsGroupBlending_openswiftui_safe_wrapper:(BOOL)allows OPENSWIFTUI_SWIFT_NAME(setAllowsGroupBlending(_:)); +@property (nonatomic, assign) BOOL allowsGroupBlending_openswiftui_safe_wrapper OPENSWIFTUI_SWIFT_NAME(allowsGroupBlending); @property (nonatomic, assign) uint64_t openSwiftUI_viewTestProperties; @end diff --git a/Sources/OpenSwiftUI_SPI/Shims/CoreAnimation/CoreAnimation_Private.m b/Sources/OpenSwiftUI_SPI/Shims/CoreAnimation/CoreAnimation_Private.m index c81a74fa..85dc7de6 100644 --- a/Sources/OpenSwiftUI_SPI/Shims/CoreAnimation/CoreAnimation_Private.m +++ b/Sources/OpenSwiftUI_SPI/Shims/CoreAnimation/CoreAnimation_Private.m @@ -16,14 +16,9 @@ - (BOOL)hasBeenCommitted_openswiftui_safe_wrapper { return func(self, selector); } -- (void)setAllowsEdgeAntialiasing_openswiftui_safe_wrapper:(BOOL)allows { - OPENSWIFTUI_SAFE_WRAPPER_IMP(void, @"setAllowsEdgeAntialiasing:", , BOOL); - func(self, selector, allows); -} - -- (void)setAllowsGroupOpacity_openswiftui_safe_wrapper:(BOOL)allows { - OPENSWIFTUI_SAFE_WRAPPER_IMP(void, @"setAllowsGroupOpacity:", , BOOL); - func(self, selector, allows); +- (BOOL)allowsGroupBlending_openswiftui_safe_wrapper { + OPENSWIFTUI_SAFE_WRAPPER_IMP(BOOL, @"allowsGroupBlending", NO); + return func(self, selector); } - (void)setAllowsGroupBlending_openswiftui_safe_wrapper:(BOOL)allows { diff --git a/Tests/OpenSwiftUI_SPITests/Shims/CoreAnimationPrivateTests.swift b/Tests/OpenSwiftUI_SPITests/Shims/CoreAnimationPrivateTests.swift index beda59a1..3ed70726 100644 --- a/Tests/OpenSwiftUI_SPITests/Shims/CoreAnimationPrivateTests.swift +++ b/Tests/OpenSwiftUI_SPITests/Shims/CoreAnimationPrivateTests.swift @@ -12,10 +12,14 @@ struct CoreAnimationPrivateTests { func layer() { let layer = CALayer() #expect(layer.hasBeenCommitted == false) - layer.setAllowsEdgeAntialiasing(true) - layer.setAllowsGroupOpacity(true) - layer.setAllowsGroupBlending(true) - + + #expect(layer.allowsGroupBlending == true) + layer.allowsGroupBlending = false + #expect(layer.allowsGroupBlending == false) + layer.allowsGroupBlending = true + #expect(layer.allowsGroupBlending == true) + + #expect(layer.openSwiftUI_viewTestProperties == 0) layer.openSwiftUI_viewTestProperties = 42 #expect(layer.openSwiftUI_viewTestProperties == 42) }