mirror of
https://github.com/mihonapp/mihon.git
synced 2025-10-23 11:38:55 +02:00
Changes according to feedback
This commit is contained in:
@@ -29,9 +29,9 @@ import tachiyomi.domain.library.model.LibrarySort
|
||||
import tachiyomi.domain.library.model.sort
|
||||
import tachiyomi.domain.library.service.LibraryPreferences
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.BaseSortItem
|
||||
import tachiyomi.presentation.core.components.CheckboxItem
|
||||
import tachiyomi.presentation.core.components.HeadingItem
|
||||
import tachiyomi.presentation.core.components.NondirectionalSortItem
|
||||
import tachiyomi.presentation.core.components.SettingsChipRow
|
||||
import tachiyomi.presentation.core.components.SliderItem
|
||||
import tachiyomi.presentation.core.components.SortItem
|
||||
@@ -184,10 +184,14 @@ private fun ColumnScope.SortPage(
|
||||
MR.strings.action_sort_random to LibrarySort.Type.Random,
|
||||
).plus(trackerSortOption).map { (titleRes, mode) ->
|
||||
if (mode == LibrarySort.Type.Random) {
|
||||
NondirectionalSortItem(
|
||||
val enabledIcon = if (sortingMode == LibrarySort.Type.Random) {
|
||||
Icons.Default.Refresh
|
||||
} else {
|
||||
null
|
||||
}
|
||||
BaseSortItem(
|
||||
label = stringResource(titleRes),
|
||||
enabled = sortingMode == LibrarySort.Type.Random,
|
||||
enabledIcon = Icons.Default.Refresh,
|
||||
icon = enabledIcon,
|
||||
onClick = {
|
||||
screenModel.setSort(category, mode, LibrarySort.Direction.Ascending)
|
||||
},
|
||||
|
@@ -268,7 +268,7 @@ class LibraryScreenModel(
|
||||
|
||||
fun LibrarySort.comparator(): Comparator<LibraryItem> = Comparator { i1, i2 ->
|
||||
when (this.type) {
|
||||
LibrarySort.Type.Alphabetical, LibrarySort.Type.Random -> {
|
||||
LibrarySort.Type.Alphabetical -> {
|
||||
sortAlphabetically(i1, i2)
|
||||
}
|
||||
LibrarySort.Type.LastRead -> {
|
||||
@@ -301,6 +301,10 @@ class LibraryScreenModel(
|
||||
val item2Score = trackerScores[i2.libraryManga.id] ?: defaultTrackerScoreSortValue
|
||||
item1Score.compareTo(item2Score)
|
||||
}
|
||||
LibrarySort.Type.Random -> {
|
||||
error("A comparator should not be requested for the random sort style. Instead, intercept this " +
|
||||
"case and call .shuffle()")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user