package com.gh.vspace.menu

import android.os.Bundle
import android.view.View
import com.gh.gamecenter.R
import com.gh.gamecenter.common.base.fragment.BaseBottomDialogFragment
import com.gh.gamecenter.common.utils.setRootBackgroundDrawable
import com.gh.gamecenter.common.utils.toColor
import com.gh.gamecenter.common.utils.toDrawable
import com.gh.gamecenter.databinding.DialogGameDownloadManagerMenuBinding

/**
 * @author : liujiarui
 * date : 2023/3/20
 * description : 畅玩游戏管理item菜单
 */
class VDownLoadManagerItemMenuDialog :
    BaseBottomDialogFragment<DialogGameDownloadManagerMenuBinding>() {

    var onAddIconToLauncherClickListener: (() -> Unit)? = null
    var onClearGameDataClickListener: (() -> Unit)? = null
    var onDeleteGameClickListener: (() -> Unit)? = null


    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        mBinding.addIconToDesktopBtn.setOnClickListener {
            dismissAllowingStateLoss()
            onAddIconToLauncherClickListener?.invoke()
        }
        mBinding.clearGameDataBtn.setOnClickListener {
            dismissAllowingStateLoss()
            onClearGameDataClickListener?.invoke()
        }
        mBinding.uninstallGameBtn.setOnClickListener {
            dismissAllowingStateLoss()
            onDeleteGameClickListener?.invoke()
        }
        mBinding.cancelBtn.setOnClickListener {
            dismissAllowingStateLoss()
        }
    }

    override fun onDarkModeChanged() {
        super.onDarkModeChanged()
        mBinding.run {
            root.setRootBackgroundDrawable(R.drawable.background_shape_white_radius_12_top_only)
            cancelBtn.background = R.drawable.bg_shape_f5_radius_999.toDrawable(requireContext())
            dialogTitleTv.setTextColor(R.color.text_title.toColor(requireContext()))
            cancelBtn.setTextColor(R.color.text_subtitle.toColor(requireContext()))
        }
    }

}