Show current filter in list header
parent
c1b6cef362
commit
675e95da2b
@ -0,0 +1,23 @@
|
|||||||
|
package org.koitharu.kotatsu.list.ui.adapter
|
||||||
|
|
||||||
|
import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding
|
||||||
|
import org.koitharu.kotatsu.base.ui.widgets.ChipsView
|
||||||
|
import org.koitharu.kotatsu.core.model.MangaTag
|
||||||
|
import org.koitharu.kotatsu.databinding.ItemCurrentFilterBinding
|
||||||
|
import org.koitharu.kotatsu.list.ui.model.CurrentFilterModel
|
||||||
|
import org.koitharu.kotatsu.list.ui.model.ListModel
|
||||||
|
|
||||||
|
fun currentFilterAD(
|
||||||
|
onTagRemoveClick: (MangaTag) -> Unit,
|
||||||
|
) = adapterDelegateViewBinding<CurrentFilterModel, ListModel, ItemCurrentFilterBinding>(
|
||||||
|
{ inflater, parent -> ItemCurrentFilterBinding.inflate(inflater, parent, false) }
|
||||||
|
) {
|
||||||
|
|
||||||
|
binding.chipsTags.onChipCloseClickListener = ChipsView.OnChipCloseClickListener { chip, data ->
|
||||||
|
onTagRemoveClick(data as? MangaTag ?: return@OnChipCloseClickListener)
|
||||||
|
}
|
||||||
|
|
||||||
|
bind {
|
||||||
|
binding.chipsTags.setChips(item.chips)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
package org.koitharu.kotatsu.list.ui.model
|
||||||
|
|
||||||
|
import org.koitharu.kotatsu.base.ui.widgets.ChipsView
|
||||||
|
|
||||||
|
data class CurrentFilterModel(
|
||||||
|
val chips: Collection<ChipsView.ChipModel>,
|
||||||
|
) : ListModel
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<HorizontalScrollView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<org.koitharu.kotatsu.base.ui.widgets.ChipsView
|
||||||
|
android:id="@+id/chips_tags"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:closeIconEnabled="true"
|
||||||
|
app:singleLine="true" />
|
||||||
|
|
||||||
|
</HorizontalScrollView>
|
||||||
Loading…
Reference in New Issue