|
@@ -4,6 +4,7 @@ import androidx.annotation.StringRes
|
|
|
import androidx.compose.foundation.clickable
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
|
import androidx.compose.foundation.layout.Row
|
|
|
+import androidx.compose.foundation.layout.RowScope
|
|
|
import androidx.compose.foundation.layout.Spacer
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
import androidx.compose.foundation.layout.padding
|
|
@@ -20,6 +21,7 @@ import androidx.compose.material3.Text
|
|
|
import androidx.compose.runtime.Composable
|
|
|
import androidx.compose.ui.Alignment
|
|
|
import androidx.compose.ui.Modifier
|
|
|
+import androidx.compose.ui.graphics.vector.ImageVector
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
import tachiyomi.presentation.core.theme.header
|
|
@@ -50,13 +52,20 @@ fun HeadingItem(
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
|
-fun BasicItem(
|
|
|
+fun IconItem(
|
|
|
label: String,
|
|
|
+ icon: ImageVector,
|
|
|
onClick: () -> Unit,
|
|
|
) {
|
|
|
- SortItem(
|
|
|
+ BaseSettingsItem(
|
|
|
label = label,
|
|
|
- sortDescending = null,
|
|
|
+ widget = {
|
|
|
+ Icon(
|
|
|
+ imageVector = icon,
|
|
|
+ contentDescription = null,
|
|
|
+ tint = MaterialTheme.colorScheme.primary,
|
|
|
+ )
|
|
|
+ },
|
|
|
onClick = onClick,
|
|
|
)
|
|
|
}
|
|
@@ -73,28 +82,21 @@ fun SortItem(
|
|
|
null -> null
|
|
|
}
|
|
|
|
|
|
- Row(
|
|
|
- modifier = Modifier
|
|
|
- .clickable(onClick = onClick)
|
|
|
- .fillMaxWidth()
|
|
|
- .padding(horizontal = SettingsItemsPaddings.Horizontal, vertical = SettingsItemsPaddings.Vertical),
|
|
|
- verticalAlignment = Alignment.CenterVertically,
|
|
|
- horizontalArrangement = Arrangement.spacedBy(24.dp),
|
|
|
- ) {
|
|
|
- if (arrowIcon != null) {
|
|
|
- Icon(
|
|
|
- imageVector = arrowIcon,
|
|
|
- contentDescription = null,
|
|
|
- tint = MaterialTheme.colorScheme.primary,
|
|
|
- )
|
|
|
- } else {
|
|
|
- Spacer(modifier = Modifier.size(24.dp))
|
|
|
- }
|
|
|
- Text(
|
|
|
- text = label,
|
|
|
- style = MaterialTheme.typography.bodyMedium,
|
|
|
- )
|
|
|
- }
|
|
|
+ BaseSettingsItem(
|
|
|
+ label = label,
|
|
|
+ widget = {
|
|
|
+ if (arrowIcon != null) {
|
|
|
+ Icon(
|
|
|
+ imageVector = arrowIcon,
|
|
|
+ contentDescription = null,
|
|
|
+ tint = MaterialTheme.colorScheme.primary,
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ Spacer(modifier = Modifier.size(24.dp))
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onClick = onClick,
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
@@ -103,23 +105,16 @@ fun CheckboxItem(
|
|
|
checked: Boolean,
|
|
|
onClick: () -> Unit,
|
|
|
) {
|
|
|
- Row(
|
|
|
- modifier = Modifier
|
|
|
- .clickable(onClick = onClick)
|
|
|
- .fillMaxWidth()
|
|
|
- .padding(horizontal = SettingsItemsPaddings.Horizontal, vertical = SettingsItemsPaddings.Vertical),
|
|
|
- verticalAlignment = Alignment.CenterVertically,
|
|
|
- horizontalArrangement = Arrangement.spacedBy(24.dp),
|
|
|
- ) {
|
|
|
- Checkbox(
|
|
|
- checked = checked,
|
|
|
- onCheckedChange = null,
|
|
|
- )
|
|
|
- Text(
|
|
|
- text = label,
|
|
|
- style = MaterialTheme.typography.bodyMedium,
|
|
|
- )
|
|
|
- }
|
|
|
+ BaseSettingsItem(
|
|
|
+ label = label,
|
|
|
+ widget = {
|
|
|
+ Checkbox(
|
|
|
+ checked = checked,
|
|
|
+ onCheckedChange = null,
|
|
|
+ )
|
|
|
+ },
|
|
|
+ onClick = onClick,
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
@@ -127,6 +122,24 @@ fun RadioItem(
|
|
|
label: String,
|
|
|
selected: Boolean,
|
|
|
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(
|
|
|
modifier = Modifier
|
|
@@ -136,10 +149,7 @@ fun RadioItem(
|
|
|
verticalAlignment = Alignment.CenterVertically,
|
|
|
horizontalArrangement = Arrangement.spacedBy(24.dp),
|
|
|
) {
|
|
|
- RadioButton(
|
|
|
- selected = selected,
|
|
|
- onClick = null,
|
|
|
- )
|
|
|
+ widget(this)
|
|
|
Text(
|
|
|
text = label,
|
|
|
style = MaterialTheme.typography.bodyMedium,
|