Update app/src/main/java/eu/kanade/presentation/library/LibrarySettingsDialog.kt

Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
This commit is contained in:
Jack Hamilton 2024-10-11 21:07:08 -05:00 committed by GitHub
parent d328ded17f
commit 2eb1580788
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -183,40 +183,37 @@ private fun ColumnScope.SortPage(
MR.strings.action_sort_date_added to LibrarySort.Type.DateAdded,
MR.strings.action_sort_random to LibrarySort.Type.Random,
).plus(trackerSortOption).map { (titleRes, mode) ->
when(mode) {
LibrarySort.Type.Random -> {
NondirectionalSortItem(
label = stringResource(titleRes),
enabled = sortingMode == LibrarySort.Type.Random,
enabledIcon = Icons.Default.Refresh,
onClick = {
screenModel.setSort(category, mode, LibrarySort.Direction.Ascending)
},
)
}
else -> {
SortItem(
label = stringResource(titleRes),
sortDescending = sortDescending.takeIf { sortingMode == mode },
onClick = {
val isTogglingDirection = sortingMode == mode
val direction = when {
isTogglingDirection -> if (sortDescending) {
LibrarySort.Direction.Ascending
} else {
LibrarySort.Direction.Descending
}
else -> if (sortDescending) {
LibrarySort.Direction.Descending
} else {
LibrarySort.Direction.Ascending
}
}
screenModel.setSort(category, mode, direction)
},
)
}
if (mode == LibrarySort.Type.Random) {
NondirectionalSortItem(
label = stringResource(titleRes),
enabled = sortingMode == LibrarySort.Type.Random,
enabledIcon = Icons.Default.Refresh,
onClick = {
screenModel.setSort(category, mode, LibrarySort.Direction.Ascending)
},
)
return@map
}
SortItem(
label = stringResource(titleRes),
sortDescending = sortDescending.takeIf { sortingMode == mode },
onClick = {
val isTogglingDirection = sortingMode == mode
val direction = when {
isTogglingDirection -> if (sortDescending) {
LibrarySort.Direction.Ascending
} else {
LibrarySort.Direction.Descending
}
else -> if (sortDescending) {
LibrarySort.Direction.Descending
} else {
LibrarySort.Direction.Ascending
}
}
screenModel.setSort(category, mode, direction)
},
)
}
}