Skip to content

Commit

Permalink
login redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
Til7701 committed Oct 13, 2023
1 parent 8170321 commit 6e08a1d
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package de.schlunzis.client.controller;

import com.google.common.eventbus.EventBus;
import javafx.fxml.FXML;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class MainMenuController {

private final EventBus eventBus;

public MainMenuController(EventBus eventBus) {
this.eventBus = eventBus;
eventBus.register(this);
}

@FXML
private void logout() {
log.info("Logout button clicked");
// TODO implement, see issue
}

}
2 changes: 1 addition & 1 deletion client/src/main/java/de/schlunzis/client/scene/Scene.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
public enum Scene {

LOGIN,
CHAT;
MAIN

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public SceneController(EventBus eventBus) {

@Subscribe
public void onLoginSuccessfulResponse(LoginSuccessfulResponse lsr) {
eventBus.post(new SceneChangeEvent(Scene.CHAT));
eventBus.post(new SceneChangeEvent(Scene.MAIN));
}

}
11 changes: 7 additions & 4 deletions client/src/main/java/de/schlunzis/client/scene/SceneManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
@Component
public class SceneManager {

private static final String LOGIN_FXML_PATH = "/fxml/login.fxml";
private static final String MAIN_MENU_FXML_PATH = "/fxml/main.fxml";

private final ApplicationContext context;

@Setter
Expand All @@ -39,12 +42,12 @@ public void onSceneChangeMessage(SceneChangeEvent event) {

switch (event.scene()) {
case LOGIN -> {
path = "/fxml/login.fxml";
path = LOGIN_FXML_PATH;
stage.setTitle("Login");
}
case CHAT -> {
path = "/fxml/chat.fxml";
stage.setTitle("Chat");
case MAIN -> {
path = MAIN_MENU_FXML_PATH;
stage.setTitle("Kurtama");
}
}

Expand Down
24 changes: 9 additions & 15 deletions client/src/main/resources/fxml/chat.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,13 @@
<?import javafx.scene.layout.*?>
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" prefHeight="400.0" prefWidth="600.0"
xmlns="http://javafx.com/javafx/17.0.2-ea" fx:controller="de.schlunzis.client.controller.ChatController">
<children>
<VBox prefHeight="200.0" prefWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<ListView fx:id="chatListView" prefWidth="243.0"/>
<HBox>
<children>
<TextField fx:id="senderNameTextField" text="Jon Doe"/>
<TextField fx:id="chatTextField" onAction="#sendMessage" HBox.hgrow="ALWAYS"/>
<Button mnemonicParsing="false" onAction="#sendMessage" text="Senden"/>
</children>
</HBox>
</children>
</VBox>
</children>
<VBox prefHeight="200.0" prefWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<ListView fx:id="chatListView" prefWidth="243.0"/>
<HBox>
<TextField fx:id="senderNameTextField" text="Jon Doe"/>
<TextField fx:id="chatTextField" onAction="#sendMessage" HBox.hgrow="ALWAYS"/>
<Button mnemonicParsing="false" onAction="#sendMessage" text="Senden"/>
</HBox>
</VBox>
</AnchorPane>
22 changes: 22 additions & 0 deletions client/src/main/resources/fxml/css/login.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
GridPane {
-fx-pref-width: 500px;
-fx-pref-height: 250px;
-fx-alignment: center;
-fx-hgap: 10px;
-fx-vgap: 10px;
-fx-padding: 20px;
-fx-background-color: #ffffff;
}

Label {
-fx-text-fill: black;
}

TextField, PasswordField {
-fx-padding: 10px;
-fx-pref-width: 300px;
}

#loginButton {
-fx-max-width: 99999px;
}
13 changes: 13 additions & 0 deletions client/src/main/resources/fxml/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
* {
-fx-font-size: 14px;
}

Button {
-fx-pref-height: 40px;
-fx-background-color: #8f8f8f;
-fx-text-fill: white;
}

Button:hover {
-fx-background-color: #c2c2c2;
}
13 changes: 10 additions & 3 deletions client/src/main/resources/fxml/login.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@

<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<GridPane xmlns:fx="http://javafx.com/fxml/1" alignment="center" hgap="10" style="-fx-padding: 20px;" vgap="10"
xmlns="http://javafx.com/javafx/17.0.2-ea" fx:controller="de.schlunzis.client.controller.LoginController">
<?import java.net.URL?>
<GridPane xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/17.0.2-ea"
fx:controller="de.schlunzis.client.controller.LoginController">
<stylesheets>
<URL value="@css/style.css"/>
<URL value="@css/login.css"/>
</stylesheets>

<Label text="Email:" GridPane.columnIndex="0" GridPane.rowIndex="0"/>
<TextField fx:id="emailField" GridPane.columnIndex="1" GridPane.rowIndex="0"/>
<Label text="Password:" GridPane.columnIndex="0" GridPane.rowIndex="1"/>
<PasswordField fx:id="passwordField" GridPane.columnIndex="1" GridPane.rowIndex="1" onAction="#handleLogin"/>
<Button fx:id="loginButton" text="Login" GridPane.columnIndex="1" GridPane.rowIndex="2" onAction="#handleLogin"/>
<Button fx:id="loginButton" text="Login" GridPane.columnIndex="0" GridPane.rowIndex="2" GridPane.columnSpan="2"
onAction="#handleLogin"/>
</GridPane>
17 changes: 17 additions & 0 deletions client/src/main/resources/fxml/main.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.AnchorPane?>
<?import java.net.URL?>
<AnchorPane xmlns:fx="http://javafx.com/fxml"
xmlns="http://javafx.com/javafx"
fx:controller="de.schlunzis.client.controller.MainMenuController"
prefHeight="400.0" prefWidth="600.0">
<stylesheets>
<URL value="@css/style.css"/>
</stylesheets>

<fx:include source="chat.fxml"/>
<Button mnemonicParsing="false" onAction="#logout" text="Logout"/>

</AnchorPane>

0 comments on commit 6e08a1d

Please sign in to comment.