diff --git a/app/src/main/java/eu/kanade/presentation/more/AboutScreen.kt b/app/src/main/java/eu/kanade/presentation/more/about/AboutScreen.kt similarity index 98% rename from app/src/main/java/eu/kanade/presentation/more/AboutScreen.kt rename to app/src/main/java/eu/kanade/presentation/more/about/AboutScreen.kt index 5c8cd17c6..6850d4466 100644 --- a/app/src/main/java/eu/kanade/presentation/more/AboutScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/about/AboutScreen.kt @@ -1,4 +1,4 @@ -package eu.kanade.presentation.more +package eu.kanade.presentation.more.about import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row @@ -17,6 +17,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import eu.kanade.presentation.components.LinkIcon import eu.kanade.presentation.components.PreferenceRow +import eu.kanade.presentation.more.LogoHeader import eu.kanade.tachiyomi.BuildConfig import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.updater.RELEASE_URL diff --git a/app/src/main/java/eu/kanade/presentation/more/LicensesScreen.kt b/app/src/main/java/eu/kanade/presentation/more/about/LicensesScreen.kt similarity index 95% rename from app/src/main/java/eu/kanade/presentation/more/LicensesScreen.kt rename to app/src/main/java/eu/kanade/presentation/more/about/LicensesScreen.kt index f4d048007..374c22e03 100644 --- a/app/src/main/java/eu/kanade/presentation/more/LicensesScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/about/LicensesScreen.kt @@ -1,4 +1,4 @@ -package eu.kanade.presentation.more +package eu.kanade.presentation.more.about import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.MaterialTheme diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/SettingsMainScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/SettingsMainScreen.kt new file mode 100644 index 000000000..111561537 --- /dev/null +++ b/app/src/main/java/eu/kanade/presentation/more/settings/SettingsMainScreen.kt @@ -0,0 +1,37 @@ +package eu.kanade.presentation.more.settings + +import androidx.annotation.StringRes +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.painter.Painter +import androidx.compose.ui.input.nestedscroll.NestedScrollConnection +import androidx.compose.ui.input.nestedscroll.nestedScroll +import androidx.compose.ui.res.stringResource +import eu.kanade.presentation.components.PreferenceRow + +@Composable +fun SettingsMainScreen( + nestedScrollInterop: NestedScrollConnection, + sections: List, +) { + LazyColumn( + modifier = Modifier.nestedScroll(nestedScrollInterop), + ) { + sections.map { + item { + PreferenceRow( + title = stringResource(it.titleRes), + painter = it.painter, + onClick = it.onClick, + ) + } + } + } +} + +data class SettingsSection( + @StringRes val titleRes: Int, + val painter: Painter, + val onClick: () -> Unit, +) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt index 10b520745..635ce0997 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt @@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.ui.more import androidx.compose.runtime.Composable import androidx.compose.ui.input.nestedscroll.NestedScrollConnection -import eu.kanade.presentation.more.AboutScreen +import eu.kanade.presentation.more.about.AboutScreen import eu.kanade.tachiyomi.BuildConfig import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferencesHelper diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/LicensesController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/LicensesController.kt index d9a1127f4..ba9a9c2a5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/LicensesController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/LicensesController.kt @@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.ui.more import androidx.compose.runtime.Composable import androidx.compose.ui.input.nestedscroll.NestedScrollConnection -import eu.kanade.presentation.more.LicensesScreen +import eu.kanade.presentation.more.about.LicensesScreen import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.base.controller.BasicComposeController diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt index 5fb7f232d..9076efd14 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt @@ -4,88 +4,96 @@ import android.view.Menu import android.view.MenuInflater import android.view.MenuItem import androidx.appcompat.widget.SearchView -import androidx.preference.PreferenceScreen +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.ChromeReaderMode +import androidx.compose.material.icons.outlined.Code +import androidx.compose.material.icons.outlined.GetApp +import androidx.compose.material.icons.outlined.Palette +import androidx.compose.material.icons.outlined.Security +import androidx.compose.material.icons.outlined.SettingsBackupRestore +import androidx.compose.material.icons.outlined.Sync +import androidx.compose.material.icons.outlined.Tune +import androidx.compose.runtime.Composable +import androidx.compose.ui.graphics.vector.rememberVectorPainter +import androidx.compose.ui.input.nestedscroll.NestedScrollConnection +import androidx.compose.ui.res.painterResource +import eu.kanade.presentation.more.settings.SettingsMainScreen +import eu.kanade.presentation.more.settings.SettingsSection import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.data.preference.PreferencesHelper +import eu.kanade.tachiyomi.ui.base.controller.BasicComposeController import eu.kanade.tachiyomi.ui.base.controller.pushController import eu.kanade.tachiyomi.ui.setting.search.SettingsSearchController -import eu.kanade.tachiyomi.util.preference.iconRes -import eu.kanade.tachiyomi.util.preference.iconTint -import eu.kanade.tachiyomi.util.preference.onClick -import eu.kanade.tachiyomi.util.preference.preference -import eu.kanade.tachiyomi.util.preference.titleRes -import eu.kanade.tachiyomi.util.system.getResourceColor +import uy.kohesive.injekt.injectLazy -class SettingsMainController : SettingsController() { +class SettingsMainController : BasicComposeController() { - override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply { - titleRes = R.string.label_settings + private val preferences: PreferencesHelper by injectLazy() - val tintColor = context.getResourceColor(R.attr.colorAccent) + override fun getTitle() = resources?.getString(R.string.label_settings) - preference { - iconRes = R.drawable.ic_tune_24dp - iconTint = tintColor - titleRes = R.string.pref_category_general - onClick { router.pushController(SettingsGeneralController()) } - } - preference { - iconRes = R.drawable.ic_palette_24dp - iconTint = tintColor - titleRes = R.string.pref_category_appearance - onClick { router.pushController(SettingsAppearanceController()) } - } - preference { - iconRes = R.drawable.ic_library_outline_24dp - iconTint = tintColor - titleRes = R.string.pref_category_library - onClick { router.pushController(SettingsLibraryController()) } - } - preference { - iconRes = R.drawable.ic_chrome_reader_mode_24dp - iconTint = tintColor - titleRes = R.string.pref_category_reader - onClick { router.pushController(SettingsReaderController()) } - } - preference { - iconRes = R.drawable.ic_get_app_24dp - iconTint = tintColor - titleRes = R.string.pref_category_downloads - onClick { router.pushController(SettingsDownloadController()) } - } - preference { - iconRes = R.drawable.ic_sync_24dp - iconTint = tintColor - titleRes = R.string.pref_category_tracking - onClick { router.pushController(SettingsTrackingController()) } - } - preference { - iconRes = R.drawable.ic_browse_outline_24dp - iconTint = tintColor - titleRes = R.string.browse - onClick { router.pushController(SettingsBrowseController()) } - } - preference { - iconRes = R.drawable.ic_settings_backup_restore_24dp - iconTint = tintColor - titleRes = R.string.label_backup - onClick { router.pushController(SettingsBackupController()) } - } - preference { - iconRes = R.drawable.ic_security_24dp - iconTint = tintColor - titleRes = R.string.pref_category_security - onClick { router.pushController(SettingsSecurityController()) } - } - preference { - iconRes = R.drawable.ic_code_24dp - iconTint = tintColor - titleRes = R.string.pref_category_advanced - onClick { router.pushController(SettingsAdvancedController()) } - } + @Composable + override fun ComposeContent(nestedScrollInterop: NestedScrollConnection) { + val settingsSections = listOf( + SettingsSection( + titleRes = R.string.pref_category_general, + painter = rememberVectorPainter(Icons.Outlined.Tune), + onClick = { router.pushController(SettingsGeneralController()) }, + ), + SettingsSection( + titleRes = R.string.pref_category_appearance, + painter = rememberVectorPainter(Icons.Outlined.Palette), + onClick = { router.pushController(SettingsAppearanceController()) }, + ), + SettingsSection( + titleRes = R.string.pref_category_library, + painter = painterResource(R.drawable.ic_library_outline_24dp), + onClick = { router.pushController(SettingsLibraryController()) }, + ), + SettingsSection( + titleRes = R.string.pref_category_reader, + painter = rememberVectorPainter(Icons.Outlined.ChromeReaderMode), + onClick = { router.pushController(SettingsReaderController()) }, + ), + SettingsSection( + titleRes = R.string.pref_category_downloads, + painter = rememberVectorPainter(Icons.Outlined.GetApp), + onClick = { router.pushController(SettingsDownloadController()) }, + ), + SettingsSection( + titleRes = R.string.pref_category_tracking, + painter = rememberVectorPainter(Icons.Outlined.Sync), + onClick = { router.pushController(SettingsTrackingController()) }, + ), + SettingsSection( + titleRes = R.string.browse, + painter = painterResource(R.drawable.ic_browse_outline_24dp), + onClick = { router.pushController(SettingsBrowseController()) }, + ), + SettingsSection( + titleRes = R.string.label_backup, + painter = rememberVectorPainter(Icons.Outlined.SettingsBackupRestore), + onClick = { router.pushController(SettingsBackupController()) }, + ), + SettingsSection( + titleRes = R.string.pref_category_security, + painter = rememberVectorPainter(Icons.Outlined.Security), + onClick = { router.pushController(SettingsSecurityController()) }, + ), + SettingsSection( + titleRes = R.string.pref_category_advanced, + painter = rememberVectorPainter(Icons.Outlined.Code), + onClick = { router.pushController(SettingsAdvancedController()) }, + ), + ) + + SettingsMainScreen( + nestedScrollInterop = nestedScrollInterop, + sections = settingsSections, + ) } override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { - // Inflate menu inflater.inflate(R.menu.settings_main, menu) // Initialize search option.