Skip to content

Commit 7d0a030

Browse files
committed
changes
dismissSheet now expects non optional Window rolled back proposed size try
1 parent b3cfc04 commit 7d0a030

File tree

5 files changed

+10
-18
lines changed

5 files changed

+10
-18
lines changed

Sources/AppKitBackend/AppKitBackend.swift

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,18 +1724,13 @@ public final class AppKitBackend: AppBackend {
17241724
print("warning: Cannot show sheet without a parent window")
17251725
return
17261726
}
1727-
// critical sheets stack
1728-
// beginSheet only shows a nested
1729-
// sheet after its parent gets dismissed
1727+
// Critical sheets stack. beginSheet only shows a nested sheet
1728+
// after its parent gets dismissed.
17301729
window.beginCriticalSheet(sheet)
17311730
}
17321731

1733-
public func dismissSheet(_ sheet: NSCustomSheet, window: NSCustomWindow?) {
1734-
if let window {
1735-
window.endSheet(sheet)
1736-
} else {
1737-
NSApplication.shared.stopModal()
1738-
}
1732+
public func dismissSheet(_ sheet: NSCustomSheet, window: NSCustomWindow) {
1733+
window.endSheet(sheet)
17391734
}
17401735

17411736
public func setPresentationBackground(of sheet: NSCustomSheet, to color: Color) {

Sources/GtkBackend/GtkBackend.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,7 @@ public final class GtkBackend: AppBackend {
16851685
sheet.present()
16861686
}
16871687

1688-
public func dismissSheet(_ sheet: Gtk.Window, window: ApplicationWindow?) {
1688+
public func dismissSheet(_ sheet: Gtk.Window, window: ApplicationWindow) {
16891689
let key: OpaquePointer = OpaquePointer(sheet.widgetPointer)
16901690
if let ctx = sheetContexts[key] {
16911691
ctx.isProgrammaticDismiss = true

Sources/SwiftCrossUI/Backend/AppBackend.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,6 @@ public protocol AppBackend: Sendable {
612612
/// Updates the content and appearance of a sheet.
613613
func updateSheet(
614614
_ sheet: Sheet,
615-
proposedSize: SIMD2<Int>,
616615
onDismiss: @escaping () -> Void
617616
)
618617

@@ -632,7 +631,7 @@ public protocol AppBackend: Sendable {
632631

633632
/// Dismisses a sheet programmatically.
634633
/// Gets used by the ``View/sheet`` modifier to close a sheet.
635-
func dismissSheet(_ sheet: Sheet, window: Window?)
634+
func dismissSheet(_ sheet: Sheet, window: Window)
636635

637636
/// Get the dimensions of a sheet
638637
func sizeOf(_ sheet: Sheet) -> SIMD2<Int>
@@ -1267,7 +1266,6 @@ extension AppBackend {
12671266

12681267
public func updateSheet(
12691268
_ sheet: Sheet,
1270-
proposedSize: SIMD2<Int>,
12711269
onDismiss: @escaping () -> Void
12721270
) {
12731271
todo()
@@ -1286,7 +1284,7 @@ extension AppBackend {
12861284
todo()
12871285
}
12881286

1289-
public func dismissSheet(_ sheet: Sheet, window: Window?) {
1287+
public func dismissSheet(_ sheet: Sheet, window: Window) {
12901288
todo()
12911289
}
12921290

Sources/SwiftCrossUI/Views/Modifiers/SheetModifier.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,13 @@ struct SheetModifier<Content: View, SheetContent: View>: TypeSafeView {
9191

9292
let _ = children.sheetContentNode.update(
9393
with: sheetContent(),
94-
proposedSize: dryRunResult.size.idealSize,
94+
proposedSize: backend.sizeOf(sheet),
9595
environment: sheetEnvironment,
9696
dryRun: false
9797
)
9898

9999
backend.updateSheet(
100100
sheet,
101-
proposedSize: dryRunResult.size.idealSize,
102101
onDismiss: handleDismiss
103102
)
104103

@@ -134,7 +133,7 @@ struct SheetModifier<Content: View, SheetContent: View>: TypeSafeView {
134133
} else if !isPresented.wrappedValue && children.sheet != nil {
135134
backend.dismissSheet(
136135
children.sheet as! Backend.Sheet,
137-
window: .some(environment.window! as! Backend.Window)
136+
window: environment.window! as! Backend.Window
138137
)
139138
children.sheet = nil
140139
}

Sources/UIKitBackend/UIKitBackend+Sheet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extension UIKitBackend {
2323
topController?.present(sheet, animated: true)
2424
}
2525

26-
public func dismissSheet(_ sheet: CustomSheet, window: UIWindow?) {
26+
public func dismissSheet(_ sheet: CustomSheet, window: UIWindow) {
2727
// If this sheet has a presented view controller (nested sheet), dismiss it first
2828
if let presentedVC = sheet.presentedViewController {
2929
presentedVC.dismiss(animated: false) { [weak sheet] in

0 commit comments

Comments
 (0)