mirror of
https://github.com/mihonapp/mihon.git
synced 2025-06-29 20:47:50 +02:00
Refactor grid size slider composable for reuse
This commit is contained in:
@ -3,6 +3,7 @@ package tachiyomi.presentation.core.components
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.RowScope
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
@ -17,6 +18,7 @@ import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.RadioButton
|
||||
import androidx.compose.material3.Slider
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
@ -135,6 +137,43 @@ fun RadioItem(
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SliderItem(
|
||||
label: String,
|
||||
min: Int,
|
||||
max: Int,
|
||||
value: Int,
|
||||
valueText: String,
|
||||
onChange: (Int) -> Unit,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(
|
||||
horizontal = SettingsItemsPaddings.Horizontal,
|
||||
vertical = SettingsItemsPaddings.Vertical,
|
||||
),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(24.dp),
|
||||
) {
|
||||
Column(modifier = Modifier.weight(0.5f)) {
|
||||
Text(
|
||||
text = label,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
)
|
||||
Text(valueText)
|
||||
}
|
||||
|
||||
Slider(
|
||||
value = value.toFloat(),
|
||||
onValueChange = { onChange(it.toInt()) },
|
||||
modifier = Modifier.weight(1.5f),
|
||||
valueRange = min.toFloat()..max.toFloat(),
|
||||
steps = max - min,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun BaseSettingsItem(
|
||||
label: String,
|
||||
|
Reference in New Issue
Block a user