package com.gamedog.vididin.features.version

import android.app.Activity
import android.content.Intent
import android.view.LayoutInflater
import androidx.activity.viewModels
import androidx.core.view.isVisible
import com.ama.core.architecture.appBase.AppViewsActivity
import com.ama.core.architecture.util.AndroidUtil
import com.gamedog.vididin.beans.RecordGold
import com.gamedog.vididin.core.login.login.AccountManager
import com.viddin.videos.free.R
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
import com.remax.notification.BuildConfig
import dagger.hilt.android.AndroidEntryPoint
import kotlin.getValue
import com.viddin.videos.free.databinding.ActivityVersionBinding as ViewBinding
import com.gamedog.vididin.main.MainUiState as UiState
import com.gamedog.vididin.main.MainViewModel as ViewModel


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

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

    override fun ViewBinding.initViews() {

        with(binding) {
            titlebar.setBackIconColor(R.color.black)
            titlebar.setTitleText(R.string.version, R.color.black)

            tvVersion.text = AndroidUtil.getAppVersionInfo()



            // For Testing
            llTesting.isVisible = BuildConfig.DEBUG
            if (BuildConfig.DEBUG) {
                butCash.setOnClickListener {
                    try {
                        val cashNum: Double = evCash.text.toString().toDouble()
                        AccountManager.adjustCash(cashNum, null)
                    } catch (e: Exception) {
                        e.printStackTrace()
                    }
                }

                butGold.setOnClickListener {
                    try {
                        val goldNum = evGold.text.toString().toLong()
                        AccountManager.adjustGold(goldNum, RecordGold())
                    } catch (e: Exception) {
                        e.printStackTrace()
                    }
                }
            }
        }

    }

    override fun ViewBinding.initWindowInsets() {
        setImmerseRootView(contentRoot)
    }

    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")
    }


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

}