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), CoverOnlyGrid(MR.strings.display_cover_only),
List(MR.strings.display_list), 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) : constructor(mode: String, factory: (String) -> PreferenceStore) :
this(mode, factory(mode)) 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) fun default(): Preference<Boolean> = preferenceStore.getBoolean("default", defaultMode != null)

View File

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

View File

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

View File

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

View File

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

View File

@@ -248,7 +248,7 @@ private fun LinkDisplay() {
BoxWithConstraints { BoxWithConstraints {
FlowRow(Modifier.fillMaxWidth(), mainAxisAlignment = FlowMainAxisAlignment.Center) { FlowRow(Modifier.fillMaxWidth(), mainAxisAlignment = FlowMainAxisAlignment.Center) {
if (maxWidth > 720.dp) { if (maxWidth > 720.dp) {
Link.values().asList().fastForEach { Link.entries.fastForEach {
Column( Column(
Modifier Modifier
.width(92.dp) .width(92.dp)
@@ -276,7 +276,7 @@ private fun LinkDisplay() {
} }
} }
} else { } else {
Link.values().asList().fastForEach { Link.entries.fastForEach {
Box( Box(
modifier = Modifier.clickable { uriHandler.openUri(it.uri) } modifier = Modifier.clickable { uriHandler.openUri(it.uri) }
.padding(horizontal = 16.dp, vertical = 8.dp) .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.Composable
import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.compositionLocalOf import androidx.compose.runtime.compositionLocalOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
@@ -77,7 +76,7 @@ fun WithBottomNav(
@Composable @Composable
fun BottomNav(navigator: Navigator) { fun BottomNav(navigator: Navigator) {
BottomNavigation { BottomNavigation {
remember { TopLevelMenus.values().asList() }.fastForEach { TopLevelMenus.entries.fastForEach {
val isSelected = it.isSelected(navigator) val isSelected = it.isSelected(navigator)
BottomNavigationItem( BottomNavigationItem(
selected = isSelected, selected = isSelected,

View File

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

View File

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

View File

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

View File

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