package com.yidian.shenghuoquan.newscontent.wallet.ui

import android.os.Bundle
import androidx.core.content.ContextCompat
import com.yidian.common.AppConfig
import com.yidian.common.XRouterPathConstants
import com.yidian.common.base.BaseActivity
import com.yidian.common.extensions.clickAntiShake
import com.yidian.shenghuoquan.newscontent.R
import com.yidian.shenghuoquan.newscontent.databinding.ActivityMyWalletBinding
import com.yidian.shenghuoquan.newscontent.ui.ProtocolActivity
import com.yidian.xpage.XPageManager


/**
 * 我的钱包
 */
class MyWalletActivity : BaseActivity<ActivityMyWalletBinding>() {

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

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

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

  private fun initClick() {
    // 交易明细
    viewBind.tvTransactionDetails.clickAntiShake {
      XPageManager.push(XRouterPathConstants.TRANSACTION_LIST, null)
    }
    // todo 提现(仅管理员可以发起提现)
    viewBind.tvWithdraw.clickAntiShake {
      XPageManager.push(XRouterPathConstants.VERIFY_IDENTITY, null)
    }
  }

  private fun initTitle() {
    viewBind.include.tvTitle.text = "我的钱包"
    viewBind.include.ivBack.setOnClickListener {
      XPageManager.pop(null)
    }
    viewBind.include.tvMenu.background = ContextCompat.getDrawable(this, R.drawable.icon_faq)
    viewBind.include.tvMenu.setOnClickListener {
      val urlMap = HashMap<String, String>()
      urlMap[ProtocolActivity.ProtocolUrlKey] = AppConfig.commonProblem
      XPageManager.push(XRouterPathConstants.COMMON_PROBLEM, urlMap)
    }
  }
}
