Only add back button if required

This commit is contained in:
Dean Herbert 2020-05-17 17:27:52 +09:00
parent 2c0ac8cc36
commit 864c1a73ae
1 changed files with 16 additions and 16 deletions

View File

@ -46,18 +46,6 @@ protected TournamentEditorScreen(TournamentScreen parentScreen = null)
[BackgroundDependencyLoader]
private void load()
{
BackButton.Receptor receptor = new BackButton.Receptor();
backButton = new BackButton(receptor)
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Action = () =>
{
if (parentScreen != null)
backAction.Invoke();
}
};
AddRangeInternal(new Drawable[]
{
new Box
@ -76,10 +64,8 @@ private void load()
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Spacing = new Vector2(20),
Padding = new MarginPadding { Bottom = backButton.Height * 2 },
},
},
backButton,
ControlPanel = new ControlPanel
{
Children = new Drawable[]
@ -101,7 +87,21 @@ private void load()
});
if (parentScreen != null)
backButton.Show();
{
AddInternal(backButton = new BackButton(new BackButton.Receptor())
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
State = { Value = Visibility.Visible },
Action = () =>
{
if (parentScreen != null)
backAction.Invoke();
}
});
flow.Padding = new MarginPadding { Bottom = backButton.Height * 2 };
}
Storage.CollectionChanged += (_, args) =>
{
@ -126,7 +126,7 @@ public bool OnPressed(GlobalAction action)
switch (action)
{
case GlobalAction.Back:
backAction.Invoke();
backAction?.Invoke();
return true;
}