Skip to content

Commit e19e9f6

Browse files
authored
Bookings: Fix styling for booking list on iOS 18 (#16366)
2 parents 2e81b4c + b5d2f50 commit e19e9f6

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Modules/Sources/WooFoundation/ViewModifiers/View+Conditionals.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ public extension View {
1111
return self
1212
}
1313

14+
/// Applies modifiers within a closure.
15+
/// Helpful for setting different modifiers conditionally (e.g. OS versions).
16+
///
17+
func apply<V: View>(@ViewBuilder _ block: (Self) -> V) -> V {
18+
block(self)
19+
}
20+
1421
/// Applies the given transform if the given condition evaluates to `true`.
1522
/// - Parameters:
1623
/// - condition: The condition to evaluate.

WooCommerce/Classes/Bookings/BookingList/BookingListView.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,21 @@ private extension BookingListView {
120120
} header: {
121121
header
122122
.listRowInsets(EdgeInsets())
123+
.textCase(nil)
123124
}
124125
}
125-
.listStyle(.plain)
126+
.apply {
127+
/// Plain list style in iOS prior to 26.0 comes with extra spacing at the top of header.
128+
/// Use grouped style for these versions instead.
129+
/// Grouped list style doesn't pin header at the top, we have to accept this.
130+
if #available(iOS 26.0, *) {
131+
$0.listStyle(.plain)
132+
} else {
133+
$0.listStyle(.grouped)
134+
}
135+
}
136+
.listStyle(.grouped)
137+
.scrollContentBackground(.hidden)
126138
.listSectionSeparator(.hidden, edges: .top)
127139
.background(Color(.listBackground))
128140
.refreshable {

0 commit comments

Comments
 (0)