package com.abbidot.tracker.ui.activity

import android.content.Intent
import android.view.View
import com.abbidot.baselibrary.constant.EventName
import com.abbidot.baselibrary.constant.MMKVKey
import com.abbidot.baselibrary.eventbus.XEventBus
import com.abbidot.baselibrary.util.MMKVUtil
import com.abbidot.tracker.R
import com.abbidot.tracker.base.BaseActivity
import com.abbidot.tracker.databinding.ActivitySayHelloBinding
import com.abbidot.tracker.ui.activity.account.CreateAccountV2Activity
import com.abbidot.tracker.ui.activity.account.LoginV2Activity

class SayHelloActivity : BaseActivity<ActivitySayHelloBinding>(ActivitySayHelloBinding::inflate) {

    override fun getTopBar() = null

    override fun initData() {
        super.initData()

        mViewBinding.apply {
            root.setBackgroundResource(R.drawable.icon_say_hi_bg)
            setOnClickListenerViews(btnSayHelloLogin, btnSayHelloSignup)
        }
    }

    override fun liveDataObserve() {
        XEventBus.observe(this, EventName.FinishActivity) {
            finish()
        }
    }

    override fun onClick(v: View?) {
        mViewBinding.apply {
            when (v!!) {
                btnSayHelloLogin -> {
                    val intent = Intent(mContext, LoginV2Activity::class.java)
                    val email = MMKVUtil.getString(MMKVKey.Email)
                    intent.putExtra(MMKVKey.Email, email)
                    startActivity(intent)
                }

                btnSayHelloSignup -> startActivity(
                    Intent(
                        mContext, CreateAccountV2Activity::class.java
                    )
                )
            }
        }
    }
}