package com.adealink.weparty.playmate.userpush

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.playmate.Playmate
import com.adealink.weparty.playmate.databinding.ActivityPlaymateUserPushBinding
import com.adealink.weparty.util.applyImmersive
import com.adealink.weparty.R as APP_R

@RouterUri(
    path = [Playmate.UserPush.PATH],
    desc = "潜在用户推送"
)
class UserPushActivity : BaseActivity() {

    private val binding by viewBinding(ActivityPlaymateUserPushBinding::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, UserPushFragment(), "VisitorFragment")
            .commitAllowingStateLoss()
    }

}