package com.kaixed.kchat.view.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.ActivityApplyFriendsDetailBinding
import com.kaixed.kchat.model.search.User

class ApplyFriendsDetailActivity : AppCompatActivity() {

    private lateinit var binding: ActivityApplyFriendsDetailBinding
    private lateinit var user: User

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

        user = (intent.getParcelableExtra("user") as? User)!!

        setContent()

        setOnClick()
    }

    private fun setContent() {
        binding.tvContactName.text = user.nickname
        binding.tvContactSignature.text = user.signature
        binding.tvSignatureContent.text = user.signature
        Glide.with(this).load(user.avatarUrl).into(binding.ifvAvatar)
    }

    private fun setOnClick() {

        binding.rlSendMessage.setOnClickListener {
            val intent = Intent(this, ApplyAddFriendActivity::class.java)
            intent.putExtra("contactId", user.username)
            startActivity(intent)
        }

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

        binding.rlSetRemark.setOnClickListener {
            val intent = Intent(this, SetRemarkActivity::class.java)
            startActivity(intent)
        }
    }
}