@@ -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,27 +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- . if ( item == bookings. first) {
113- $0. listSectionSeparator ( . hidden, edges: . top)
114- }
115- . 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 )
116123 }
117-
118- InfiniteScrollIndicator ( showContent: viewModel. shouldShowBottomActivityIndicator)
119- . padding ( . top, BookingListViewLayout . viewPadding)
120- . onAppear {
121- onNextPage ( )
122- }
123- } header: {
124- header
125- . listRowInsets ( EdgeInsets ( ) )
126- . textCase ( nil )
127124 }
128125 }
129126 . apply {
@@ -143,6 +140,23 @@ private extension BookingListView {
143140 }
144141 }
145142
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+
146160 func bookingItem( _ booking: Booking ) -> some View {
147161 VStack ( alignment: . leading, spacing: BookingListViewLayout . bookingSummaryBadgeSpacing) {
148162 VStack ( alignment: . leading, spacing: BookingListViewLayout . bookingSummarySpacing) {
@@ -182,13 +196,19 @@ private extension BookingListView {
182196 func emptyStateView( isSearching: Bool , onRefresh: @escaping ( ) async -> Void ) -> some View {
183197 GeometryReader { proxy in
184198 ScrollView {
185- LazyVStack ( spacing: 0 , pinnedViews: . sectionHeaders) {
186- Section {
187- emptyStateContent ( isSearching: isSearching)
188- . frame ( minWidth: proxy. size. width,
189- minHeight: proxy. size. height - BookingListViewLayout. defaultHeaderHeight * scale)
190- } header: {
191- 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+ }
192212 }
193213 }
194214 }
0 commit comments