@@ -49,6 +49,7 @@ private extension BookingListView {
4949 loadingView
5050 case . results:
5151 bookingList ( with: viewModel. bookings,
52+ isSearching: false ,
5253 onNextPage: { viewModel. onLoadNextPageAction ( ) } ,
5354 onRefresh: { await viewModel. onRefreshAction ( ) } )
5455 }
@@ -66,15 +67,18 @@ private extension BookingListView {
6667 }
6768
6869 var searchContentView : some View {
69- VStack {
70+ VStack ( spacing : 0 ) {
7071 if searchViewModel. isSearching {
7172 loadingView
7273 } else if searchViewModel. searchResults. isEmpty {
74+ header
7375 emptyStateView ( isSearching: true ) {
7476 await searchViewModel. onRefreshAction ( )
7577 }
7678 } else {
79+ header
7780 bookingList ( with: searchViewModel. searchResults,
81+ isSearching: true ,
7882 onNextPage: { searchViewModel. onLoadNextPageAction ( ) } ,
7983 onRefresh: { await searchViewModel. onRefreshAction ( ) } )
8084 }
@@ -103,24 +107,20 @@ private extension BookingListView {
103107 }
104108
105109 func bookingList( with bookings: [ Booking ] ,
110+ isSearching: Bool ,
106111 onNextPage: @escaping ( ) -> Void ,
107112 onRefresh: @escaping ( ) async -> Void ) -> some View {
108113 List ( selection: $selectedBooking) {
109- Section {
110- ForEach ( bookings) { item in
111- bookingItem ( item)
112- . tag ( item)
114+ if isSearching {
115+ bookingListSection ( with: bookings, onNextPage: onNextPage)
116+ } else {
117+ Section {
118+ bookingListSection ( with: bookings, onNextPage: onNextPage)
119+ } header: {
120+ header
121+ . listRowInsets ( EdgeInsets ( ) )
122+ . textCase ( nil )
113123 }
114-
115- InfiniteScrollIndicator ( showContent: viewModel. shouldShowBottomActivityIndicator)
116- . padding ( . top, BookingListViewLayout . viewPadding)
117- . onAppear {
118- onNextPage ( )
119- }
120- } header: {
121- header
122- . listRowInsets ( EdgeInsets ( ) )
123- . textCase ( nil )
124124 }
125125 }
126126 . apply {
@@ -131,17 +131,32 @@ private extension BookingListView {
131131 $0. listStyle ( . plain)
132132 } else {
133133 $0. listStyle ( . grouped)
134+ . scrollContentBackground ( . hidden)
134135 }
135136 }
136- . listStyle ( . grouped)
137- . scrollContentBackground ( . hidden)
138- . listSectionSeparator ( . hidden, edges: . top)
139137 . background ( Color ( . listBackground) )
140138 . refreshable {
141139 await onRefresh ( )
142140 }
143141 }
144142
143+ @ViewBuilder
144+ func bookingListSection( with bookings: [ Booking ] , onNextPage: @escaping ( ) -> Void ) -> some View {
145+ ForEach ( bookings) { item in
146+ bookingItem ( item)
147+ . if ( item == bookings. first) {
148+ $0. listSectionSeparator ( . hidden, edges: . top)
149+ }
150+ . tag ( item)
151+ }
152+
153+ InfiniteScrollIndicator ( showContent: viewModel. shouldShowBottomActivityIndicator)
154+ . padding ( . top, BookingListViewLayout . viewPadding)
155+ . onAppear {
156+ onNextPage ( )
157+ }
158+ }
159+
145160 func bookingItem( _ booking: Booking ) -> some View {
146161 VStack ( alignment: . leading, spacing: BookingListViewLayout . bookingSummaryBadgeSpacing) {
147162 VStack ( alignment: . leading, spacing: BookingListViewLayout . bookingSummarySpacing) {
@@ -181,13 +196,19 @@ private extension BookingListView {
181196 func emptyStateView( isSearching: Bool , onRefresh: @escaping ( ) async -> Void ) -> some View {
182197 GeometryReader { proxy in
183198 ScrollView {
184- LazyVStack ( spacing: 0 , pinnedViews: . sectionHeaders) {
185- Section {
186- emptyStateContent ( isSearching: isSearching)
187- . frame ( minWidth: proxy. size. width,
188- minHeight: proxy. size. height - BookingListViewLayout. defaultHeaderHeight * scale)
189- } header: {
190- header
199+ if isSearching {
200+ emptyStateContent ( isSearching: isSearching)
201+ . frame ( minWidth: proxy. size. width,
202+ minHeight: proxy. size. height)
203+ } else {
204+ LazyVStack ( spacing: 0 , pinnedViews: . sectionHeaders) {
205+ Section {
206+ emptyStateContent ( isSearching: isSearching)
207+ . frame ( minWidth: proxy. size. width,
208+ minHeight: proxy. size. height - BookingListViewLayout. defaultHeaderHeight * scale)
209+ } header: {
210+ header
211+ }
191212 }
192213 }
193214 }
0 commit comments