Simplify DeletedChildrenPlaceholder behavior

This commit is contained in:
Andrei Zavatski 2019-10-15 12:47:35 +03:00
parent 7ba15df0c0
commit 2543de22bd
1 changed files with 9 additions and 18 deletions

View File

@ -16,8 +16,6 @@ public class DeletedChildrenPlaceholder : FillFlowContainer
public readonly BindableBool ShowDeleted = new BindableBool();
public readonly BindableInt DeletedCount = new BindableInt();
private bool canBeShown;
private readonly SpriteText countText;
public DeletedChildrenPlaceholder()
@ -42,29 +40,22 @@ public DeletedChildrenPlaceholder()
protected override void LoadComplete()
{
DeletedCount.BindValueChanged(onCountChanged, true);
ShowDeleted.BindValueChanged(onShowDeletedChanged, true);
DeletedCount.BindValueChanged(_ => updateDisplay(), true);
ShowDeleted.BindValueChanged(_ => updateDisplay(), true);
base.LoadComplete();
}
private void onShowDeletedChanged(ValueChangedEvent<bool> showDeleted)
private void updateDisplay()
{
if (canBeShown)
this.FadeTo(showDeleted.NewValue ? 0 : 1);
if (DeletedCount.Value != 0)
{
countText.Text = @"deleted comment".ToQuantity(DeletedCount.Value);
this.FadeTo(ShowDeleted.Value ? 0 : 1);
}
private void onCountChanged(ValueChangedEvent<int> count)
{
canBeShown = count.NewValue != 0;
if (!canBeShown)
else
{
Hide();
return;
}
countText.Text = @"deleted comment".ToQuantity(count.NewValue);
Show();
}
}
}