mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-22 20:42:34 +01:00
Minor cleanup
This commit is contained in:
@@ -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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|
||||||
|
|||||||
@@ -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()),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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 = {
|
||||||
|
|||||||
@@ -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 = {
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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(
|
||||||
|
|||||||
@@ -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()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 = {
|
||||||
|
|||||||
Reference in New Issue
Block a user