Skip to content

Commit 38426a4

Browse files
committed
Added login to UserAppScreenGateway
1 parent 31ac556 commit 38426a4

File tree

5 files changed

+31
-21
lines changed

5 files changed

+31
-21
lines changed

src/main/java/appscreen/AppScreen.java

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

3-
import testerEntities.Chat;
43

54
import javax.swing.*;
65
import java.awt.*;

src/main/java/appscreen/AppScreenController.java

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

3-
import testerEntities.*;
4-
53
public interface AppScreenController{
64
Chat getChat(String chatID);
75

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package appscreen;
22

3-
import testerEntities.*;
43
import java.util.ArrayList;
54

65
public class AppScreenLoader implements AppScreenPresenter {
@@ -12,11 +11,10 @@ public class AppScreenLoader implements AppScreenPresenter {
1211
/**
1312
* Create the app screen loader (and store its user and chat information)
1413
* @param username The username of the current user
15-
* @param userDataBase User information
1614
*/
17-
public AppScreenLoader(String username, UserDataBase userDataBase){
15+
public AppScreenLoader(String username, ArrayList<Chat> chats){
1816
this.username = username;
19-
this.chats = userDataBase.getUserChats(username);
17+
this.chats = chats;
2018
try {
2119
openScreen();
2220
} catch (Exception e) {
@@ -33,17 +31,4 @@ public void openScreen() {
3331
this.appScreen = new AppScreen(this.username, this.chats);
3432
}
3533

36-
/**
37-
* @return The username of the current user
38-
*/
39-
public String getUsername(){
40-
return this.username;
41-
}
42-
43-
/**
44-
* @return A list of chats that the user is in
45-
*/
46-
public ArrayList<Chat> getChats(){
47-
return new ArrayList<>(this.chats);
48-
}
4934
}

src/main/java/appscreen/ChatName.java

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

3-
import testerEntities.*;
43

54
public interface ChatName {
65
String getChatName(Chat chat);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package appscreen;
2+
3+
import java.util.ArrayList;
4+
5+
public class UserAppScreenGateway {
6+
7+
private final UserDataBase userDataBase;
8+
private String username;
9+
private ArrayList<Chat> userChats;
10+
11+
/**
12+
* Create gateway between user and appscreen
13+
* @param userDataBase The user database
14+
*/
15+
public UserAppScreenGateway(UserDataBase userDataBase){
16+
this.userDataBase = userDataBase;
17+
}
18+
19+
/**
20+
* Log the user into the system
21+
* @param user The current user
22+
*/
23+
public void login(User user){
24+
this.username = user.getUsername();
25+
this.userChats = userDataBase.getUserChats(this.username);
26+
AppScreenLoader appScreenLoader = new AppScreenLoader(this.username, this.userChats);
27+
}
28+
29+
}

0 commit comments

Comments
 (0)