feat: first ui draft
This uses JFoenix for a material design feel
This commit is contained in:
parent
062880407b
commit
4e681e0637
8 changed files with 200 additions and 42 deletions
13
build.gradle
13
build.gradle
|
@ -12,7 +12,7 @@ repositories {
|
||||||
|
|
||||||
javafx {
|
javafx {
|
||||||
version = "11.0.2"
|
version = "11.0.2"
|
||||||
modules = [ 'javafx.controls', 'javafx.fxml' ]
|
modules = ['javafx.controls', 'javafx.fxml']
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -22,6 +22,7 @@ dependencies {
|
||||||
implementation 'org.xerial:sqlite-jdbc:3.32.3'
|
implementation 'org.xerial:sqlite-jdbc:3.32.3'
|
||||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0")
|
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0")
|
||||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0")
|
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0")
|
||||||
|
compile 'com.jfoenix:jfoenix:9.0.10'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,4 +39,14 @@ jar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run {
|
||||||
|
jvmArgs = [
|
||||||
|
"--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED",
|
||||||
|
"--add-exports=javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED",
|
||||||
|
"--add-exports=javafx.base/com.sun.javafx.binding=ALL-UNNAMED",
|
||||||
|
"--add-exports=javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED",
|
||||||
|
"--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
mainClassName = 'fr.insa.clavardator.MainApp'
|
mainClassName = 'fr.insa.clavardator.MainApp'
|
45
src/main/java/fr/insa/clavardator/ChatController.java
Normal file
45
src/main/java/fr/insa/clavardator/ChatController.java
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
package fr.insa.clavardator;
|
||||||
|
|
||||||
|
import com.jfoenix.controls.JFXHamburger;
|
||||||
|
import com.jfoenix.transitions.hamburger.HamburgerBackArrowBasicTransition;
|
||||||
|
import com.jfoenix.transitions.hamburger.HamburgerSlideCloseTransition;
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.fxml.Initializable;
|
||||||
|
import javafx.scene.control.ListView;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
public class ChatController implements Initializable {
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private ListView<String> messageList;
|
||||||
|
@FXML
|
||||||
|
private JFXHamburger hamburger;
|
||||||
|
|
||||||
|
private HamburgerBackArrowBasicTransition burgerTask;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(URL url, ResourceBundle rb) {
|
||||||
|
|
||||||
|
ObservableList<String> messages = FXCollections.observableArrayList(
|
||||||
|
"test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test");
|
||||||
|
|
||||||
|
messageList.setItems(messages);
|
||||||
|
messageList.scrollTo(messageList.getItems().size() - 1);
|
||||||
|
burgerTask = new HamburgerBackArrowBasicTransition(hamburger);
|
||||||
|
burgerTask.setRate(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onHamburgerClick() {
|
||||||
|
burgerTask.setRate(burgerTask.getRate() * -1);
|
||||||
|
burgerTask.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
public JFXHamburger getHamburger() {
|
||||||
|
return hamburger;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
23
src/main/java/fr/insa/clavardator/DrawerController.java
Normal file
23
src/main/java/fr/insa/clavardator/DrawerController.java
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
package fr.insa.clavardator;
|
||||||
|
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.fxml.Initializable;
|
||||||
|
import javafx.scene.control.ListView;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
public class DrawerController implements Initializable {
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private ListView<String> userList;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(URL url, ResourceBundle rb) {
|
||||||
|
ObservableList<String> activeList = FXCollections.observableArrayList(
|
||||||
|
"Julia", "Ian", "Sue", "Matthew", "Hannah", "Stephan", "Denise", "Julia", "Ian", "Sue", "Matthew", "Hannah", "Stephan", "Denise", "Julia", "Ian", "Sue", "Matthew", "Hannah", "Stephan", "Denise", "Julia", "Ian", "Sue", "Matthew", "Hannah", "Stephan", "Denise");
|
||||||
|
userList.setItems(activeList);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,21 +0,0 @@
|
||||||
package fr.insa.clavardator;
|
|
||||||
|
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.fxml.Initializable;
|
|
||||||
import javafx.scene.control.Label;
|
|
||||||
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
|
|
||||||
public class FXMLController implements Initializable {
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Label label;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initialize(URL url, ResourceBundle rb) {
|
|
||||||
String javaVersion = System.getProperty("java.version");
|
|
||||||
String javafxVersion = System.getProperty("javafx.version");
|
|
||||||
label.setText("-= CLAVARDATOR =-\nusing JavaFX " + javafxVersion + "\nRunning on Java " + javaVersion + ".");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +1,11 @@
|
||||||
package fr.insa.clavardator;
|
package fr.insa.clavardator;
|
||||||
|
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.fxml.FXMLLoader;
|
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
// See here : https://github.com/jfoenixadmin/JFoenix/blob/master/demo/src/main/java/demos/components/DrawerDemo.java
|
||||||
|
|
||||||
public class MainApp extends Application {
|
public class MainApp extends Application {
|
||||||
|
|
||||||
|
@ -15,13 +15,19 @@ public class MainApp extends Application {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage stage) throws Exception {
|
public void start(Stage stage) throws Exception {
|
||||||
Parent root = FXMLLoader.load(getClass().getResource("scene.fxml"));
|
// String javaVersion = System.getProperty("java.version");
|
||||||
|
// String javafxVersion = System.getProperty("javafx.version");
|
||||||
|
|
||||||
Scene scene = new Scene(root);
|
final MainController main = new MainController();
|
||||||
scene.getStylesheets().add(getClass().getResource("styles.css").toExternalForm());
|
final Parent content = main.init();
|
||||||
|
|
||||||
|
Scene scene = new Scene(content);
|
||||||
|
|
||||||
stage.setTitle("Clavardator");
|
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
|
stage.setTitle("Clavardator");
|
||||||
|
stage.setMinHeight(640);
|
||||||
|
stage.setMinWidth(640);
|
||||||
|
stage.setMaximized(true);
|
||||||
stage.show();
|
stage.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
47
src/main/java/fr/insa/clavardator/MainController.java
Normal file
47
src/main/java/fr/insa/clavardator/MainController.java
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
package fr.insa.clavardator;
|
||||||
|
|
||||||
|
import com.jfoenix.controls.JFXButton;
|
||||||
|
import com.jfoenix.controls.JFXDrawer;
|
||||||
|
import com.jfoenix.controls.JFXDrawersStack;
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.layout.FlowPane;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static javafx.scene.input.MouseEvent.MOUSE_CLICKED;
|
||||||
|
import static javafx.scene.input.MouseEvent.MOUSE_PRESSED;
|
||||||
|
|
||||||
|
public class MainController {
|
||||||
|
|
||||||
|
private final JFXDrawer leftDrawer ;
|
||||||
|
private final JFXDrawersStack drawersStack;
|
||||||
|
|
||||||
|
public MainController() {
|
||||||
|
leftDrawer = new JFXDrawer();
|
||||||
|
drawersStack = new JFXDrawersStack();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Parent init() throws IOException {
|
||||||
|
FXMLLoader chatLoader = new FXMLLoader(getClass().getResource("scene.fxml"));
|
||||||
|
Parent chatContent = chatLoader.load();
|
||||||
|
ChatController chatController = chatLoader.getController();
|
||||||
|
|
||||||
|
FXMLLoader drawerLoader = new FXMLLoader(getClass().getResource("drawer.fxml"));
|
||||||
|
Parent drawerContent = drawerLoader.load();
|
||||||
|
|
||||||
|
leftDrawer.setSidePane(drawerContent);
|
||||||
|
leftDrawer.setDefaultDrawerSize(300);
|
||||||
|
leftDrawer.setResizeContent(true);
|
||||||
|
leftDrawer.setOverLayVisible(false);
|
||||||
|
leftDrawer.setResizableOnDrag(false);
|
||||||
|
leftDrawer.setOverLayVisible(false);
|
||||||
|
|
||||||
|
drawersStack.setContent(chatContent);
|
||||||
|
|
||||||
|
chatController.getHamburger().addEventHandler(MOUSE_CLICKED, e -> drawersStack.toggle(leftDrawer));
|
||||||
|
|
||||||
|
return drawersStack;
|
||||||
|
}
|
||||||
|
}
|
22
src/main/resources/fr/insa/clavardator/drawer.fxml
Normal file
22
src/main/resources/fr/insa/clavardator/drawer.fxml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import com.jfoenix.controls.*?>
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
|
|
||||||
|
<AnchorPane prefHeight="673.0" prefWidth="392.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.insa.clavardator.DrawerController">
|
||||||
|
<children>
|
||||||
|
<VBox prefHeight="673.0" prefWidth="392.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<children>
|
||||||
|
<HBox alignment="CENTER" prefHeight="48.0" prefWidth="200.0" spacing="10.0">
|
||||||
|
<children>
|
||||||
|
<Label text="Utilisateurs" />
|
||||||
|
<JFXButton mnemonicParsing="false" text="Rafraichir" />
|
||||||
|
</children>
|
||||||
|
</HBox>
|
||||||
|
<JFXListView fx:id="userList" prefHeight="533.0" prefWidth="282.0" VBox.vgrow="ALWAYS" />
|
||||||
|
</children>
|
||||||
|
</VBox>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
|
@ -1,17 +1,42 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import javafx.scene.control.Label?>
|
<?import com.jfoenix.controls.*?>
|
||||||
<?import javafx.scene.layout.BorderPane?>
|
<?import javafx.geometry.*?>
|
||||||
<?import javafx.scene.layout.StackPane?>
|
<?import javafx.scene.control.*?>
|
||||||
<StackPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0"
|
<?import javafx.scene.layout.*?>
|
||||||
prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1"
|
|
||||||
fx:controller="fr.insa.clavardator.FXMLController">
|
<AnchorPane prefHeight="562.0" prefWidth="786.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.insa.clavardator.ChatController">
|
||||||
<children>
|
<children>
|
||||||
<Label fx:id="label" stylesheets="@styles.css" text="Label" textAlignment="CENTER"/>
|
<VBox prefHeight="440.0" prefWidth="400.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<BorderPane prefHeight="200.0" prefWidth="200.0">
|
<children>
|
||||||
<top>
|
<FlowPane alignment="CENTER_LEFT" prefHeight="40.0" prefWidth="200.0">
|
||||||
<BorderPane prefHeight="11.0" prefWidth="368.0" BorderPane.alignment="CENTER"/>
|
<children>
|
||||||
</top>
|
<JFXHamburger fx:id="hamburger" onMouseClicked="#onHamburgerClick">
|
||||||
</BorderPane>
|
<FlowPane.margin>
|
||||||
</children>
|
<Insets left="10.0" right="10.0" />
|
||||||
</StackPane>
|
</FlowPane.margin>
|
||||||
|
</JFXHamburger>
|
||||||
|
<Label text="Connecté en tant que : " />
|
||||||
|
<Label text="<USERNAME>" />
|
||||||
|
<JFXButton mnemonicParsing="false" text="Changer">
|
||||||
|
<FlowPane.margin>
|
||||||
|
<Insets left="10.0" right="10.0" />
|
||||||
|
</FlowPane.margin>
|
||||||
|
</JFXButton>
|
||||||
|
</children>
|
||||||
|
</FlowPane>
|
||||||
|
<JFXListView fx:id="messageList" prefHeight="200.0" prefWidth="200.0" VBox.vgrow="ALWAYS" />
|
||||||
|
<HBox alignment="CENTER" prefHeight="48.0" prefWidth="200.0" spacing="10.0">
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||||
|
</padding>
|
||||||
|
<children>
|
||||||
|
<JFXTextField HBox.hgrow="ALWAYS" />
|
||||||
|
<JFXButton mnemonicParsing="false" text="Joindre" />
|
||||||
|
<JFXButton layoutX="725.0" layoutY="22.0" mnemonicParsing="false" text="Envoyer" />
|
||||||
|
</children>
|
||||||
|
</HBox>
|
||||||
|
</children>
|
||||||
|
</VBox>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
|
Loading…
Reference in a new issue