Skip to content

Commit b7fe852

Browse files
committed
Improved UIs and added demo to readme
2 parents ca81695 + 06eec7c commit b7fe852

File tree

15 files changed

+52
-25
lines changed

15 files changed

+52
-25
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ Each of us have created one or more PRs and most of these have been merged into
3535
![img_6.png](img_6.png)
3636

3737

38+
### App Screen UI
39+
- By Amy
40+
- The App Screen UI is the screen that acts as a proxy between the user's login screen and their individual chats
41+
- Upon logging in, a user will will be rendered with a view of app screen
42+
- App Screen provides an ordered list of a user's chats, allowing the user to open an individual chat by clicking the chat button
43+
- ChatView(the window referenced above) will open, displaying the chats's GUI
44+
- Apart from that, app screen also provides buttons that allow a user to create new chats
45+
46+
47+
3848
## Template Readme
3949
This is a template repository for CSC 207 projects.
4050
This repository contains starter code for a gradle project.

src/main/java/data_access/UserDatabase.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
package data_access;
22

3+
import entities.chat.Chat;
34
import interface_adapters.User_search_IA.IRetrieveList;
45
import interface_adapters.user_registration_interface_adapters.UserExists;
56
import entities.user_entities.User;
67
import interface_adapters.profile_modification_IA.UserModificationGateway;
78
import use_cases.user_registration_use_cases.UserCreator;
89
import entities.user_entities.UserFactory;
10+
import interface_adapters.Chat.UserChatGateway;
911
import interface_adapters.User_search_IA.UserRetriever;
1012

