package com.renrenliao.im.ui.activity

import android.widget.ImageView
import androidx.lifecycle.lifecycleScope
import com.renrenliao.im.R
import com.renrenliao.im.base.BaseVMActivity
import com.renrenliao.im.ext.click
import com.renrenliao.im.model.repository.LocalDataSource
import com.renrenliao.im.utils.LogUtils
import com.renrenliao.im.utils.RouteUtils
import com.renrenliao.im.viewmodel.SettingViewModel
import kotlinx.android.synthetic.main.activity_setting.*
import org.koin.androidx.viewmodel.ext.android.getViewModel

/**
 **@ClassName SettingActivity
 **@Description
 **@Author gan
 **@Date 2022/5/28 14:35
 **/
class SettingActivity :BaseVMActivity<SettingViewModel>(){


    override fun getLayoutResId(): Int = R.layout.activity_setting

    override fun initVM(): SettingViewModel = getViewModel()

    override fun initView() {

        onClick()

    }

    override fun initData() {
       // LogUtils.error("testlivedata:"+LocalDataSource.testLiveData.value)
    }



    override fun startObserve() {
        lifecycleScope.launchWhenResumed {
//            mViewModel.userInfo.collect{
//                mTvAbout.text = it?.nickname
//            }
        }
//        LocalDataSource.testLiveData.observe(this) {
//            LogUtils.error("xxx:$it")
//        }
    }

    private fun onClick(){
        //返回按钮
        tool_bar.setOnBackListener {
            onBackPressed()
        }
        //账户安全
        rl_safe.click {
            RouteUtils.gotoAccountSafe(this)
        }

        //退出登陆成功后 再退出IM  在清除用户数据   跳转到登陆
        tv_logout.click {
            mViewModel.logout()
        }
        rl_clear_cache.click {
         //   mViewModel.change()
        }
        rl_about.click {

        }
    }
}