From 31df626f0ebe022884f2b5bd2bce49898661ec1d Mon Sep 17 00:00:00 2001 From: cdwcgt Date: Tue, 28 Mar 2023 21:32:28 +0900 Subject: [PATCH] disable button when select other reason --- .../Graphics/UserInterfaceV2/ReportPopover.cs | 24 ++++++++++++------- osu.Game/Overlays/Chat/ReportChatPopover.cs | 6 ++++- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/osu.Game/Graphics/UserInterfaceV2/ReportPopover.cs b/osu.Game/Graphics/UserInterfaceV2/ReportPopover.cs index 44af108ab1..46006402ad 100644 --- a/osu.Game/Graphics/UserInterfaceV2/ReportPopover.cs +++ b/osu.Game/Graphics/UserInterfaceV2/ReportPopover.cs @@ -24,8 +24,6 @@ namespace osu.Game.Graphics.UserInterfaceV2 private OsuEnumDropdown reasonDropdown = null!; private OsuTextBox commentsTextBox = null!; private RoundedButton submitButton = null!; - - public bool CanSubmitEmptyReason = false; public LocalisableString Header; protected ReportPopover(LocalisableString headerString) @@ -102,13 +100,21 @@ namespace osu.Game.Graphics.UserInterfaceV2 } }; - if (!CanSubmitEmptyReason) - { - commentsTextBox.Current.BindValueChanged(e => - { - submitButton.Enabled.Value = !string.IsNullOrWhiteSpace(e.NewValue); - }, true); - } + commentsTextBox.Current.BindValueChanged(_ => updateStatus()); + + reasonDropdown.Current.BindValueChanged(_ => updateStatus()); + + updateStatus(); + } + + private void updateStatus() + { + submitButton.Enabled.Value = !string.IsNullOrWhiteSpace(commentsTextBox.Current.Value) || CheckCanSubmitEmptyComment(reasonDropdown.Current.Value); + } + + protected virtual bool CheckCanSubmitEmptyComment(T reason) + { + return false; } } } diff --git a/osu.Game/Overlays/Chat/ReportChatPopover.cs b/osu.Game/Overlays/Chat/ReportChatPopover.cs index 79c3922795..de5f3268b8 100644 --- a/osu.Game/Overlays/Chat/ReportChatPopover.cs +++ b/osu.Game/Overlays/Chat/ReportChatPopover.cs @@ -12,7 +12,11 @@ namespace osu.Game.Overlays.Chat public ReportChatPopover(APIUser? user) : base(ReportStrings.UserTitle(user?.Username ?? @"Someone")) { - CanSubmitEmptyReason = true; + } + + protected override bool CheckCanSubmitEmptyComment(ChatReportReason reason) + { + return reason != ChatReportReason.Other; } } }