Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 77bd71e4 authored by Fahim M. Choudhury's avatar Fahim M. Choudhury
Browse files

refactor: update tab-wise error UI

parent 773e0571
Loading
Loading
Loading
Loading
Loading
+26 −25
Original line number Diff line number Diff line
@@ -187,37 +187,32 @@ private fun SearchTabPage(
    installButtonStateProvider: (Application) -> InstallButtonState,
    modifier: Modifier = Modifier,
) {
    val items = when (tab) {
        SearchTabType.COMMON_APPS -> playStoreItems
        SearchTabType.OPEN_SOURCE -> fossItems
        SearchTabType.PWA -> pwaItems
    }
    val items: LazyPagingItems<Application>?
    val emptyResultsStringResource: Int
    val errorTitleStringResource: Int

    val emptyResultsStringResource = when (tab) {
        SearchTabType.COMMON_APPS -> R.string.search_empty_results_title_playstore
        SearchTabType.OPEN_SOURCE -> R.string.search_empty_results_title_open_source
        SearchTabType.PWA -> R.string.search_empty_results_title_pwa
    when (tab) {
        SearchTabType.COMMON_APPS -> {
            items = playStoreItems
            emptyResultsStringResource = R.string.search_empty_results_title_playstore
            errorTitleStringResource = R.string.search_error_title_playstore
        }

    when (tab) {
        SearchTabType.OPEN_SOURCE -> {
            PagingSearchResultList(
                items = items,
                searchVersion = searchVersion,
                tab = tab,
                getScrollPosition = getScrollPosition,
                onScrollPositionChange = onScrollPositionChange,
                onItemClick = onResultClick,
                onPrimaryActionClick = onPrimaryActionClick,
                onShowMoreClick = onShowMoreClick,
                onPrivacyClick = onPrivacyClick,
                installButtonStateProvider = installButtonStateProvider,
                emptyResultsStringResource = emptyResultsStringResource,
                modifier = modifier,
            )
            items = fossItems
            emptyResultsStringResource = R.string.search_empty_results_title_open_source
            errorTitleStringResource = R.string.search_error_title_opensource
        }

        SearchTabType.PWA -> {
            items = pwaItems
            emptyResultsStringResource = R.string.search_empty_results_title_pwa
            errorTitleStringResource = R.string.search_error_title_pwa
        }
    }

    when (tab) {
        SearchTabType.OPEN_SOURCE, SearchTabType.PWA -> {
            PagingSearchResultList(
                items = items,
                searchVersion = searchVersion,
@@ -230,6 +225,7 @@ private fun SearchTabPage(
                onPrivacyClick = onPrivacyClick,
                installButtonStateProvider = installButtonStateProvider,
                emptyResultsStringResource = emptyResultsStringResource,
                errorTitleStringResource = errorTitleStringResource,
                modifier = modifier,
            )
        }
@@ -246,6 +242,7 @@ private fun SearchTabPage(
                onPrivacyClick = onPrivacyClick,
                installButtonStateProvider = installButtonStateProvider,
                emptyResultsStringResource = emptyResultsStringResource,
                errorTitleStringResource = errorTitleStringResource,
                modifier = modifier,
            )
        }
@@ -264,6 +261,7 @@ private fun PagingPlayStoreResultList(
    onPrivacyClick: (Application) -> Unit,
    installButtonStateProvider: (Application) -> InstallButtonState,
    emptyResultsStringResource: Int,
    errorTitleStringResource: Int,
    modifier: Modifier = Modifier,
) {
    val lazyItems = items ?: return
@@ -323,6 +321,7 @@ private fun PagingPlayStoreResultList(

            initialLoadError -> {
                SearchErrorState(
                    errorTitleStringRes = errorTitleStringResource,
                    modifier = Modifier.fillMaxSize(),
                    fullScreen = true,
                )
@@ -406,6 +405,7 @@ private fun PagingSearchResultList(
    onPrivacyClick: (Application) -> Unit,
    installButtonStateProvider: (Application) -> InstallButtonState,
    emptyResultsStringResource: Int,
    errorTitleStringResource: Int,
    modifier: Modifier = Modifier,
) {
    val lazyItems = items ?: return
@@ -463,6 +463,7 @@ private fun PagingSearchResultList(

            initialLoadError -> {
                SearchErrorState(
                    errorTitleStringRes = errorTitleStringResource,
                    modifier = Modifier.fillMaxSize(),
                    fullScreen = true,
                )
+12 −21
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@

package foundation.e.apps.ui.compose.components.search

import androidx.annotation.StringRes
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
@@ -25,13 +26,11 @@ 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.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
@@ -43,6 +42,7 @@ import foundation.e.apps.ui.compose.theme.AppTheme

@Composable
fun SearchErrorState(
    @StringRes errorTitleStringRes: Int,
    modifier: Modifier = Modifier,
    fullScreen: Boolean = true,
) {
@@ -69,22 +69,18 @@ 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_title),
                text = stringResource(id = errorTitleStringRes),
                fontSize = 18.sp,
                fontWeight = FontWeight.Medium,
                color = MaterialTheme.colorScheme.onBackground,
                color = MaterialTheme.colorScheme.onPrimary,
            )
            Text(
                modifier = Modifier.padding(horizontal = 48.dp),
                modifier = Modifier.padding(horizontal = 24.dp),
                textAlign = TextAlign.Center,
                text = stringResource(id = R.string.search_error),
                fontSize = 16.sp,
                color = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.38F),
                text = stringResource(id = R.string.search_error_message),
                fontSize = 15.sp,
                color = MaterialTheme.colorScheme.onPrimary.copy(alpha = 0.38F),
            )
        }
    }
@@ -94,14 +90,9 @@ fun SearchErrorState(
@Composable
private fun SearchErrorStateFullScreenPreview() {
    AppTheme {
        SearchErrorState(fullScreen = true)
    }
}

@Preview(showBackground = true)
@Composable
private fun SearchErrorStateFooterPreview() {
    AppTheme {
        SearchErrorState(fullScreen = false)
        SearchErrorState(
            errorTitleStringRes = R.string.search_error_title_opensource,
            fullScreen = true
        )
    }
}
+0 −10
Original line number Diff line number Diff line
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="64dp"
    android:height="64dp"
    android:viewportWidth="64"
    android:viewportHeight="64">
  <path
      android:pathData="M35.826,40.194L51.16,55.527L56.552,50.007L41.218,34.674L35.826,40.194ZM45.333,26.905C44.336,26.905 43.263,26.777 42.42,26.419L13.312,55.399L7.919,50.007L26.856,31.096L22.333,26.547L20.493,28.336L16.787,24.733V32.042L14.998,33.83L6.003,24.733L7.792,22.944H14.973L11.395,19.34L20.493,10.243C23.483,7.253 28.287,7.253 31.277,10.243L25.885,15.762L29.488,19.34L27.674,21.155L32.248,25.704L36.9,20.899C36.542,20.056 36.388,18.983 36.388,18.037C36.388,13.002 40.375,9.041 45.333,9.041C46.841,9.041 48.17,9.399 49.371,10.115L42.547,16.938L46.381,20.771L53.204,13.948C53.92,15.149 54.277,16.427 54.277,18.037C54.277,22.944 50.316,26.905 45.333,26.905Z"
      android:fillColor="#000000"
      android:fillAlpha="0.12"/>
</vector>
+0 −2
Original line number Diff line number Diff line
@@ -22,8 +22,6 @@
    <string name="menu_settings">Einstellungen</string>
    <string name="no_apps_found">Keine Apps gefunden …</string>
    <string name="search_error">Diese Seite oder Ressource ist wegen Wartungsarbeiten nicht verfügbar.</string>
    <string name="search_error_title">Bitte versuchen Sie es später erneut</string>
    <string name="search_error_icon_cd">Suchfehler</string>
    <string name="apps">Anwendungen</string>
    <string name="games">Spiele</string>
    <string name="category_icon">Kategorien-Symbol</string>
+0 −2
Original line number Diff line number Diff line
@@ -38,8 +38,6 @@
    <string name="search_clear_button">Borrar búsqueda</string>
    <string name="no_apps_found">No se encontraron aplicaciones…</string>
    <string name="search_error">Esta página o recurso no está disponible por mantenimiento.</string>
    <string name="search_error_title">Por favor, inténtelo de nuevo más tarde</string>
    <string name="search_error_icon_cd">Error de búsqueda</string>
    <string name="games">Juegos</string>
    <string name="open_source">Código abierto</string>
    <string name="pwa">PWA</string>
Loading