package com.yidian.shenghuoquan.bdemo.ui

import android.os.Bundle
import com.yidian.bcommon.base.BaseActivity
import com.yidian.bcommon.constant.XBirdPageConstants
import com.yidian.bcommon.constant.XRouterPathConstants
import com.yidian.bcommon.extensions.clickAntiShake
import com.yidian.bcommon.utils.ToastUtils
import com.yidian.shenghuoquan.bdemo.databinding.ActivityH5TestBinding
import com.yidian.xpage.XPageManager

class H5TestActivity : BaseActivity<ActivityH5TestBinding>() {

  override fun getXPageName(): String {
    return XRouterPathConstants.H5_TEST_ACTIVITY
  }

  override fun createViewBinding(): ActivityH5TestBinding {
    return ActivityH5TestBinding.inflate(layoutInflater)
  }

  override fun init(savedInstanceState: Bundle?) {
    super.init(savedInstanceState)
    initClick()
  }

  private fun initClick() {
    viewBind.btnEnterPage.clickAntiShake {
      val pageUrl = viewBind.etPath.text.trim().toString()
      if (pageUrl.isBlank()) {
        ToastUtils.showShortSafe("请输入页面地址及参数，才能进入")
        return@clickAntiShake
      }
      // 进入页面
      XPageManager.push(XRouterPathConstants.COMMON_WEB_VIEW_ACTIVITY, hashMapOf(Pair(XBirdPageConstants.PAGE_URL, pageUrl)))
    }
  }

}
