package com.example.chatapp.activities

import android.annotation.SuppressLint
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
import com.example.chatapp.R
import com.example.chatapp.network.SocketClient
import com.google.android.material.button.MaterialButton
import com.google.android.material.textfield.TextInputLayout
import java.sql.Connection

class RegisterActivity : AppCompatActivity() {

    lateinit var tvUsername: TextInputLayout
    lateinit var tvPassword: TextInputLayout
    lateinit var tvPassword2: TextInputLayout
    lateinit var btnRegister: MaterialButton

    @SuppressLint("MissingInflatedId")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_register)

        tvUsername = findViewById(R.id.loginText)
        tvPassword = findViewById(R.id.passText)
        tvPassword2 = findViewById(R.id.passVerif)
        btnRegister = findViewById(R.id.registerBtn)

        btnRegister.setOnClickListener {
            val login = tvUsername.editText?.text.toString()
            val pass = tvPassword.editText?.text.toString()
            val verif = tvPassword2.editText?.text.toString()

            if (login.isNotEmpty() && pass.isNotEmpty() && pass == verif) {
                val connection = SocketClient()

//                Thread {
//                    try {
//                        var response = connection.
//                    }
//                }
            }
        }
    }
}