package net.huansi.app.hssummarizingboard.activity.login

import android.annotation.SuppressLint
import android.app.Activity
import android.content.Intent
import baseform.android.huansi.net.configui.ConfigActivity
import baseform.android.huansi.net.util.DeviceUtil
import net.huansi.app.hssummarizingboard.R
import net.huansi.app.hssummarizingboard.activity.main.MainActivity
import net.huansi.app.hssummarizingboard.base.SutureClothBaseActivity
import net.huansi.app.hssummarizingboard.databinding.ActivityLoginBinding
import net.huansi.app.hssummarizingboard.dialog.LoginSettingDialog

@SuppressLint("CheckResult")
class LoginActivity : SutureClothBaseActivity<ActivityLoginBinding, LoginPresenter>() {
    override fun getLayoutId(): Int {
        return R.layout.activity_login
    }

    override fun init() {
        super.init()

        initListener()
    }

    private fun initListener() {
        mBinding.tvBoardConfigGo.setOnClickListener {
            gotoMain()
        }
        //修改IP
        mBinding.tvBoardConfigIP.setOnClickListener {
            ConfigActivity.toThisFromOtherPage(this)
            finish()
        }
        mBinding.tvBoardSetting.setOnClickListener {
            val view = LoginSettingDialog(this)
            mDialogManager1.showCustomerView(
                view,
                width = (DeviceUtil.getScreenWidth(this) * 0.6f).toInt()
            )
        }

    }

    private fun gotoMain() {
        MainActivity.toThis(this)
        finish()
    }

    companion object {
        fun toThis(from: Activity) {
            val intent = Intent(from, LoginActivity::class.java)
            from.startActivity(intent)
        }
    }

}