Minor cleanup

This commit is contained in:
Syer10
2024-03-30 16:44:41 -04:00
parent 0a00f74cde
commit 5a24bca7fc
12 changed files with 16 additions and 23 deletions

View File

@@ -22,10 +22,4 @@ enum class DisplayMode(
CoverOnlyGrid(MR.strings.display_cover_only),
List(MR.strings.display_list),
;
companion object {
val values by lazy {
values().asList()
}
}
}

View File

@@ -20,7 +20,7 @@ class ReaderModePreferences(
constructor(mode: String, factory: (String) -> PreferenceStore) :
this(mode, factory(mode))
private val defaultMode by lazy { DefaultReaderMode.values().find { it.res == mode } }
private val defaultMode by lazy { DefaultReaderMode.entries.find { it.res == mode } }
fun default(): Preference<Boolean> = preferenceStore.getBoolean("default", defaultMode != null)

View File

@@ -23,7 +23,7 @@ class ReaderPreferences(
fun modes(): Preference<List<String>> =
preferenceStore.getJsonObject(
"modes",
DefaultReaderMode.values().map { it.res },
DefaultReaderMode.entries.map { it.res },
ListSerializer(String.serializer()),
)

View File

@@ -58,7 +58,7 @@ fun LibraryDisplay(
) {
Column(Modifier.fillMaxWidth()) {
TitleText(stringResource(MR.strings.display_mode))
DisplayMode.values.fastForEach {
DisplayMode.entries.fastForEach {
RadioSelectionItem(
text = stringResource(it.res),
selected = it == displayMode,

View File

@@ -51,7 +51,7 @@ fun LibrarySheet(
librarySort: @Composable () -> Unit,
libraryDisplay: @Composable () -> Unit,
) {
val pagerState = rememberPagerState { LibrarySheetTabs.values().size }
val pagerState = rememberPagerState { LibrarySheetTabs.entries.size }
val selectedPage = pagerState.currentPage
val scope = rememberCoroutineScope()
Column(Modifier.fillMaxSize()) {
@@ -63,7 +63,7 @@ fun LibrarySheet(
)
},
) {
LibrarySheetTabs.values().asList().fastForEachIndexed { index, tab ->
LibrarySheetTabs.entries.fastForEachIndexed { index, tab ->
Tab(
selected = selectedPage == index,
onClick = {

View File

@@ -49,7 +49,7 @@ fun LibrarySort(
setAscending: (Boolean) -> Unit,
) {
Column(Modifier.fillMaxWidth()) {
Sort.values().asList().fastForEach { sort ->
Sort.entries.fastForEach { sort ->
SourceFilterAction(
name = stringResource(sort.res),
onClick = {

View File

@@ -248,7 +248,7 @@ private fun LinkDisplay() {
BoxWithConstraints {
FlowRow(Modifier.fillMaxWidth(), mainAxisAlignment = FlowMainAxisAlignment.Center) {
if (maxWidth > 720.dp) {
Link.values().asList().fastForEach {
Link.entries.fastForEach {
Column(
Modifier
.width(92.dp)
@@ -276,7 +276,7 @@ private fun LinkDisplay() {
}
}
} else {
Link.values().asList().fastForEach {
Link.entries.fastForEach {
Box(
modifier = Modifier.clickable { uriHandler.openUri(it.uri) }
.padding(horizontal = 16.dp, vertical = 8.dp)

View File

@@ -33,7 +33,6 @@ import androidx.compose.material.primarySurface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -77,7 +76,7 @@ fun WithBottomNav(
@Composable
fun BottomNav(navigator: Navigator) {
BottomNavigation {
remember { TopLevelMenus.values().asList() }.fastForEach {
TopLevelMenus.entries.fastForEach {
val isSelected = it.isSelected(navigator)
BottomNavigationItem(
selected = isSelected,

View File

@@ -78,7 +78,7 @@ fun SideMenu(
}
}
Spacer(Modifier.height(20.dp))
remember { TopLevelMenus.values().asList().dropLast(1) }.fastForEach { topLevelMenu ->
remember { TopLevelMenus.entries.dropLast(1) }.fastForEach { topLevelMenu ->
SideMenuItem(
topLevelMenu.isSelected(navigator),
topLevelMenu,
@@ -89,7 +89,7 @@ fun SideMenu(
Column {
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.BottomStart) {
Column(Modifier.padding(vertical = 8.dp)) {
remember { MoreMenus.values() }.forEach { topLevelMenu ->
MoreMenus.entries.forEach { topLevelMenu ->
SideMenuItem(
topLevelMenu.isSelected(navigator),
topLevelMenu,

View File

@@ -85,7 +85,7 @@ fun MoreContent() {
item {
Divider()
}
MoreMenus.values().asList().fastForEach {
MoreMenus.entries.fastForEach {
item {
val navigator = LocalNavigator.current
Row(

View File

@@ -120,7 +120,7 @@ class SettingsReaderViewModel
}
fun getDirectionChoices() =
Direction.values().associateWith { it.res.toPlatformString() }
Direction.entries.associateWith { it.res.toPlatformString() }
.toImmutableMap()
fun getPaddingChoices() =
@@ -149,11 +149,11 @@ class SettingsReaderViewModel
}.toImmutableMap()
fun getImageScaleChoices() =
ImageScale.values().associateWith { it.res.toPlatformString() }
ImageScale.entries.associateWith { it.res.toPlatformString() }
.toImmutableMap()
fun getNavigationModeChoices() =
NavigationMode.values().associateWith { it.res.toPlatformString() }
NavigationMode.entries.associateWith { it.res.toPlatformString() }
.toImmutableMap()
}

View File

@@ -456,7 +456,7 @@ fun DisplayModeSelect(
isVisible,
onDismissRequest,
) {
val list = DisplayMode.values().toList() - DisplayMode.CoverOnlyGrid
val list = DisplayMode.entries - DisplayMode.CoverOnlyGrid
list.fastForEach {
DropdownMenuItem(
onClick = {