Skip to content

Commit 8fb3ab7

Browse files
authored
Add rotate screen support for UIHostingView (#410)
1 parent 316111d commit 8fb3ab7

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

Sources/OpenSwiftUI/Integration/Hosting/UIKit/View/UIHostingView.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ open class _UIHostingView<Content>: UIView, XcodeViewDebugDataProvider where Con
236236
}
237237
let oldValue = super.frame
238238
super.frame = newValue
239-
frameDidChange(oldValue: oldValue)
239+
base.frameDidChange(oldValue: oldValue)
240240
}
241241
}
242242

@@ -250,7 +250,7 @@ open class _UIHostingView<Content>: UIView, XcodeViewDebugDataProvider where Con
250250
}
251251
let oldValue = super.bounds
252252
super.bounds = newValue
253-
frameDidChange(oldValue: oldValue)
253+
base.frameDidChange(oldValue: oldValue)
254254
}
255255
}
256256

@@ -439,10 +439,6 @@ extension _UIHostingView {
439439
func didChangeColorScheme(from oldColorScheme: ColorScheme?) {
440440
// TODO
441441
}
442-
443-
private func frameDidChange(oldValue: CGRect) {
444-
// TODO
445-
}
446442

447443
package var isInSizeTransition: Bool {
448444
_base.isInSizeTransition

Sources/OpenSwiftUI/Integration/Hosting/UIKit/View/UIHostingViewBase.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,12 @@ package class UIHostingViewBase {
460460
// MARK: - UIView related
461461

462462
package func frameDidChange(oldValue: CGRect) {
463-
_openSwiftUIUnimplementedWarning()
463+
guard let uiView, let host, uiView.bounds.size != .zero else {
464+
return
465+
}
466+
var props: ViewRendererHostProperties = [.size, .containerSize]
467+
props.insert(.safeArea)
468+
host.invalidateProperties(props, mayDeferUpdate: false)
464469
}
465470

466471
package func _geometryChanged(_: UnsafeRawPointer, forAncestor: UIView?) {

0 commit comments

Comments
 (0)