-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PORT] NanoСhat #1055
[PORT] NanoСhat #1055
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -26,8 +26,16 @@ protected override void Open() | |||||||||
_window.OnNameChanged += OnNameChanged; | ||||||||||
_window.OnJobChanged += OnJobChanged; | ||||||||||
_window.OnJobIconChanged += OnJobIconChanged; | ||||||||||
_window.OnNumberChanged += OnNumberChanged; // Corvax-Next-PDAChat | ||||||||||
} | ||||||||||
|
||||||||||
// Corvax-Next-PDAChat-Start | ||||||||||
private void OnNumberChanged(uint newNumber) | ||||||||||
{ | ||||||||||
SendMessage(new AgentIDCardNumberChangedMessage(newNumber)); | ||||||||||
} | ||||||||||
// Corvax-Next-PDAChat-End | ||||||||||
|
||||||||||
private void OnNameChanged(string newName) | ||||||||||
{ | ||||||||||
SendMessage(new AgentIDCardNameChangedMessage(newName)); | ||||||||||
|
@@ -56,6 +64,7 @@ protected override void UpdateState(BoundUserInterfaceState state) | |||||||||
_window.SetCurrentName(cast.CurrentName); | ||||||||||
_window.SetCurrentJob(cast.CurrentJob); | ||||||||||
_window.SetAllowedIcons(cast.CurrentJobIconId); | ||||||||||
_window.SetCurrentNumber(cast.CurrentNumber); // Corvax-Next-PDAChat | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Добавьте обработку null для номера карты. При установке номера карты необходимо учитывать возможность null значения. -_window.SetCurrentNumber(cast.CurrentNumber); // Corvax-Next-PDAChat
+_window.SetCurrentNumber(cast.CurrentNumber ?? 0); // Corvax-Next-PDAChat 📝 Committable suggestion
Suggested change
🛠️ Refactor suggestion Добавьте проверку на null. При установке номера необходимо проверять значение на null во избежание исключений. - _window.SetCurrentNumber(cast.CurrentNumber); // Corvax-Next-PDAChat
+ _window.SetCurrentNumber(cast.CurrentNumber ?? 0); // Corvax-Next-PDAChat 📝 Committable suggestion
Suggested change
|
||||||||||
} | ||||||||||
} | ||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,48 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||
<BoxContainer | ||||||||||||||||||||||||||||||||||||||||||||||||
xmlns="https://spacestation14.io" | ||||||||||||||||||||||||||||||||||||||||||||||||
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client" | ||||||||||||||||||||||||||||||||||||||||||||||||
HorizontalExpand="True"> | ||||||||||||||||||||||||||||||||||||||||||||||||
<Button Name="ChatButton" | ||||||||||||||||||||||||||||||||||||||||||||||||
StyleClasses="ButtonSquare" | ||||||||||||||||||||||||||||||||||||||||||||||||
HorizontalExpand="True" | ||||||||||||||||||||||||||||||||||||||||||||||||
MaxSize="137 64" | ||||||||||||||||||||||||||||||||||||||||||||||||
Margin="0 1"> | ||||||||||||||||||||||||||||||||||||||||||||||||
<BoxContainer Orientation="Horizontal" | ||||||||||||||||||||||||||||||||||||||||||||||||
HorizontalExpand="True" | ||||||||||||||||||||||||||||||||||||||||||||||||
VerticalExpand="True" | ||||||||||||||||||||||||||||||||||||||||||||||||
MinWidth="132" | ||||||||||||||||||||||||||||||||||||||||||||||||
Margin="6 4" | ||||||||||||||||||||||||||||||||||||||||||||||||
VerticalAlignment="Center"> | ||||||||||||||||||||||||||||||||||||||||||||||||
<!-- Unread indicator dot --> | ||||||||||||||||||||||||||||||||||||||||||||||||
<PanelContainer Name="UnreadIndicator" | ||||||||||||||||||||||||||||||||||||||||||||||||
MinSize="8 8" | ||||||||||||||||||||||||||||||||||||||||||||||||
MaxSize="8 8" | ||||||||||||||||||||||||||||||||||||||||||||||||
VerticalAlignment="Center" | ||||||||||||||||||||||||||||||||||||||||||||||||
Margin="0 0 6 0"> | ||||||||||||||||||||||||||||||||||||||||||||||||
<PanelContainer.PanelOverride> | ||||||||||||||||||||||||||||||||||||||||||||||||
<graphics:StyleBoxFlat | ||||||||||||||||||||||||||||||||||||||||||||||||
BackgroundColor="#17c622" | ||||||||||||||||||||||||||||||||||||||||||||||||
BorderColor="#0f7a15" /> | ||||||||||||||||||||||||||||||||||||||||||||||||
</PanelContainer.PanelOverride> | ||||||||||||||||||||||||||||||||||||||||||||||||
</PanelContainer> | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
<!-- Text container --> | ||||||||||||||||||||||||||||||||||||||||||||||||
<BoxContainer Orientation="Vertical" | ||||||||||||||||||||||||||||||||||||||||||||||||
HorizontalExpand="True" | ||||||||||||||||||||||||||||||||||||||||||||||||
VerticalExpand="True" | ||||||||||||||||||||||||||||||||||||||||||||||||
VerticalAlignment="Center"> | ||||||||||||||||||||||||||||||||||||||||||||||||
<RichTextLabel Name="NameLabel" | ||||||||||||||||||||||||||||||||||||||||||||||||
StyleClasses="LabelHeading" | ||||||||||||||||||||||||||||||||||||||||||||||||
HorizontalExpand="True" | ||||||||||||||||||||||||||||||||||||||||||||||||
HorizontalAlignment="Center" | ||||||||||||||||||||||||||||||||||||||||||||||||
VerticalAlignment="Center" | ||||||||||||||||||||||||||||||||||||||||||||||||
Margin="0 -2 0 0" /> | ||||||||||||||||||||||||||||||||||||||||||||||||
<Label Name="JobLabel" | ||||||||||||||||||||||||||||||||||||||||||||||||
StyleClasses="LabelSubText" | ||||||||||||||||||||||||||||||||||||||||||||||||
HorizontalExpand="True" | ||||||||||||||||||||||||||||||||||||||||||||||||
ClipText="False" | ||||||||||||||||||||||||||||||||||||||||||||||||
HorizontalAlignment="Center" /> | ||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+34
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Добавьте обработку переполнения текста. Для меток имени и должности следует добавить обработку случаев переполнения текста. <RichTextLabel Name="NameLabel"
StyleClasses="LabelHeading"
HorizontalExpand="True"
HorizontalAlignment="Center"
VerticalAlignment="Center"
+ ClipText="True"
Margin="0 -2 0 0" /> 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||
</BoxContainer> | ||||||||||||||||||||||||||||||||||||||||||||||||
</BoxContainer> | ||||||||||||||||||||||||||||||||||||||||||||||||
</Button> | ||||||||||||||||||||||||||||||||||||||||||||||||
</BoxContainer> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Content.Shared._CorvaxNext.CartridgeLoader.Cartridges; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
|
||
namespace Content.Client._CorvaxNext.CartridgeLoader.Cartridges; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class NanoChatEntry : BoxContainer | ||
{ | ||
public event Action<uint>? OnPressed; | ||
private uint _number; | ||
private Action<EventArgs>? _pressHandler; | ||
|
||
public NanoChatEntry() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
} | ||
|
||
public void SetRecipient(NanoChatRecipient recipient, uint number, bool isSelected) | ||
{ | ||
// Remove old handler if it exists | ||
if (_pressHandler != null) | ||
ChatButton.OnPressed -= _pressHandler; | ||
|
||
_number = number; | ||
|
||
// Create and store new handler | ||
_pressHandler = _ => OnPressed?.Invoke(_number); | ||
ChatButton.OnPressed += _pressHandler; | ||
|
||
NameLabel.Text = recipient.Name; | ||
JobLabel.Text = recipient.JobTitle ?? ""; | ||
JobLabel.Visible = !string.IsNullOrEmpty(recipient.JobTitle); | ||
UnreadIndicator.Visible = recipient.HasUnread; | ||
|
||
ChatButton.ModulateSelfOverride = isSelected ? NanoChatMessageBubble.OwnMessageColor : null; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<BoxContainer xmlns="https://spacestation14.io" | ||
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls" | ||
Margin="4" | ||
Orientation="Vertical"> | ||
<BoxContainer Orientation="Horizontal"> | ||
<Label Name="NumberLabel" | ||
Align="Right" | ||
SetWidth="26" | ||
ClipText="True" /> | ||
<Label Name="TimeLabel" | ||
Align="Center" | ||
SetWidth="100" | ||
ClipText="True" /> | ||
<Label Name="MessageLabel" | ||
Align="Left" | ||
MinWidth="390" | ||
HorizontalExpand="True" | ||
ClipText="False" /> | ||
</BoxContainer> | ||
<customControls:HSeparator Margin="0 5 0 5" /> | ||
</BoxContainer> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
|
||
namespace Content.Client._CorvaxNext.CartridgeLoader.Cartridges; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class NanoChatLogEntry : BoxContainer | ||
{ | ||
public NanoChatLogEntry(int number, string time, string message) | ||
{ | ||
RobustXamlLoader.Load(this); | ||
NumberLabel.Text = number.ToString(); | ||
TimeLabel.Text = time; | ||
MessageLabel.Text = message; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Добавьте валидацию номера перед отправкой.
Рекомендуется проверять корректность номера перед отправкой сообщения на сервер.
📝 Committable suggestion
🛠️ Refactor suggestion
Добавьте валидацию номера.
Необходимо добавить валидацию номера перед отправкой сообщения на сервер.
📝 Committable suggestion