mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-21 14:51:52 +01:00
Add an icon to "Item Per Row" on library sheet (#9414)
Also cleanup `SettingsItems.kt`
This commit is contained in:
parent
2cb08e6bb1
commit
c21813a8b5
@ -5,6 +5,8 @@ import androidx.compose.foundation.layout.ColumnScope
|
|||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.outlined.Apps
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
@ -25,9 +27,9 @@ import tachiyomi.domain.library.model.display
|
|||||||
import tachiyomi.domain.library.model.sort
|
import tachiyomi.domain.library.model.sort
|
||||||
import tachiyomi.domain.library.service.LibraryPreferences
|
import tachiyomi.domain.library.service.LibraryPreferences
|
||||||
import tachiyomi.domain.manga.model.TriStateFilter
|
import tachiyomi.domain.manga.model.TriStateFilter
|
||||||
import tachiyomi.presentation.core.components.BasicItem
|
|
||||||
import tachiyomi.presentation.core.components.CheckboxItem
|
import tachiyomi.presentation.core.components.CheckboxItem
|
||||||
import tachiyomi.presentation.core.components.HeadingItem
|
import tachiyomi.presentation.core.components.HeadingItem
|
||||||
|
import tachiyomi.presentation.core.components.IconItem
|
||||||
import tachiyomi.presentation.core.components.RadioItem
|
import tachiyomi.presentation.core.components.RadioItem
|
||||||
import tachiyomi.presentation.core.components.SortItem
|
import tachiyomi.presentation.core.components.SortItem
|
||||||
|
|
||||||
@ -206,8 +208,9 @@ private fun ColumnScope.DisplayPage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (category.display != LibraryDisplayMode.List) {
|
if (category.display != LibraryDisplayMode.List) {
|
||||||
BasicItem(
|
IconItem(
|
||||||
label = stringResource(R.string.pref_library_columns),
|
label = stringResource(R.string.pref_library_columns),
|
||||||
|
icon = Icons.Outlined.Apps,
|
||||||
onClick = { showColumnsDialog = true },
|
onClick = { showColumnsDialog = true },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import androidx.annotation.StringRes
|
|||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.RowScope
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
@ -20,6 +21,7 @@ import androidx.compose.material3.Text
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
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.vector.ImageVector
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import tachiyomi.presentation.core.theme.header
|
import tachiyomi.presentation.core.theme.header
|
||||||
@ -50,13 +52,20 @@ fun HeadingItem(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun BasicItem(
|
fun IconItem(
|
||||||
label: String,
|
label: String,
|
||||||
|
icon: ImageVector,
|
||||||
onClick: () -> Unit,
|
onClick: () -> Unit,
|
||||||
) {
|
) {
|
||||||
SortItem(
|
BaseSettingsItem(
|
||||||
label = label,
|
label = label,
|
||||||
sortDescending = null,
|
widget = {
|
||||||
|
Icon(
|
||||||
|
imageVector = icon,
|
||||||
|
contentDescription = null,
|
||||||
|
tint = MaterialTheme.colorScheme.primary,
|
||||||
|
)
|
||||||
|
},
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -73,28 +82,21 @@ fun SortItem(
|
|||||||
null -> null
|
null -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
Row(
|
BaseSettingsItem(
|
||||||
modifier = Modifier
|
label = label,
|
||||||
.clickable(onClick = onClick)
|
widget = {
|
||||||
.fillMaxWidth()
|
if (arrowIcon != null) {
|
||||||
.padding(horizontal = SettingsItemsPaddings.Horizontal, vertical = SettingsItemsPaddings.Vertical),
|
Icon(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
imageVector = arrowIcon,
|
||||||
horizontalArrangement = Arrangement.spacedBy(24.dp),
|
contentDescription = null,
|
||||||
) {
|
tint = MaterialTheme.colorScheme.primary,
|
||||||
if (arrowIcon != null) {
|
)
|
||||||
Icon(
|
} else {
|
||||||
imageVector = arrowIcon,
|
Spacer(modifier = Modifier.size(24.dp))
|
||||||
contentDescription = null,
|
}
|
||||||
tint = MaterialTheme.colorScheme.primary,
|
},
|
||||||
)
|
onClick = onClick,
|
||||||
} else {
|
)
|
||||||
Spacer(modifier = Modifier.size(24.dp))
|
|
||||||
}
|
|
||||||
Text(
|
|
||||||
text = label,
|
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -103,23 +105,16 @@ fun CheckboxItem(
|
|||||||
checked: Boolean,
|
checked: Boolean,
|
||||||
onClick: () -> Unit,
|
onClick: () -> Unit,
|
||||||
) {
|
) {
|
||||||
Row(
|
BaseSettingsItem(
|
||||||
modifier = Modifier
|
label = label,
|
||||||
.clickable(onClick = onClick)
|
widget = {
|
||||||
.fillMaxWidth()
|
Checkbox(
|
||||||
.padding(horizontal = SettingsItemsPaddings.Horizontal, vertical = SettingsItemsPaddings.Vertical),
|
checked = checked,
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
onCheckedChange = null,
|
||||||
horizontalArrangement = Arrangement.spacedBy(24.dp),
|
)
|
||||||
) {
|
},
|
||||||
Checkbox(
|
onClick = onClick,
|
||||||
checked = checked,
|
)
|
||||||
onCheckedChange = null,
|
|
||||||
)
|
|
||||||
Text(
|
|
||||||
text = label,
|
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -127,6 +122,24 @@ fun RadioItem(
|
|||||||
label: String,
|
label: String,
|
||||||
selected: Boolean,
|
selected: Boolean,
|
||||||
onClick: () -> Unit,
|
onClick: () -> Unit,
|
||||||
|
) {
|
||||||
|
BaseSettingsItem(
|
||||||
|
label = label,
|
||||||
|
widget = {
|
||||||
|
RadioButton(
|
||||||
|
selected = selected,
|
||||||
|
onClick = null,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
onClick = onClick,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun BaseSettingsItem(
|
||||||
|
label: String,
|
||||||
|
widget: @Composable RowScope.() -> Unit,
|
||||||
|
onClick: () -> Unit,
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@ -136,10 +149,7 @@ fun RadioItem(
|
|||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.spacedBy(24.dp),
|
horizontalArrangement = Arrangement.spacedBy(24.dp),
|
||||||
) {
|
) {
|
||||||
RadioButton(
|
widget(this)
|
||||||
selected = selected,
|
|
||||||
onClick = null,
|
|
||||||
)
|
|
||||||
Text(
|
Text(
|
||||||
text = label,
|
text = label,
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
Loading…
Reference in New Issue
Block a user