package com.base.locationsharewhite.ui.main

import android.graphics.Color
import androidx.activity.addCallback
import androidx.core.view.updatePadding
import com.base.locationsharewhite.R
import com.base.locationsharewhite.databinding.ActivityLocationCodeBinding
import com.base.locationsharewhite.helper.BaseActivity
import com.base.locationsharewhite.location.LocationLoginUtils
import com.base.locationsharewhite.utils.BarUtils
import com.base.locationsharewhite.utils.ClipboardUtils.copyText
import com.base.locationsharewhite.utils.ToastUtils.toast


class LocationCodeActivity : BaseActivity<ActivityLocationCodeBinding>() {

    override val binding: ActivityLocationCodeBinding by lazy {
        ActivityLocationCodeBinding.inflate(layoutInflater)
    }


    override fun initView() {
        BarUtils.setStatusBarLightMode(this, true)
        BarUtils.setStatusBarColor(this, Color.WHITE)
        binding.root.updatePadding(top = BarUtils.getStatusBarHeight())

        binding.tvCode.text = LocationLoginUtils.invitationCodeSp
        binding.tvCopy.setOnClickListener {
            copyText("MyLocationCode", binding.tvCode.text.toString())
            toast(resources.getString(R.string.copy))
        }
    }

    override fun initListener() {
        super.initListener()

        onBackPressedDispatcher.addCallback {
            finishToMain()
        }
        binding.flFanhui.setOnClickListener {
            onBackPressedDispatcher.onBackPressed()
        }
    }

}