package com.kaixed.kchat.ui.activity

import android.content.Intent
import android.os.Build
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import com.bumptech.glide.Glide
import com.kaixed.kchat.databinding.ActivityApproveDetailBinding
import com.kaixed.kchat.model.friend.FriendRequestItem

class ApproveDetailActivity : AppCompatActivity() {

    private lateinit var binding: ActivityApproveDetailBinding

    private var request: FriendRequestItem? = null

    @RequiresApi(Build.VERSION_CODES.TIRAMISU)
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        binding = ActivityApproveDetailBinding.inflate(layoutInflater)
        setContentView(binding.root)

        request = intent.getParcelableExtra("request", FriendRequestItem::class.java)

        setOnClick()
    }

    private fun setContent() {
        val nickname = request?.nickname
        val signature = request?.signature
        val avatarUrl = request?.avatarUrl

        binding.tvContactName.text = nickname
        binding.tvContactSignature.text = signature
        binding.tvSignatureContent.text = signature
        Glide.with(this).load(avatarUrl).into(binding.ifvAvatar)
    }

    private fun setOnClick() {
        binding.ctl.setOnSettingClickListener {
            val intent = Intent(this, DataSettingActivity::class.java)
            startActivity(intent)
        }

        binding.rlGotoVerify.setOnClickListener {
            startActivity(
                Intent(this, ApproveContactRequestActivity::class.java).apply {
                    putExtra("nickname", request?.nickname)
                    putExtra("message", request?.message)
                }
            )
        }
    }
}
