package com.gh.gamecenter.login.provider

import android.app.Dialog
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.Window
import com.therouter.router.Route
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.common.databinding.SetWaitDialogBinding
import com.gh.gamecenter.common.utils.toColor
import com.gh.gamecenter.common.utils.toDrawable
import com.gh.gamecenter.common.utils.toResString
import com.gh.gamecenter.core.provider.ILoginProvider
import com.gh.gamecenter.login.R
import com.gh.gamecenter.login.databinding.LayoutQuickLoginBackgroundBinding
import com.gh.gamecenter.login.user.LoginTag
import com.gh.gamecenter.login.utils.DialogHelper
import com.gh.gamecenter.login.utils.QuickLoginHelper

@com.therouter.inject.ServiceProvider
class LoginProviderImpl : ILoginProvider {

    override fun showLoginPolicyDialog(
        authContent: Context,
        context: Context,
        isFromQuickLogin: Boolean,
        privacyText: String,
        callback: () -> Unit
    ) {
        DialogHelper.showLoginPolicyDialog(authContent, context, true, privacyText) {
            callback()
        }
    }

    override fun createQuickLoginBackgroundView(context: Context): View =
        LayoutQuickLoginBackgroundBinding.inflate(LayoutInflater.from(context)).root


    override fun startQuickLoginHelperPageFromQuickLogin(
        loginToken: String,
        context: Context,
        continuablePath: String?,
        callback: (() -> Unit)?
    ) {
        QuickLoginHelper.startQuickLoginHelperPage(LoginTag.oauth, loginToken, context, continuablePath, callback)
    }

    override fun startCodeLoginPageFromQuickLogin(
        openAuthPageSuccess: Boolean,
        context: Context,
        continuablePath: String?,
        callback: (() -> Unit)?
    ) {
        QuickLoginHelper.startCodeLoginPage(openAuthPageSuccess, context, continuablePath, callback)
    }

    override fun createCustomView(context: Context, continuablePath: String?, callback: (() -> Unit)?): View {
        return QuickLoginHelper.createCustomView(context, continuablePath, callback)
    }

}