package com.assimilate.alltrans.viewui


import android.os.Bundle
import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.assimilate.alltrans.R
import com.assimilate.alltrans.databinding.ActivityQuickSetBinding
import com.google.android.material.slider.Slider

class QuickSetActivity : AppCompatActivity() {

    private lateinit var binding: ActivityQuickSetBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityQuickSetBinding.inflate(layoutInflater)
        enableEdgeToEdge()
        setContentView(binding.root)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        sliderSet()
        initClick()
    }

    private fun initClick() {
        binding.qsBack.setOnClickListener { finish() }
    }

    private fun sliderSet() {
        binding.slider1.setLabelFormatter { value ->
            val percentage = ((value / 5) * 100).toInt()
            "$percentage%"
        }
        binding.slider1.addOnChangeListener(Slider.OnChangeListener { _, value, _ ->
            val percentage = ((value / 5) * 100).toInt()
            Toast.makeText(this, "Value: $percentage", Toast.LENGTH_SHORT).show()

        })
    }
}