Merge remote-tracking branch 'origin/Connection-UI' into Connection-UI
# Conflicts: # src/main/java/org/to/telegramfinalproject/UI/ChatPageController.java
This commit is contained in:
@@ -72,6 +72,11 @@ public class ChatPageController {
|
|||||||
@FXML
|
@FXML
|
||||||
private ImageView sendIcon;
|
private ImageView sendIcon;
|
||||||
|
|
||||||
|
// ===== Time formatter for messages =====
|
||||||
|
private static final DateTimeFormatter FMT_HHMM = DateTimeFormatter.ofPattern("HH:mm");
|
||||||
|
private static final DateTimeFormatter FMT_DATE_TIME = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm");
|
||||||
|
private static final String YESTERDAY_LABEL = "Yesterday";
|
||||||
|
|
||||||
// ===== state =====
|
// ===== state =====
|
||||||
private String chatName;
|
private String chatName;
|
||||||
private final ThemeManager themeManager = ThemeManager.getInstance();
|
private final ThemeManager themeManager = ThemeManager.getInstance();
|
||||||
@@ -149,7 +154,6 @@ public class ChatPageController {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
|
||||||
initCurrentUserId();
|
initCurrentUserId();
|
||||||
|
|
||||||
// Send button
|
// Send button
|
||||||
@@ -257,6 +261,44 @@ public class ChatPageController {
|
|||||||
themeManager.darkModeProperty().addListener((o, oldVal, isDark) -> syncIconsWithTheme());
|
themeManager.darkModeProperty().addListener((o, oldVal, isDark) -> syncIconsWithTheme());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initCurrentUserId() {
|
||||||
|
try {
|
||||||
|
String meStr = org.to.telegramfinalproject.Client.Session
|
||||||
|
.currentUser.getString("internal_uuid");
|
||||||
|
me = UUID.fromString(meStr);
|
||||||
|
} catch (Exception ignore) {
|
||||||
|
me = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String formatWhen(LocalDateTime ts) {
|
||||||
|
if (ts == null) return "";
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
LocalDate d = ts.toLocalDate();
|
||||||
|
|
||||||
|
if (d.isEqual(today)) {
|
||||||
|
return FMT_HHMM.format(ts);
|
||||||
|
} else if (d.isEqual(today.minusDays(1))) {
|
||||||
|
return YESTERDAY_LABEL + " " + FMT_HHMM.format(ts);
|
||||||
|
} else {
|
||||||
|
return FMT_DATE_TIME.format(ts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** ISO → LocalDateTime (با پشتیبانی از Offset/Z) */
|
||||||
|
private LocalDateTime parseWhen(String iso) {
|
||||||
|
if (iso == null || iso.isEmpty()) return null;
|
||||||
|
try {
|
||||||
|
return OffsetDateTime.parse(iso).toLocalDateTime();
|
||||||
|
} catch (Exception ignore) {
|
||||||
|
try {
|
||||||
|
return LocalDateTime.parse(iso);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void openSearchPanel() {
|
private void openSearchPanel() {
|
||||||
MainController.getInstance().showSearchPanel();
|
MainController.getInstance().showSearchPanel();
|
||||||
|
|||||||
@@ -50,6 +50,12 @@ public class MainController {
|
|||||||
@FXML private ImageView menuIcon;
|
@FXML private ImageView menuIcon;
|
||||||
private SidebarMenuController sidebarController; //save sidebar controller
|
private SidebarMenuController sidebarController; //save sidebar controller
|
||||||
|
|
||||||
|
// === Time formatter for messages ===
|
||||||
|
private static final java.time.format.DateTimeFormatter FMT_HHMM =
|
||||||
|
java.time.format.DateTimeFormatter.ofPattern("HH:mm");
|
||||||
|
private static final java.time.format.DateTimeFormatter FMT_DATE_TIME =
|
||||||
|
java.time.format.DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm");
|
||||||
|
private static final String YESTERDAY_LABEL = "Yesterday";
|
||||||
|
|
||||||
// === STATE ===
|
// === STATE ===
|
||||||
private static MainController instance;
|
private static MainController instance;
|
||||||
@@ -174,13 +180,6 @@ public class MainController {
|
|||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
private static final java.time.format.DateTimeFormatter FMT_HHMM =
|
|
||||||
java.time.format.DateTimeFormatter.ofPattern("HH:mm");
|
|
||||||
private static final java.time.format.DateTimeFormatter FMT_DATE_TIME =
|
|
||||||
java.time.format.DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm");
|
|
||||||
private static final String YESTERDAY_LABEL = "Yesterday";
|
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
private String formatChatTime(java.time.LocalDateTime ts) {
|
private String formatChatTime(java.time.LocalDateTime ts) {
|
||||||
if (ts == null) return "";
|
if (ts == null) return "";
|
||||||
@@ -198,9 +197,6 @@ public class MainController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void populateChatListFromSession() {
|
private void populateChatListFromSession() {
|
||||||
chatListContainer.getChildren().clear();
|
chatListContainer.getChildren().clear();
|
||||||
|
|
||||||
@@ -216,7 +212,6 @@ public class MainController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// private void addChatNode(ChatEntry chat ) {
|
// private void addChatNode(ChatEntry chat ) {
|
||||||
// try {
|
// try {
|
||||||
// FXMLLoader fx = new FXMLLoader(getClass().getResource(
|
// FXMLLoader fx = new FXMLLoader(getClass().getResource(
|
||||||
@@ -260,7 +255,6 @@ public class MainController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String mapTypeToLabel(String t) {
|
private String mapTypeToLabel(String t) {
|
||||||
switch (t.toUpperCase()) {
|
switch (t.toUpperCase()) {
|
||||||
case "IMAGE": return "[Image]";
|
case "IMAGE": return "[Image]";
|
||||||
@@ -271,7 +265,6 @@ public class MainController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// private void addChat(String name, String lastMsg, String time, int unread) {
|
// private void addChat(String name, String lastMsg, String time, int unread) {
|
||||||
// try {
|
// try {
|
||||||
// FXMLLoader loader = new FXMLLoader(getClass().getResource("/org/to/telegramfinalproject/Fxml/chat_item.fxml"));
|
// FXMLLoader loader = new FXMLLoader(getClass().getResource("/org/to/telegramfinalproject/Fxml/chat_item.fxml"));
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ public class SidebarMenuController {
|
|||||||
String img = user.optString("image_url", "");
|
String img = user.optString("image_url", "");
|
||||||
Image pic = tryLoadImage(img);
|
Image pic = tryLoadImage(img);
|
||||||
if (pic == null) {
|
if (pic == null) {
|
||||||
pic = loadImage("/org/to/telegramfinalproject/Avatars/profile.png");
|
pic = loadImage("/org/to/telegramfinalproject/Avatars/default_profile.png");
|
||||||
}
|
}
|
||||||
if (pic != null) profileImage.setImage(pic);
|
if (pic != null) profileImage.setImage(pic);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ import java.io.IOException;
|
|||||||
public class TelegramApplication extends Application {
|
public class TelegramApplication extends Application {
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage stage) throws IOException {
|
public void start(Stage stage) throws IOException {
|
||||||
// اول intro.fxml
|
// First: intro.fxml
|
||||||
FXMLLoader fx = new FXMLLoader(
|
FXMLLoader fx = new FXMLLoader(
|
||||||
TelegramApplication.class.getResource("/org/to/telegramfinalproject/Fxml/intro.fxml"));
|
TelegramApplication.class.getResource("/org/to/telegramfinalproject/Fxml/intro.fxml"));
|
||||||
Scene scene = new Scene(fx.load(), 1480, 820);
|
Scene scene = new Scene(fx.load(), 1480, 820);
|
||||||
|
|||||||
Reference in New Issue
Block a user