package com.gh.gamecenter.personal

import android.os.Bundle
import android.view.View
import com.gh.common.util.DirectUtils
import com.gh.gamecenter.R
import com.gh.gamecenter.databinding.FragmentDeliveryInfoBinding
import com.gh.gamecenter.common.base.fragment.ToolbarFragment
import com.gh.gamecenter.common.utils.toColor

class DeliveryInfoFragment : ToolbarFragment() {

    private val mBinding by lazy { FragmentDeliveryInfoBinding.inflate(layoutInflater) }

    override fun getLayoutId() = 0

    override fun getInflatedLayout() = mBinding.root

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        arrayListOf(
            mBinding.addressContainer,
            mBinding.prizeContainer,
            mBinding.withdrawContainer
        ).forEach {
            it.setOnClickListener(this)
        }
    }

    override fun onClick(v: View) {
        super.onClick(v)
        when (v.id) {
            R.id.addressContainer -> DirectUtils.directToAddressInfo(requireContext())

            R.id.prizeContainer -> DirectUtils.directToPrizeInfo(requireContext())

            R.id.withdrawContainer -> DirectUtils.directToWithdrawInfo(requireContext())
        }
    }

    override fun onDarkModeChanged() {
        super.onDarkModeChanged()
        mBinding.divider.setBackgroundColor(R.color.background.toColor(requireContext()))
        mBinding.divider2.setBackgroundColor(R.color.background.toColor(requireContext()))
        mBinding.divider3.setBackgroundColor(R.color.background.toColor(requireContext()))
        mBinding.divider4.setBackgroundColor(R.color.background.toColor(requireContext()))
        mBinding.root.setBackgroundColor(R.color.background_white.toColor(requireContext()))
        mBinding.container.setBackgroundColor(R.color.background_white.toColor(requireContext()))
        mBinding.addressTv.setTextColor(R.color.text_title.toColor(requireContext()))
        mBinding.prizeTv.setTextColor(R.color.text_title.toColor(requireContext()))
        mBinding.withdrawTv.setTextColor(R.color.text_title.toColor(requireContext()))
    }
}