Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Commit

Permalink
controls hidden if list is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiebrynes7 committed Jun 16, 2020
1 parent 4faa9f6 commit b0003d0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class PaginatedListView<TElement, TData> : VisualElement
private readonly Pool elementPool;
private readonly int elementsPerPage;

private readonly VisualElement controlsContainer;
private readonly Button forwardButton;
private readonly Button backButton;
private readonly Label pageCounter;
Expand All @@ -36,6 +37,8 @@ public PaginatedListView(string label, Func<TElement> makeElement, Action<int, T

this.Q<Label>(name: "list-name").text = label;
container = this.Q<VisualElement>(className: "user-defined-type-container-data");

controlsContainer = this.Q<VisualElement>(className: "paginated-list-controls");
pageCounter = this.Q<Label>(name: "page-counter");

backButton = this.Q<Button>(name: "back-button");
Expand All @@ -52,6 +55,16 @@ public PaginatedListView(string label, Func<TElement> makeElement, Action<int, T
public void Update(List<TData> newData)
{
data = newData;

if (data.Count == 0)
{
controlsContainer.AddToClassList("hidden");
}
else
{
controlsContainer.RemoveFromClassList("hidden");
}

CalculatePages();
RefreshView();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<VisualElement class="user-defined-type-container">
<Label name="list-name" />
<VisualElement class="user-defined-type-container-data" />
<VisualElement class="paginated-list-controls">
<VisualElement class="paginated-list-controls hidden">
<Button class="paginated-list-controls__child" name="back-button"/>
<Label class="paginated-list-controls__child" name="page-counter" />
<Button class="paginated-list-controls__child" name="forward-button"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,7 @@
.paginated-list-controls__child {
margin: 0 5px;
}

.hidden {
display: none;
}

0 comments on commit b0003d0

Please sign in to comment.