package com.example.defenseapplication.liveVideo

import android.content.Intent
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import com.example.defenseapplication.R
import com.example.defenseapplication.base.BaseActivity
import com.example.defenseapplication.databinding.WaterGunSettingsActivityBinding
import com.example.defenseapplication.view.ContainerSelectDialog
import com.example.defenseapplication.view.CustomDialogFragmentText
import com.gyf.immersionbar.ImmersionBar
//水枪设置
class WaterGunSettingsActivity : BaseActivity() {

    private lateinit var binding: WaterGunSettingsActivityBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = WaterGunSettingsActivityBinding.inflate(layoutInflater)
        setContentView(binding.root)

        ImmersionBar.with(this)
            .statusBarDarkFont(true)
            .titleBar(binding.topBar)
            .init()

        initListeners()
    }

    private fun initListeners() {
        binding.ivBack.setOnClickListener {
            finish()
        }

        binding.itemDistance.setOnClickListener {
            val dialog = CustomDialogFragmentText()
                .setTitle(getString(R.string.strike_distance))
                .setInputText(binding.tvDistance.text.toString().replace("m", ""))
            dialog.setOnConfirmListener { distance ->
                binding.tvDistance.text = "${distance}m"
            }
            dialog.show(supportFragmentManager, "DistanceDialog")
        }

        binding.itemInterval.setOnClickListener {
            val dialog = CustomDialogFragmentText()
                .setTitle(getString(R.string.strike_interval))
                .setInputText(binding.tvInterval.text.toString().replace("s", ""))
            dialog.setOnConfirmListener { interval ->
                binding.tvInterval.text = "${interval}s"
            }
            dialog.show(supportFragmentManager, "IntervalDialog")
        }

        binding.itemContainer.setOnClickListener {
            val dialog = ContainerSelectDialog(this)
            dialog.setSelectedContainer(binding.tvContainer.text.toString())
            dialog.setOnConfirmListener { container ->
                binding.tvContainer.text = container
            }
            dialog.show()
        }
        binding.itemPosition.setOnClickListener {
            startActivity(Intent(this, StrikePositionActivity::class.java))
        }
    }
}