package com.dowerx.quack.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.dowerx.quack.R;
import com.dowerx.quack.service.AuthService;

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
    }

    public void login(View view) {
        String email = String.valueOf(((EditText)findViewById(R.id.email)).getText());
        String password = String.valueOf(((EditText)findViewById(R.id.password)).getText());

        if (email.isEmpty() || password.isEmpty())
            return;

        AuthService.Login loginTask = new AuthService.Login(this);
        loginTask.execute(email, password);
    }

    public void redirect_register(View view) {
        startActivity(new Intent(this, RegisterActivity.class));
    }
}