@@ -5,6 +5,7 @@ import androidx.compose.foundation.background
55import androidx.compose.foundation.clickable
66import androidx.compose.foundation.layout.Arrangement
77import androidx.compose.foundation.layout.Column
8+ import androidx.compose.foundation.layout.IntrinsicSize
89import androidx.compose.foundation.layout.PaddingValues
910import androidx.compose.foundation.layout.Row
1011import androidx.compose.foundation.layout.Spacer
@@ -22,6 +23,8 @@ import androidx.compose.foundation.lazy.LazyColumn
2223import androidx.compose.foundation.lazy.LazyListState
2324import androidx.compose.foundation.lazy.itemsIndexed
2425import androidx.compose.foundation.lazy.rememberLazyListState
26+ import androidx.compose.foundation.rememberScrollState
27+ import androidx.compose.foundation.verticalScroll
2528import androidx.compose.material.icons.Icons
2629import androidx.compose.material.icons.automirrored.filled.ArrowBack
2730import androidx.compose.material.icons.filled.Search
@@ -108,13 +111,13 @@ fun BookingListScreen(state: BookingListViewState) {
108111 state.tabState.onTabChanged(it)
109112 }
110113 )
111- BookingListControls (state.controlsState)
112114 HorizontalDivider (thickness = 0.5 .dp)
113115
114116 when {
115117 state.contentState.isNotEmpty() -> {
116118 BookingList (
117119 state = state.contentState,
120+ controlsState = state.controlsState,
118121 listState = lazyListState,
119122 modifier = Modifier .fillMaxSize()
120123 )
@@ -131,23 +134,12 @@ fun BookingListScreen(state: BookingListViewState) {
131134 }
132135
133136 else -> {
134- val modifier = Modifier
135- .background(MaterialTheme .colorScheme.surface)
136- .fillMaxSize()
137- .padding(32 .dp)
138-
139- if (state.searchState.isSearchActive) {
140- EmptySearchResultsView (
141- query = state.searchState.query.orEmpty(),
142- modifier = modifier
143- )
144- } else {
145- EmptyView (
146- selectedTab = state.tabState.selectedTab,
147- areFiltersActive = state.areFiltersActive,
148- modifier = modifier
149- )
150- }
137+ EmptyView (
138+ state = state,
139+ modifier = Modifier
140+ .background(MaterialTheme .colorScheme.surface)
141+ .fillMaxSize()
142+ )
151143 }
152144 }
153145 }
@@ -213,6 +205,7 @@ private fun SearchSection(
213205@Composable
214206private fun BookingList (
215207 state : BookingListContentState ,
208+ controlsState : BookingListControlsState ,
216209 listState : LazyListState ,
217210 modifier : Modifier = Modifier
218211) {
@@ -227,6 +220,10 @@ private fun BookingList(
227220 modifier = Modifier
228221 .fillMaxSize()
229222 ) {
223+ stickyHeader {
224+ BookingListControls (controlsState)
225+ }
226+
230227 itemsIndexed(state.bookings) { _, booking ->
231228 Column (modifier = Modifier .background(MaterialTheme .colorScheme.surfaceContainer)) {
232229 BookingSummary (
@@ -304,6 +301,37 @@ private fun BookingListControls(
304301
305302@Composable
306303private fun EmptyView (
304+ state : BookingListViewState ,
305+ modifier : Modifier
306+ ) {
307+ Column (
308+ modifier
309+ .verticalScroll(rememberScrollState())
310+ .height(IntrinsicSize .Max )
311+ ) {
312+ BookingListControls (state.controlsState)
313+
314+ val innerEmptyViewModifier = Modifier
315+ .fillMaxSize()
316+ .padding(32 .dp)
317+
318+ if (state.searchState.isSearchActive) {
319+ EmptySearchResultsView (
320+ query = state.searchState.query.orEmpty(),
321+ modifier = innerEmptyViewModifier
322+ )
323+ } else {
324+ EmptyListView (
325+ selectedTab = state.tabState.selectedTab,
326+ areFiltersActive = state.areFiltersActive,
327+ modifier = innerEmptyViewModifier
328+ )
329+ }
330+ }
331+ }
332+
333+ @Composable
334+ private fun EmptyListView (
307335 selectedTab : BookingListTab ,
308336 areFiltersActive : Boolean ,
309337 modifier : Modifier
0 commit comments