Skip to content

Commit 022274b

Browse files
committed
mostly comment changes
1 parent 8c9d96f commit 022274b

File tree

9 files changed

+53
-55
lines changed

9 files changed

+53
-55
lines changed

Sources/GtkBackend/GtkBackend.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1595,7 +1595,7 @@ public final class GtkBackend: AppBackend {
15951595
public func updateSheet(_ sheet: Gtk.Window, onDismiss: @escaping () -> Void) {
15961596
let key: OpaquePointer = OpaquePointer(sheet.widgetPointer)
15971597

1598-
//add a slight border to not be just a flat corner
1598+
// Add a slight border to not be just a flat corner
15991599
sheet.css.set(property: .border(color: SwiftCrossUI.Color.gray.gtkColor, width: 1))
16001600

16011601
let ctx = getOrCreateSheetContext(for: sheet)

Sources/SwiftCrossUI/Backend/AppBackend.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ public protocol AppBackend: Sendable {
667667
/// - visibility: visibility of the drag indicator (visible or hidden)
668668
func setPresentationDragIndicatorVisibility(
669669
of sheet: Sheet,
670-
to visibility: PresentationDragIndicatorVisibility
670+
to visibility: Visibility
671671
)
672672

673673
/// Sets the background color for a sheet presentation.
@@ -1297,7 +1297,7 @@ extension AppBackend {
12971297
}
12981298

12991299
public func setPresentationDragIndicatorVisibility(
1300-
of sheet: Sheet, to visibility: PresentationDragIndicatorVisibility
1300+
of sheet: Sheet, to visibility: Visibility
13011301
) {
13021302
ignored()
13031303
}

Sources/SwiftCrossUI/Values/PresentationDetent.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ public enum PresentationDetent: Sendable, Hashable {
1111
/// - Parameter fraction: A value between 0 and 1 representing the fraction of available height.
1212
case fraction(Double)
1313

14-
/// A detent at a specific fixed height in pixels.
15-
/// falling back to medium on iOS 15
14+
/// A detent at a specific fixed height in points.
15+
/// Falls back to medium on iOS 15
1616
/// - Parameter height: The height
1717
case height(Double)
1818
}

Sources/SwiftCrossUI/Values/PresentationDragIndicatorVisibility.swift

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public enum Visibility: Sendable {
2+
case automatic, hidden, visible
3+
}

Sources/SwiftCrossUI/ViewGraph/PreferenceValues.swift

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,26 @@ public struct PreferenceValues: Sendable {
1212

1313
public var onOpenURL: (@Sendable @MainActor (URL) -> Void)?
1414

15-
/// The available detents for a sheet presentation. Only applies to the top-level view in a sheet.
15+
/// The available detents for a sheet presentation. Applies to enclosing sheets.
1616
public var presentationDetents: [PresentationDetent]?
1717

18-
/// The corner radius for a sheet presentation. Only applies to the top-level view in a sheet.
18+
/// The corner radius for a sheet presentation. Applies to enclosing sheets.
1919
public var presentationCornerRadius: Double?
2020

21-
/// The drag indicator visibility for a sheet presentation. Only applies to the top-level view in a sheet.
22-
public var presentationDragIndicatorVisibility: PresentationDragIndicatorVisibility?
21+
/// The drag indicator visibility for a sheet presentation. Applies to enclosing sheets.
22+
public var presentationDragIndicatorVisibility: Visibility?
2323

24-
/// The backgroundcolor of a sheet. Only applies to the top-level view in a sheet
24+
/// The backgroundcolor of a sheet. Applies to enclosing sheets.
2525
public var presentationBackground: Color?
26-
26+
27+
/// Controls whether the user can interactively dismiss enclosing sheets. Applies to enclosing sheets.
2728
public var interactiveDismissDisabled: Bool?
2829

2930
public init(
3031
onOpenURL: (@Sendable @MainActor (URL) -> Void)?,
3132
presentationDetents: [PresentationDetent]? = nil,
3233
presentationCornerRadius: Double? = nil,
33-
presentationDragIndicatorVisibility: PresentationDragIndicatorVisibility? = nil,
34+
presentationDragIndicatorVisibility: Visibility? = nil,
3435
presentationBackground: Color? = nil,
3536
interactiveDismissDisabled: Bool? = nil
3637
) {
@@ -53,12 +54,13 @@ public struct PreferenceValues: Sendable {
5354
}
5455
}
5556

56-
// For presentation modifiers, take the first (top-level) value only
57-
// This ensures only the root view's presentation modifiers apply to the sheet
58-
presentationDetents = children.first?.presentationDetents
59-
presentationCornerRadius = children.first?.presentationCornerRadius
60-
presentationDragIndicatorVisibility = children.first?.presentationDragIndicatorVisibility
61-
presentationBackground = children.first?.presentationBackground
62-
interactiveDismissDisabled = children.first?.interactiveDismissDisabled
57+
// For presentation modifiers, take the outer-most value (using child ordering to break ties).
58+
presentationDetents = children.compactMap { $0.presentationDetents }.first
59+
presentationCornerRadius = children.compactMap { $0.presentationCornerRadius }.first
60+
presentationDragIndicatorVisibility = children.compactMap {
61+
$0.presentationDragIndicatorVisibility
62+
}.first
63+
presentationBackground = children.compactMap { $0.presentationBackground }.first
64+
interactiveDismissDisabled = children.compactMap { $0.interactiveDismissDisabled }.first
6365
}
6466
}

Sources/SwiftCrossUI/Views/Modifiers/PresentationModifiers.swift

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
extension View {
22
/// Sets the available detents (heights) for a sheet presentation.
33
///
4-
/// This modifier only affects the sheet presentation itself when applied to the
5-
/// top-level view within a sheet. It allows users to resize the sheet to different
6-
/// predefined heights.
4+
/// This modifier only affects the sheet presentation itself.
5+
/// It allows users to resize the sheet to different predefined heights.
76
///
8-
/// supported platforms: iOS (ignored on unsupported platforms)
9-
/// ignored on: older than iOS 15
10-
/// fraction and height fall back to medium on iOS 15 and work as you'd expect on >=16
7+
/// - Supported platforms: iOS 15+ (ignored on unsupported platforms)
8+
/// - `.fraction` and `.height` fall back to `.medium` on iOS 15 and earlier
119
///
1210
/// - Parameter detents: A set of detents that the sheet can be resized to.
1311
/// - Returns: A view with the presentation detents preference set.
@@ -17,50 +15,47 @@ extension View {
1715

1816
/// Sets the corner radius for a sheet presentation.
1917
///
20-
/// This modifier only affects the sheet presentation itself when applied to the
21-
/// top-level view within a sheet. It does not affect the content's corner radius.
18+
/// This modifier only affects the sheet presentation itself.
19+
/// It does not affect the content's corner radius.
2220
///
23-
/// supported platforms: iOS 15+, Gtk4 (ignored on unsupported platforms)
21+
/// - Supported platforms: iOS 15+, Gtk4 (ignored on unsupported platforms)
2422
///
25-
/// - Parameter radius: The corner radius in pixels.
23+
/// - Parameter radius: The corner radius in points.
2624
/// - Returns: A view with the presentation corner radius preference set.
2725
public func presentationCornerRadius(_ radius: Double) -> some View {
2826
preference(key: \.presentationCornerRadius, value: radius)
2927
}
3028

3129
/// Sets the visibility of a sheet's drag indicator.
3230
///
33-
/// This modifier only affects the sheet presentation itself when applied to the
34-
/// top-level view within a sheet.
31+
/// This modifier only affects the sheet presentation itself.
3532
///
36-
/// supported platforms: iOS 15+ (ignored on unsupported platforms)
33+
/// - Supported platforms: iOS 15+ (ignored on unsupported platforms)
3734
///
38-
/// - Parameter visibiliy: visible or hidden
39-
/// - Returns: A view with the presentation corner radius preference set.
35+
/// - Parameter visibility: visible or hidden
36+
/// - Returns: A view with the presentationDragIndicatorVisibility preference set.
4037
public func presentationDragIndicatorVisibility(
41-
_ visibility: PresentationDragIndicatorVisibility
38+
_ visibility: Visibility
4239
) -> some View {
4340
preference(key: \.presentationDragIndicatorVisibility, value: visibility)
4441
}
4542

4643
/// Sets the background of a sheet.
4744
///
48-
/// This modifier only affects the sheet presentation itself when applied to the
49-
/// top-level view within a sheet.
45+
/// This modifier only affects the sheet presentation itself.
5046
///
5147
/// - Parameter color: the background color
52-
/// - Returns: A view with the presentation corner radius preference set.
48+
/// - Returns: A view with the presentationBackground preference set.
5349
public func presentationBackground(_ color: Color) -> some View {
5450
preference(key: \.presentationBackground, value: color)
5551
}
5652

57-
/// Sets wether the user should be able to dismiss the sheet themself.
53+
/// Sets whether the user should be able to dismiss the sheet themself.
5854
///
59-
/// This modifier only affects the sheet presentation itself when applied to the
60-
/// top-level view within a sheet.
55+
/// This modifier only affects the sheet presentation itself.
6156
///
62-
/// - Parameter isDisabled: is it disabled
63-
/// - Returns: A view with the presentation corner radius preference set.
57+
/// - Parameter isDisabled: Whether interactive dismissal is disabled
58+
/// - Returns: A view with the interactiveDismissDisabled preference set.
6459
public func interactiveDismissDisabled(_ isDisabled: Bool = true) -> some View {
6560
preference(key: \.interactiveDismissDisabled, value: isDisabled)
6661
}

Sources/SwiftCrossUI/Views/Modifiers/SheetModifier.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
extension View {
2-
/// Presents a conditional modal overlay
3-
/// onDismiss optional handler gets executed before
4-
/// dismissing the sheet
2+
/// Presents a conditional modal overlay. `onDismiss` gets invoked when the sheet is dismissed.
53
public func sheet<SheetContent: View>(
64
isPresented: Binding<Bool>, onDismiss: (() -> Void)? = nil,
75
@ViewBuilder content: @escaping () -> SheetContent
86
) -> some View {
97
SheetModifier(
10-
isPresented: isPresented, body: TupleView1(self), onDismiss: onDismiss,
11-
sheetContent: content)
8+
isPresented: isPresented,
9+
body: TupleView1(self),
10+
onDismiss: onDismiss,
11+
sheetContent: content
12+
)
1213
}
1314
}
1415

Sources/UIKitBackend/UIKitBackend+Sheet.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ extension UIKitBackend {
7575
} else {
7676
#if DEBUG
7777
print(
78-
"your current OS Version doesn't support variable sheet heights.\n Setting presentationDetents is only available from iOS 15.0"
78+
"your current OS Version doesn't support variable sheet heights. Setting presentationDetents is only available from iOS 15.0"
7979
)
8080
#endif
8181
}
@@ -91,14 +91,14 @@ extension UIKitBackend {
9191
} else {
9292
#if DEBUG
9393
print(
94-
"your current OS Version doesn't support variable sheet corner radii.\n Setting them is only available from iOS 15.0"
94+
"your current OS Version doesn't support variable sheet corner radii. Setting them is only available from iOS 15.0"
9595
)
9696
#endif
9797
}
9898
}
9999

100100
public func setPresentationDragIndicatorVisibility(
101-
of sheet: Sheet, to visibility: PresentationDragIndicatorVisibility
101+
of sheet: Sheet, to visibility: Visibility
102102
) {
103103
if #available(iOS 15.0, *) {
104104
#if !os(visionOS)
@@ -109,7 +109,7 @@ extension UIKitBackend {
109109
} else {
110110
#if DEBUG
111111
print(
112-
"Your current OS Version doesn't support setting sheet drag indicator visibility.\n Setting this is only available from iOS 15.0"
112+
"Your current OS Version doesn't support setting sheet drag indicator visibility. Setting this is only available from iOS 15.0"
113113
)
114114
#endif
115115
}

0 commit comments

Comments
 (0)