package com.swago.home

import android.os.Bundle
import android.view.View
import androidx.core.content.ContextCompat
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.gyf.immersionbar.ImmersionBar
import com.swago.baseswago.dialog.ReportBlockDialogFragment
import com.swago.baseswago.activity.BaseXActivity
import com.swago.baseswago.constant.ARouteConstant
import com.swago.baseswago.util.NoDoubleClickListener
import com.swago.home.databinding.ActivityChatDetailBinding
import com.tencent.imsdk.v2.V2TIMConversation
import com.tencent.qcloud.tim.uikit.modules.chat.base.ChatInfo

/**
 *@date 2021/8/24 15:01
 *description:
 */
@Route(path = ARouteConstant.Home.chatDetail)
class ChatDetailActivity  : BaseXActivity<ActivityChatDetailBinding>() {

    @Autowired(required = true)
    @JvmField
    var account: String = ""

    @Autowired(required = true)
    @JvmField
    var chatName: String = ""


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        ImmersionBar.with(this)
            .statusBarDarkFont(true)
            .keyboardEnable(true)
            .fitsSystemWindows(true)
            .init()
    }

    override fun loadData() {

    }

    override fun initOther() {
        ARouter.getInstance().inject(this)

        val chatInfo = ChatInfo()
        chatInfo.type = V2TIMConversation.V2TIM_C2C
        chatInfo.chatName = chatName
        chatInfo.id = account
        binding.chatLayout.initDefault()
        binding.chatLayout.chatInfo = chatInfo
        binding.chatLayout.titleBar.setBackgroundColor(ContextCompat.getColor(this,R.color.white))
        binding.chatLayout.titleBar.setLeftIcon(R.mipmap.back)
        binding.chatLayout.titleBar.rightIcon.visibility = View.GONE

        binding.chatLayout.inputLayout.disableSendFileAction(true)

        binding.ivMore.setOnClickListener(object:NoDoubleClickListener(){
            override fun onClick() {
                ReportBlockDialogFragment.newInstance(account).show(supportFragmentManager,"ReportDialog")
            }
        })
    }

    override fun initLiveData() {

    }


}