diff options
| author | Kostya <mail@sartin.in> | 2026-10-15 15:18:30 +0300 |
|---|---|---|
| committer | Kostya <mail@sartin.in> | 2026-10-15 15:18:55 +0300 |
| commit | c67d5ff663b876a15a3831f5a2b564c4002e99b6 (patch) | |
| tree | 98dcbbd1b8b21c5e88865ae0ebd8b270ff80d9a9 | |
| parent | 4563c9d6d6c1576b6fb45899c2b6d6073966d8b8 (diff) | |
| download | guess-market-c67d5ff663b876a15a3831f5a2b564c4002e99b6.tar.gz guess-market-c67d5ff663b876a15a3831f5a2b564c4002e99b6.tar.xz guess-market-c67d5ff663b876a15a3831f5a2b564c4002e99b6.zip | |
ui: add chat drawer to the desktop client
3.0
ServerClient fetches new chat lines on the same one-second poll as the
market and hands them over separately from market changes.
The shared UI gets a chat icon in the status bar, beside the eject
button, shown only against a server. It opens a drawer above the status
bar with everyone's lines and a field to send one, laid over the
content so the window keeps its size. While the drawer is closed the
icon counts unread lines. A line the server refuses is reported in the
drawer itself.
9 files changed, 250 insertions, 3 deletions
diff --git a/ui-client/src/main/java/market/guess/ui/client/App.java b/ui-client/src/main/java/market/guess/ui/client/App.java index 4ba9600..93ae414 100644 --- a/ui-client/src/main/java/market/guess/ui/client/App.java +++ b/ui-client/src/main/java/market/guess/ui/client/App.java | |||
| @@ -2,11 +2,13 @@ package market.guess.ui.client; | |||
| 2 | 2 | ||
| 3 | import java.io.IOException; | 3 | import java.io.IOException; |
| 4 | import java.io.UncheckedIOException; | 4 | import java.io.UncheckedIOException; |
| 5 | import java.util.concurrent.CompletableFuture; | ||
| 5 | import javafx.application.Application; | 6 | import javafx.application.Application; |
| 6 | import javafx.application.Platform; | 7 | import javafx.application.Platform; |
| 7 | import javafx.fxml.FXMLLoader; | 8 | import javafx.fxml.FXMLLoader; |
| 8 | import javafx.scene.Scene; | 9 | import javafx.scene.Scene; |
| 9 | import javafx.stage.Stage; | 10 | import javafx.stage.Stage; |
| 11 | import market.guess.model.chat.ChatMessageDTO; | ||
| 10 | import market.guess.ui.desktop.AppView; | 12 | import market.guess.ui.desktop.AppView; |
| 11 | 13 | ||
| 12 | public final class App extends Application { | 14 | public final class App extends Application { |
| @@ -47,7 +49,20 @@ public final class App extends Application { | |||
| 47 | new RemoteGuessMarketContext(client), | 49 | new RemoteGuessMarketContext(client), |
| 48 | new RemoteAccountContext(client), | 50 | new RemoteAccountContext(client), |
| 49 | user); | 51 | user); |
| 50 | client.startPolling(() -> Platform.runLater(view.getState()::refreshData)); | 52 | var state = view.getState(); |
| 53 | state.setChatSender( | ||
| 54 | text -> | ||
| 55 | CompletableFuture.runAsync( | ||
| 56 | () -> { | ||
| 57 | var sent = client.say(text); | ||
| 58 | if (!sent.isSuccess()) { | ||
| 59 | var note = new ChatMessageDTO(0, "", "Not sent", sent.getMessage()); | ||
| 60 | Platform.runLater(() -> state.getChat().add(note)); | ||
| 61 | } | ||
| 62 | })); | ||
| 63 | client.startPolling( | ||
| 64 | () -> Platform.runLater(state::refreshData), | ||
| 65 | said -> Platform.runLater(() -> state.getChat().addAll(said))); | ||
| 51 | stage.show(); | 66 | stage.show(); |
| 52 | } | 67 | } |
| 53 | 68 | ||
diff --git a/ui-client/src/main/java/market/guess/ui/client/ServerClient.java b/ui-client/src/main/java/market/guess/ui/client/ServerClient.java index 01962a2..00f3d68 100644 --- a/ui-client/src/main/java/market/guess/ui/client/ServerClient.java +++ b/ui-client/src/main/java/market/guess/ui/client/ServerClient.java | |||
| @@ -2,6 +2,7 @@ package market.guess.ui.client; | |||
| 2 | 2 | ||
| 3 | import com.google.gson.Gson; | 3 | import com.google.gson.Gson; |
| 4 | import com.google.gson.JsonObject; | 4 | import com.google.gson.JsonObject; |
| 5 | import com.google.gson.reflect.TypeToken; | ||
| 5 | import java.io.IOException; | 6 | import java.io.IOException; |
| 6 | import java.lang.reflect.Type; | 7 | import java.lang.reflect.Type; |
| 7 | import java.util.HashMap; | 8 | import java.util.HashMap; |
| @@ -11,7 +12,9 @@ import java.util.concurrent.ConcurrentHashMap; | |||
| 11 | import java.util.concurrent.Executors; | 12 | import java.util.concurrent.Executors; |
| 12 | import java.util.concurrent.ScheduledExecutorService; | 13 | import java.util.concurrent.ScheduledExecutorService; |
| 13 | import java.util.concurrent.TimeUnit; | 14 | import java.util.concurrent.TimeUnit; |
| 15 | import java.util.function.Consumer; | ||
| 14 | import market.guess.api.Result; | 16 | import market.guess.api.Result; |
| 17 | import market.guess.model.chat.ChatMessageDTO; | ||
| 15 | import market.guess.model.event.EventDetailDTO; | 18 | import market.guess.model.event.EventDetailDTO; |
| 16 | import market.guess.model.event.EventSummaryDTO; | 19 | import market.guess.model.event.EventSummaryDTO; |
| 17 | import market.guess.model.ledger.LedgerDTO; | 20 | import market.guess.model.ledger.LedgerDTO; |
| @@ -51,6 +54,7 @@ public final class ServerClient implements AutoCloseable { | |||
| 51 | return t; | 54 | return t; |
| 52 | }); | 55 | }); |
| 53 | private volatile Snapshot snapshot = new Snapshot(-1, List.of(), Map.of(), List.of(), null); | 56 | private volatile Snapshot snapshot = new Snapshot(-1, List.of(), Map.of(), List.of(), null); |
| 57 | private long lastChatId; // touched only under the pullChat lock | ||
| 54 | 58 | ||
| 55 | public ServerClient(String apiUrl) { | 59 | public ServerClient(String apiUrl) { |
| 56 | this.api = HttpUrl.get(apiUrl); | 60 | this.api = HttpUrl.get(apiUrl); |
| @@ -115,13 +119,34 @@ public final class ServerClient implements AutoCloseable { | |||
| 115 | return true; | 119 | return true; |
| 116 | } | 120 | } |
| 117 | 121 | ||
| 118 | public void startPolling(Runnable onChange) { | 122 | public synchronized List<ChatMessageDTO> pullChat() { |
| 123 | var url = url("chat").newBuilder().addQueryParameter("since", "" + lastChatId).build(); | ||
| 124 | Result<List<ChatMessageDTO>> res = | ||
| 125 | call( | ||
| 126 | new Request.Builder().url(url).build(), | ||
| 127 | new TypeToken<List<ChatMessageDTO>>() {}.getType()); | ||
| 128 | if (!res.isSuccess() || res.getData().isEmpty()) { | ||
| 129 | return List.of(); | ||
| 130 | } | ||
| 131 | lastChatId = res.getData().getLast().id(); | ||
| 132 | return res.getData(); | ||
| 133 | } | ||
| 134 | |||
| 135 | public Result<ChatMessageDTO> say(String text) { | ||
| 136 | return post(ChatMessageDTO.class, new FormBody.Builder().add("text", text).build(), "chat"); | ||
| 137 | } | ||
| 138 | |||
| 139 | public void startPolling(Runnable onChange, Consumer<List<ChatMessageDTO>> onChat) { | ||
| 119 | poller.scheduleWithFixedDelay( | 140 | poller.scheduleWithFixedDelay( |
| 120 | () -> { | 141 | () -> { |
| 121 | try { | 142 | try { |
| 122 | if (pull()) { | 143 | if (pull()) { |
| 123 | onChange.run(); | 144 | onChange.run(); |
| 124 | } | 145 | } |
| 146 | var said = pullChat(); | ||
| 147 | if (!said.isEmpty()) { | ||
| 148 | onChat.accept(said); | ||
| 149 | } | ||
| 125 | } catch (RuntimeException e) { | 150 | } catch (RuntimeException e) { |
| 126 | } | 151 | } |
| 127 | }, | 152 | }, |
diff --git a/ui-client/src/test/java/market/guess/ui/client/RemoteContextsTest.java b/ui-client/src/test/java/market/guess/ui/client/RemoteContextsTest.java index e3b11f0..ea9d5ea 100644 --- a/ui-client/src/test/java/market/guess/ui/client/RemoteContextsTest.java +++ b/ui-client/src/test/java/market/guess/ui/client/RemoteContextsTest.java | |||
| @@ -72,7 +72,7 @@ class RemoteContextsTest { | |||
| 72 | 72 | ||
| 73 | maya.pull(); | 73 | maya.pull(); |
| 74 | var heard = new CountDownLatch(1); | 74 | var heard = new CountDownLatch(1); |
| 75 | maya.startPolling(heard::countDown); | 75 | maya.startPolling(heard::countDown, said -> {}); |
| 76 | var bought = | 76 | var bought = |
| 77 | tomMarket.placeOrder("Tom", event.key(), event.key() + ":0", "BUY", BigDecimal.ONE, 10); | 77 | tomMarket.placeOrder("Tom", event.key(), event.key() + ":0", "BUY", BigDecimal.ONE, 10); |
| 78 | assertTrue(bought.isSuccess(), bought.getMessage()); | 78 | assertTrue(bought.isSuccess(), bought.getMessage()); |
| @@ -150,6 +150,28 @@ class RemoteContextsTest { | |||
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | @Test | 152 | @Test |
| 153 | void chatReachesEveryoneOnceAndLeavesTheMarketAlone() { | ||
| 154 | try (var yael = new ServerClient(server.api); | ||
| 155 | var zohar = new ServerClient(server.api)) { | ||
| 156 | yael.login("Yael"); | ||
| 157 | zohar.login("Zohar"); | ||
| 158 | zohar.pullChat(); // whatever other tests said | ||
| 159 | zohar.pull(); | ||
| 160 | |||
| 161 | var hello = "שלום, anyone trading?"; | ||
| 162 | assertTrue(yael.say(hello).isSuccess()); | ||
| 163 | assertFalse(yael.say(" ").isSuccess()); | ||
| 164 | |||
| 165 | var heard = zohar.pullChat(); | ||
| 166 | assertEquals(1, heard.size()); | ||
| 167 | assertEquals("Yael", heard.get(0).sender()); | ||
| 168 | assertEquals(hello, heard.get(0).text()); | ||
| 169 | assertTrue(zohar.pullChat().isEmpty(), "a message is delivered once"); | ||
| 170 | assertFalse(zohar.pull(), "chat must not look like a market change"); | ||
| 171 | } | ||
| 172 | } | ||
| 173 | |||
| 174 | @Test | ||
| 153 | void anUnreachableServerIsAFailedResultNotAnException() { | 175 | void anUnreachableServerIsAFailedResultNotAnException() { |
| 154 | try (var nobody = new ServerClient("http://localhost:1/api")) { | 176 | try (var nobody = new ServerClient("http://localhost:1/api")) { |
| 155 | assertFalse(nobody.login("Zed").isSuccess()); | 177 | assertFalse(nobody.login("Zed").isSuccess()); |
diff --git a/ui-fx/src/main/java/market/guess/ui/desktop/AppState.java b/ui-fx/src/main/java/market/guess/ui/desktop/AppState.java index 5c73e1f..095a188 100644 --- a/ui-fx/src/main/java/market/guess/ui/desktop/AppState.java +++ b/ui-fx/src/main/java/market/guess/ui/desktop/AppState.java | |||
| @@ -8,6 +8,7 @@ import java.time.format.DateTimeFormatter; | |||
| 8 | import java.util.ArrayList; | 8 | import java.util.ArrayList; |
| 9 | import java.util.Collections; | 9 | import java.util.Collections; |
| 10 | import java.util.List; | 10 | import java.util.List; |
| 11 | import java.util.function.Consumer; | ||
| 11 | import javafx.beans.property.BooleanProperty; | 12 | import javafx.beans.property.BooleanProperty; |
| 12 | import javafx.beans.property.ObjectProperty; | 13 | import javafx.beans.property.ObjectProperty; |
| 13 | import javafx.beans.property.SimpleBooleanProperty; | 14 | import javafx.beans.property.SimpleBooleanProperty; |
| @@ -20,6 +21,7 @@ import javafx.collections.ObservableList; | |||
| 20 | import market.guess.api.AccountContext; | 21 | import market.guess.api.AccountContext; |
| 21 | import market.guess.api.CatalogContext; | 22 | import market.guess.api.CatalogContext; |
| 22 | import market.guess.api.GuessMarketContext; | 23 | import market.guess.api.GuessMarketContext; |
| 24 | import market.guess.model.chat.ChatMessageDTO; | ||
| 23 | import market.guess.model.event.EventDetailDTO; | 25 | import market.guess.model.event.EventDetailDTO; |
| 24 | import market.guess.model.event.EventStatus; | 26 | import market.guess.model.event.EventStatus; |
| 25 | import market.guess.model.event.EventSummaryDTO; | 27 | import market.guess.model.event.EventSummaryDTO; |
| @@ -52,6 +54,10 @@ public final class AppState { | |||
| 52 | public final ObservableList<EventData> events = FXCollections.observableArrayList(); | 54 | public final ObservableList<EventData> events = FXCollections.observableArrayList(); |
| 53 | public final ObservableList<UserData> users = FXCollections.observableArrayList(); | 55 | public final ObservableList<UserData> users = FXCollections.observableArrayList(); |
| 54 | 56 | ||
| 57 | private final ObservableList<ChatMessageDTO> chat = FXCollections.observableArrayList(); | ||
| 58 | private final BooleanProperty chatOpen = new SimpleBooleanProperty(false); | ||
| 59 | private Consumer<String> chatSender = text -> {}; | ||
| 60 | |||
| 55 | private final StringProperty selectedEventId = new SimpleStringProperty(null); | 61 | private final StringProperty selectedEventId = new SimpleStringProperty(null); |
| 56 | private final ObjectProperty<EventData> selectedEvent = new SimpleObjectProperty<>(); | 62 | private final ObjectProperty<EventData> selectedEvent = new SimpleObjectProperty<>(); |
| 57 | 63 | ||
| @@ -459,6 +465,26 @@ public final class AppState { | |||
| 459 | actingUser.set(u); | 465 | actingUser.set(u); |
| 460 | } | 466 | } |
| 461 | 467 | ||
| 468 | public ObservableList<ChatMessageDTO> getChat() { | ||
| 469 | return chat; | ||
| 470 | } | ||
| 471 | |||
| 472 | public BooleanProperty chatOpenProperty() { | ||
| 473 | return chatOpen; | ||
| 474 | } | ||
| 475 | |||
| 476 | public void setChatSender(Consumer<String> chatSender) { | ||
| 477 | this.chatSender = chatSender; | ||
| 478 | } | ||
| 479 | |||
| 480 | public void sendChat(String text) { | ||
| 481 | chatSender.accept(text); | ||
| 482 | } | ||
| 483 | |||
| 484 | public String getSessionUser() { | ||
| 485 | return sessionUser; | ||
| 486 | } | ||
| 487 | |||
| 462 | public boolean isRemote() { | 488 | public boolean isRemote() { |
| 463 | return sessionUser != null; | 489 | return sessionUser != null; |
| 464 | } | 490 | } |
diff --git a/ui-fx/src/main/java/market/guess/ui/desktop/controllers/AppController.java b/ui-fx/src/main/java/market/guess/ui/desktop/controllers/AppController.java index e544200..97d31d6 100644 --- a/ui-fx/src/main/java/market/guess/ui/desktop/controllers/AppController.java +++ b/ui-fx/src/main/java/market/guess/ui/desktop/controllers/AppController.java | |||
| @@ -25,6 +25,7 @@ import javafx.stage.FileChooser; | |||
| 25 | import javafx.stage.FileChooser.ExtensionFilter; | 25 | import javafx.stage.FileChooser.ExtensionFilter; |
| 26 | import javafx.util.Duration; | 26 | import javafx.util.Duration; |
| 27 | import market.guess.api.Result; | 27 | import market.guess.api.Result; |
| 28 | import market.guess.model.chat.ChatMessageDTO; | ||
| 28 | import market.guess.model.event.CreateEventRequest; | 29 | import market.guess.model.event.CreateEventRequest; |
| 29 | import market.guess.model.event.EventStatus; | 30 | import market.guess.model.event.EventStatus; |
| 30 | import market.guess.model.event.MechanismType; | 31 | import market.guess.model.event.MechanismType; |
| @@ -47,6 +48,7 @@ public class AppController { | |||
| 47 | private static final PseudoClass SKIN_CATPPUCCIN = PseudoClass.getPseudoClass("skin-catppuccin"); | 48 | private static final PseudoClass SKIN_CATPPUCCIN = PseudoClass.getPseudoClass("skin-catppuccin"); |
| 48 | private static final PseudoClass SKIN_GRUVBOX = PseudoClass.getPseudoClass("skin-gruvbox"); | 49 | private static final PseudoClass SKIN_GRUVBOX = PseudoClass.getPseudoClass("skin-gruvbox"); |
| 49 | 50 | ||
| 51 | private static final String CHAT_GLYPH = ""; // nf-md-chat | ||
| 50 | private static final Duration TOAST_DURATION = Duration.millis(2500); | 52 | private static final Duration TOAST_DURATION = Duration.millis(2500); |
| 51 | private static final Duration FADE_AWAY_DURATION = Duration.millis(500); | 53 | private static final Duration FADE_AWAY_DURATION = Duration.millis(500); |
| 52 | private AppView appView; | 54 | private AppView appView; |
| @@ -63,6 +65,10 @@ public class AppController { | |||
| 63 | @FXML private Label loadedFilePathLabel; | 65 | @FXML private Label loadedFilePathLabel; |
| 64 | @FXML private ComboBox<String> skinComboBox; | 66 | @FXML private ComboBox<String> skinComboBox; |
| 65 | @FXML private Button animationsButton; | 67 | @FXML private Button animationsButton; |
| 68 | @FXML private Button chatButton; | ||
| 69 | @FXML private Node chatPanel; | ||
| 70 | @FXML private ChatPanelController chatPanelController; | ||
| 71 | private int unreadChat; | ||
| 66 | @FXML private Label balanceValueLabel; | 72 | @FXML private Label balanceValueLabel; |
| 67 | @FXML private Label actingAsLabel; | 73 | @FXML private Label actingAsLabel; |
| 68 | @FXML private StackPane centerContainer; | 74 | @FXML private StackPane centerContainer; |
| @@ -155,6 +161,32 @@ public class AppController { | |||
| 155 | usersTabController.setOnToast(this::toast); | 161 | usersTabController.setOnToast(this::toast); |
| 156 | usersTabController.setOnPlaceOrder(this::placeOrder); | 162 | usersTabController.setOnPlaceOrder(this::placeOrder); |
| 157 | usersTabController.setOnDeposit(this::openDepositDialog); | 163 | usersTabController.setOnDeposit(this::openDepositDialog); |
| 164 | |||
| 165 | chatPanelController.init(state); | ||
| 166 | chatButton.setVisible(state.isRemote()); | ||
| 167 | chatButton.setManaged(state.isRemote()); | ||
| 168 | chatPanel.visibleProperty().bind(state.chatOpenProperty()); | ||
| 169 | chatPanel.managedProperty().bind(state.chatOpenProperty()); | ||
| 170 | state | ||
| 171 | .getChat() | ||
| 172 | .addListener( | ||
| 173 | (ListChangeListener<ChatMessageDTO>) | ||
| 174 | c -> { | ||
| 175 | while (c.next()) { | ||
| 176 | if (!state.chatOpenProperty().get()) { | ||
| 177 | unreadChat += c.getAddedSize(); | ||
| 178 | } | ||
| 179 | } | ||
| 180 | updateChatButton(); | ||
| 181 | }); | ||
| 182 | state | ||
| 183 | .chatOpenProperty() | ||
| 184 | .addListener( | ||
| 185 | (obs, was, open) -> { | ||
| 186 | unreadChat = 0; | ||
| 187 | updateChatButton(); | ||
| 188 | }); | ||
| 189 | updateChatButton(); | ||
| 158 | } | 190 | } |
| 159 | 191 | ||
| 160 | private void setupStateBindings() { | 192 | private void setupStateBindings() { |
| @@ -408,6 +440,17 @@ public class AppController { | |||
| 408 | } | 440 | } |
| 409 | 441 | ||
| 410 | @FXML | 442 | @FXML |
| 443 | private void handleChatToggled() { | ||
| 444 | var open = appView.getState().chatOpenProperty(); | ||
| 445 | open.set(!open.get()); | ||
| 446 | } | ||
| 447 | |||
| 448 | private void updateChatButton() { | ||
| 449 | chatButton.setText(CHAT_GLYPH + " " + (unreadChat == 0 ? "" : unreadChat)); | ||
| 450 | Views.setSelected(chatButton, appView.getState().chatOpenProperty().get()); | ||
| 451 | } | ||
| 452 | |||
| 453 | @FXML | ||
| 411 | private void handleLoadFile() { | 454 | private void handleLoadFile() { |
| 412 | startLoad(); | 455 | startLoad(); |
| 413 | } | 456 | } |
diff --git a/ui-fx/src/main/java/market/guess/ui/desktop/controllers/ChatPanelController.java b/ui-fx/src/main/java/market/guess/ui/desktop/controllers/ChatPanelController.java new file mode 100644 index 0000000..7c98692 --- /dev/null +++ b/ui-fx/src/main/java/market/guess/ui/desktop/controllers/ChatPanelController.java | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | package market.guess.ui.desktop.controllers; | ||
| 2 | |||
| 3 | import javafx.application.Platform; | ||
| 4 | import javafx.collections.ListChangeListener; | ||
| 5 | import javafx.fxml.FXML; | ||
| 6 | import javafx.scene.Node; | ||
| 7 | import javafx.scene.control.Label; | ||
| 8 | import javafx.scene.control.ScrollPane; | ||
| 9 | import javafx.scene.control.TextField; | ||
| 10 | import javafx.scene.layout.VBox; | ||
| 11 | import market.guess.model.chat.ChatMessageDTO; | ||
| 12 | import market.guess.ui.desktop.AppState; | ||
| 13 | |||
| 14 | public class ChatPanelController { | ||
| 15 | private static final int MAX_LENGTH = 500; | ||
| 16 | |||
| 17 | private AppState state; | ||
| 18 | |||
| 19 | @FXML private ScrollPane scroll; | ||
| 20 | @FXML private VBox messages; | ||
| 21 | @FXML private TextField input; | ||
| 22 | |||
| 23 | public void init(AppState state) { | ||
| 24 | this.state = state; | ||
| 25 | state | ||
| 26 | .getChat() | ||
| 27 | .addListener( | ||
| 28 | (ListChangeListener<ChatMessageDTO>) | ||
| 29 | c -> { | ||
| 30 | while (c.next()) { | ||
| 31 | for (var message : c.getAddedSubList()) { | ||
| 32 | messages.getChildren().add(row(message)); | ||
| 33 | } | ||
| 34 | } | ||
| 35 | Platform.runLater(() -> scroll.setVvalue(1.0)); | ||
| 36 | }); | ||
| 37 | } | ||
| 38 | |||
| 39 | private Node row(ChatMessageDTO message) { | ||
| 40 | var mine = message.sender().equalsIgnoreCase(state.getSessionUser()); | ||
| 41 | var head = new Label(message.sender() + " " + message.at()); | ||
| 42 | head.getStyleClass() | ||
| 43 | .addAll("gm-text-xs", "gm-font-semibold", mine ? "gm-text-accent" : "gm-text-ink2"); | ||
| 44 | var text = new Label(message.text()); | ||
| 45 | text.setWrapText(true); | ||
| 46 | text.getStyleClass().addAll("gm-text-base", "gm-text-ink"); | ||
| 47 | return new VBox(2, head, text); | ||
| 48 | } | ||
| 49 | |||
| 50 | @FXML | ||
| 51 | private void handleSend() { | ||
| 52 | var text = input.getText().trim(); | ||
| 53 | if (text.isEmpty()) { | ||
| 54 | return; | ||
| 55 | } | ||
| 56 | state.sendChat(text.length() > MAX_LENGTH ? text.substring(0, MAX_LENGTH) : text); | ||
| 57 | input.clear(); | ||
| 58 | } | ||
| 59 | } | ||
diff --git a/ui-fx/src/main/resources/market/guess/ui/desktop/app_view.fxml b/ui-fx/src/main/resources/market/guess/ui/desktop/app_view.fxml index 3a34a7e..8dd7b4c 100644 --- a/ui-fx/src/main/resources/market/guess/ui/desktop/app_view.fxml +++ b/ui-fx/src/main/resources/market/guess/ui/desktop/app_view.fxml | |||
| @@ -131,6 +131,11 @@ | |||
| 131 | <children> | 131 | <children> |
| 132 | <Label fx:id="statusBarLabel" styleClass="gm-text-sm, gm-font-mono, gm-text-ink2" /> | 132 | <Label fx:id="statusBarLabel" styleClass="gm-text-sm, gm-font-mono, gm-text-ink2" /> |
| 133 | <Region HBox.hgrow="ALWAYS" /> | 133 | <Region HBox.hgrow="ALWAYS" /> |
| 134 | <Button fx:id="chatButton" onAction="#handleChatToggled" styleClass="gm-link-button"> | ||
| 135 | <tooltip> | ||
| 136 | <Tooltip text="Chat" /> | ||
| 137 | </tooltip> | ||
| 138 | </Button> | ||
| 134 | <Button fx:id="ejectButton" onAction="#handleEjectFile" styleClass="gm-link-button" text="" visible="false" /> | 139 | <Button fx:id="ejectButton" onAction="#handleEjectFile" styleClass="gm-link-button" text="" visible="false" /> |
| 135 | </children> | 140 | </children> |
| 136 | </HBox> | 141 | </HBox> |
| @@ -138,6 +143,14 @@ | |||
| 138 | </BorderPane> | 143 | </BorderPane> |
| 139 | </content> | 144 | </content> |
| 140 | </ScrollPane> | 145 | </ScrollPane> |
| 146 | <StackPane alignment="BOTTOM_RIGHT" pickOnBounds="false"> | ||
| 147 | <padding> | ||
| 148 | <Insets bottom="30.0" right="14.0" /> | ||
| 149 | </padding> | ||
| 150 | <children> | ||
| 151 | <fx:include fx:id="chatPanel" managed="false" source="controllers/chat_panel.fxml" visible="false" /> | ||
| 152 | </children> | ||
| 153 | </StackPane> | ||
| 141 | <StackPane fx:id="dialogContainer" mouseTransparent="true" visible="false"> | 154 | <StackPane fx:id="dialogContainer" mouseTransparent="true" visible="false"> |
| 142 | <children> | 155 | <children> |
| 143 | <fx:include fx:id="loadDialog" managed="false" source="controllers/dialog_load.fxml" visible="false" /> | 156 | <fx:include fx:id="loadDialog" managed="false" source="controllers/dialog_load.fxml" visible="false" /> |
diff --git a/ui-fx/src/main/resources/market/guess/ui/desktop/controllers/chat_panel.fxml b/ui-fx/src/main/resources/market/guess/ui/desktop/controllers/chat_panel.fxml new file mode 100644 index 0000000..8c65cb1 --- /dev/null +++ b/ui-fx/src/main/resources/market/guess/ui/desktop/controllers/chat_panel.fxml | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | |||
| 3 | <?import javafx.geometry.Insets?> | ||
| 4 | <?import javafx.scene.control.Button?> | ||
| 5 | <?import javafx.scene.control.Label?> | ||
| 6 | <?import javafx.scene.control.ScrollPane?> | ||
| 7 | <?import javafx.scene.control.TextField?> | ||
| 8 | <?import javafx.scene.layout.HBox?> | ||
| 9 | <?import javafx.scene.layout.VBox?> | ||
| 10 | |||
| 11 | <VBox maxHeight="380.0" maxWidth="320.0" minWidth="320.0" pickOnBounds="false" prefHeight="380.0" prefWidth="320.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="market.guess.ui.desktop.controllers.ChatPanelController"> | ||
| 12 | <padding> | ||
| 13 | <Insets bottom="6.0" /> | ||
| 14 | </padding> | ||
| 15 | <children> | ||
| 16 | <VBox pickOnBounds="false" spacing="8.0" styleClass="gm-card, gm-chat-drawer" VBox.vgrow="ALWAYS"> | ||
| 17 | <padding> | ||
| 18 | <Insets bottom="12.0" left="12.0" right="12.0" top="12.0" /> | ||
| 19 | </padding> | ||
| 20 | <children> | ||
| 21 | <Label styleClass="gm-text-base, gm-font-semibold, gm-text-ink" text="Chat" /> | ||
| 22 | <ScrollPane fx:id="scroll" fitToWidth="true" hbarPolicy="NEVER" styleClass="gm-scroll-transparent" VBox.vgrow="ALWAYS"> | ||
| 23 | <content> | ||
| 24 | <VBox fx:id="messages" spacing="9.0" /> | ||
| 25 | </content> | ||
| 26 | </ScrollPane> | ||
| 27 | <HBox spacing="8.0"> | ||
| 28 | <children> | ||
| 29 | <TextField fx:id="input" onAction="#handleSend" promptText="Message everyone" styleClass="gm-textfield" HBox.hgrow="ALWAYS" /> | ||
| 30 | <Button minWidth="-Infinity" onAction="#handleSend" styleClass="gm-btn, gm-btn-primary" text="Send" /> | ||
| 31 | </children> | ||
| 32 | </HBox> | ||
| 33 | </children> | ||
| 34 | </VBox> | ||
| 35 | </children> | ||
| 36 | </VBox> | ||
diff --git a/ui-fx/src/main/resources/market/guess/ui/desktop/theme.css b/ui-fx/src/main/resources/market/guess/ui/desktop/theme.css index 3f5d4b7..2f8246e 100644 --- a/ui-fx/src/main/resources/market/guess/ui/desktop/theme.css +++ b/ui-fx/src/main/resources/market/guess/ui/desktop/theme.css | |||
| @@ -523,6 +523,14 @@ | |||
| 523 | -fx-border-width: 0; | 523 | -fx-border-width: 0; |
| 524 | } | 524 | } |
| 525 | 525 | ||
| 526 | .gm-link-button:selected { | ||
| 527 | -fx-text-fill: -gm-accent; | ||
| 528 | } | ||
| 529 | |||
| 530 | .gm-chat-drawer { | ||
| 531 | -fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.3), 18, 0, 0, 4); | ||
| 532 | } | ||
| 533 | |||
| 526 | .gm-toast { | 534 | .gm-toast { |
| 527 | -fx-background-color: -gm-ink; | 535 | -fx-background-color: -gm-ink; |
| 528 | -fx-text-fill: -gm-bg; | 536 | -fx-text-fill: -gm-bg; |