1113
import java.io.*;
1214
import java.util.ArrayList;
1315
import java.util.List;
14-
public class UserDatabase implements UserExists, UserRetriever, UserCreator, IRetrieveList, UserModificationGateway {
16+
public class UserDatabase implements UserExists, UserRetriever, UserCreator, IRetrieveList, UserModificationGateway, UserChatGateway {
1517
File accounts;
1618
List<User> accountList;
1719
public UserDatabase(){
@@ -125,6 +127,16 @@ public void modifyUser(String oldUsername, User modified){
125127
}
126128
}
127129

130+
@Override
131+
public ArrayList<Chat> getUserChats(String username) {
132+
for (User user: accountList){
133+
if (getUser(username).equals(user)){
134+
return user.getUserChats();
135+
}
136+
}
137+
throw new RuntimeException("Invalid username");
138+
}
139+
128140
// Below two methods are used by conversation history-related interactors
129141
// (Commented as objects are not found)
130142
// /**

src/main/java/entities/chat/PrivateChat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void setRecipientUsername(String recipientUsername) {
4848
public String getSendertUsername(){
4949
return this.senderUsername;
5050
}
51-
public String setSendertUsername(String recipientUsername){
51+
public void setSendertUsername(String recipientUsername){
5252
this.recipientUsername = recipientUsername;
5353
}
5454

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package entities.user_entities;
2+
import entities.chat.Chat;
3+
4+
import java.util.ArrayList;
25

36
public class UserFactory {
47
//Following the factory design pattern, just in case in the future we decide to add various different types of Users
58
public static User BirthUser(String Username, String Password, String Email, String type){
6-
return new BasicUser(Username, Password, Email);
9+
return new BasicUser(Username, Password, Email, new ArrayList<>());
710
}
811
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package interface_adapters.Chat;
22

3+
import entities.chat.Chat;
4+
35
import java.util.ArrayList;
46

57
public interface UserChatGateway {
68

7-
// ArrayList<Chat> getUserChats(String username);
9+
ArrayList<Chat> getUserChats(String username);
810
}

src/main/java/interface_adapters/User_search_IA/IRetrieveList.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package interface_adapters.User_search_IA;
22

3-
import entities.user_entities.User;
4-
53
import entities.user_entities.User;
64
import java.util.List;
75

src/main/java/interface_adapters/app_screen_interface_adapters/AppScreenLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package interface_adapters.app_screen_interface_adapters;
22

3-
import entities.chat.Chat;
43
import use_cases.app_screen_use_case.AppScreenPresenter;
4+
import entities.*;
55
import screens.app_screen.AppScreen;
66

77
import java.util.ArrayList;
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package interface_adapters.app_screen_interface_adapters;
22

3-
import java.util.ArrayList;
4-
5-
import entities.chat.Chat;
6-
import interface_adapters.*;
73
import data_access.UserDatabase;
4+
import entities.chat.Chat;
85
import interface_adapters.login_interface_adapters.Login;
96

107
import java.util.ArrayList;
@@ -13,7 +10,6 @@ public class UserAppScreenGateway implements Login {
1310

1411
private final UserDatabase userDatabase;
1512
private final String username;
16-
private ArrayList<Chat> userChats;
1713

1814
/**
1915
* Create gateway between user and appscreen
@@ -27,9 +23,9 @@ public UserAppScreenGateway(String username){
2723
/**
2824
* Log the user into the system
2925
*/
30-
public void login(){;
31-
this.userChats = this.userDatabase.getUserChats(this.username);
32-
AppScreenLoader appScreenLoader = new AppScreenLoader(this.username, this.userChats);
26+
public void login(){
27+
ArrayList<Chat> userChats = this.userDatabase.getUserChats(this.username);
28+
AppScreenLoader appScreenLoader = new AppScreenLoader(this.username, userChats);
3329
}
3430

3531
}

src/main/java/interface_adapters/user_registration_interface_adapters/UserExists.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
package interface_adapters.user_registration_interface_adapters;
21

2+
package interface_adapters.user_registration_interface_adapters;
33
public interface UserExists {
44
boolean UserExists(String username, String email);
55
boolean UserExists(String username);

src/main/java/interface_adapters/user_registration_interface_adapters/UserRegistrationController.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package interface_adapters.user_registration_interface_adapters;
22

3+
import interface_adapters.User_search_IA.UserRetriever;
4+
import screens.login_screen.UserLoginUI;
35
import use_cases.user_registration_use_cases.verificationMethodFactory;
6+
import use_cases.user_registration_use_cases.UserCreator;
47

58
import javax.swing.*;
69
import java.awt.event.ActionEvent;
@@ -89,14 +92,14 @@ public static void accountExistsMessage(){
8992
accountExistsFrame.setVisible(true);
9093
}
9194

92-
public static void verificationSuccessMessage(){
95+
public static void verificationSuccessMessage(String message){
9396
JFrame verificationSuccessFrame = new JFrame();
9497
verificationSuccessFrame.setSize(400, 100);
9598
verificationSuccessFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
9699
JPanel verificationSuccessPanel = new JPanel();
97100
verificationSuccessPanel.setLayout(null);
98101
verificationSuccessFrame.add(verificationSuccessPanel);
99-
JLabel errorMessage = new JLabel("Could not verify please try again");
102+
JLabel errorMessage = new JLabel(message);
100103
errorMessage.setBounds(10,20, 350, 20);
101104
verificationSuccessPanel.add(errorMessage);
102105
verificationSuccessFrame.setVisible(true);
@@ -107,9 +110,11 @@ public void actionPerformed(ActionEvent e) {
107110
int verCode = Integer.parseInt(verificationCodeText.getText());
108111
if(verCode == this.code){
109112
database.createUser(this.username, this.password, this.email, "Basic");
110-
System.out.println("Verification successful");
113+
verificationSuccessMessage("Verification successful");
114+
UserLoginUI loginUI = new UserLoginUI((UserRetriever) database);
115+
loginUI.getLoginCredentials();
111116
}else{
112-
verificationSuccessMessage();
117+
verificationSuccessMessage("Could not verify please try again");
113118
}
114119
}
115120
}

0 commit comments

Comments
 (0)