更新界面
This commit is contained in:
1 parent
60b9f922cc
commit
f8a39f1a24
17 files changed
+795
-233
No files matched your search
@@ -24,7 +24,9 @@ class DetailSeekBar @JvmOverloads constructor(
|
||||
private val isBottomBackground: Boolean
|
||||
|
||||
var valueFormat: ((progress: Int) -> String)? = null
|
||||
var onStartTracking: (() -> Unit)? = null
|
||||
var onChanged: ((progress: Int) -> Unit)? = null
|
||||
var onStopTracking: (() -> Unit)? = null
|
||||
|
||||
var progress: Int
|
||||
get() = binding.slider.value.toInt()
|
||||
@@ -50,14 +52,6 @@ class DetailSeekBar @JvmOverloads constructor(
|
||||
}
|
||||
binding.slider.valueTo = typedArray.getInteger(R.styleable.DetailSeekBar_max, 0).toFloat()
|
||||
typedArray.recycle()
|
||||
if (isBottomBackground && !isInEditMode) {
|
||||
// val isLight = ColorUtils.isColorLight(context.bottomBackground)
|
||||
// val textColor = context.getPrimaryTextColor(isLight)
|
||||
// binding.tvSeekTitle.setTextColor(textColor)
|
||||
// binding.ivSeekPlus.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
|
||||
// binding.ivSeekReduce.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
|
||||
// binding.tvSeekValue.setTextColor(textColor)
|
||||
}
|
||||
binding.ivSeekPlus.setOnClickListener {
|
||||
val newValue = (binding.slider.value + 1).coerceAtMost(binding.slider.valueTo)
|
||||
binding.slider.value = newValue
|
||||
@@ -72,14 +66,19 @@ class DetailSeekBar @JvmOverloads constructor(
|
||||
|
||||
binding.slider.addOnChangeListener { _, value, fromUser ->
|
||||
upValue(value.toInt())
|
||||
|
||||
if (fromUser) {
|
||||
onChanged?.invoke(value.toInt())
|
||||
}
|
||||
}
|
||||
|
||||
binding.slider.addOnSliderTouchListener(object : Slider.OnSliderTouchListener {
|
||||
override fun onStartTrackingTouch(slider: Slider) {
|
||||
// 可以添加开始拖动时的逻辑
|
||||
onStartTracking?.invoke()
|
||||
}
|
||||
|
||||
override fun onStopTrackingTouch(slider: Slider) {
|
||||
onStopTracking?.invoke()
|
||||
onChanged?.invoke(slider.value.toInt())
|
||||
}
|
||||
})
|
||||
|
||||
@@ -9,19 +9,20 @@ import io.legato.kazusa.lib.theme.Selector
|
||||
import io.legato.kazusa.utils.ColorUtils
|
||||
import io.legato.kazusa.utils.dpToPx
|
||||
import androidx.core.content.withStyledAttributes
|
||||
import io.legato.kazusa.utils.themeColor
|
||||
|
||||
class AccentBgTextView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null
|
||||
) : MaterialTextView(context, attrs) {
|
||||
|
||||
private var radiusPx = 0
|
||||
private var radiusPx = 32
|
||||
|
||||
init {
|
||||
context.withStyledAttributes(attrs, R.styleable.AccentBgTextView) {
|
||||
val radiusDp = getDimensionPixelOffset(R.styleable.AccentBgTextView_radius, 0)
|
||||
radiusPx = radiusDp
|
||||
}
|
||||
// context.withStyledAttributes(attrs, R.styleable.AccentBgTextView) {
|
||||
// val radiusDp = getDimensionPixelOffset(R.styleable.AccentBgTextView_radius, 0)
|
||||
// radiusPx = radiusDp
|
||||
// }
|
||||
updateBackground()
|
||||
}
|
||||
|
||||
@@ -31,16 +32,8 @@ class AccentBgTextView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun updateBackground() {
|
||||
val backgroundColor = MaterialColors.getColor(
|
||||
this,
|
||||
com.google.android.material.R.attr.colorPrimaryContainer,
|
||||
//context.getColorCompat(R.color.fallback_bg)
|
||||
)
|
||||
val textColor = MaterialColors.getColor(
|
||||
this,
|
||||
com.google.android.material.R.attr.colorOnPrimaryContainer,
|
||||
//context.getColorCompat(R.color.fallback_text)
|
||||
)
|
||||
val backgroundColor = context.themeColor(com.google.android.material.R.attr.colorPrimaryContainer)
|
||||
val textColor = context.themeColor(com.google.android.material.R.attr.colorOnPrimaryContainer)
|
||||
|
||||
background = Selector.shapeBuild()
|
||||
.setCornerRadius(radiusPx)
|
||||
|
||||
Reference in new issue
Block a user