Skip to content

Commit

Permalink
use user preferred title language
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed May 25, 2024
1 parent 11912d5 commit 52bc90f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import dev.datlag.aniflow.anilist.state.DiscoverListType
import dev.datlag.aniflow.anilist.state.DiscoverState
import dev.datlag.aniflow.anilist.state.SearchState
import dev.datlag.aniflow.anilist.type.MediaType
import dev.datlag.aniflow.settings.model.TitleLanguage
import dev.datlag.aniflow.ui.navigation.Component
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow

interface DiscoverComponent : Component {
val loggedIn: Flow<Boolean>
val titleLanguage: Flow<TitleLanguage?>

val initialSearchValue: String?
val type: Flow<MediaType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ fun DiscoverScreen(component: DiscoverComponent) {
)
}
is DiscoverState.Success -> {
val titleLanguage by component.titleLanguage.collectAsStateWithLifecycle(null)

LazyVerticalGrid(
state = listState,
modifier = Modifier.fillMaxSize().haze(state = LocalHaze.current),
Expand All @@ -167,7 +169,7 @@ fun DiscoverScreen(component: DiscoverComponent) {
items(current.collection.toList(), key = { it.id }) {
MediumCard(
medium = it,
titleLanguage = null,
titleLanguage = titleLanguage,
modifier = Modifier.fillMaxWidth().aspectRatio(0.65F),
onClick = component::details
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import dev.datlag.aniflow.anilist.state.SearchState
import dev.datlag.aniflow.anilist.type.MediaType
import dev.datlag.aniflow.common.onRender
import dev.datlag.aniflow.other.UserHelper
import dev.datlag.aniflow.settings.Settings
import dev.datlag.aniflow.settings.model.TitleLanguage
import dev.datlag.tooling.compose.ioDispatcher
import dev.datlag.tooling.decompose.ioScope
import kotlinx.coroutines.flow.Flow
Expand All @@ -36,6 +38,9 @@ class DiscoverScreenComponent(
private val userHelper by instance<UserHelper>()
override val loggedIn: Flow<Boolean> = userHelper.isLoggedIn

private val appSettings by instance<Settings.PlatformAppSettings>()
override val titleLanguage: Flow<TitleLanguage?> = appSettings.titleLanguage

private val searchRepository by instance<SearchStateMachine>()

override val initialSearchValue: String?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,13 @@ fun FavoritesScreen(component: FavoritesComponent) {
}
) { padding ->
val state by component.listState.collectAsStateWithLifecycle()
val titleLanguage by component.titleLanguage.collectAsStateWithLifecycle(null)

ListData(
state = state,
listState = listState,
padding = padding,
titleLanguage = null,
titleLanguage = titleLanguage,
onClick = component::details,
onIncrease = component::increase,
onLoadMore = component::nextPage
Expand Down

0 comments on commit 52bc90f

Please sign in to comment.