Skip to content

Commit

Permalink
added search state
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed May 28, 2024
1 parent 62dc4ef commit cddcda7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ sealed interface SearchState {
internal val throwable: Throwable?
) : PostLoading

data object Empty : PostLoading

companion object {
fun fromResponse(response: ApolloResponse<PageMediaQuery.Data>?): SearchState {
return if (response == null) {
Expand All @@ -46,7 +48,11 @@ sealed interface SearchState {
val mediumList = data.Page?.mediaFilterNotNull()

if (mediumList.isNullOrEmpty()) {
Failure(response.exception)
if (response.hasNonCacheError()) {
Failure(response.exception)
} else {
Empty
}
} else {
Success(mediumList.map(::Medium).distinctBy { it.id }.toImmutableList())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import dev.chrisbanes.haze.hazeChild
import dev.datlag.aniflow.LocalHaze
Expand Down Expand Up @@ -182,6 +183,19 @@ fun DiscoverSearchBar(
}
}
}

is SearchState.Empty -> {
Box(
modifier = Modifier.fillMaxSize().padding(horizontal = 16.dp),
contentAlignment = Alignment.Center
) {
Text(
text = stringResource(SharedRes.strings.nothing_on_search),
textAlign = TextAlign.Center
)
}
}

}
}
)
Expand Down
1 change: 1 addition & 0 deletions composeApp/src/commonMain/moko-resources/base/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
<string name="recommendation">Recommendation</string>
<string name="bs_version_requirement">This feature will be supported with Burning-Series version 6.0.0 and upwards.</string>
<string name="nothing_on_list">You have nothing on your list, either change the filter or add any Anime/Manga.</string>
<string name="nothing_on_search">Nothing found, please change your search query.</string>
<string name="enable">Enable</string>
<string name="ignore">Ignore</string>
<string name="share_domain_title">Enable In-App View</string>
Expand Down
1 change: 1 addition & 0 deletions composeApp/src/commonMain/moko-resources/de-DE/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
<string name="recommendation">Empfehlung</string>
<string name="bs_version_requirement">Diese Option wird mit Burning-Series Version 6.0.0 und höher unterstützt.</string>
<string name="nothing_on_list">Du hast nichts auf deiner Liste, ändere den Filter oder füge einen Anime/Manga hinzu.</string>
<string name="nothing_on_search">Nichts gefunden, passe bitte deine Suche an.</string>
<string name="enable">Aktivieren</string>
<string name="ignore">Ignorieren</string>
<string name="share_domain_title">In-App Ansicht aktivieren</string>
Expand Down

0 comments on commit cddcda7

Please sign in to comment.