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.im.AlarmEntity
import com.renrenliao.im.viewmodel.AddFriendSureViewModel
import kotlinx.android.synthetic.main.activity_addfriendsure.*
import org.koin.androidx.viewmodel.ext.android.getViewModel

/**
 **@ClassName AddFriendSureActivity
 **@Description
 **@Author gan
 **@Date 2022/6/21 12:43
 **/
class AddFriendSureActivity:BaseVMActivity<AddFriendSureViewModel>() {

    var alarmEntity :AlarmEntity? = null

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

    override fun initVM(): AddFriendSureViewModel = getViewModel()

    override fun initView() {

        alarmEntity = intent.getParcelableExtra<AlarmEntity>("alarm")

        tool_bar.setOnBackListener { onBackPressed() }

        submit.click {
            agreeAddFriend()
        }

    }
    private fun agreeAddFriend(){
        val buddyRemark = et_bz.text.toString().trim()

        if (alarmEntity!=null){
            mViewModel.agreeAddFriend(buddyRemark,alarmEntity!!)
        }
    }

    override fun initData() {

    }


    override fun startObserve() {
        mViewModel.agreeLiveData.observe(this){
            if (it){
                intent.putExtra("data","agree")
                setResult(RESULT_OK,intent)
                finish()
            }
        }
    }



}