diff --git a/src/main/java/org/to/telegramfinalproject/UI/MainController.java b/src/main/java/org/to/telegramfinalproject/UI/MainController.java index 535712c..f544cd9 100644 --- a/src/main/java/org/to/telegramfinalproject/UI/MainController.java +++ b/src/main/java/org/to/telegramfinalproject/UI/MainController.java @@ -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); + } } \ No newline at end of file diff --git a/src/main/java/org/to/telegramfinalproject/UI/MyProfileController.java b/src/main/java/org/to/telegramfinalproject/UI/MyProfileController.java index 02f870f..f7d4a3a 100644 --- a/src/main/java/org/to/telegramfinalproject/UI/MyProfileController.java +++ b/src/main/java/org/to/telegramfinalproject/UI/MyProfileController.java @@ -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())); -// } -// } -} \ No newline at end of file + @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); + } +} diff --git a/src/main/java/org/to/telegramfinalproject/UI/SidebarMenuController.java b/src/main/java/org/to/telegramfinalproject/UI/SidebarMenuController.java index 0a492f0..289cf12 100644 --- a/src/main/java/org/to/telegramfinalproject/UI/SidebarMenuController.java +++ b/src/main/java/org/to/telegramfinalproject/UI/SidebarMenuController.java @@ -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..."); } diff --git a/src/main/resources/org/to/telegramfinalproject/CSS/dark_theme.css b/src/main/resources/org/to/telegramfinalproject/CSS/dark_theme.css index 8360317..8d3d228 100644 --- a/src/main/resources/org/to/telegramfinalproject/CSS/dark_theme.css +++ b/src/main/resources/org/to/telegramfinalproject/CSS/dark_theme.css @@ -294,3 +294,75 @@ -fx-background-radius: 10; -fx-font-weight: bold; } + +/* ===== Overlay ===== */ +.overlay-root { + -fx-alignment: CENTER; +} + +.overlay-background { + -fx-background-color: transparent; + -fx-pref-width: 100%; + -fx-pref-height: 100%; +} + +/* ===== Profile Card ===== */ +.profile-card { + -fx-background-color: #0f1c26; + -fx-background-radius: 10; + -fx-padding: 16; + -fx-max-width: 320; + -fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.6), 12, 0, 0, 4); +} + +/* ===== Header ===== */ +.profile-title { + -fx-font-size: 16px; + -fx-font-weight: bold; + -fx-text-fill: #eee; +} +.icon-button { + -fx-background-color: transparent; + -fx-padding: 4; + -fx-cursor: hand; + -fx-text-fill: #fff; +} + +/* ===== Text Styles ===== */ +.profile-name { + -fx-font-size: 18px; + -fx-font-weight: bold; + -fx-text-fill: #eee; +} + +.profile-status { + -fx-font-size: 12px; + -fx-text-fill: #2196f3; /* online */ +} + +.profile-bio { + -fx-font-size: 13px; + -fx-text-fill: #bbb; +} + +.profile-id { + -fx-font-size: 13px; + -fx-text-fill: #999; +} + +/* Section separators */ +.section-separator { + -fx-background-color: #223446; + -fx-pref-height: 2; +} + +/* Info text */ +.profile-info-main { + -fx-font-size: 14px; + -fx-text-fill: #eee; +} + +.profile-info-sub { + -fx-font-size: 11px; + -fx-text-fill: #999; +} diff --git a/src/main/resources/org/to/telegramfinalproject/CSS/light_theme.css b/src/main/resources/org/to/telegramfinalproject/CSS/light_theme.css index f2b261d..8f4adaa 100644 --- a/src/main/resources/org/to/telegramfinalproject/CSS/light_theme.css +++ b/src/main/resources/org/to/telegramfinalproject/CSS/light_theme.css @@ -293,3 +293,74 @@ -fx-background-radius: 10; -fx-font-weight: bold; } + +/* ===== Overlay ===== */ +.overlay-root { + -fx-alignment: CENTER; +} + +.overlay-background { + -fx-background-color: rgba(0, 0, 0, 0.4); + -fx-pref-width: 100%; + -fx-pref-height: 100%; +} + +/* ===== Profile Card ===== */ +.profile-card { + -fx-background-color: white; + -fx-background-radius: 10; + -fx-padding: 16; + -fx-max-width: 320; + -fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.35), 12, 0, 0, 4); +} + +/* ===== Header ===== */ +.profile-title { + -fx-font-size: 16px; + -fx-font-weight: bold; +} +.icon-button { + -fx-background-color: transparent; + -fx-padding: 4; + -fx-cursor: hand; + -fx-text-fill: #000; +} + +/* ===== Text Styles ===== */ +.profile-name { + -fx-font-size: 18px; + -fx-font-weight: bold; + -fx-text-fill: #222; +} + +.profile-status { + -fx-font-size: 12px; + -fx-text-fill: #2196f3; /* online */ +} + +.profile-bio { + -fx-font-size: 13px; + -fx-text-fill: #555; +} + +.profile-id { + -fx-font-size: 13px; + -fx-text-fill: #888; +} + +/* Section separators */ +.section-separator { + -fx-background-color: #ddd; + -fx-pref-height: 2; +} + +/* Info text */ +.profile-info-main { + -fx-font-size: 14px; + -fx-text-fill: #222; +} + +.profile-info-sub { + -fx-font-size: 11px; + -fx-text-fill: #888; +} diff --git a/src/main/resources/org/to/telegramfinalproject/CSS/my_profile.css b/src/main/resources/org/to/telegramfinalproject/CSS/my_profile.css deleted file mode 100644 index 5dcdfac..0000000 --- a/src/main/resources/org/to/telegramfinalproject/CSS/my_profile.css +++ /dev/null @@ -1,26 +0,0 @@ -.my-profile-root { - -fx-background-color: white; -} - -.profile-image { - -fx-clip-radius: 40; /* Rounded image */ -} - -.profile-name { - -fx-font-size: 18px; - -fx-font-weight: bold; -} - -.profile-status { - -fx-text-fill: green; - -fx-font-size: 14px; -} - -.field-label { - -fx-font-weight: bold; - -fx-text-fill: #333; -} - -.field-value { - -fx-text-fill: #555; -} \ No newline at end of file diff --git a/src/main/resources/org/to/telegramfinalproject/Fxml/my_profile.fxml b/src/main/resources/org/to/telegramfinalproject/Fxml/my_profile.fxml index 29d6b39..56c23cc 100644 --- a/src/main/resources/org/to/telegramfinalproject/Fxml/my_profile.fxml +++ b/src/main/resources/org/to/telegramfinalproject/Fxml/my_profile.fxml @@ -1,40 +1,63 @@ - - + + - - + + - + + - + + + + - - -