package com.gamedog.vididin.features.zero

import android.app.Activity
import android.content.Intent
import android.view.LayoutInflater
import androidx.activity.viewModels
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updatePadding
import com.ama.core.architecture.appBase.AppViewsActivity
import com.ama.core.architecture.util.setOnClickBatch
import com.gamedog.vididin.R
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
import com.gamedog.vididin.router.Router
import dagger.hilt.android.AndroidEntryPoint
import kotlin.getValue
import com.gamedog.vididin.databinding.ActivityZerobuyBinding as ViewBinding
import com.gamedog.vididin.main.MainUiState as UiState
import com.gamedog.vididin.main.MainViewModel as ViewModel


@AndroidEntryPoint
class ZeroBuyActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnTabStyleListener {

    override val mViewModel: ViewModel by viewModels()
    override fun inflateViewBinding(inflater: LayoutInflater) = ViewBinding.inflate(inflater)

    override fun ViewBinding.initViews() {
        binding.run {
            setOnClickBatch(tvZeroGoldNum, tvZeroLotteryList) {
                when (this) {
                    tvZeroGoldNum ->  {

                    }
                    tvZeroLotteryList ->  {
                        gotoLotteryRecords()
                    }
                }
            }


            titlebar.setTitleText(R.string.zero_buy)
            titlebar.addRightIcon(R.mipmap.icon_question_mark, {
                showHintInfo()
            })
        }


        ZeroBuyRulesDialog(this@ZeroBuyActivity).show()
    }

    override fun ViewBinding.initWindowInsets() {
        ViewCompat.setOnApplyWindowInsetsListener(contentRoot) { v, insets ->
            val systemBars =
                insets.getInsets(WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout())
            v.updatePadding(top = systemBars.top)
            insets
        }
    }

    private fun showHintInfo() {
        //TODO("Not yet implemented")
    }

    override fun ViewBinding.initListeners() {
        //TODO("Not yet implemented")
    }

    override fun ViewBinding.initObservers() {
        //TODO("Not yet implemented")
    }

    override fun ViewBinding.onUiStateCollect(uiState: UiState) {
        //TODO("Not yet implemented")
    }

    override fun onTabIsDarkFont(isDarkFont: Boolean) {
        //TODO("Not yet implemented")
    }


    private fun gotoLotteryRecords() {
        Router.WinRecord.startActivity(this)
    }


    companion object {
        internal fun startActivity(activity: Activity) {
            activity.startActivity(Intent(activity.applicationContext, ZeroBuyActivity::class.java))
        }
    }

}