Skip to content

Commit c64eb0c

Browse files
committed
Revert "Fix PlatformView layoutSubviews on AppKit"
This reverts commit b7ef214.
1 parent b7ef214 commit c64eb0c

File tree

2 files changed

+2
-52
lines changed

2 files changed

+2
-52
lines changed

Sources/BuddyPlatform/PlatformTypes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public typealias PlatformImage = NSImage
6161
public typealias PlatformColor = NSColor
6262

6363
/// `UIView/NSView` alias for platform-agnostic code.
64-
open class PlatformView: NSView { }
64+
public typealias PlatformView = NSView
6565

6666
/// `UIViewController/NSViewController` alias for platform-agnostic code.
6767
public typealias PlatformViewController = NSViewController

Sources/BuddyPlatform/PlatformView+Layer.swift

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#if !os(watchOS)
2-
import SwiftUI
32

43
#if os(macOS)
54
import AppKit
@@ -32,13 +31,9 @@ import AppKit
3231
/// - note: Check out ``PlatformWindowScene`` for details on how this behaves in AppKit.
3332
open var hostingWindowScene: PlatformWindowScene? { window?.screen }
3433

35-
open override func layout() {
36-
layoutSubviews()
37-
}
38-
3934
/// This offers a place to override `layoutSubviews` for both UIKit and AppKit, since the method name on `NSView` is just `layout`.
4035
open func layoutSubviews() {
41-
super.layout()
36+
layout()
4237
}
4338

4439
/// This offers a place to override `didMoveToSuperview` for both UIKit and AppKit, since the method name on `NSView` is different.
@@ -81,48 +76,3 @@ import UIKit
8176
#endif // os(macOS)
8277

8378
#endif // !os(watchOS)
84-
85-
#if DEBUG
86-
private final class TestView: PlatformView {
87-
override func layoutSubviews() {
88-
super.layoutSubviews()
89-
90-
let testLayer: CALayer
91-
92-
if let layer = platformLayer.sublayers?.first {
93-
testLayer = layer
94-
} else {
95-
testLayer = CALayer()
96-
testLayer.backgroundColor = PlatformColor.systemGreen.cgColor
97-
platformLayer.addSublayer(testLayer)
98-
}
99-
100-
101-
CATransaction.begin()
102-
CATransaction.setDisableActions(true)
103-
CATransaction.setAnimationDuration(0)
104-
105-
testLayer.bounds = CGRect(
106-
x: 0,
107-
y: 0,
108-
width: platformLayer.bounds.width * 0.5,
109-
height: platformLayer.bounds.height * 0.5
110-
)
111-
testLayer.position = CGPoint(
112-
x: platformLayer.frame.midX,
113-
y: platformLayer.frame.midY
114-
)
115-
116-
platformLayer.backgroundColor = PlatformColor.systemBlue.cgColor
117-
118-
CATransaction.commit()
119-
120-
print(#function, bounds, "testLayer:", testLayer.bounds)
121-
}
122-
}
123-
124-
@available(macOS 15.0, iOS 18.0, *)
125-
#Preview {
126-
TestView(frame: .init(x: 0, y: 0, width: 200, height: 200))
127-
}
128-
#endif

0 commit comments

Comments
 (0)