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:
parent
23e4cfb469
commit
23a78e6fad
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user