From 30bea8b753fbc40b1c889bdc180cb99f643f89e8 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 15 Jul 2023 14:31:13 -0400 Subject: [PATCH] Replace library sheet display modes with FlowRow of Chips --- .../library/LibrarySettingsDialog.kt | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/library/LibrarySettingsDialog.kt b/app/src/main/java/eu/kanade/presentation/library/LibrarySettingsDialog.kt index d91f8fc046..1db4c0f183 100644 --- a/app/src/main/java/eu/kanade/presentation/library/LibrarySettingsDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/library/LibrarySettingsDialog.kt @@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.remember @@ -25,10 +26,11 @@ import tachiyomi.domain.library.model.sort import tachiyomi.domain.library.service.LibraryPreferences import tachiyomi.presentation.core.components.CheckboxItem import tachiyomi.presentation.core.components.HeadingItem -import tachiyomi.presentation.core.components.RadioItem +import tachiyomi.presentation.core.components.SettingsFlowRow import tachiyomi.presentation.core.components.SliderItem import tachiyomi.presentation.core.components.SortItem import tachiyomi.presentation.core.components.TriStateItem +import tachiyomi.presentation.core.components.material.ChoiceChip @Composable fun LibrarySettingsDialog( @@ -167,23 +169,26 @@ private fun ColumnScope.SortPage( } } +private val displayModes = listOf( + R.string.action_display_grid to LibraryDisplayMode.CompactGrid, + R.string.action_display_comfortable_grid to LibraryDisplayMode.ComfortableGrid, + R.string.action_display_cover_only_grid to LibraryDisplayMode.CoverOnlyGrid, + R.string.action_display_list to LibraryDisplayMode.List, +) + @Composable private fun ColumnScope.DisplayPage( screenModel: LibrarySettingsScreenModel, ) { - HeadingItem(R.string.action_display_mode) val displayMode by screenModel.libraryPreferences.libraryDisplayMode().collectAsState() - listOf( - R.string.action_display_grid to LibraryDisplayMode.CompactGrid, - R.string.action_display_comfortable_grid to LibraryDisplayMode.ComfortableGrid, - R.string.action_display_cover_only_grid to LibraryDisplayMode.CoverOnlyGrid, - R.string.action_display_list to LibraryDisplayMode.List, - ).map { (titleRes, mode) -> - RadioItem( - label = stringResource(titleRes), - selected = displayMode == mode, - onClick = { screenModel.setDisplayMode(mode) }, - ) + SettingsFlowRow(R.string.action_display_mode) { + displayModes.map { (titleRes, mode) -> + ChoiceChip( + isSelected = displayMode == mode, + onClick = { screenModel.setDisplayMode(mode) }, + content = { Text(stringResource(titleRes)) }, + ) + } } if (displayMode != LibraryDisplayMode.List) {