mirror of
https://github.com/mihonapp/mihon.git
synced 2025-02-14 11:08:55 +01:00
Compare commits
6 Commits
ab0893b2d4
...
dae7a00b41
Author | SHA1 | Date | |
---|---|---|---|
|
dae7a00b41 | ||
|
c3adf103d7 | ||
|
945ae821fb | ||
|
aefce87650 | ||
|
c70685584f | ||
|
36c864d873 |
@ -184,14 +184,10 @@ 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) {
|
||||||
val enabledIcon = if (sortingMode == LibrarySort.Type.Random) {
|
|
||||||
Icons.Default.Refresh
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
BaseSortItem(
|
BaseSortItem(
|
||||||
label = stringResource(titleRes),
|
label = stringResource(titleRes),
|
||||||
icon = enabledIcon,
|
icon = Icons.Default.Refresh
|
||||||
|
.takeIf { sortingMode == LibrarySort.Type.Random },
|
||||||
onClick = {
|
onClick = {
|
||||||
screenModel.setSort(category, mode, LibrarySort.Direction.Ascending)
|
screenModel.setSort(category, mode, LibrarySort.Direction.Ascending)
|
||||||
},
|
},
|
||||||
|
@ -302,16 +302,15 @@ class LibraryScreenModel(
|
|||||||
item1Score.compareTo(item2Score)
|
item1Score.compareTo(item2Score)
|
||||||
}
|
}
|
||||||
LibrarySort.Type.Random -> {
|
LibrarySort.Type.Random -> {
|
||||||
error("A comparator should not be requested for the random sort style. Instead, intercept this " +
|
error("Why Are We Still Here? Just To Suffer?")
|
||||||
"case and call .shuffle()")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapValues { (key, value) ->
|
return mapValues { (key, value) ->
|
||||||
if (key.sort.type == LibrarySort.Type.Random) {
|
if (key.sort.type == LibrarySort.Type.Random) {
|
||||||
return@mapValues value.shuffled(Random(libraryPreferences.currentRandomSortSeed().get()))
|
return@mapValues value.shuffled(Random(libraryPreferences.randomSortSeed().get()))
|
||||||
}
|
}
|
||||||
|
|
||||||
val comparator = key.sort.comparator()
|
val comparator = key.sort.comparator()
|
||||||
.let { if (key.sort.isAscending) it else it.reversed() }
|
.let { if (key.sort.isAscending) it else it.reversed() }
|
||||||
|
@ -17,7 +17,7 @@ class SetSortModeForCategory(
|
|||||||
val category = categoryId?.let { categoryRepository.get(it) }
|
val category = categoryId?.let { categoryRepository.get(it) }
|
||||||
val flags = (category?.flags ?: 0) + type + direction
|
val flags = (category?.flags ?: 0) + type + direction
|
||||||
if (type == LibrarySort.Type.Random) {
|
if (type == LibrarySort.Type.Random) {
|
||||||
preferences.currentRandomSortSeed().set(Random.nextInt())
|
preferences.randomSortSeed().set(Random.nextInt())
|
||||||
}
|
}
|
||||||
if (category != null && preferences.categorizedDisplaySettings().get()) {
|
if (category != null && preferences.categorizedDisplaySettings().get()) {
|
||||||
categoryRepository.updatePartial(
|
categoryRepository.updatePartial(
|
||||||
|
@ -31,7 +31,7 @@ data class LibrarySort(
|
|||||||
data object ChapterFetchDate : Type(0b00011000)
|
data object ChapterFetchDate : Type(0b00011000)
|
||||||
data object DateAdded : Type(0b00011100)
|
data object DateAdded : Type(0b00011100)
|
||||||
data object TrackerMean : Type(0b00100000)
|
data object TrackerMean : Type(0b00100000)
|
||||||
data object Random : Type(0b00100100)
|
data object Random : Type(0b00111100)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun valueOf(flag: Long): Type {
|
fun valueOf(flag: Long): Type {
|
||||||
|
@ -26,7 +26,7 @@ class LibraryPreferences(
|
|||||||
LibrarySort.Serializer::deserialize,
|
LibrarySort.Serializer::deserialize,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun currentRandomSortSeed() = preferenceStore.getInt("library_random_sort_seed", 0)
|
fun randomSortSeed() = preferenceStore.getInt("library_random_sort_seed", 0)
|
||||||
|
|
||||||
fun portraitColumns() = preferenceStore.getInt("pref_library_columns_portrait_key", 0)
|
fun portraitColumns() = preferenceStore.getInt("pref_library_columns_portrait_key", 0)
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
|||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.ArrowDownward
|
import androidx.compose.material.icons.filled.ArrowDownward
|
||||||
import androidx.compose.material.icons.filled.ArrowUpward
|
import androidx.compose.material.icons.filled.ArrowUpward
|
||||||
import androidx.compose.material.icons.filled.Refresh
|
|
||||||
import androidx.compose.material.icons.rounded.CheckBox
|
import androidx.compose.material.icons.rounded.CheckBox
|
||||||
import androidx.compose.material.icons.rounded.CheckBoxOutlineBlank
|
import androidx.compose.material.icons.rounded.CheckBoxOutlineBlank
|
||||||
import androidx.compose.material.icons.rounded.DisabledByDefault
|
import androidx.compose.material.icons.rounded.DisabledByDefault
|
||||||
|
Loading…
x
Reference in New Issue
Block a user