fix(settings): 对比度滑块标签不显示
This commit is contained in:
parent
2fbccaf081
commit
0c566aa7e1
4 changed files with 26 additions and 30 deletions
|
|
@ -15,8 +15,8 @@ enum class ContrastLevel(val value: Float) {
|
|||
VeryLow -> R.string.contrast_very_low
|
||||
Low -> R.string.contrast_low
|
||||
Default -> R.string.contrast_default
|
||||
Medium -> R.string.contrast_medium
|
||||
High -> R.string.contrast_high
|
||||
Medium -> R.string.contrast_high
|
||||
High -> R.string.contrast_very_high
|
||||
}
|
||||
return context.getString(resId)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
package cn.super12138.todo.ui.pages.settings.components.contrast
|
||||
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.sizeIn
|
||||
import androidx.compose.foundation.layout.wrapContentWidth
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Label
|
||||
import androidx.compose.material3.PlainTooltip
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Slider
|
||||
import androidx.compose.material3.SliderDefaults
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
|
|
@ -40,7 +41,6 @@ fun ContrastPicker(
|
|||
Constants.PREF_CONTRAST_LEVEL,
|
||||
Constants.PREF_CONTRAST_LEVEL_DEFAULT
|
||||
)
|
||||
val interactionSource = remember { MutableInteractionSource() }
|
||||
|
||||
Slider(
|
||||
modifier = Modifier.semantics {
|
||||
|
|
@ -53,23 +53,19 @@ fun ContrastPicker(
|
|||
},
|
||||
valueRange = -1f..1f,
|
||||
steps = 3,
|
||||
interactionSource = interactionSource,
|
||||
thumb = {
|
||||
Label(
|
||||
label = {
|
||||
PlainTooltip(
|
||||
modifier = Modifier
|
||||
.sizeIn(45.dp, 25.dp)
|
||||
.wrapContentWidth()
|
||||
) {
|
||||
Text(ContrastLevel.fromFloat(contrastState).getDisplayName(context))
|
||||
}
|
||||
},
|
||||
interactionSource = interactionSource
|
||||
) {
|
||||
SliderDefaults.Thumb(interactionSource)
|
||||
}
|
||||
}
|
||||
)
|
||||
Spacer(Modifier.size(5.dp))
|
||||
CompositionLocalProvider(LocalTextStyle provides MaterialTheme.typography.bodyMedium) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text(stringResource(R.string.contrast_very_low))
|
||||
Text(stringResource(R.string.contrast_low))
|
||||
Text(stringResource(R.string.contrast_default))
|
||||
Text(stringResource(R.string.contrast_high))
|
||||
Text(stringResource(R.string.contrast_very_high))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -68,11 +68,11 @@
|
|||
<string name="dark_mode_dark">深色模式</string>
|
||||
<string name="pref_contrast_level">对比度</string>
|
||||
<string name="pref_contrast_level_desc">调整应用的颜色对比度</string>
|
||||
<string name="contrast_very_low">非常低</string>
|
||||
<string name="contrast_very_low">极低</string>
|
||||
<string name="contrast_low">低</string>
|
||||
<string name="contrast_default">默认</string>
|
||||
<string name="contrast_medium">中</string>
|
||||
<string name="contrast_high">高</string>
|
||||
<string name="contrast_very_high">极高</string>
|
||||
<string name="tip_change_contrast_level">更改颜色对比度</string>
|
||||
<string name="pref_interface">界面</string>
|
||||
<string name="pref_interface_desc">待办列表、排序方式</string>
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@
|
|||
<string name="contrast_very_low">Very Low</string>
|
||||
<string name="contrast_low">Low</string>
|
||||
<string name="contrast_default">Default</string>
|
||||
<string name="contrast_medium">Medium</string>
|
||||
<string name="contrast_high">High</string>
|
||||
<string name="contrast_very_high">Very High</string>
|
||||
<string name="tip_change_contrast_level">Change the contrast level</string>
|
||||
<string name="pref_interface">Interface</string>
|
||||
<string name="pref_interface_desc">To-Do List, sorting method</string>
|
||||
|
|
|
|||
Loading…
Reference in a new issue