Change settings screen to object (#8604)
This commit is contained in:
parent
e2179a6669
commit
7d34ff214c
14 changed files with 150 additions and 152 deletions
|
@ -52,7 +52,7 @@ import java.text.SimpleDateFormat
|
|||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
|
||||
class AboutScreen : Screen {
|
||||
object AboutScreen : Screen {
|
||||
|
||||
@Composable
|
||||
override fun Content() {
|
||||
|
@ -199,7 +199,6 @@ class AboutScreen : Screen {
|
|||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getVersionName(withBuildDate: Boolean): String {
|
||||
return when {
|
||||
BuildConfig.DEBUG -> {
|
||||
|
@ -250,5 +249,4 @@ class AboutScreen : Screen {
|
|||
BuildConfig.BUILD_TIME
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ import uy.kohesive.injekt.Injekt
|
|||
import uy.kohesive.injekt.api.get
|
||||
import java.io.File
|
||||
|
||||
class SettingsAdvancedScreen : SearchableSettings {
|
||||
object SettingsAdvancedScreen : SearchableSettings {
|
||||
@ReadOnlyComposable
|
||||
@Composable
|
||||
@StringRes
|
||||
|
|
|
@ -27,7 +27,7 @@ import uy.kohesive.injekt.Injekt
|
|||
import uy.kohesive.injekt.api.get
|
||||
import java.util.Date
|
||||
|
||||
class SettingsAppearanceScreen : SearchableSettings {
|
||||
object SettingsAppearanceScreen : SearchableSettings {
|
||||
|
||||
@ReadOnlyComposable
|
||||
@Composable
|
||||
|
|
|
@ -59,7 +59,7 @@ import kotlinx.coroutines.launch
|
|||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class SettingsBackupScreen : SearchableSettings {
|
||||
object SettingsBackupScreen : SearchableSettings {
|
||||
|
||||
@ReadOnlyComposable
|
||||
@Composable
|
||||
|
|
|
@ -16,7 +16,7 @@ import eu.kanade.tachiyomi.util.system.AuthenticatorUtil.authenticate
|
|||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class SettingsBrowseScreen : SearchableSettings {
|
||||
object SettingsBrowseScreen : SearchableSettings {
|
||||
|
||||
@ReadOnlyComposable
|
||||
@Composable
|
||||
|
|
|
@ -32,7 +32,7 @@ import uy.kohesive.injekt.Injekt
|
|||
import uy.kohesive.injekt.api.get
|
||||
import java.io.File
|
||||
|
||||
class SettingsDownloadScreen : SearchableSettings {
|
||||
object SettingsDownloadScreen : SearchableSettings {
|
||||
|
||||
@ReadOnlyComposable
|
||||
@Composable
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.xmlpull.v1.XmlPullParser
|
|||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class SettingsGeneralScreen : SearchableSettings {
|
||||
object SettingsGeneralScreen : SearchableSettings {
|
||||
|
||||
@Composable
|
||||
@ReadOnlyComposable
|
||||
|
|
|
@ -61,7 +61,7 @@ import kotlinx.coroutines.runBlocking
|
|||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class SettingsLibraryScreen : SearchableSettings {
|
||||
object SettingsLibraryScreen : SearchableSettings {
|
||||
|
||||
@Composable
|
||||
@ReadOnlyComposable
|
||||
|
|
|
@ -175,76 +175,75 @@ object SettingsMainScreen : Screen {
|
|||
private fun Navigator.navigate(screen: Screen, twoPane: Boolean) {
|
||||
if (twoPane) replaceAll(screen) else push(screen)
|
||||
}
|
||||
}
|
||||
|
||||
private data class Item(
|
||||
private data class Item(
|
||||
@StringRes val titleRes: Int,
|
||||
@StringRes val subtitleRes: Int,
|
||||
val formatSubtitle: @Composable () -> String = { stringResource(subtitleRes) },
|
||||
val icon: ImageVector,
|
||||
val screen: Screen,
|
||||
)
|
||||
)
|
||||
|
||||
private val items = listOf(
|
||||
private val items = listOf(
|
||||
Item(
|
||||
titleRes = R.string.pref_category_general,
|
||||
subtitleRes = R.string.pref_general_summary,
|
||||
icon = Icons.Outlined.Tune,
|
||||
screen = SettingsGeneralScreen(),
|
||||
screen = SettingsGeneralScreen,
|
||||
),
|
||||
Item(
|
||||
titleRes = R.string.pref_category_appearance,
|
||||
subtitleRes = R.string.pref_appearance_summary,
|
||||
icon = Icons.Outlined.Palette,
|
||||
screen = SettingsAppearanceScreen(),
|
||||
screen = SettingsAppearanceScreen,
|
||||
),
|
||||
Item(
|
||||
titleRes = R.string.pref_category_library,
|
||||
subtitleRes = R.string.pref_library_summary,
|
||||
icon = Icons.Outlined.CollectionsBookmark,
|
||||
screen = SettingsLibraryScreen(),
|
||||
screen = SettingsLibraryScreen,
|
||||
),
|
||||
Item(
|
||||
titleRes = R.string.pref_category_reader,
|
||||
subtitleRes = R.string.pref_reader_summary,
|
||||
icon = Icons.Outlined.ChromeReaderMode,
|
||||
screen = SettingsReaderScreen(),
|
||||
screen = SettingsReaderScreen,
|
||||
),
|
||||
Item(
|
||||
titleRes = R.string.pref_category_downloads,
|
||||
subtitleRes = R.string.pref_downloads_summary,
|
||||
icon = Icons.Outlined.GetApp,
|
||||
screen = SettingsDownloadScreen(),
|
||||
screen = SettingsDownloadScreen,
|
||||
),
|
||||
Item(
|
||||
titleRes = R.string.pref_category_tracking,
|
||||
subtitleRes = R.string.pref_tracking_summary,
|
||||
icon = Icons.Outlined.Sync,
|
||||
screen = SettingsTrackingScreen(),
|
||||
screen = SettingsTrackingScreen,
|
||||
),
|
||||
Item(
|
||||
titleRes = R.string.browse,
|
||||
subtitleRes = R.string.pref_browse_summary,
|
||||
icon = Icons.Outlined.Explore,
|
||||
screen = SettingsBrowseScreen(),
|
||||
screen = SettingsBrowseScreen,
|
||||
),
|
||||
Item(
|
||||
titleRes = R.string.label_backup,
|
||||
subtitleRes = R.string.pref_backup_summary,
|
||||
icon = Icons.Outlined.SettingsBackupRestore,
|
||||
screen = SettingsBackupScreen(),
|
||||
screen = SettingsBackupScreen,
|
||||
),
|
||||
Item(
|
||||
titleRes = R.string.pref_category_security,
|
||||
subtitleRes = R.string.pref_security_summary,
|
||||
icon = Icons.Outlined.Security,
|
||||
screen = SettingsSecurityScreen(),
|
||||
screen = SettingsSecurityScreen,
|
||||
),
|
||||
Item(
|
||||
titleRes = R.string.pref_category_advanced,
|
||||
subtitleRes = R.string.pref_advanced_summary,
|
||||
icon = Icons.Outlined.Code,
|
||||
screen = SettingsAdvancedScreen(),
|
||||
screen = SettingsAdvancedScreen,
|
||||
),
|
||||
Item(
|
||||
titleRes = R.string.pref_category_about,
|
||||
|
@ -253,6 +252,7 @@ private val items = listOf(
|
|||
"${stringResource(R.string.app_name)} ${AboutScreen.getVersionName(withBuildDate = false)}"
|
||||
},
|
||||
icon = Icons.Outlined.Info,
|
||||
screen = AboutScreen(),
|
||||
screen = AboutScreen,
|
||||
),
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import eu.kanade.tachiyomi.util.system.isReleaseBuildType
|
|||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class SettingsReaderScreen : SearchableSettings {
|
||||
object SettingsReaderScreen : SearchableSettings {
|
||||
|
||||
@ReadOnlyComposable
|
||||
@Composable
|
||||
|
|
|
@ -282,16 +282,16 @@ private fun getLocalizedBreadcrumb(path: String, node: String?): String {
|
|||
}
|
||||
|
||||
private val settingScreens = listOf(
|
||||
SettingsGeneralScreen(),
|
||||
SettingsAppearanceScreen(),
|
||||
SettingsLibraryScreen(),
|
||||
SettingsReaderScreen(),
|
||||
SettingsDownloadScreen(),
|
||||
SettingsTrackingScreen(),
|
||||
SettingsBrowseScreen(),
|
||||
SettingsBackupScreen(),
|
||||
SettingsSecurityScreen(),
|
||||
SettingsAdvancedScreen(),
|
||||
SettingsGeneralScreen,
|
||||
SettingsAppearanceScreen,
|
||||
SettingsLibraryScreen,
|
||||
SettingsReaderScreen,
|
||||
SettingsDownloadScreen,
|
||||
SettingsTrackingScreen,
|
||||
SettingsBrowseScreen,
|
||||
SettingsBackupScreen,
|
||||
SettingsSecurityScreen,
|
||||
SettingsAdvancedScreen,
|
||||
)
|
||||
|
||||
private data class SettingsData(
|
||||
|
|
|
@ -18,7 +18,7 @@ import eu.kanade.tachiyomi.util.system.AuthenticatorUtil.isAuthenticationSupport
|
|||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class SettingsSecurityScreen : SearchableSettings {
|
||||
object SettingsSecurityScreen : SearchableSettings {
|
||||
|
||||
@ReadOnlyComposable
|
||||
@Composable
|
||||
|
|
|
@ -59,7 +59,7 @@ import eu.kanade.tachiyomi.util.system.toast
|
|||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class SettingsTrackingScreen : SearchableSettings {
|
||||
object SettingsTrackingScreen : SearchableSettings {
|
||||
|
||||
@ReadOnlyComposable
|
||||
@Composable
|
||||
|
|
|
@ -45,9 +45,9 @@ class SettingsMainController(bundle: Bundle = bundleOf()) : BasicFullComposeCont
|
|||
if (!isTabletUi) {
|
||||
Navigator(
|
||||
screen = if (toBackupScreen) {
|
||||
SettingsBackupScreen()
|
||||
SettingsBackupScreen
|
||||
} else if (toAboutScreen) {
|
||||
AboutScreen()
|
||||
AboutScreen
|
||||
} else {
|
||||
SettingsMainScreen
|
||||
},
|
||||
|
@ -63,11 +63,11 @@ class SettingsMainController(bundle: Bundle = bundleOf()) : BasicFullComposeCont
|
|||
} else {
|
||||
Navigator(
|
||||
screen = if (toBackupScreen) {
|
||||
SettingsBackupScreen()
|
||||
SettingsBackupScreen
|
||||
} else if (toAboutScreen) {
|
||||
AboutScreen()
|
||||
AboutScreen
|
||||
} else {
|
||||
SettingsGeneralScreen()
|
||||
SettingsGeneralScreen
|
||||
},
|
||||
) {
|
||||
TwoPanelBox(
|
||||
|
|
Reference in a new issue