Fix chips style

pull/592/head
Koitharu 2 years ago
parent fca9ba98cd
commit 353d856bf5
Signed by: Koitharu
GPG Key ID: 676DEE768C17A9D7

@ -1,6 +1,5 @@
package org.koitharu.kotatsu.core.ui.widgets
import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.view.View.OnClickListener
@ -27,6 +26,7 @@ class ChipsView @JvmOverloads constructor(
private val chipOnCloseListener = OnClickListener {
onChipCloseClickListener?.onChipCloseClick(it as Chip, it.tag)
}
private val chipStyle: Int
var onChipClickListener: OnChipClickListener? = null
set(value) {
field = value
@ -41,10 +41,9 @@ class ChipsView @JvmOverloads constructor(
}
init {
@SuppressLint("CustomViewStyleable")
val a = context.obtainStyledAttributes(null, com.google.android.material.R.styleable.Chip, 0, R.style.Widget_Kotatsu_Chip)
a.recycle()
chipStyle = context.obtainStyledAttributes(attrs, R.styleable.ChipsView, defStyleAttr, 0).use {
it.getResourceId(R.styleable.ChipsView_chipStyle, R.style.Widget_Kotatsu_Chip)
}
if (isInEditMode) {
setChips(
List(5) {
@ -104,12 +103,11 @@ class ChipsView @JvmOverloads constructor(
private fun addChip(): Chip {
val chip = Chip(context)
val drawable = ChipDrawable.createFromAttributes(context, null, 0, R.style.Widget_Kotatsu_Chip)
val drawable = ChipDrawable.createFromAttributes(context, null, 0, chipStyle)
chip.setChipDrawable(drawable)
chip.isCheckedIconVisible = true
chip.isChipIconVisible = false
chip.setCheckedIconResource(R.drawable.ic_check)
// chip.checkedIconTint = chip.ic
chip.isCloseIconVisible = onChipCloseClickListener != null
chip.setOnCloseIconClickListener(chipOnCloseListener)
chip.setEnsureMinTouchTargetSize(false)

@ -114,10 +114,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:paddingVertical="8dp"
android:drawablePadding="16dp"
android:paddingHorizontal="@dimen/margin_normal"
android:gravity="center_vertical"
android:paddingHorizontal="@dimen/margin_normal"
android:paddingVertical="8dp"
android:textAppearance="?textAppearanceBodySmall"
android:visibility="gone"
app:drawableStartCompat="@drawable/ic_error_small"

@ -120,18 +120,9 @@
<item name="trackCornerRadius">@dimen/mtrl_progress_indicator_full_rounded_corner_radius</item>
</style>
<style name="Widget.Kotatsu.Chip" parent="Widget.Material3.Chip.Suggestion">
<!--<item name="chipBackgroundColor">?attr/m3ColorBackground</item>-->
<item name="rippleColor">?attr/colorControlHighlight</item>
<style name="Widget.Kotatsu.Chip" parent="Widget.Material3.Chip.Suggestion" />
<!-- Custom chip states -->
<item name="android:clickable">true</item>
<item name="android:focusable">true</item>
</style>
<style name="Widget.Kotatsu.Chip.Filter" parent="Widget.Material3.Chip.Filter">
</style>
<style name="Widget.Kotatsu.Chip.Filter" parent="Widget.Material3.Chip.Filter" />
<style name="Widget.Kotatsu.Button.More" parent="Widget.Material3.Button.TextButton">
<item name="android:minWidth">48dp</item>

Loading…
Cancel
Save