package com.gh.gamecenter.login.utils

import android.content.Context
import android.text.Html
import com.gh.gamecenter.common.utils.DialogHelper.showGuideDialog
import com.gh.gamecenter.common.utils.toColor
import com.gh.gamecenter.common.utils.toDrawable
import com.gh.gamecenter.core.utils.EmptyCallback
import com.gh.gamecenter.login.R

object DialogHelper {

    @JvmStatic
    fun showLoginPolicyDialog(
        oauthContext: Context,
        context: Context,
        isFromQuickLogin: Boolean,
        privacyText: CharSequence,
        confirmClickCallback: EmptyCallback,
    ) {
        val contentTvStr = if (isFromQuickLogin) {
            context.getString(R.string.dialog_quick_login_policy_content, privacyText)
        } else {
            context.getString(R.string.dialog_login_policy_content)
        }
        showGuideDialog(
            oauthContext,
            "服务协议和隐私政策等指引",
            Html.fromHtml(contentTvStr),
            "同意并继续",
            "不同意",
            {
                NewFlatLogUtils.logLoginPrivacyPolicyPopClick("同意并继续")
                confirmClickCallback.onCallback()
            },
            {
                NewFlatLogUtils.logLoginPrivacyPolicyPopClick("不同意")
            },
            uiModificationCallback = { binding ->
                binding.run {
                    rootContainer.background = com.gh.gamecenter.common.R.drawable.background_shape_white_radius_8.toDrawable(context)
                    titleTv.setTextColor(com.gh.gamecenter.common.R.color.text_primary.toColor(context))
                    contentTv.setTextColor(com.gh.gamecenter.common.R.color.text_secondary.toColor(context))
                    cancelTv.setTextColor(com.gh.gamecenter.common.R.color.text_primary.toColor(context))
                    cancelTv.background = com.gh.gamecenter.common.R.drawable.bg_shape_ui_container_2_radius_999.toDrawable(context)
                    confirmTv.setTextColor(com.gh.gamecenter.common.R.color.text_aw_primary.toColor(context))
                    confirmTv.background = com.gh.gamecenter.common.R.drawable.button_blue_oval.toDrawable(context)
                }
            }
        )
    }
}