1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 02:02:53 +08:00

Combine commit button enabled handling

This commit is contained in:
Dean Herbert 2023-01-10 23:57:38 +09:00
parent 23e4cfb469
commit 23a78e6fad

View File

@ -35,19 +35,16 @@ namespace osu.Game.Overlays.Comments
private RoundedButton commitButton = null!;
private LoadingSpinner loadingSpinner = null!;
private bool showLoadingSpinner;
protected bool ShowLoadingSpinner
{
set
{
commitButton.Enabled.Value = !value && !string.IsNullOrEmpty(Current.Value);
showLoadingSpinner = value;
if (value)
loadingSpinner.Show();
else
loadingSpinner.Hide();
updateCommitButtonState();
}
}
@ -146,14 +143,14 @@ namespace osu.Game.Overlays.Comments
protected override void LoadComplete()
{
base.LoadComplete();
Current.BindValueChanged(text =>
{
commitButton.Enabled.Value = !showLoadingSpinner && !string.IsNullOrEmpty(text.NewValue);
}, true);
Current.BindValueChanged(_ => updateCommitButtonState(), true);
}
protected abstract void OnCommit(string text);
private void updateCommitButtonState() =>
commitButton.Enabled.Value = loadingSpinner.State.Value == Visibility.Hidden && !string.IsNullOrEmpty(Current.Value);
private partial class EditorTextBox : BasicTextBox
{
protected override float LeftRightPadding => side_padding;