ADD::added friends pane and button to dashboard

ADD::added load animations to register window
This commit is contained in:
Sem van der Hoeven
2019-03-21 10:45:54 +01:00
parent 93aaf19f13
commit dfdbc8d5a9
5 changed files with 105 additions and 22 deletions

View File

@@ -24,35 +24,40 @@ public class DashBoardController {
@Autowired
UserService userService;
private FadeTransition fadeTrans; //transition for switching between the different panels
private int net;
private int count = 0;
@FXML
private AnchorPane dashboardPane;
@FXML
private AnchorPane userPane;
@FXML
private AnchorPane activitiesPane;
@FXML
private AnchorPane friendsPane;
@FXML
private Label veganMealCounter;
@FXML
private Label totalVeganMealCounter;
@FXML
private Label welcomebacktext;
@FXML
public Button dashboardButton;
public Button activitiesButton;
public Button userButton;
public Line pathLine;
public AnchorPane menuBar;
public Button addNewActivityButton;
private Button dashboardButton;
@FXML
private Button activitiesButton;
@FXML
private Button userButton;
@FXML
private Button friendsButton;
@FXML
private Line pathLine;
@FXML
private AnchorPane menuBar;
@FXML
private Button addNewActivityButton;
FadeTransition fadeTrans; //transition for switching between the different panels
/**
* loads the the necessary things before anything else.
@@ -66,6 +71,7 @@ public class DashBoardController {
dashboardButton.setSkin(new MyButtonSkin(dashboardButton));
activitiesButton.setSkin(new MyButtonSkin(activitiesButton));
userButton.setSkin(new MyButtonSkin(userButton));
friendsButton.setSkin(new MyButtonSkin(friendsButton));
@@ -94,7 +100,7 @@ public class DashBoardController {
dashboardPane.setVisible(true);
userPane.setVisible(false);
activitiesPane.setVisible(false);
friendsPane.setVisible(false);
}
@@ -107,13 +113,13 @@ public class DashBoardController {
addFadeTransition(activitiesPane);
int net = userService.currentUser.getVeganMeal() + count;
net = userService.currentUser.getVeganMeal() + count;
totalVeganMealCounter.setText("" + net);
System.out.println("display activities");
dashboardPane.setVisible(false);
userPane.setVisible(false);
activitiesPane.setVisible(true);
friendsPane.setVisible(false);
}
/**
@@ -126,10 +132,21 @@ public class DashBoardController {
dashboardPane.setVisible(false);
userPane.setVisible(true);
activitiesPane.setVisible(false);
friendsPane.setVisible(false);
}
public void displayFriends(ActionEvent event) {
addFadeTransition(friendsPane);
System.out.println("display friends");
dashboardPane.setVisible(false);
userPane.setVisible(false);
activitiesPane.setVisible(false);
friendsPane.setVisible(true);
}
/**
* adds a vegetarian meal.
* @param event the event (clicking the button)
@@ -137,7 +154,7 @@ public class DashBoardController {
public void addVeganMeal(ActionEvent event) {
count++;
int net = userService.currentUser.getVeganMeal() + count;
net = userService.currentUser.getVeganMeal() + count;
totalVeganMealCounter.setText("" + net);
veganMealCounter.setText("" + count);
System.out.println(userService);
@@ -154,11 +171,21 @@ public class DashBoardController {
//class for the animations on the navigation buttons
public class MyButtonSkin extends ButtonSkin {
/**
* adds a skin and scale animation to a button.
* the scale transition is for hovering over it so it then scales up
* and scales down when you stop hovering over it.
* @param button the button to add the animation to
*/
public MyButtonSkin(Button button) {
//inherit the button properties
super(button);
//transition to scale up on hover
final ScaleTransition scaleUp = new ScaleTransition(Duration.millis(100));
//add the node and the position to scale to
scaleUp.setNode(button);
scaleUp.setToX(1.1);
//play the transition when hovered over the button
button.setOnMouseEntered(e -> scaleUp.playFromStart());
final ScaleTransition scaleDown = new ScaleTransition(Duration.millis(100));

View File

@@ -1,16 +1,23 @@
package greenify.client.controller;
import greenify.client.rest.UserService;
import javafx.animation.TranslateTransition;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.shape.Line;
import javafx.stage.Stage;
import javafx.stage.Window;
import javafx.util.Duration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import java.util.concurrent.TimeUnit;
//class that controls the actions for the register window
@Controller
public class RegisterWindowController {
@@ -26,6 +33,25 @@ public class RegisterWindowController {
private PasswordField passwordField2;
@FXML
private Button signupButton;
@FXML
private Line uNamePathLine;
public void initialize() throws InterruptedException {
// PathTransition pathTransUName = new PathTransition(Duration.millis(1100), uNamePathLine, userNameText);
// pathTransUName.play();
addSlideAnimation(1100, userNameText, -300);
addSlideAnimation(1100, passwordField, 300);
TimeUnit.MILLISECONDS.sleep(300);
addSlideAnimation(1100, passwordField2, -420);
}
public void addSlideAnimation(int duration, Node node, int from) {
TranslateTransition slideIn = new TranslateTransition(Duration.millis(duration), node);
slideIn.setFromX(from);
slideIn.setToX(0);
slideIn.play();
}
/**
* signs the user up.