Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit 32ad61b

Browse files
committed
Rename ButtonListSource
1 parent df33042 commit 32ad61b

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

src/UI/Widgets/ButtonList/ButtonListSource.cs renamed to src/UI/Widgets/ButtonList/ButtonListHandler.cs

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010

1111
namespace UnityExplorer.UI.Widgets
1212
{
13-
public class ButtonListSource<T> : ICellPoolDataSource<ButtonCell>
13+
public class ButtonListHandler<TData, TCell> : ICellPoolDataSource<TCell> where TCell : ButtonCell
1414
{
15-
internal ScrollPool<ButtonCell> ScrollPool;
15+
internal ScrollPool<TCell> ScrollPool;
1616

1717
public int ItemCount => currentEntries.Count;
18-
public readonly List<T> currentEntries = new List<T>();
18+
public readonly List<TData> currentEntries = new List<TData>();
1919

20-
public Func<List<T>> GetEntries;
21-
public Action<ButtonCell, int> SetICell;
22-
public Func<T, string, bool> ShouldDisplay;
20+
public Func<List<TData>> GetEntries;
21+
public Action<TCell, int> SetICell;
22+
public Func<TData, string, bool> ShouldDisplay;
2323
public Action<int> OnCellClicked;
2424

2525
public string CurrentFilter
@@ -29,8 +29,8 @@ public string CurrentFilter
2929
}
3030
private string currentFilter;
3131

32-
public ButtonListSource(ScrollPool<ButtonCell> scrollPool, Func<List<T>> getEntriesMethod,
33-
Action<ButtonCell, int> setICellMethod, Func<T, string, bool> shouldDisplayMethod,
32+
public ButtonListHandler(ScrollPool<TCell> scrollPool, Func<List<TData>> getEntriesMethod,
33+
Action<TCell, int> setICellMethod, Func<TData, string, bool> shouldDisplayMethod,
3434
Action<int> onCellClickedMethod)
3535
{
3636
ScrollPool = scrollPool;
@@ -43,14 +43,14 @@ public ButtonListSource(ScrollPool<ButtonCell> scrollPool, Func<List<T>> getEntr
4343

4444
public void RefreshData()
4545
{
46-
var allEntries = GetEntries.Invoke();
46+
var allEntries = GetEntries();
4747
currentEntries.Clear();
4848

4949
foreach (var entry in allEntries)
5050
{
5151
if (!string.IsNullOrEmpty(currentFilter))
5252
{
53-
if (!ShouldDisplay.Invoke(entry, currentFilter))
53+
if (!ShouldDisplay(entry, currentFilter))
5454
continue;
5555

5656
currentEntries.Add(entry);
@@ -60,17 +60,12 @@ public void RefreshData()
6060
}
6161
}
6262

63-
public void OnCellBorrowed(ButtonCell cell)
63+
public virtual void OnCellBorrowed(TCell cell)
6464
{
6565
cell.OnClick += OnCellClicked;
6666
}
6767

68-
public void ReleaseCell(ButtonCell cell)
69-
{
70-
cell.OnClick -= OnCellClicked;
71-
}
72-
73-
public void SetCell(ButtonCell cell, int index)
68+
public virtual void SetCell(TCell cell, int index)
7469
{
7570
if (currentEntries == null)
7671
RefreshData();
@@ -81,10 +76,8 @@ public void SetCell(ButtonCell cell, int index)
8176
{
8277
cell.Enable();
8378
cell.CurrentDataIndex = index;
84-
SetICell.Invoke(cell, index);
79+
SetICell(cell, index);
8580
}
8681
}
87-
88-
//public void DisableCell(ButtonCell cell, int index) => cell.Disable();
8982
}
9083
}

0 commit comments

Comments
 (0)