Migrate TriState usages to TriStateFilter enum

This commit is contained in:
arkon
2023-02-24 16:09:47 -05:00
parent a0e76d2fd9
commit 7ec87e76db
9 changed files with 108 additions and 85 deletions

View File

@@ -16,7 +16,6 @@ import eu.kanade.presentation.components.TriStateItem
import eu.kanade.presentation.util.collectAsState
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.library.LibrarySettingsScreenModel
import eu.kanade.tachiyomi.widget.toTriStateFilter
import tachiyomi.domain.category.model.Category
import tachiyomi.domain.library.model.LibraryDisplayMode
import tachiyomi.domain.library.model.LibrarySort
@@ -76,7 +75,7 @@ private fun ColumnScope.FilterPage(
state = if (downloadedOnly) {
TriStateFilter.ENABLED_IS
} else {
filterDownloaded.toTriStateFilter()
filterDownloaded
},
enabled = !downloadedOnly,
onClick = { screenModel.toggleFilter(LibraryPreferences::filterDownloaded) },
@@ -84,25 +83,25 @@ private fun ColumnScope.FilterPage(
val filterUnread by screenModel.libraryPreferences.filterUnread().collectAsState()
TriStateItem(
label = stringResource(R.string.action_filter_unread),
state = filterUnread.toTriStateFilter(),
state = filterUnread,
onClick = { screenModel.toggleFilter(LibraryPreferences::filterUnread) },
)
val filterStarted by screenModel.libraryPreferences.filterStarted().collectAsState()
TriStateItem(
label = stringResource(R.string.label_started),
state = filterStarted.toTriStateFilter(),
state = filterStarted,
onClick = { screenModel.toggleFilter(LibraryPreferences::filterStarted) },
)
val filterBookmarked by screenModel.libraryPreferences.filterBookmarked().collectAsState()
TriStateItem(
label = stringResource(R.string.action_filter_bookmarked),
state = filterBookmarked.toTriStateFilter(),
state = filterBookmarked,
onClick = { screenModel.toggleFilter(LibraryPreferences::filterBookmarked) },
)
val filterCompleted by screenModel.libraryPreferences.filterCompleted().collectAsState()
TriStateItem(
label = stringResource(R.string.completed),
state = filterCompleted.toTriStateFilter(),
state = filterCompleted,
onClick = { screenModel.toggleFilter(LibraryPreferences::filterCompleted) },
)
@@ -115,7 +114,7 @@ private fun ColumnScope.FilterPage(
val filterTracker by screenModel.libraryPreferences.filterTracking(service.id.toInt()).collectAsState()
TriStateItem(
label = stringResource(R.string.action_filter_tracked),
state = filterTracker.toTriStateFilter(),
state = filterTracker,
onClick = { screenModel.toggleTracker(service.id.toInt()) },
)
}
@@ -125,7 +124,7 @@ private fun ColumnScope.FilterPage(
val filterTracker by screenModel.libraryPreferences.filterTracking(service.id.toInt()).collectAsState()
TriStateItem(
label = stringResource(service.nameRes()),
state = filterTracker.toTriStateFilter(),
state = filterTracker,
onClick = { screenModel.toggleTracker(service.id.toInt()) },
)
}