diff --git a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/components/NavbarController.java b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/components/NavbarController.java new file mode 100644 index 0000000..4c4975d --- /dev/null +++ b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/components/NavbarController.java @@ -0,0 +1,58 @@ +package ntnu.systemutvikling.team6.controller.components; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.TextField; + +public class NavbarController extends BaseController { + @FXML protected TextField frontSearchField; + @FXML private Button loginButton; + @FXML private Button profileButton; + + @Override + protected void authTokenisSet() { + boolean loggedIn = super.isLoggedin(); + if (loggedIn){ + loginButton.setVisible(false); + loginButton.setManaged(false); + profileButton.setVisible(true); + profileButton.setManaged(true); + profileButton.setText(authToken.getCurrentUser().getDisplayName().substring(0,2)); + } else { + loginButton.setVisible(true); + loginButton.setManaged(true); + profileButton.setVisible(false); + profileButton.setManaged(false); + } + + } + @FXML + private void handleFrontSearch(ActionEvent event){ + String query = frontSearchField.getText().trim(); + + if (query.isEmpty()) { + return; + } + + LoaderScene.LoadScene("availableOrganization", event, null, query); + } + + @FXML + private void switchToFrontPage(ActionEvent event) { + System.out.println("Click!"); + LoaderScene.LoadScene("FrontPage", event, null, null); + } + + @FXML + private void switchToProfilePage(ActionEvent event) { + System.out.println("Click!"); + LoaderScene.LoadScene("aboutPage", event, null, null); + } + + @FXML + private void switchToLoginPage(ActionEvent event) { + System.out.println("Click!"); + LoaderScene.LoadScene("aboutPage", event, null, null); + } +} diff --git a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/components/NavbarFooterController.java b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/components/NavbarFooterController.java deleted file mode 100644 index 0075893..0000000 --- a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/components/NavbarFooterController.java +++ /dev/null @@ -1,33 +0,0 @@ -package ntnu.systemutvikling.team6.controller.components; - -import javafx.event.ActionEvent; -import javafx.fxml.FXML; -import javafx.scene.control.TextField; - -public interface NavbarFooterController { - - default void switchToFrontPage(ActionEvent event) { - System.out.println("Click!"); - LoaderScene.LoadScene("FrontPage", event, null, null); - } - - default void switchToAboutPage(ActionEvent event) { - System.out.println("Click!"); - LoaderScene.LoadScene("aboutPage", event, null, null); - } - - default void switchToProfilePage(ActionEvent event) { - System.out.println("Click!"); - LoaderScene.LoadScene("aboutPage", event, null, null); - } - - default void handleSearch(ActionEvent event) { - System.out.println("Click!"); - LoaderScene.LoadScene("aboutPage", event, null, null); - } - - default void switchToLoginPage(ActionEvent event) { - System.out.println("Click!"); - LoaderScene.LoadScene("aboutPage", event, null, null); - } -} diff --git a/helpmehelpapplication/src/main/resources/fxml/components/navbar.fxml b/helpmehelpapplication/src/main/resources/fxml/components/navbar.fxml index f3cca80..a7221e5 100644 --- a/helpmehelpapplication/src/main/resources/fxml/components/navbar.fxml +++ b/helpmehelpapplication/src/main/resources/fxml/components/navbar.fxml @@ -12,78 +12,59 @@ - + + + - - - + + + - + + + - - - - - - - + + + + + + + + + + + - + + + + + - - - + - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file +