package com.adealink.weparty.profile.relation

import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.updateLayoutParams
import com.adealink.frame.aab.util.getCompatDimension
import com.adealink.frame.mvvm.view.viewBinding
import com.adealink.frame.router.Router
import com.adealink.frame.router.annotation.RouterUri
import com.adealink.weparty.commonui.BaseActivity
import com.adealink.weparty.module.profile.Profile
import com.adealink.weparty.profile.databinding.ActivityProfileVisitorBinding
import com.adealink.weparty.util.applyImmersive
import com.adealink.weparty.R as APP_R

@RouterUri(
    path = [Profile.Visitor.PATH],
    desc = "最近访客"
)
class VisitorActivity : BaseActivity() {

    private val binding by viewBinding(ActivityProfileVisitorBinding::inflate)
    override fun onBeforeCreate() {
        super.onBeforeCreate()
        Router.bind(this)
    }

    override fun initViews() {
        super.initViews()
        setContentView(binding.root)
        applyImmersive { top ->
            binding.topBar.setPadding(0, top, 0, 0)
            binding.topBar.updateLayoutParams<ConstraintLayout.LayoutParams> {
                height = getCompatDimension(APP_R.dimen.common_top_bar_height).toInt() + top
            }
        }
        inflateFragment()
    }

    private fun inflateFragment() {
        supportFragmentManager.beginTransaction()
            .replace(binding.fcvContainer.id, VisitorFragment(), "VisitorFragment")
            .commitAllowingStateLoss()
    }

}