1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-07 20:07:24 +08:00

disable button when select other reason

This commit is contained in:
cdwcgt 2023-03-28 21:32:28 +09:00
parent 899860dd77
commit 31df626f0e
2 changed files with 20 additions and 10 deletions

View File

@ -24,8 +24,6 @@ namespace osu.Game.Graphics.UserInterfaceV2
private OsuEnumDropdown<T> reasonDropdown = null!; private OsuEnumDropdown<T> reasonDropdown = null!;
private OsuTextBox commentsTextBox = null!; private OsuTextBox commentsTextBox = null!;
private RoundedButton submitButton = null!; private RoundedButton submitButton = null!;
public bool CanSubmitEmptyReason = false;
public LocalisableString Header; public LocalisableString Header;
protected ReportPopover(LocalisableString headerString) protected ReportPopover(LocalisableString headerString)
@ -102,13 +100,21 @@ namespace osu.Game.Graphics.UserInterfaceV2
} }
}; };
if (!CanSubmitEmptyReason) commentsTextBox.Current.BindValueChanged(_ => updateStatus());
{
commentsTextBox.Current.BindValueChanged(e => reasonDropdown.Current.BindValueChanged(_ => updateStatus());
{
submitButton.Enabled.Value = !string.IsNullOrWhiteSpace(e.NewValue); updateStatus();
}, true); }
}
private void updateStatus()
{
submitButton.Enabled.Value = !string.IsNullOrWhiteSpace(commentsTextBox.Current.Value) || CheckCanSubmitEmptyComment(reasonDropdown.Current.Value);
}
protected virtual bool CheckCanSubmitEmptyComment(T reason)
{
return false;
} }
} }
} }

View File

@ -12,7 +12,11 @@ namespace osu.Game.Overlays.Chat
public ReportChatPopover(APIUser? user) public ReportChatPopover(APIUser? user)
: base(ReportStrings.UserTitle(user?.Username ?? @"Someone")) : base(ReportStrings.UserTitle(user?.Username ?? @"Someone"))
{ {
CanSubmitEmptyReason = true; }
protected override bool CheckCanSubmitEmptyComment(ChatReportReason reason)
{
return reason != ChatReportReason.Other;
} }
} }
} }