package com.renrenliao.im.ui.activity

import com.renrenliao.im.R
import com.renrenliao.im.base.BaseVMActivity
import com.renrenliao.im.ext.click
import com.renrenliao.im.utils.DataCacheUtils
import com.renrenliao.im.utils.LogUtils
import com.renrenliao.im.utils.RouteUtils
import com.renrenliao.im.viewmodel.FriendSearchViewModel
import kotlinx.android.synthetic.main.activity_friendsearch.*
import org.koin.androidx.viewmodel.ext.android.getViewModel

/**
 **@ClassName FriendSearchActivity
 **@Description
 **@Author gan
 **@Date 2022/6/13 16:30
 **/
class FriendSearchActivity:BaseVMActivity<FriendSearchViewModel>() {

    override fun initVM(): FriendSearchViewModel = getViewModel()

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

    override fun initView() {
        tool_bar.setOnBackListener { onBackPressed() }
        search_btn.click {
            val key = keyword_edit.text.toString().trim()
            if (key.isBlank()){
                return@click
            }
            mViewModel.searchFriend(key)
        }

    }

    override fun initData() {

    }


    override fun startObserve() {
        mViewModel.searchLiveData.observe(this){
            RouteUtils.gotoFriendInfo(this,it)
        }
    }
}