@@ -7,14 +7,14 @@ import androidx.compose.runtime.collectAsState
77import androidx.compose.runtime.getValue
88import androidx.compose.runtime.remember
99import androidx.compose.ui.Modifier
10+ import androidx.paging.LoadState
1011import androidx.paging.compose.LazyPagingItems
12+ import kotlinx.coroutines.flow.StateFlow
1113import st.slex.csplashscreen.core.photos.ui.component.LazyListPhotos
1214import st.slex.csplashscreen.core.photos.ui.model.PhotoModel
1315import st.slex.csplashscreen.feature.search.ui.components.TopAppBarSearch
1416import st.slex.csplashscreen.feature.search.ui.components.history.LazyListHistorySearch
1517import st.slex.csplashscreen.feature.search.ui.model.SearchItem
16- import st.slex.csplashscreen.feature.search.ui.utils.UiExt.isNotLoading
17- import kotlinx.coroutines.flow.StateFlow
1818
1919@Composable
2020fun SearchPhotosScreen (
@@ -39,22 +39,23 @@ fun SearchPhotosScreen(
3939 search = onQuery
4040 )
4141
42- if (photos.loadState.isNotLoading) {
43- if (photos.itemCount == 0 ) {
44- LazyListHistorySearch (
45- modifier = Modifier .weight(1f ),
46- items = searchHistory,
47- onSearchClick = remember { onQuery },
48- clearHistory = clearHistory
49- )
50- } else {
51- LazyListPhotos (
52- modifier = Modifier .weight(1f ),
53- items = photos,
54- onUserClick = onUserClick,
55- onImageClick = onImageClick,
56- )
57- }
42+ if (
43+ photos.loadState.refresh is LoadState .NotLoading &&
44+ photos.itemCount == 0
45+ ) {
46+ LazyListHistorySearch (
47+ modifier = Modifier .weight(1f ),
48+ items = searchHistory,
49+ onSearchClick = remember { onQuery },
50+ clearHistory = clearHistory
51+ )
52+ } else {
53+ LazyListPhotos (
54+ modifier = Modifier .weight(1f ),
55+ items = photos,
56+ onUserClick = onUserClick,
57+ onImageClick = onImageClick,
58+ )
5859 }
5960 }
6061}
0 commit comments