package com.remax.visualnovel.ui.search


import androidx.activity.viewModels
import androidx.lifecycle.Observer
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.remax.visualnovel.app.base.BaseBindingActivity
import com.remax.visualnovel.utils.Routers
import com.remax.visualnovel.utils.StatusBarUtils
import com.pengxr.modular.eventbus.generated.events.EventDefineOfUserEvents
import com.remax.visualnovel.databinding.ActivityCheckinBinding
import com.remax.visualnovel.databinding.ActivitySearchBinding
import com.remax.visualnovel.event.model.OnLoginEvent
import com.remax.visualnovel.extension.launchWithRequest
import com.remax.visualnovel.ui.main.MainViewModel
import dagger.hilt.android.AndroidEntryPoint



@AndroidEntryPoint
@Route(path = Routers.SEARCH)
class SearchActivity : BaseBindingActivity<ActivitySearchBinding>() {

    private val mViewModel by viewModels<MainViewModel>()

    override fun initView() {
        StatusBarUtils.setStatusBarAndNavBarIsLight(this, false)
        StatusBarUtils.setTransparent(this)

        with(binding) {

        }
    }

    override fun initData() {

    }

    private val loginObserver = Observer<OnLoginEvent?> {
        launchWithRequest({
            //TODO - business handling for login events
            if (it?.isLogin() == true) {

            } else {

            }
        })
    }

    override fun onDestroy() {
        super.onDestroy()
        EventDefineOfUserEvents.onLoginStatusChanged().removeObserver(loginObserver)
    }


    companion object {
        fun start() {
            ARouter.getInstance()
                .build(Routers.SEARCH)
                .navigation()
        }
    }


}