Private chat info UI updated.

This commit is contained in:
Asal Lotfi
2025-09-05 15:59:39 +03:30
parent 0ba0abc4ed
commit f4be87a6df
2 changed files with 73 additions and 23 deletions
@@ -5,6 +5,7 @@ import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import org.json.JSONObject;
@@ -13,6 +14,8 @@ import org.to.telegramfinalproject.Client.AvatarLocalResolver;
import org.to.telegramfinalproject.Client.Session;
import org.to.telegramfinalproject.Models.ChatEntry;
import java.net.URL;
public class UserInfoController {
@FXML private VBox profileCard;
@@ -22,9 +25,9 @@ public class UserInfoController {
@FXML private ImageView profileImage;
@FXML private Label profileName;
@FXML private Label profileStatus;
@FXML private VBox bioBlock;
@FXML private HBox bioBlock;
@FXML private Label userBio;
@FXML private VBox usernameBlock;
@FXML private HBox usernameBlock;
@FXML private Label userId;
@FXML private Button moreButton;
@@ -32,9 +35,14 @@ public class UserInfoController {
@FXML private MenuItem deleteChatItem;
@FXML private MenuItem blockItem;
@FXML private MenuItem unblockItem;
@FXML private ImageView moreIcon;
@FXML private ImageView bioIcon;
@FXML private ImageView usernameIcon;
private String otherUserId; // internal_uuid of the other user
private static final String ICON_PATH = "/org/to/telegramfinalproject/Icons/";
@FXML
private void initialize() {
closeButton.setOnAction(e ->
@@ -67,6 +75,21 @@ public class UserInfoController {
deleteChatItem.setOnAction(e -> handleDeleteChat());
blockItem.setOnAction(e -> handleBlock());
unblockItem.setOnAction(e -> handleUnblock());
// Register scene for ThemeManager → stylesheet swap will handle colors/icons
Platform.runLater(() -> {
if (profileCard.getScene() != null) {
ThemeManager.getInstance().registerScene(profileCard.getScene());
}
});
// Listener for theme change
ThemeManager.getInstance().darkModeProperty().addListener((obs, oldVal, newVal) -> {
updateIcons(newVal);
});
// Set initial state
updateIcons(ThemeManager.getInstance().isDarkMode());
}
/** Backend JSON → UI */
@@ -168,4 +191,23 @@ public class UserInfoController {
blockItem.setVisible(!isBlocked);
unblockItem.setVisible(isBlocked);
}
private void updateIcons(boolean darkMode) {
String suffix = darkMode ? "_light.png" : "_dark.png";
moreIcon.setImage(loadImage(ICON_PATH + "more" + suffix));
bioIcon.setImage(loadImage(ICON_PATH + "bio" + suffix));
usernameIcon.setImage(loadImage(ICON_PATH + "user_id" + suffix));
}
// --- helpers -------------------------------------------------------------
private Image loadImage(String path) {
URL res = getClass().getResource(path);
if (res == null) {
System.err.println("Resource not found: " + path);
return null;
}
return new Image(res.toExternalForm());
}
}
@@ -26,7 +26,7 @@
<!-- More / overflow -->
<Button fx:id="moreButton" styleClass="icon-button">
<graphic>
<ImageView fitWidth="18" fitHeight="18" preserveRatio="true">
<ImageView fx:id="moreIcon" fitWidth="18" fitHeight="18" preserveRatio="true">
<image>
<Image url="@/org/to/telegramfinalproject/Icons/more_dark.png"/>
</image>
@@ -91,30 +91,38 @@
<VBox spacing="16" styleClass="info-blocks">
<!-- Bio -->
<VBox fx:id="bioBlock" spacing="2">
<HBox spacing="6" alignment="CENTER_LEFT">
<ImageView fitWidth="16" fitHeight="16" preserveRatio="true">
<image>
<Image url="@/org/to/telegramfinalproject/Icons/bio_dark.png"/>
</image>
</ImageView>
<HBox spacing="10" alignment="TOP_LEFT" fx:id="bioBlock">
<!-- Icon -->
<ImageView fx:id="bioIcon" fitWidth="16" fitHeight="16" preserveRatio="true"
styleClass="info-icon">
<image>
<Image url="@/org/to/telegramfinalproject/Icons/bio_dark.png"/>
</image>
</ImageView>
<!-- Texts -->
<VBox spacing="2">
<Label fx:id="userBio" wrapText="true" styleClass="profile-info-main"/>
</HBox>
<Label text="Bio" styleClass="profile-info-sub"/>
</VBox>
<Label text="Bio" styleClass="profile-info-sub"/>
</VBox>
</HBox>
<!-- Username -->
<VBox fx:id="usernameBlock" spacing="2">
<HBox spacing="6" alignment="CENTER_LEFT">
<ImageView fitWidth="16" fitHeight="16" preserveRatio="true">
<image>
<Image url="@/org/to/telegramfinalproject/Icons/user_id_dark.png"/>
</image>
</ImageView>
<HBox spacing="10" alignment="TOP_LEFT" fx:id="usernameBlock">
<!-- Icon -->
<ImageView fx:id="usernameIcon" fitWidth="16" fitHeight="16" preserveRatio="true"
styleClass="info-icon">
<image>
<Image url="@/org/to/telegramfinalproject/Icons/user_id_dark.png"/>
</image>
</ImageView>
<!-- Texts -->
<VBox spacing="2">
<Label fx:id="userId" styleClass="profile-info-main"/>
</HBox>
<Label text="Username" styleClass="profile-info-sub"/>
</VBox>
<Label text="Username" styleClass="profile-info-sub"/>
</VBox>
</HBox>
</VBox>
</HBox>