package com.example.smartlab

import androidx.appcompat.app.AppCompatActivity
import android.app.Activity;
import android.content.Intent
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button
import android.widget.EditText
import android.widget.Spinner;
import android.widget.TextView
import android.widget.Toast;
import androidx.core.widget.doAfterTextChanged

class create_carts_klient : AppCompatActivity() {

    //private String[] Pol={"Мужской", "Женский"};

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_create_carts_klient)

        btn_click()
        zapolnenie()
    }


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



    private fun zapolnenie() {
        var vv_imya: EditText = findViewById(R.id.vv_Imya)
        var vv_otcestvo: EditText = findViewById((R.id.vv_Otcestvo))
        var vv_familiya: EditText = findViewById((R.id.vv_Familiya))
        var vv_dr: EditText = findViewById((R.id.vv_DR))
        var vv_btn: Button = findViewById(R.id.vv_button);

        vv_imya.doAfterTextChanged {
            if (vv_imya.text.isNotEmpty()) {
                vv_imya.setBackgroundResource(R.drawable.unactive_button)

            } else {
                vv_btn.setBackgroundResource(R.drawable.unactive_button)
            }

            vv_otcestvo.doAfterTextChanged {
                if (vv_otcestvo.text.isNotEmpty() ) {
                    vv_otcestvo.setBackgroundResource(R.drawable.unactive_button)

                } else {
                    vv_btn.setBackgroundResource(R.drawable.unactive_button)
                }

                vv_familiya.doAfterTextChanged {
                    if (vv_familiya.text.isNotEmpty()) {
                        vv_familiya.setBackgroundResource(R.drawable.unactive_button)

                    } else {
                        vv_btn.setBackgroundResource(R.drawable.unactive_button)
                    }

                    vv_dr.doAfterTextChanged {
                        if (vv_imya.text.isNotEmpty() && vv_otcestvo.text.isNotEmpty() && vv_familiya.text.isNotEmpty() && vv_dr.text.isNotEmpty()) {
                            vv_dr.setBackgroundResource(R.drawable.unactive_button)
                            vv_btn.setBackgroundResource(R.drawable.active_button)
                            vv_btn.setOnClickListener()
                            {
                                val intent = Intent(this, Dopolnenie::class.java)
                                startActivity(intent)
                                val myToast =
                                    Toast.makeText(this, "Hello Toast!", Toast.LENGTH_SHORT)
                                myToast.show()
                            }
                        } else {
                            vv_btn.setBackgroundResource(R.drawable.unactive_button)
                        }


                    }
                }
            }
        }
    }

}


