mirror of
https://github.com/mihonapp/mihon.git
synced 2025-04-15 17:05:41 +02:00
Changes according to feedback
This commit is contained in:
parent
078758391e
commit
ab0893b2d4
@ -29,9 +29,9 @@ import tachiyomi.domain.library.model.LibrarySort
|
|||||||
import tachiyomi.domain.library.model.sort
|
import tachiyomi.domain.library.model.sort
|
||||||
import tachiyomi.domain.library.service.LibraryPreferences
|
import tachiyomi.domain.library.service.LibraryPreferences
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
|
import tachiyomi.presentation.core.components.BaseSortItem
|
||||||
import tachiyomi.presentation.core.components.CheckboxItem
|
import tachiyomi.presentation.core.components.CheckboxItem
|
||||||
import tachiyomi.presentation.core.components.HeadingItem
|
import tachiyomi.presentation.core.components.HeadingItem
|
||||||
import tachiyomi.presentation.core.components.NondirectionalSortItem
|
|
||||||
import tachiyomi.presentation.core.components.SettingsChipRow
|
import tachiyomi.presentation.core.components.SettingsChipRow
|
||||||
import tachiyomi.presentation.core.components.SliderItem
|
import tachiyomi.presentation.core.components.SliderItem
|
||||||
import tachiyomi.presentation.core.components.SortItem
|
import tachiyomi.presentation.core.components.SortItem
|
||||||
@ -184,10 +184,14 @@ private fun ColumnScope.SortPage(
|
|||||||
MR.strings.action_sort_random to LibrarySort.Type.Random,
|
MR.strings.action_sort_random to LibrarySort.Type.Random,
|
||||||
).plus(trackerSortOption).map { (titleRes, mode) ->
|
).plus(trackerSortOption).map { (titleRes, mode) ->
|
||||||
if (mode == LibrarySort.Type.Random) {
|
if (mode == LibrarySort.Type.Random) {
|
||||||
NondirectionalSortItem(
|
val enabledIcon = if (sortingMode == LibrarySort.Type.Random) {
|
||||||
|
Icons.Default.Refresh
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
BaseSortItem(
|
||||||
label = stringResource(titleRes),
|
label = stringResource(titleRes),
|
||||||
enabled = sortingMode == LibrarySort.Type.Random,
|
icon = enabledIcon,
|
||||||
enabledIcon = Icons.Default.Refresh,
|
|
||||||
onClick = {
|
onClick = {
|
||||||
screenModel.setSort(category, mode, LibrarySort.Direction.Ascending)
|
screenModel.setSort(category, mode, LibrarySort.Direction.Ascending)
|
||||||
},
|
},
|
||||||
|
@ -268,7 +268,7 @@ class LibraryScreenModel(
|
|||||||
|
|
||||||
fun LibrarySort.comparator(): Comparator<LibraryItem> = Comparator { i1, i2 ->
|
fun LibrarySort.comparator(): Comparator<LibraryItem> = Comparator { i1, i2 ->
|
||||||
when (this.type) {
|
when (this.type) {
|
||||||
LibrarySort.Type.Alphabetical, LibrarySort.Type.Random -> {
|
LibrarySort.Type.Alphabetical -> {
|
||||||
sortAlphabetically(i1, i2)
|
sortAlphabetically(i1, i2)
|
||||||
}
|
}
|
||||||
LibrarySort.Type.LastRead -> {
|
LibrarySort.Type.LastRead -> {
|
||||||
@ -301,6 +301,10 @@ class LibraryScreenModel(
|
|||||||
val item2Score = trackerScores[i2.libraryManga.id] ?: defaultTrackerScoreSortValue
|
val item2Score = trackerScores[i2.libraryManga.id] ?: defaultTrackerScoreSortValue
|
||||||
item1Score.compareTo(item2Score)
|
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()")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ data class LibrarySort(
|
|||||||
data object LatestChapter : Type(0b00010100)
|
data object LatestChapter : Type(0b00010100)
|
||||||
data object ChapterFetchDate : Type(0b00011000)
|
data object ChapterFetchDate : Type(0b00011000)
|
||||||
data object DateAdded : Type(0b00011100)
|
data object DateAdded : Type(0b00011100)
|
||||||
data object TrackerMean : Type(0b000100000)
|
data object TrackerMean : Type(0b00100000)
|
||||||
data object Random : Type(0b000100100)
|
data object Random : Type(0b00100100)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun valueOf(flag: Long): Type {
|
fun valueOf(flag: Long): Type {
|
||||||
|
@ -99,30 +99,15 @@ fun SortItem(label: String, sortDescending: Boolean?, onClick: () -> Unit) {
|
|||||||
null -> null
|
null -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseSettingsItem(
|
BaseSortItem(
|
||||||
label = label,
|
label = label,
|
||||||
widget = {
|
icon = arrowIcon,
|
||||||
if (arrowIcon != null) {
|
|
||||||
Icon(
|
|
||||||
imageVector = arrowIcon,
|
|
||||||
contentDescription = null,
|
|
||||||
tint = MaterialTheme.colorScheme.primary,
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
Spacer(modifier = Modifier.size(24.dp))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun NondirectionalSortItem(label: String, enabled: Boolean, enabledIcon: ImageVector, onClick: () -> Unit) {
|
fun BaseSortItem(label: String, icon: ImageVector?, onClick: () -> Unit) {
|
||||||
val icon = when(enabled) {
|
|
||||||
true -> enabledIcon
|
|
||||||
false -> null
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseSettingsItem(
|
BaseSettingsItem(
|
||||||
label = label,
|
label = label,
|
||||||
widget = {
|
widget = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user