Commit e964b611 authored by shiyl's avatar shiyl

选择类目增加二次进入被选中的效果

parent 56b971c2
......@@ -5,14 +5,15 @@ package com.yidian.shenghuoquan.commodity.dto
* 类目列表
*/
data class CategoryListDto(
val category_id: Int,// 分类id
val name: String,// 分类名称
val sub_list: List<SubCategory>// 二级分类
val category_id: Int,// 分类id
val name: String,// 分类名称
val sub_list: List<SubCategory>// 二级分类
)
data class SubCategory(
val category_id: Int,
val name: String
val category_id: Int,
val name: String,
var isSelect: Boolean = false
)
/**
......
......@@ -68,6 +68,7 @@ class ChooseCategoryViewModel : BaseViewModel() {
if (categoryListDto.category_id == selectedCategory.value?.firstCategoryId) {
categoryListDto.sub_list.forEach { sub ->
if (sub.category_id == selectSecondCategoryId.value) {
sub.isSelect = true
// 匹配成功的一级类目
matchSuccessFirstCategory = categoryListDto
matchSuccess = true
......
package com.yidian.shenghuoquan.commodity.ui.coupon.adapter
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.yidian.shenghuoquan.commodity.R
import com.yidian.shenghuoquan.commodity.dto.SubCategory
class CategorySubListAdapter: BaseQuickAdapter<SubCategory, BaseViewHolder>(R.layout.commodity_layout_category_list_item) {
class CategorySubListAdapter : BaseQuickAdapter<SubCategory, BaseViewHolder>(R.layout.commodity_layout_category_list_item) {
override fun convert(holder: BaseViewHolder, item: SubCategory) {
holder.getView<TextView>(R.id.tv_category_name).text = item.name
val categoryName = holder.getView<TextView>(R.id.tv_category_name)
categoryName.text = item.name
if (item.isSelect) {
categoryName.setTextColor(ContextCompat.getColor(context, R.color.color_1852F1))
} else {
categoryName.setTextColor(ContextCompat.getColor(context, R.color.color_333333))
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment