first commit
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
package com.example.pap_teste;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
public class ClientDashboardActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
setContentView(R.layout.activity_client_dashboard);
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.clientRoot), (v, insets) -> {
|
||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||
return insets;
|
||||
});
|
||||
|
||||
TextView txtGreeting = findViewById(R.id.txtClientGreeting);
|
||||
TextView txtStatus = findViewById(R.id.txtClientStatus);
|
||||
TextView txtReservationStatus = findViewById(R.id.txtReservationStatus);
|
||||
TextView txtReservationSubtitle = findViewById(R.id.txtReservationSubtitle);
|
||||
|
||||
String actionMode = getIntent().getStringExtra(MainActivity.EXTRA_ACTION_MODE);
|
||||
String displayName = getIntent().getStringExtra(MainActivity.EXTRA_DISPLAY_NAME);
|
||||
|
||||
boolean isNewAccount = "CRIAR".equalsIgnoreCase(actionMode);
|
||||
txtGreeting.setText(String.format("Olá, %s", displayName != null ? displayName : "convidado"));
|
||||
txtStatus.setText(isNewAccount
|
||||
? "Conta criada com sucesso! Configure as suas preferências para começarmos."
|
||||
: "Bom tê-lo de volta! Já deixámos tudo pronto para a sua próxima reserva.");
|
||||
|
||||
txtReservationStatus.setText("Próxima reserva");
|
||||
txtReservationSubtitle.setText("Mesa para 2 • Amanhã às 20h • Sabor & Arte");
|
||||
|
||||
Button btnNewReservation = findViewById(R.id.btnNovaReserva);
|
||||
Button btnExplore = findViewById(R.id.btnExplorar);
|
||||
Button btnFavorites = findViewById(R.id.btnFavoritos);
|
||||
|
||||
Button btnCheckIn = findViewById(R.id.btnCheckIn);
|
||||
Button btnShare = findViewById(R.id.btnPartilhar);
|
||||
|
||||
btnNewReservation.setOnClickListener(v -> showToast("Abrindo fluxo de nova reserva..."));
|
||||
btnExplore.setOnClickListener(v -> showToast("A explorar restaurantes recomendados."));
|
||||
btnFavorites.setOnClickListener(v -> showToast("A mostrar os seus favoritos."));
|
||||
btnCheckIn.setOnClickListener(v -> showToast("Check-in antecipado registado!"));
|
||||
btnShare.setOnClickListener(v -> showToast("Partilhe a reserva com os seus convidados."));
|
||||
}
|
||||
|
||||
private void showToast(String message) {
|
||||
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.example.pap_teste;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
public class EstablishmentDashboardActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
setContentView(R.layout.activity_establishment_dashboard);
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.establishmentRoot), (v, insets) -> {
|
||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||
return insets;
|
||||
});
|
||||
|
||||
TextView txtTitle = findViewById(R.id.txtEstabTitle);
|
||||
TextView txtSubtitle = findViewById(R.id.txtEstabSubtitle);
|
||||
|
||||
String actionMode = getIntent().getStringExtra(MainActivity.EXTRA_ACTION_MODE);
|
||||
String displayName = getIntent().getStringExtra(MainActivity.EXTRA_DISPLAY_NAME);
|
||||
|
||||
boolean isNewAccount = "CRIAR".equalsIgnoreCase(actionMode);
|
||||
txtTitle.setText(displayName != null ? displayName : "Estabelecimento");
|
||||
txtSubtitle.setText(isNewAccount
|
||||
? "Perfil criado. Configure horários, mesas e abra reservas."
|
||||
: "Dashboard operacional. Acompanhe as reservas em tempo real.");
|
||||
|
||||
Button btnOpenWalkIns = findViewById(R.id.btnAbrirEspera);
|
||||
Button btnBlockTime = findViewById(R.id.btnCriarBloqueio);
|
||||
Button btnStaff = findViewById(R.id.btnGestaoStaff);
|
||||
Button btnReports = findViewById(R.id.btnVerRelatorios);
|
||||
|
||||
btnOpenWalkIns.setOnClickListener(v -> showToast("Lista de espera aberta para novos clientes."));
|
||||
btnBlockTime.setOnClickListener(v -> showToast("Bloqueio criado para o horário selecionado."));
|
||||
btnStaff.setOnClickListener(v -> showToast("Gestão de staff disponível em breve."));
|
||||
btnReports.setOnClickListener(v -> showToast("Relatórios do dia enviados para o seu email."));
|
||||
}
|
||||
|
||||
private void showToast(String message) {
|
||||
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
160
app/src/main/java/com/example/pap_teste/MainActivity.java
Normal file
160
app/src/main/java/com/example/pap_teste/MainActivity.java
Normal file
@@ -0,0 +1,160 @@
|
||||
package com.example.pap_teste;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
public static final String EXTRA_ACTION_MODE = "extra_action_mode";
|
||||
public static final String EXTRA_DISPLAY_NAME = "extra_display_name";
|
||||
public static final String EXTRA_EMAIL = "extra_email";
|
||||
|
||||
private enum AccountType {CLIENTE, ESTABELECIMENTO}
|
||||
private enum AccountAction {ENTRAR, CRIAR}
|
||||
|
||||
private AccountType selectedAccountType = AccountType.CLIENTE;
|
||||
private AccountAction selectedAccountAction = AccountAction.ENTRAR;
|
||||
|
||||
private Button btnCliente;
|
||||
private Button btnEstabelecimento;
|
||||
private Button btnEntrar;
|
||||
private Button btnCriarConta;
|
||||
private Button btnPrimaryAction;
|
||||
private EditText inputName;
|
||||
private EditText inputEmail;
|
||||
private EditText inputPassword;
|
||||
|
||||
@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;
|
||||
});
|
||||
|
||||
bindViews();
|
||||
setupTypeToggle();
|
||||
setupActionToggle();
|
||||
setupPrimaryAction();
|
||||
}
|
||||
|
||||
private void bindViews() {
|
||||
btnCliente = findViewById(R.id.btnCliente);
|
||||
btnEstabelecimento = findViewById(R.id.btnEstabelecimento);
|
||||
btnEntrar = findViewById(R.id.btnEntrar);
|
||||
btnCriarConta = findViewById(R.id.btnCriarConta);
|
||||
btnPrimaryAction = findViewById(R.id.btnFinalCriarConta);
|
||||
inputName = findViewById(R.id.inputName);
|
||||
inputEmail = findViewById(R.id.inputEmail);
|
||||
inputPassword = findViewById(R.id.inputPassword);
|
||||
}
|
||||
|
||||
private void setupTypeToggle() {
|
||||
btnCliente.setOnClickListener(v -> {
|
||||
selectedAccountType = AccountType.CLIENTE;
|
||||
updateTypeButtons();
|
||||
});
|
||||
btnEstabelecimento.setOnClickListener(v -> {
|
||||
selectedAccountType = AccountType.ESTABELECIMENTO;
|
||||
updateTypeButtons();
|
||||
});
|
||||
updateTypeButtons();
|
||||
}
|
||||
|
||||
private void setupActionToggle() {
|
||||
btnEntrar.setOnClickListener(v -> {
|
||||
selectedAccountAction = AccountAction.ENTRAR;
|
||||
updateActionButtons();
|
||||
});
|
||||
btnCriarConta.setOnClickListener(v -> {
|
||||
selectedAccountAction = AccountAction.CRIAR;
|
||||
updateActionButtons();
|
||||
});
|
||||
updateActionButtons();
|
||||
}
|
||||
|
||||
private void setupPrimaryAction() {
|
||||
btnPrimaryAction.setOnClickListener(v -> handlePrimaryAction());
|
||||
updatePrimaryActionState();
|
||||
}
|
||||
|
||||
private void updateTypeButtons() {
|
||||
setSelectedState(btnCliente, selectedAccountType == AccountType.CLIENTE);
|
||||
setSelectedState(btnEstabelecimento, selectedAccountType == AccountType.ESTABELECIMENTO);
|
||||
}
|
||||
|
||||
private void updateActionButtons() {
|
||||
setSelectedState(btnEntrar, selectedAccountAction == AccountAction.ENTRAR);
|
||||
setSelectedState(btnCriarConta, selectedAccountAction == AccountAction.CRIAR);
|
||||
updatePrimaryActionState();
|
||||
}
|
||||
|
||||
private void setSelectedState(Button button, boolean isSelected) {
|
||||
button.setBackgroundResource(isSelected ? R.drawable.tab_selected : R.drawable.tab_unselected);
|
||||
button.setTextColor(isSelected ? Color.WHITE : Color.parseColor("#00001A"));
|
||||
}
|
||||
|
||||
private void updatePrimaryActionState() {
|
||||
boolean creatingAccount = selectedAccountAction == AccountAction.CRIAR;
|
||||
btnPrimaryAction.setText(creatingAccount ? "Criar Conta" : "Entrar");
|
||||
inputName.setVisibility(creatingAccount ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
private void handlePrimaryAction() {
|
||||
String email = inputEmail.getText().toString().trim();
|
||||
String password = inputPassword.getText().toString().trim();
|
||||
String providedName = inputName.getText().toString().trim();
|
||||
|
||||
if (TextUtils.isEmpty(email) || TextUtils.isEmpty(password)) {
|
||||
Toast.makeText(this, "Preencha email e palavra-passe.", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedAccountAction == AccountAction.CRIAR && TextUtils.isEmpty(providedName)) {
|
||||
Toast.makeText(this, "Indique o seu nome para criar conta.", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
String fallbackName = !TextUtils.isEmpty(providedName) ? providedName : deriveNameFromEmail(email);
|
||||
Intent nextScreen;
|
||||
|
||||
if (selectedAccountType == AccountType.CLIENTE) {
|
||||
nextScreen = new Intent(this, ClientDashboardActivity.class);
|
||||
} else {
|
||||
nextScreen = new Intent(this, EstablishmentDashboardActivity.class);
|
||||
}
|
||||
|
||||
nextScreen.putExtra(EXTRA_ACTION_MODE, selectedAccountAction.name());
|
||||
nextScreen.putExtra(EXTRA_DISPLAY_NAME, fallbackName);
|
||||
nextScreen.putExtra(EXTRA_EMAIL, email);
|
||||
startActivity(nextScreen);
|
||||
}
|
||||
|
||||
private String deriveNameFromEmail(String email) {
|
||||
if (!email.contains("@")) {
|
||||
return "Utilizador";
|
||||
}
|
||||
String candidate = email.substring(0, email.indexOf("@"));
|
||||
if (candidate.isEmpty()) {
|
||||
return "Utilizador";
|
||||
}
|
||||
String firstLetter = candidate.substring(0, 1).toUpperCase();
|
||||
String rest = candidate.length() > 1 ? candidate.substring(1) : "";
|
||||
return firstLetter + rest;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user