package com.adealink.weparty.ui.category.data

import com.adealink.weparty.commonui.recycleview.diffutil.BaseListItemData
import com.adealink.weparty.module.playmate.data.PlaymateCategoryData
import com.adealink.weparty.module.profile.data.UserInterest


sealed class CategoryItemData : BaseListItemData
data class CategoryListTitleData(
    val data: PlaymateCategoryData,
    val marginTop: Int = 0,

    var selected: Boolean = false
) : CategoryItemData()

data class CategoryListData(
    val data: PlaymateCategoryData
) : CategoryItemData() {

    var selectedCodes = mutableSetOf<String>()
    fun getUserInterest(): List<UserInterest> {
        val interests = mutableListOf<UserInterest>()
        for (categoryData in data.subCategoryList) {
            if (selectedCodes.contains(categoryData.code)) {
                interests.add(UserInterest(categoryData.code, categoryData.name))
            }
        }
        return interests
    }
}

data class CategoryListItemData(
    val firstCode: String,
    val data: PlaymateCategoryData,
    var selected: Boolean = false
) : CategoryItemData() {
    override fun areContentsTheSame(newItem: Any): Boolean {
        val other = (newItem as? CategoryListItemData) ?: return false
        return data == other.data
                && selected == other.selected
    }
}


data class CategoryListBottomData(
    var height: Int
) : CategoryItemData()