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

Verified Commit 12e4d8ad authored by Saalim Quadri's avatar Saalim Quadri
Browse files

feat: Handle "No apps found" state

parent 5f466d4c
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -53,7 +53,7 @@ fun SearchPlaceholder(modifier: Modifier = Modifier) {
        ) {
        ) {
            Image(
            Image(
                painter = painterResource(id = R.drawable.ic_error_circular),
                painter = painterResource(id = R.drawable.ic_error_circular),
                contentDescription = stringResource(id = R.string.menu_search),
                contentDescription = stringResource(id = R.string.no_apps_found),
                contentScale = ContentScale.Fit,
                contentScale = ContentScale.Fit,
                modifier = Modifier
                modifier = Modifier
                    .padding(bottom = 4.dp)
                    .padding(bottom = 4.dp)
+17 −3
Original line number Original line Diff line number Diff line
@@ -79,11 +79,26 @@ fun SearchResultsContent(
    onPrivacyClick: (Application) -> Unit = {},
    onPrivacyClick: (Application) -> Unit = {},
    installButtonStateProvider: (Application) -> InstallButtonState,
    installButtonStateProvider: (Application) -> InstallButtonState,
) {
) {
    when {
    if (tabs.isEmpty() || selectedTab !in tabs) {
        tabs.isEmpty() || selectedTab !in tabs -> {
        return
        return
    }
    }


    val fossEmpty = fossItems?.let {
        it.loadState.refresh is LoadState.NotLoading && it.itemCount == 0
    } ?: true
    val pwaEmpty = pwaItems?.let {
        it.loadState.refresh is LoadState.NotLoading && it.itemCount == 0
    } ?: true
    val playEmpty = playStoreItems?.let {
        it.loadState.refresh is LoadState.NotLoading && it.itemCount == 0
    } ?: true
    val allSourcesEmpty = fossEmpty && pwaEmpty && playEmpty

    when {
        allSourcesEmpty -> {
            SearchPlaceholder(modifier = modifier.fillMaxSize())
        }

        // Don't show tabs when a single source is checked in the Settings screen
        // Don't show tabs when a single source is checked in the Settings screen
        tabs.size == 1 -> {
        tabs.size == 1 -> {
            SearchTabPage(
            SearchTabPage(
@@ -101,7 +116,6 @@ fun SearchResultsContent(
                installButtonStateProvider = installButtonStateProvider,
                installButtonStateProvider = installButtonStateProvider,
                modifier = modifier.fillMaxSize(),
                modifier = modifier.fillMaxSize(),
            )
            )
            return
        }
        }


        else -> {
        else -> {