Skip to content

Commit b5d2f50

Browse files
committed
Set grouped list style for iOS lower than 26
1 parent e893147 commit b5d2f50

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,16 @@ private extension BookingListView {
123123
.textCase(nil)
124124
}
125125
}
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+
}
126136
.listStyle(.grouped)
127137
.scrollContentBackground(.hidden)
128138
.listSectionSeparator(.hidden, edges: .top)

0 commit comments

Comments
 (0)