diff --git a/app/src/androidTest/java/foundation/e/apps/ui/compose/components/SearchResultsContentTest.kt b/app/src/androidTest/java/foundation/e/apps/ui/compose/components/SearchResultsContentTest.kt index b673259f9b27d323f9c2d41fd7313035afa03171..59c60ed228d582e05e09f2b6c3623c81a5859838 100644 --- a/app/src/androidTest/java/foundation/e/apps/ui/compose/components/SearchResultsContentTest.kt +++ b/app/src/androidTest/java/foundation/e/apps/ui/compose/components/SearchResultsContentTest.kt @@ -204,51 +204,6 @@ class SearchResultsContentTest { composeRule.onAllNodesWithText("Open App").assertCountEquals(0) } - @Test - fun refreshError_showsRetry() { - val pagingData = PagingData.empty( - sourceLoadStates = loadStates(refresh = LoadState.Error(RuntimeException("boom"))) - ) - - renderSearchResults( - tabs = listOf(SearchTabType.OPEN_SOURCE), - selectedTab = SearchTabType.OPEN_SOURCE, - fossPagingData = pagingData, - ) - - composeRule.onNodeWithText( - composeRule.activity.getString(R.string.search_error) - ).assertIsDisplayed() - composeRule.onNodeWithText( - composeRule.activity.getString(R.string.retry) - ).assertIsDisplayed() - } - - @Test - fun appendError_showsFooterRetryWithResults() { - val pagingData = PagingData.from( - listOf(sampleApp("Loaded App")), - sourceLoadStates = loadStates( - refresh = LoadState.NotLoading(endOfPaginationReached = false), - append = LoadState.Error(RuntimeException("append boom")) - ) - ) - - renderSearchResults( - tabs = listOf(SearchTabType.OPEN_SOURCE), - selectedTab = SearchTabType.OPEN_SOURCE, - fossPagingData = pagingData, - ) - - composeRule.onNodeWithText("Loaded App").assertIsDisplayed() - composeRule.onNodeWithText( - composeRule.activity.getString(R.string.search_error) - ).assertIsDisplayed() - composeRule.onNodeWithText( - composeRule.activity.getString(R.string.retry) - ).assertIsDisplayed() - } - @Test fun emptyResults_showsPlaceholder() { val pagingData = PagingData.empty( diff --git a/app/src/androidTest/java/foundation/e/apps/ui/compose/components/search/SearchErrorStateTest.kt b/app/src/androidTest/java/foundation/e/apps/ui/compose/components/search/SearchErrorStateTest.kt index 8662ae8b33f969bb2d7e606ef122c90fb6461450..675219eb13a385016201664c60714e76844f88d0 100644 --- a/app/src/androidTest/java/foundation/e/apps/ui/compose/components/search/SearchErrorStateTest.kt +++ b/app/src/androidTest/java/foundation/e/apps/ui/compose/components/search/SearchErrorStateTest.kt @@ -41,7 +41,7 @@ class SearchErrorStateTest { composeRule.setContent { AppTheme(darkTheme = false) { Surface(color = MaterialTheme.colorScheme.background) { - SearchErrorState(onRetry = {}, fullScreen = true) + SearchErrorState(fullScreen = true) } } } @@ -49,9 +49,6 @@ class SearchErrorStateTest { composeRule.onNodeWithText( composeRule.activity.getString(R.string.search_error) ).assertIsDisplayed() - composeRule.onNodeWithText( - composeRule.activity.getString(R.string.retry) - ).assertIsDisplayed() } @Test @@ -59,7 +56,7 @@ class SearchErrorStateTest { composeRule.setContent { AppTheme(darkTheme = false) { Surface(color = MaterialTheme.colorScheme.background) { - SearchErrorState(onRetry = {}, fullScreen = false) + SearchErrorState(fullScreen = false) } } } @@ -67,8 +64,5 @@ class SearchErrorStateTest { composeRule.onNodeWithText( composeRule.activity.getString(R.string.search_error) ).assertIsDisplayed() - composeRule.onNodeWithText( - composeRule.activity.getString(R.string.retry) - ).assertIsDisplayed() } } diff --git a/app/src/main/java/foundation/e/apps/ui/compose/components/SearchResultsContent.kt b/app/src/main/java/foundation/e/apps/ui/compose/components/SearchResultsContent.kt index 154b4af3b0c70fc755b3e242900044d0eaca8de4..8910db61d88bd94fdc07b05aed2eb918c500d640 100644 --- a/app/src/main/java/foundation/e/apps/ui/compose/components/SearchResultsContent.kt +++ b/app/src/main/java/foundation/e/apps/ui/compose/components/SearchResultsContent.kt @@ -295,11 +295,7 @@ private fun PagingPlayStoreResultList( } val initialLoadError = refreshError != null && !hasLoadedCurrentQuery.value - val showFooterError = hasLoadedCurrentQuery.value && listOf( - refreshError, - appendError, - prependError - ).any { it != null } + val isEmpty = !isRefreshing && refreshError == null && appendError == null && prependError == null && lazyItems.itemCount == 0 @@ -311,7 +307,6 @@ private fun PagingPlayStoreResultList( initialLoadError -> { SearchErrorState( - onRetry = { lazyItems.retry() }, modifier = Modifier.fillMaxSize(), fullScreen = true, ) @@ -375,18 +370,6 @@ private fun PagingPlayStoreResultList( } } } - - if (showFooterError) { - item(key = "error_footer_play_store") { - SearchErrorState( - onRetry = { lazyItems.retry() }, - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 12.dp), - fullScreen = false, - ) - } - } } } } @@ -448,11 +431,7 @@ private fun PagingSearchResultList( } val initialLoadError = refreshError != null && !hasLoadedCurrentQuery.value - val showFooterError = hasLoadedCurrentQuery.value && listOf( - refreshError, - appendError, - prependError - ).any { it != null } + val isEmpty = !isRefreshing && refreshError == null && appendError == null && prependError == null && lazyItems.itemCount == 0 @@ -466,7 +445,6 @@ private fun PagingSearchResultList( initialLoadError -> { SearchErrorState( - onRetry = { lazyItems.retry() }, modifier = Modifier.fillMaxSize(), fullScreen = true, ) @@ -535,18 +513,6 @@ private fun PagingSearchResultList( } } } - - if (showFooterError) { - item(key = "error_footer") { - SearchErrorState( - onRetry = { lazyItems.retry() }, - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 12.dp), - fullScreen = false, - ) - } - } } } } diff --git a/app/src/main/java/foundation/e/apps/ui/compose/components/search/SearchErrorState.kt b/app/src/main/java/foundation/e/apps/ui/compose/components/search/SearchErrorState.kt index 964253ab57bf5b3de81dd21633f1a1c029817c6e..edd034dbb787c5d221aa1a603d0b9ce240ab481c 100644 --- a/app/src/main/java/foundation/e/apps/ui/compose/components/search/SearchErrorState.kt +++ b/app/src/main/java/foundation/e/apps/ui/compose/components/search/SearchErrorState.kt @@ -25,21 +25,24 @@ import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.material3.Button +import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp import foundation.e.apps.R import foundation.e.apps.ui.compose.theme.AppTheme @Composable fun SearchErrorState( - onRetry: () -> Unit, modifier: Modifier = Modifier, fullScreen: Boolean = true, ) { @@ -66,14 +69,23 @@ fun SearchErrorState( horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(12.dp), ) { + Icon( + painter = painterResource(R.drawable.ic_maintainance), + contentDescription = stringResource(R.string.search_error_icon_cd) + ) Text( - text = stringResource(id = R.string.search_error), - style = MaterialTheme.typography.bodyLarge, + text = stringResource(id = R.string.search_error_title), + fontSize = 18.sp, + fontWeight = FontWeight.Medium, color = MaterialTheme.colorScheme.onBackground, ) - Button(onClick = onRetry) { - Text(text = stringResource(id = R.string.retry)) - } + Text( + modifier = Modifier.padding(horizontal = 48.dp), + textAlign = TextAlign.Center, + text = stringResource(id = R.string.search_error), + fontSize = 16.sp, + color = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.38F), + ) } } } @@ -82,7 +94,7 @@ fun SearchErrorState( @Composable private fun SearchErrorStateFullScreenPreview() { AppTheme { - SearchErrorState(onRetry = {}, fullScreen = true) + SearchErrorState(fullScreen = true) } } @@ -90,6 +102,6 @@ private fun SearchErrorStateFullScreenPreview() { @Composable private fun SearchErrorStateFooterPreview() { AppTheme { - SearchErrorState(onRetry = {}, fullScreen = false) + SearchErrorState(fullScreen = false) } } diff --git a/app/src/main/res/drawable/ic_maintainance.xml b/app/src/main/res/drawable/ic_maintainance.xml new file mode 100644 index 0000000000000000000000000000000000000000..4f2c3bf75b807281ccd73986f76f68c63083ae4e --- /dev/null +++ b/app/src/main/res/drawable/ic_maintainance.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 69a761f4f7f730f54f56896be91567924358d8e6..d3e3d752457ffe67cb351be1be8b09b6204c5a14 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -35,7 +35,9 @@ OPEN SOURCE WEB APPS No apps found… - Error in search + This page or resource is unavailable due to maintenance. + Please try again later + Search error Applications