Skip to content

Commit

Permalink
Main Login Page
Browse files Browse the repository at this point in the history
  • Loading branch information
kmags1 committed Nov 28, 2023
1 parent f10be55 commit cac27e9
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 3 deletions.
15 changes: 14 additions & 1 deletion app/src/main/java/cse/gradle/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,25 @@ static void setListeners(NewRecipePane recipePane, View appScenes, Scene cancelS
static void setListeners(UserCreateAccount createPane, View appScenes, Scene cancelScene, Scene nextScene) {

createPane.getCreateButton().setOnAction(e -> {

appScenes.displayScene(cancelScene);
});

// Display cancelScene when backButton is pushed
createPane.getBackButton().setOnAction(e -> {
appScenes.displayScene(nextScene);
});
}

// Sets the listensers for all the buttons within the recipe creation window
static void setListeners(UserLogin createPane, View appScenes, Scene createScene, Scene accepedtScene) {

createPane.getCreateButton().setOnAction(e -> {
appScenes.displayScene(createScene);
});

// Display cancelScene when backButton is pushed
createPane.getLoginButton().setOnAction(e -> {
appScenes.displayScene(accepedtScene);
});
}
}
81 changes: 79 additions & 2 deletions app/src/main/java/cse/gradle/View.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ public class View {
private Scene newRecipeScene;
private Scene ingredientsInputScene;
private Scene userAcccountScene;
private Scene mainLoginScene;
private RecipeList recipeListRoot;
private AudioRecorder audioRecorder;
private Stage stage;

public View(Stage stage) {
audioRecorder = new AudioRecorder();
this.stage = stage;
UserLoginConstructor();
UserAccountSceneConstructor();
recipeListRoot = new RecipeList(this);
recipeListScene = new Scene(recipeListRoot, 500, 600);
Expand All @@ -39,6 +41,7 @@ public View(Stage stage) {
public View(Stage stage, List<Recipe> arrayList) {
audioRecorder = new AudioRecorder();
this.stage = stage;
UserLoginConstructor();
UserAccountSceneConstructor();
recipeListRoot = new RecipeList(this, arrayList);
recipeListScene = new Scene(recipeListRoot, 500, 600);
Expand All @@ -56,20 +59,29 @@ public void displayNewRecipeScene() {
}
//////////////////////////// NEW
public void UserAccountSceneConstructor(){
UserCreateAccount userCreateAccount = new UserCreateAccount(this, null, recipeListScene);
UserCreateAccount userCreateAccount = new UserCreateAccount(this, mainLoginScene, recipeListScene);
userAcccountScene = new Scene(userCreateAccount, 500, 600);
}

public void displayUserAccountSceneConstructor(){
displayScene(userAcccountScene);
}

public void UserLoginConstructor(){
UserLogin userLoginAccount = new UserLogin(this, userAcccountScene, recipeListScene);
mainLoginScene = new Scene(userLoginAccount, 500, 600);
}

public void displayUserLoginConstructor(){
displayScene(mainLoginScene);
}
/////////////////////////////
public void displayScene(Scene s) {
stage.setScene(s);
}

public Scene getScene() {
return userAcccountScene;
return mainLoginScene;
}

public RecipeList getRecipeListRoot() {
Expand Down Expand Up @@ -533,4 +545,69 @@ public Button getCreateButton(){
public Button getBackButton(){
return BackButton;
}
}

class UserLogin extends BorderPane{
private TextField usernameField;
private PasswordField passwordField;
private Button CreateButton;
private Button LoginButton;

public UserLogin(View appScenes, Scene createScene, Scene accepedtScene){
VBox vbox = new VBox();
vbox.setAlignment(Pos.CENTER);

Label title = new Label("Login");
title.setStyle("-fx-font-size: 24;");

usernameField = new TextField();
passwordField = new PasswordField();

usernameField.setPromptText("Username");
usernameField.setStyle("-fx-pref-width: 50; -fx-font-size: 14;");

passwordField.setPromptText("Password");
passwordField.setStyle("-fx-pref-width: 50; -fx-font-size: 14;");


CreateButton = new Button("Create Account");
CreateButton.setPrefSize(200, 20);
CreateButton.setStyle("-fx-background-color: #DAE5EA; -fx-border-width: 1; -fx-border-color: #737778;");

LoginButton = new Button("Login");
LoginButton.setPrefSize(200, 20);
LoginButton.setStyle("-fx-background-color: #DAE5EA; -fx-border-width: 1; -fx-border-color: #737778;");

HBox hbox = new HBox();
hbox.setAlignment(Pos.CENTER);
hbox.getChildren().addAll(CreateButton, LoginButton);

Controller.setListeners(this, appScenes, createScene, accepedtScene);
vbox.getChildren().addAll(usernameField, passwordField);

VBox vbox2 = new VBox();
vbox2.setAlignment(Pos.TOP_CENTER);
vbox2.getChildren().addAll(title);

this.setCenter(vbox);
this.setBottom(hbox);
this.setTop(vbox2);
}


public TextField getUsernameField(){
return usernameField;
}

public PasswordField getPasswordField(){
return passwordField;
}

public Button getCreateButton(){
return CreateButton;
}

public Button getLoginButton(){
return LoginButton;
}
}

0 comments on commit cac27e9

Please sign in to comment.