package com.example.smartlab

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.Toast
import com.example.smartlab.databinding.ActivityCodePassBinding

class CodePassActivity : AppCompatActivity() {
    lateinit var binding: ActivityCodePassBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityCodePassBinding.inflate(layoutInflater)
        setContentView(binding.root)
        binding.pinView.clearPin()
        binding.pinView.deletePin()
        binding.pinView.setOnCompletedListener = { pinCode ->

            if(pinCode == "1234")
                startActivity(Intent(this,create_carts_klient::class.java))
            else
                binding.pinView.showError(true)
            binding.pinView.clearPin()
        }
        binding.pinView.setOnPinKeyClickListener = { keyPressed ->
            Toast.makeText(this,"Key pressed was $keyPressed",Toast.LENGTH_SHORT).show()
        }
        btn_click()
    }

    private fun btn_click()
    {
        val btn: Button =findViewById(R.id.propusk_code)
        btn.setOnClickListener()
        {
            val intent = Intent(this,create_carts_klient::class.java )
            startActivity(intent)
        }
    }
}