New Channel UI updated.

This commit is contained in:
Asal Lotfi
2025-09-03 13:48:37 +03:30
parent 7b54835468
commit 9cd71d33d4
2 changed files with 29 additions and 2 deletions
@@ -30,6 +30,8 @@ public class NewChannelController {
@FXML private Button createButton; @FXML private Button createButton;
@FXML private StackPane overlayRoot; // the root @FXML private StackPane overlayRoot; // the root
@FXML private Label descCounter; @FXML private Label descCounter;
@FXML private Label channelIdLabel;
@FXML private TextField channelIdField;
private File channelImageFile; private File channelImageFile;
@@ -67,6 +69,7 @@ public class NewChannelController {
// Create button → validate name + submit // Create button → validate name + submit
createButton.setOnAction(e -> { createButton.setOnAction(e -> {
String channelName = channelNameField.getText().trim(); String channelName = channelNameField.getText().trim();
String channelId = channelIdField.getText().trim();
String description = channelDescField.getText().trim(); String description = channelDescField.getText().trim();
if (channelName.isEmpty()) { if (channelName.isEmpty()) {
@@ -76,6 +79,13 @@ public class NewChannelController {
return; return;
} }
if (channelId.isEmpty()) {
// Apply error style
channelIdField.getStyleClass().add("error");
channelIdLabel.getStyleClass().add("error");
return;
}
try { try {
// Load Add Members overlay // Load Add Members overlay
FXMLLoader loader = new FXMLLoader(getClass().getResource( FXMLLoader loader = new FXMLLoader(getClass().getResource(
@@ -84,7 +94,7 @@ public class NewChannelController {
// Pass channel info to AddMembersController // Pass channel info to AddMembersController
AddSubscriberController controller = loader.getController(); AddSubscriberController controller = loader.getController();
controller.setChannelInfo(channelName, description, channelImageFile); controller.setChannelInfo(channelName, channelId, description, channelImageFile);
// Close the current "New Channel" overlay // Close the current "New Channel" overlay
MainController.getInstance().closeOverlay(overlayRoot); MainController.getInstance().closeOverlay(overlayRoot);
@@ -133,6 +143,14 @@ public class NewChannelController {
} }
}); });
// Reset error state when typing
channelIdField.textProperty().addListener((obs, oldVal, newVal) -> {
if (!newVal.trim().isEmpty()) {
channelIdField.getStyleClass().remove("error");
channelIdLabel.getStyleClass().remove("error");
}
});
// Auto-focus channel name on open // Auto-focus channel name on open
Platform.runLater(() -> channelNameField.requestFocus()); Platform.runLater(() -> channelNameField.requestFocus());
@@ -17,7 +17,7 @@
spacing="16" spacing="16"
alignment="CENTER" alignment="CENTER"
prefWidth="400" maxWidth="400" prefWidth="400" maxWidth="400"
prefHeight="280" maxHeight="280"> prefHeight="380" maxHeight="380">
<!-- Header Row: Picture + Name --> <!-- Header Row: Picture + Name -->
<HBox alignment="CENTER_LEFT" spacing="12"> <HBox alignment="CENTER_LEFT" spacing="12">
@@ -42,6 +42,15 @@
</VBox> </VBox>
</HBox> </HBox>
<!-- ID -->
<VBox spacing="4" alignment="CENTER_LEFT">
<Label fx:id="channelIdLabel" text="Channel ID" styleClass="group-name-label"/>
<TextField fx:id="channelIdField"
promptText="Enter channel ID"
styleClass="group-name-field"
HBox.hgrow="ALWAYS"/>
</VBox>
<!-- Channel Description --> <!-- Channel Description -->
<VBox spacing="4" alignment="CENTER_LEFT"> <VBox spacing="4" alignment="CENTER_LEFT">
<Label fx:id="channelDescLabel" text="Description (optional)" styleClass="group-name-label"/> <Label fx:id="channelDescLabel" text="Description (optional)" styleClass="group-name-label"/>