My Profile UI implemented.
This commit is contained in:
@@ -277,4 +277,13 @@ public class MainController {
|
||||
private void updateLabelsForLightMode() {
|
||||
//myLabel.setStyle("-fx-text-fill: black;");
|
||||
}
|
||||
|
||||
// === Overlay Handling ===
|
||||
public void showOverlay(Node overlayNode) {
|
||||
mainRoot.getChildren().add(overlayNode);
|
||||
}
|
||||
|
||||
public void closeOverlay(Node overlayNode) {
|
||||
mainRoot.getChildren().remove(overlayNode);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,96 @@
|
||||
package org.to.telegramfinalproject.UI;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import org.to.telegramfinalproject.Models.User;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.shape.Circle;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class MyProfileController {
|
||||
|
||||
@FXML private Pane overlayBackground;
|
||||
@FXML private Button closeButton;
|
||||
@FXML private Button editButton;
|
||||
@FXML private ImageView profileImage;
|
||||
@FXML private Label displayName;
|
||||
@FXML private Label status;
|
||||
@FXML private Label bio;
|
||||
@FXML private Label profileName;
|
||||
@FXML private Label profileStatus;
|
||||
@FXML private Label userBio;
|
||||
@FXML private Label userId;
|
||||
@FXML private VBox profileCard;
|
||||
@FXML private VBox bioBlock;
|
||||
|
||||
private final ThemeManager themeManager = ThemeManager.getInstance();
|
||||
|
||||
// public void initialize() {
|
||||
// // Load data from your logged-in user object
|
||||
// // Example:
|
||||
// displayName.setText(CurrentUser.getName());
|
||||
// status.setText(CurrentUser.isOnline() ? "online" : "offline");
|
||||
// bio.setText(CurrentUser.getBio());
|
||||
// userId.setText(CurrentUser.getUserId());
|
||||
//
|
||||
// if (CurrentUser.getProfileImagePath() != null) {
|
||||
// profileImage.setImage(new Image(CurrentUser.getProfileImagePath()));
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@FXML
|
||||
private void initialize() {
|
||||
overlayBackground.setOnMouseClicked(e -> closeProfile());
|
||||
closeButton.setOnAction(e -> closeProfile());
|
||||
|
||||
// Round profile picture
|
||||
profileImage.setClip(new Circle(40, 40, 40));
|
||||
|
||||
// Default avatar
|
||||
profileImage.setImage(new Image(
|
||||
Objects.requireNonNull(getClass().getResourceAsStream(
|
||||
"/org/to/telegramfinalproject/Avatars/default_profile.png"))
|
||||
));
|
||||
|
||||
// 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) -> {
|
||||
updateEditIcon(newVal);
|
||||
});
|
||||
|
||||
// Set initial state
|
||||
updateEditIcon(ThemeManager.getInstance().isDarkMode());
|
||||
}
|
||||
|
||||
private void closeProfile() {
|
||||
MainController.getInstance().closeOverlay(profileCard.getParent());
|
||||
}
|
||||
|
||||
// Populate user data from DB or active session
|
||||
public void setProfileData(String name, String status, String bio, String userId, String imageUrl) {
|
||||
profileName.setText(name);
|
||||
profileStatus.setText(status);
|
||||
|
||||
if (bio == null || bio.isBlank()) {
|
||||
bioBlock.setVisible(false);
|
||||
bioBlock.setManaged(false);
|
||||
} else {
|
||||
userBio.setText(bio);
|
||||
userBio.setVisible(true);
|
||||
userBio.setManaged(true);
|
||||
}
|
||||
|
||||
this.userId.setText(userId);
|
||||
|
||||
if (imageUrl != null && !imageUrl.isEmpty()) {
|
||||
profileImage.setImage(new Image(imageUrl));
|
||||
}
|
||||
}
|
||||
|
||||
// === Theme-specific updates ===
|
||||
private void updateEditIcon(boolean darkMode) {
|
||||
String iconPath = darkMode
|
||||
? "/org/to/telegramfinalproject/Icons/edit_light.png"
|
||||
: "/org/to/telegramfinalproject/Icons/edit_dark.png";
|
||||
|
||||
ImageView icon = new ImageView(new Image(getClass().getResourceAsStream(iconPath)));
|
||||
icon.setFitWidth(16);
|
||||
icon.setFitHeight(16);
|
||||
editButton.setGraphic(icon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ package org.to.telegramfinalproject.UI;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.image.Image;
|
||||
@@ -12,6 +15,7 @@ import javafx.scene.layout.Region;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.util.Duration;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
public class SidebarMenuController {
|
||||
@@ -167,8 +171,24 @@ public class SidebarMenuController {
|
||||
return iv;
|
||||
}
|
||||
|
||||
// Sidebar actions
|
||||
private void openMyProfile() {
|
||||
try {
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("/org/to/telegramfinalproject/Fxml/my_profile.fxml"));
|
||||
Node profileOverlay = loader.load();
|
||||
|
||||
MyProfileController controller = loader.getController();
|
||||
controller.setProfileData("Asal", "online", "Pass me that lovely little gun♡.", "@Whales_suicide", null);
|
||||
|
||||
// Show the overlay on top of mainRoot
|
||||
MainController.getInstance().showOverlay(profileOverlay);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Example button actions
|
||||
private void openMyProfile() { System.out.println("Opening My Profile..."); }
|
||||
private void createNewGroup() { System.out.println("Creating New Group..."); }
|
||||
private void createNewChannel() { System.out.println("Creating New Channel..."); }
|
||||
private void openContacts() { System.out.println("Opening Contacts..."); }
|
||||
|
||||
Reference in New Issue
Block a user