| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- using Content.Client.Message;
- using Content.Shared.MassMedia.Systems;
- using Robust.Client.AutoGenerated;
- using Robust.Client.UserInterface.Controls;
- using Robust.Client.UserInterface.XAML;
- namespace Content.Client.CartridgeLoader.Cartridges;
- [GenerateTypedNameReferences]
- public sealed partial class NewsReaderUiFragment : BoxContainer
- {
- public event Action? OnNextButtonPressed;
- public event Action? OnPrevButtonPressed;
- public event Action? OnNotificationSwithPressed;
- public NewsReaderUiFragment()
- {
- RobustXamlLoader.Load(this);
- Next.OnPressed += _ => OnNextButtonPressed?.Invoke();
- Prev.OnPressed += _ => OnPrevButtonPressed?.Invoke();
- NotificationSwitch.OnPressed += _ => OnNotificationSwithPressed?.Invoke();
- }
- public void UpdateState(NewsArticle article, int targetNum, int totalNum, bool notificationOn)
- {
- PageNum.Visible = true;
- PageText.Visible = true;
- ShareTime.Visible = true;
- Author.Visible = true;
- PageName.Text = article.Title;
- PageText.SetMarkupPermissive(article.Content);
- PageNum.Text = $"{targetNum}/{totalNum}";
- NotificationSwitch.Text = Loc.GetString(notificationOn ? "news-read-ui-notification-on" : "news-read-ui-notification-off");
- string shareTime = article.ShareTime.ToString(@"hh\:mm\:ss");
- ShareTime.SetMarkup(Loc.GetString("news-read-ui-time-prefix-text") + " " + shareTime);
- Author.SetMarkup(Loc.GetString("news-read-ui-author-prefix") + " " + (article.Author != null ? article.Author : Loc.GetString("news-read-ui-no-author")));
- Prev.Disabled = targetNum <= 1;
- Next.Disabled = targetNum >= totalNum;
- }
- public void UpdateEmptyState(bool notificationOn)
- {
- PageNum.Visible = false;
- PageText.Visible = false;
- ShareTime.Visible = false;
- Author.Visible = false;
- PageName.Text = Loc.GetString("news-read-ui-not-found-text");
- NotificationSwitch.Text = Loc.GetString(notificationOn ? "news-read-ui-notification-on" : "news-read-ui-notification-off");
- }
- }
|