Channel & Group add members updated.
This commit is contained in:
@@ -109,8 +109,10 @@ public class AddMembersController {
|
|||||||
String name = c.optString("profile_name", "");
|
String name = c.optString("profile_name", "");
|
||||||
String id = c.optString("contact_id", ""); // ← internal_uuid مخاطب
|
String id = c.optString("contact_id", ""); // ← internal_uuid مخاطب
|
||||||
if (id.isBlank()) continue;
|
if (id.isBlank()) continue;
|
||||||
String imageUrl = c.optString("image_url",
|
String imageUrl = c.optString("image_url", "").trim();
|
||||||
"/org/to/telegramfinalproject/Avatars/default_user_profile.png");
|
if (imageUrl.isEmpty() || imageUrl.equals("null")) {
|
||||||
|
imageUrl = "/org/to/telegramfinalproject/Avatars/default_user_profile.png";
|
||||||
|
}
|
||||||
String status = Optional.ofNullable(c.optString("last_seen", ""))
|
String status = Optional.ofNullable(c.optString("last_seen", ""))
|
||||||
.filter(s -> !s.isBlank()).map(s -> "last seen " + s).orElse("");
|
.filter(s -> !s.isBlank()).map(s -> "last seen " + s).orElse("");
|
||||||
allContacts.add(new Contact(id, name, status, imageUrl));
|
allContacts.add(new Contact(id, name, status, imageUrl));
|
||||||
@@ -146,12 +148,13 @@ public class AddMembersController {
|
|||||||
HBox item = new HBox(10);
|
HBox item = new HBox(10);
|
||||||
item.getStyleClass().add("contact-item");
|
item.getStyleClass().add("contact-item");
|
||||||
|
|
||||||
// آواتار
|
// Avatar
|
||||||
ImageView avatar = new ImageView(loadAvatar(c.getImageUrl()));
|
ImageView avatar = new ImageView(loadAvatar(c.getImageUrl()));
|
||||||
avatar.setFitWidth(48);
|
avatar.setFitWidth(48);
|
||||||
avatar.setFitHeight(48);
|
avatar.setFitHeight(48);
|
||||||
avatar.setPreserveRatio(true);
|
avatar.setPreserveRatio(true);
|
||||||
|
|
||||||
|
// Details (name + status)
|
||||||
VBox details = new VBox(2);
|
VBox details = new VBox(2);
|
||||||
Label nameLabel = new Label(c.getName());
|
Label nameLabel = new Label(c.getName());
|
||||||
nameLabel.getStyleClass().add("contact-name");
|
nameLabel.getStyleClass().add("contact-name");
|
||||||
@@ -162,28 +165,27 @@ public class AddMembersController {
|
|||||||
Region spacer = new Region();
|
Region spacer = new Region();
|
||||||
HBox.setHgrow(spacer, Priority.ALWAYS);
|
HBox.setHgrow(spacer, Priority.ALWAYS);
|
||||||
|
|
||||||
CheckBox cb = new CheckBox();
|
// Add elements (no checkbox here)
|
||||||
cb.setSelected(selectedContacts.contains(c));
|
item.getChildren().addAll(avatar, details, spacer);
|
||||||
cb.selectedProperty().addListener((obs, ov, nv) -> {
|
|
||||||
if (nv) selectedContacts.add(c); else selectedContacts.remove(c);
|
// Highlight if already selected
|
||||||
|
if (selectedContacts.contains(c)) {
|
||||||
|
item.getStyleClass().add("contact-selected");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toggle selection by clicking the whole row
|
||||||
|
item.setOnMouseClicked(e -> {
|
||||||
|
if (selectedContacts.contains(c)) {
|
||||||
|
selectedContacts.remove(c);
|
||||||
|
item.getStyleClass().remove("contact-selected");
|
||||||
|
} else {
|
||||||
|
selectedContacts.add(c);
|
||||||
|
item.getStyleClass().add("contact-selected");
|
||||||
|
}
|
||||||
updateMemberCount();
|
updateMemberCount();
|
||||||
updateSelectedMembersPane();
|
updateSelectedMembersPane();
|
||||||
// برای هایلایت
|
|
||||||
if (nv) item.getStyleClass().add("contact-selected");
|
|
||||||
else item.getStyleClass().remove("contact-selected");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
item.getChildren().addAll(avatar, details, spacer, cb);
|
|
||||||
|
|
||||||
// کلیک روی ردیف = toggle
|
|
||||||
item.setOnMouseClicked(e -> {
|
|
||||||
boolean newVal = !cb.isSelected();
|
|
||||||
cb.setSelected(newVal);
|
|
||||||
});
|
|
||||||
|
|
||||||
// هایلایت انتخابشده
|
|
||||||
if (selectedContacts.contains(c)) item.getStyleClass().add("contact-selected");
|
|
||||||
|
|
||||||
contactsList.getChildren().add(item);
|
contactsList.getChildren().add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,8 +106,10 @@ public class AddSubscriberController {
|
|||||||
String name = c.optString("profile_name", "");
|
String name = c.optString("profile_name", "");
|
||||||
String id = c.optString("contact_id", ""); // internal_uuid
|
String id = c.optString("contact_id", ""); // internal_uuid
|
||||||
if (id.isBlank()) continue;
|
if (id.isBlank()) continue;
|
||||||
String imageUrl = c.optString("image_url",
|
String imageUrl = c.optString("image_url", "").trim();
|
||||||
"/org/to/telegramfinalproject/Avatars/default_user_profile.png");
|
if (imageUrl.isEmpty() || imageUrl.equals("null")) {
|
||||||
|
imageUrl = "/org/to/telegramfinalproject/Avatars/default_user_profile.png";
|
||||||
|
}
|
||||||
String status = Optional.ofNullable(c.optString("last_seen", ""))
|
String status = Optional.ofNullable(c.optString("last_seen", ""))
|
||||||
.filter(s -> !s.isBlank()).map(s -> "last seen " + s).orElse("");
|
.filter(s -> !s.isBlank()).map(s -> "last seen " + s).orElse("");
|
||||||
allContacts.add(new Contact(id, name, status, imageUrl));
|
allContacts.add(new Contact(id, name, status, imageUrl));
|
||||||
@@ -142,11 +144,13 @@ public class AddSubscriberController {
|
|||||||
HBox item = new HBox(10);
|
HBox item = new HBox(10);
|
||||||
item.getStyleClass().add("contact-item");
|
item.getStyleClass().add("contact-item");
|
||||||
|
|
||||||
|
// Avatar
|
||||||
ImageView avatar = new ImageView(loadAvatar(c.getImageUrl()));
|
ImageView avatar = new ImageView(loadAvatar(c.getImageUrl()));
|
||||||
avatar.setFitWidth(48);
|
avatar.setFitWidth(48);
|
||||||
avatar.setFitHeight(48);
|
avatar.setFitHeight(48);
|
||||||
avatar.setPreserveRatio(true);
|
avatar.setPreserveRatio(true);
|
||||||
|
|
||||||
|
// Details
|
||||||
VBox details = new VBox(2);
|
VBox details = new VBox(2);
|
||||||
Label nameLabel = new Label(c.getName());
|
Label nameLabel = new Label(c.getName());
|
||||||
nameLabel.getStyleClass().add("contact-name");
|
nameLabel.getStyleClass().add("contact-name");
|
||||||
@@ -157,22 +161,27 @@ public class AddSubscriberController {
|
|||||||
Region spacer = new Region();
|
Region spacer = new Region();
|
||||||
HBox.setHgrow(spacer, Priority.ALWAYS);
|
HBox.setHgrow(spacer, Priority.ALWAYS);
|
||||||
|
|
||||||
CheckBox cb = new CheckBox();
|
// Add elements (no checkbox)
|
||||||
cb.setSelected(selected.contains(c));
|
item.getChildren().addAll(avatar, details, spacer);
|
||||||
cb.selectedProperty().addListener((obs, ov, nv) -> {
|
|
||||||
if (nv) selected.add(c); else selected.remove(c);
|
// Highlight if already selected
|
||||||
|
if (selected.contains(c)) {
|
||||||
|
item.getStyleClass().add("contact-selected");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toggle selection by clicking the row
|
||||||
|
item.setOnMouseClicked(e -> {
|
||||||
|
if (selected.contains(c)) {
|
||||||
|
selected.remove(c);
|
||||||
|
item.getStyleClass().remove("contact-selected");
|
||||||
|
} else {
|
||||||
|
selected.add(c);
|
||||||
|
item.getStyleClass().add("contact-selected");
|
||||||
|
}
|
||||||
updateCount();
|
updateCount();
|
||||||
updateSelectedPane();
|
updateSelectedPane();
|
||||||
if (nv) item.getStyleClass().add("contact-selected");
|
|
||||||
else item.getStyleClass().remove("contact-selected");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
item.getChildren().addAll(avatar, details, spacer, cb);
|
|
||||||
|
|
||||||
item.setOnMouseClicked(e -> cb.setSelected(!cb.isSelected()));
|
|
||||||
|
|
||||||
if (selected.contains(c)) item.getStyleClass().add("contact-selected");
|
|
||||||
|
|
||||||
contactsList.getChildren().add(item);
|
contactsList.getChildren().add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user