ADD::added animations

added animations for switching between panes in the main stage
This commit is contained in:
Sem van der Hoeven
2019-03-18 15:30:55 +01:00
parent 6a71823885
commit 8dd8ae28d4
3 changed files with 31 additions and 5 deletions

View File

@@ -1,10 +1,13 @@
package greenify.client.controller;
import greenify.client.rest.UserService;
import javafx.animation.FadeTransition;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.AnchorPane;
import javafx.util.Duration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@@ -33,8 +36,18 @@ public class DashBoardController {
@FXML
private Label welcomebacktext;
FadeTransition fadeTrans;
public void initialize() {
welcomebacktext.setText("Welcome back " + userService.currentUser.getName() + "!");
welcomebacktext.setText("Welcome back, " + userService.currentUser.getName() + "!");
}
public void addFadeTransition(Node node) {
fadeTrans = new FadeTransition(Duration.millis(400), node);
fadeTrans.setFromValue(0);
fadeTrans.setToValue(1.0);
fadeTrans.play();
}
@@ -43,11 +56,13 @@ public class DashBoardController {
* @param event the event (clicking the button)
*/
public void displayDashboard(ActionEvent event) {
addFadeTransition(dashboardPane);
System.out.println("display dashboard");
dashboardPane.setVisible(true);
userPane.setVisible(false);
activitiesPane.setVisible(false);
}
/**
@@ -55,11 +70,13 @@ public class DashBoardController {
* @param event the event (clicking the button)
*/
public void displayActivities(ActionEvent event) {
addFadeTransition(activitiesPane);
totalVeganMealCounter.setText("" + userService.currentUser.getVeganMeal());
System.out.println("display activities");
dashboardPane.setVisible(false);
userPane.setVisible(false);
activitiesPane.setVisible(true);
}
/**
@@ -67,10 +84,13 @@ public class DashBoardController {
* @param event the event (clicking the button)
*/
public void displayUser(ActionEvent event) {
addFadeTransition(userPane);
System.out.println("display user");
dashboardPane.setVisible(false);
userPane.setVisible(true);
activitiesPane.setVisible(false);
}
/**

View File

@@ -207,6 +207,11 @@
</ImageView>
</graphic>
</Button>
<Text fill="#797676" layoutX="60.0" layoutY="105.0" strokeType="OUTSIDE" strokeWidth="0.0" text="How will you make the world greener today?">
<font>
<Font size="15.0" />
</font>
</Text>
</children>
</AnchorPane>
</children>

View File

@@ -1,16 +1,16 @@
@font-face {
font-family: 'Designio Regular ';
src: url('stylesheets/DesignioRegular.otf');
font-family: 'Designio Regular';
src: url('DesignioRegular.otf');
}
.root {
-fx-background-color: #f9fffb;
-fx-font-family: "Big Designer";
/*-fx-font-family: "Designio Regular";*/
-fx-font-family: Corbel; /*this doesn't work for some reason*/
}
#dashboardButton {
-fx-background-color: #5a635c;
}
#dashboardButton:pressed {
-fx-background-color: #b7e2c2;
@@ -29,3 +29,4 @@
#activitiesButton:pressed {
-fx-background-color: #b7e2c2;
}