package com.gh.gamecenter.gamedetail.fuli.kaifu

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatDialogFragment
import androidx.fragment.app.activityViewModels
import androidx.viewpager.widget.ViewPager.LayoutParams
import com.gh.gamecenter.R
import com.gh.gamecenter.WebActivity
import com.gh.gamecenter.common.utils.dip2px
import com.gh.gamecenter.databinding.DialogWechatReserveSuccessBinding
import com.google.android.material.bottomsheet.BottomSheetDialogFragment

/**
 * 游戏订阅成功-未绑定微信弹窗
 */
class ServersCalendarWeChatSubscriptionSuccessDialog : AppCompatDialogFragment() {

    private lateinit var viewBinding: DialogWechatReserveSuccessBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setStyle(BottomSheetDialogFragment.STYLE_NORMAL, com.gh.gamecenter.common.R.style.DialogWindowTransparent)
    }

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
        val rootView = DialogWechatReserveSuccessBinding.inflate(inflater, container, false)
            .also {
                viewBinding = it
            }.root
        return rootView.apply {
            layoutParams = ViewGroup.LayoutParams(300F.dip2px(), LayoutParams.WRAP_CONTENT)
        }
    }

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

        viewBinding.closeBtn.setOnClickListener {
            dismissAllowingStateLoss()
        }

        viewBinding.closeBtn.setOnClickListener {
            dismissAllowingStateLoss()
        }

        viewBinding.titleIv.setImageResource(R.drawable.bg_servers_calendar_reserve_success)

        viewBinding.openBtn.setOnClickListener {
            it.context.startActivity(WebActivity.getBindWechatIntent(context))
            dismissAllowingStateLoss()
        }

        viewBinding.contentTv.text = getString(R.string.servers_calendar_subscription_dialog_wechat_content)
    }
}