Skip to content

Commit 5b17676

Browse files
committed
Made changes to the UI so that it looks better
1 parent 3b71d2c commit 5b17676

File tree

7 files changed

+47
-28
lines changed

7 files changed

+47
-28
lines changed

src/main/java/entities/user_entities/User.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
import data_access.UserDatabase;
44
import entities.chat.Chat;
55
import interface_adapters.profile_modification_IA.UserAuthenticationI;
6-
import interface_adapters.login_interface_adapters.Login;
76
import use_cases.user_attribute_modification_use_case.Changeable;
87
import interface_adapters.appscreen.UserAppScreenGateway;
8+
import use_cases.user_login_use_cases.Loginable;
99

10-
import java.io.File;
1110
import java.io.Serializable;
1211
import java.util.ArrayList;
1312

14-
public abstract class User implements Serializable, Changeable, Login, UserAuthenticationI {
13+
public abstract class User implements Serializable, Changeable, Loginable, UserAuthenticationI {
1514
protected String username;
1615
protected String password;
1716
protected String email;

src/main/java/screens/login_screen/UserLoginUI.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ public void getLoginCredentials(){
5353
public void cannotVerify() {
5454
JFrame cannotVerifyFrame = new JFrame();
5555
cannotVerifyFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
56-
cannotVerifyFrame.setSize(300, 200);
56+
cannotVerifyFrame.setSize(400, 100);
5757
JPanel cannotVerifyPanel = new JPanel();
5858
cannotVerifyPanel.setLayout(null);
5959
cannotVerifyFrame.add(cannotVerifyPanel);
6060

61-
JLabel accountExists = new JLabel("The verification code you have entered is incorrect, please try again");
62-
accountExists.setBounds(10, 150, 200, 30);
63-
61+
JLabel cannotVerifyLabel = new JLabel("Incorrect verification code, please try again");
62+
cannotVerifyLabel.setBounds(10, 25, 350, 30);
63+
cannotVerifyPanel.add(cannotVerifyLabel);
6464
cannotVerifyFrame.setVisible(true);
6565

6666
}

src/main/java/screens/user_registration_screen/UserRegistrationUI.java

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ public class UserRegistrationUI implements ActionListener, userRegCredentialsRet
1616
private JTextField usernameText;
1717
private JTextField passwordText;
1818
private JTextField emailText;
19-
19+
/*
20+
currently the below variable is not used, because only email verification is implemented, but it may be used in
21+
the future.
22+
*/
2023
private JTextField deliveryText;
2124

2225
public UserRegistrationUI(UserExistsInputBoundary verifyUser) {
@@ -26,7 +29,7 @@ public UserRegistrationUI(UserExistsInputBoundary verifyUser) {
2629
public void getUserCredentials(){
2730
//Front end related objects
2831
JFrame registerFrame = new JFrame();
29-
registerFrame.setSize(500, 300);
32+
registerFrame.setSize(400, 200);
3033
registerFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
3134
JPanel registerPanel = new JPanel();
3235
registerFrame.add(registerPanel);
@@ -60,11 +63,11 @@ public void getUserCredentials(){
6063
registerPanel.add(emailText);
6164

6265
//The textbox for entering verification path
63-
JLabel deliveryLabel = new JLabel("Choose verification Path(0 for email, 1 for phone)");
64-
deliveryLabel.setBounds(10, 115, 200, 25);
66+
JLabel deliveryLabel = new JLabel("Choose verification Path(0 for email, 1 for phone):");
67+
deliveryLabel.setBounds(10, 115, 400, 25);
6568

6669
deliveryText = new JTextField(20);
67-
deliveryText.setBounds(100, 110, 50, 25);
70+
deliveryText.setBounds(320, 115, 50, 25);
6871
registerPanel.add(deliveryLabel);
6972
registerPanel.add(deliveryText);
7073

@@ -77,19 +80,37 @@ public void getUserCredentials(){
7780
}
7881

7982
public static void main(String[] args){
80-
Database testDB = new UserDatabase(new File("test20123"));
83+
//Testing purposes
84+
Database testDB = new UserDatabase(new File("test301"));
8185
UserExistsInputBoundary interactor = new UserExistsInteractor(testDB);
8286
new UserRegistrationUI(interactor).getUserCredentials();
8387
}
8488
@Override
8589
public void actionPerformed(ActionEvent e) {
86-
//Need if statements for cases
8790
String username = usernameText.getText();
8891
String password = passwordText.getText();
8992
String email = emailText.getText();
90-
String type = deliveryText.getText();
9193

92-
verifyUser.setCodeDeliveryMethod(type);
93-
verifyUser.register(username, password, email);
94+
if(username.equals("")|| password.equals("")|| email.equals("")){
95+
missingCredentials();
96+
}else{
97+
//currently only email verification is enabled.
98+
verifyUser.setCodeDeliveryMethod("Email");
99+
verifyUser.register(username, password, email);
100+
}
101+
}
102+
103+
public void missingCredentials(){
104+
JFrame credentialsMissing = new JFrame();
105+
credentialsMissing.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
106+
credentialsMissing.setSize(210, 100);
107+
JPanel CredentialsMissingPanel = new JPanel();
108+
CredentialsMissingPanel.setLayout(null);
109+
credentialsMissing.add(CredentialsMissingPanel);
110+
111+
JLabel accountExists = new JLabel("Missing required information");
112+
accountExists.setBounds(10, 20, 350, 30);
113+
CredentialsMissingPanel.add(accountExists);
114+
credentialsMissing.setVisible(true);
94115
}
95116
}

src/main/java/screens/user_registration_screen/UserVerificationScreen.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ public UserVerificationScreen(UserVerificationInputBoundary verificationInputBou
1919
@Override
2020
public void getVerificationCredentials() {
2121
JFrame verificationFrame = new JFrame();
22-
verificationFrame.setSize(400, 300);
22+
verificationFrame.setSize(250, 200);
2323
verificationFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
2424
JPanel verificationPanel = new JPanel();
2525
verificationPanel.setLayout(null);
2626
verificationFrame.add(verificationPanel);
2727

28-
JLabel verificationLabel = new JLabel("Enter the verification code");
29-
verificationLabel.setBounds(10, 100, 200, 25);
28+
JLabel verificationLabel = new JLabel("Enter the verification code:");
29+
verificationLabel.setBounds(20, 30, 200, 25);
3030
verificationPanel.add(verificationLabel);
3131

32-
verText.setBounds(10, 150, 200, 25);
32+
verText.setBounds(10, 60, 200, 25);
3333
verificationPanel.add(verText);
3434

3535
JButton verifyButton = new JButton("verify");
3636
verifyButton.addActionListener(this);
37-
verifyButton.setBounds(50, 180, 150, 30);
37+
verifyButton.setBounds(50, 90, 150, 30);
3838
verificationPanel.add(verifyButton);
3939
verificationFrame.setVisible(true);
4040
}
@@ -43,13 +43,13 @@ public void getVerificationCredentials() {
4343
public void presentUserExistsMessage() {
4444
JFrame userExistsFrame = new JFrame();
4545
userExistsFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
46-
userExistsFrame.setSize(300, 200);
46+
userExistsFrame.setSize(400, 100);
4747
JPanel userExistsPanel = new JPanel();
4848
userExistsPanel.setLayout(null);
4949
userExistsFrame.add(userExistsPanel);
5050

5151
JLabel accountExists = new JLabel("A user with this email or username already exists");
52-
accountExists.setBounds(10, 150, 200, 30);
52+
accountExists.setBounds(10, 25, 350, 30);
5353
userExistsPanel.add(accountExists);
5454
userExistsFrame.setVisible(true);
5555
}

src/main/java/use_cases/user_login_use_cases/Loginable.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package use_cases.user_login_use_cases;
22

3-
import interface_adapters.profile_modification_IA.UserAuthenticationI;
43

54
public interface Loginable {
65
void login();

src/main/java/use_cases/user_login_use_cases/UserLoginInteractor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ public UserLoginInteractor(Database database){
1414

1515
@Override
1616
public void tryLogin() {
17-
//TODO: complete this method and UserLoginOutputBoundary
1817
try{
18+
//TODO: issues here with serialization
1919
user = database.getUser(username);
2020
if(user.PasswordMatch(this.password)){
2121
user.login();
2222
}else{
2323
System.out.println("the password or username is incorrect");
2424
}
2525
}catch(NullPointerException e){
26+
//TODO: implement login output boundary
2627
System.out.println("An account with these credentials do not exist");
2728
}
2829

src/main/java/use_cases/user_registration_use_cases/UserExistsInteractor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@ public UserExistsInteractor(Database database){
1919
this.verificationInputBoundary = new UserVerificationInteractor(database);
2020
this.code = new Random().nextInt(1321512);
2121
verificationInputBoundary.setCode(code);
22-
22+
this.existsOutputBoundary = new UserVerificationScreen(verificationInputBoundary);
2323
}
2424
@Override
2525
public void register(String username, String password, String email) {
2626
if(!database.UserExists(username, email)){
2727
verificationInputBoundary.setCredentials(username, password, email);
28-
this.existsOutputBoundary = new UserVerificationScreen(verificationInputBoundary);
2928
existsOutputBoundary.getVerificationCredentials();
3029
codeMailMan.sendVerificationCode(email, code);
3130
}else{

0 commit comments

Comments
 (0)