using System;
using System.Collections.Generic;
using Eto.Drawing;
using Eto.Forms;
using UpToolLib.v1.Tool;
using UpToolLib.v2;
namespace UpToolEto.Controls
{
public class AppList : StackLayout
private readonly AppExtras _extras;
private readonly Action<Guid, App> _itemClickEvent;
private readonly StackLayout _layout;
private readonly AppListSearchProvider _searchProvider;
public AppList(AppExtras extras, Action<Guid, App> itemClickEvent, bool online)
_extras = extras;
_itemClickEvent = itemClickEvent;
_searchProvider = new AppListSearchProvider(online, Update);
Items.Add(_searchProvider);
_layout = new StackLayout
Padding = 10,
Orientation = Orientation.Vertical,
Width = 200
};
Scrollable scrollable = new()
Content = _layout
if (Main.DebugColors)
scrollable.BackgroundColor = Colors.YellowGreen;
Items.Add(new StackLayoutItem(scrollable, VerticalAlignment.Stretch, true));
Orientation = Orientation.Vertical;
BackgroundColor = Colors.Green;
Update();
}
public void Update()
_layout.Items.Clear();
foreach (App app in _extras.FindApps(_searchProvider.GetSearchTerms()))
if (_searchProvider.Matches(app))
_layout.Items.Add(new Button((_, _) => _itemClickEvent(app.Id, app))
Text = app.Name,
Image = (Icon)app.Icon,
ImagePosition = ButtonImagePosition.Left,
});