package com.example.finzora;

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    EditText inputEmail, inputPassword;
    Button btnLogin;

    // Credenciais de exemplo (podes mudar)
    private final String USER_EMAIL = "admin@gmail.com";
    private final String USER_PASSWORD = "123456";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        inputEmail = findViewById(R.id.inputEmail);
        inputPassword = findViewById(R.id.inputPassword);
        btnLogin = findViewById(R.id.btnLogin);

        btnLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String email = inputEmail.getText().toString().trim();
                String password = inputPassword.getText().toString().trim();

                if (email.isEmpty() || password.isEmpty()) {
                    Toast.makeText(MainActivity.this, "Preencha todos os campos", Toast.LENGTH_SHORT).show();
                    return;
                }

                // Verificação simples
                if (email.equals(USER_EMAIL) && password.equals(USER_PASSWORD)) {

                    Toast.makeText(MainActivity.this, "Login efetuado!", Toast.LENGTH_SHORT).show();

                    // Ir para a próxima página
                    Intent intent = new Intent(MainActivity.this, HomeActivity.class);
                    startActivity(intent);
                    finish();

                } else {
                    Toast.makeText(MainActivity.this, "Email ou palavra-passe incorretos", Toast.LENGTH_SHORT).show();
                }
            }
        });

    }
}
