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 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;
}
}
}

View File

@ -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;
}
}
}