package com.adealink.weparty.playmate.findpartner.page

import com.adealink.frame.aab.util.getCompatString
import com.adealink.frame.mvvm.view.viewBinding
import com.adealink.frame.util.onClick
import com.adealink.weparty.commonui.BaseFragment
import com.adealink.weparty.playmate.R
import com.adealink.weparty.playmate.databinding.FragmentFindPartnerOtherBinding
import com.adealink.weparty.playmate.findpartner.FindPartnerFragment
import com.adealink.weparty.playmate.findpartner.comp.FindPartnerOptionsComp
import com.adealink.weparty.playmate.findpartner.data.OptionData
import com.adealink.weparty.playmate.findpartner.viewmodel.FindPartnerViewModel
import com.adealink.weparty.viewmodel.parentFragmentViewModels
import com.adealink.weparty.R as APP_R

class SelectOtherFragment : BaseFragment(R.layout.fragment_find_partner_other) {

    companion object {
        const val TAG = "SelectOtherFragment"
    }

    private val binding by viewBinding(FragmentFindPartnerOtherBinding::bind)

    private val findPartnerViewModel by parentFragmentViewModels<FindPartnerViewModel, FindPartnerFragment>(
        FindPartnerFragment::class.java
    )

    private lateinit var genderOption: FindPartnerOptionsComp
    private lateinit var ageOption: FindPartnerOptionsComp
    private lateinit var locationOption: FindPartnerOptionsComp
    private lateinit var evaluateOption: FindPartnerOptionsComp
    private lateinit var priceOption: FindPartnerOptionsComp
    override fun initViews() {
        super.initViews()
        binding.btnReset.onClick {
            reset()
        }
        binding.btnSubmit.onClick {
            submit()
        }
    }

    override fun initComponents() {
        super.initComponents()
        FindPartnerOptionsComp(
            this,
            getCompatString(APP_R.string.common_gender),
            listOf(
                OptionData(getCompatString(R.string.playmate_find_partner_option_unlimited), true),
                OptionData(getCompatString(R.string.playmate_find_partner_option_male)),
                OptionData(getCompatString(R.string.playmate_find_partner_option_female)),
            ),
            binding.vOptionGender
        ).also { genderOption = it }.attach()

        FindPartnerOptionsComp(
            this,
            getCompatString(APP_R.string.common_age),
            listOf(
                OptionData(getCompatString(R.string.playmate_find_partner_option_unlimited), true),
                OptionData(getCompatString(R.string.playmate_find_partner_option_age_15_25)),
                OptionData(getCompatString(R.string.playmate_find_partner_option_age_25_35)),
                OptionData(getCompatString(R.string.playmate_find_partner_option_age_35)),
            ),
            binding.vOptionAge
        ).also { ageOption = it }.attach()

        FindPartnerOptionsComp(
            this,
            getCompatString(APP_R.string.common_area),
            listOf(
                OptionData(getCompatString(R.string.playmate_find_partner_option_unlimited), true),
                OptionData(getCompatString(R.string.playmate_find_partner_option_location_jakarta)),
                OptionData(getCompatString(R.string.playmate_find_partner_option_location_timur)),
                OptionData(getCompatString(R.string.playmate_find_partner_option_location_barat)),
                OptionData(getCompatString(R.string.playmate_find_partner_option_location_pasut)),
                OptionData(getCompatString(R.string.playmate_find_partner_option_location_utare)),
                OptionData(getCompatString(R.string.playmate_find_partner_option_location_selatan)),
                OptionData(getCompatString(R.string.playmate_find_partner_option_location_seribu)),
                OptionData(getCompatString(R.string.playmate_find_partner_option_location_kepulanuan)),
            ),
            binding.vOptionLocation
        ).also { locationOption = it }.attach()

        FindPartnerOptionsComp(
            this,
            getCompatString(APP_R.string.common_star_rank_filter),
            listOf(
                OptionData(getCompatString(R.string.playmate_find_partner_option_unlimited), true),
                OptionData(getCompatString(R.string.playmate_find_partner_option_evaluate_high_low)),
                OptionData(getCompatString(R.string.playmate_find_partner_option_evaluate_low_high)),
            ),
            binding.vOptionEvaluate
        ).also { evaluateOption = it }.attach()

        FindPartnerOptionsComp(
            this,
            getCompatString(APP_R.string.common_price_rank_filter),
            listOf(
                OptionData(getCompatString(R.string.playmate_find_partner_option_unlimited), true),
                OptionData(getCompatString(R.string.playmate_find_partner_option_price_0_1000)),
                OptionData(getCompatString(R.string.playmate_find_partner_option_price_1000_1500)),
                OptionData(getCompatString(R.string.playmate_find_partner_option_price_1500_2500)),
                OptionData(getCompatString(R.string.playmate_find_partner_option_price_2500_5000)),
                OptionData(getCompatString(R.string.playmate_find_partner_option_price_5000)),
            ),
            binding.vOptionPrice
        ).also { priceOption = it }.attach()
    }

    private fun reset() {
        genderOption.reset()
        ageOption.reset()
        locationOption.reset()
        evaluateOption.reset()
        priceOption.reset()
    }

    private fun submit() {

    }

}