Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update module search to include module descriptions #1003

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Blish HUD/GameServices/Modules/UI/Views/ModuleRepoView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,19 @@ protected override void Build(Container buildPanel) {

private void SearchboxOnTextChanged(object sender, EventArgs e) {
this.RepoFlowPanel.FilterChildren<ViewContainer>(viewContainer => PkgParamFilter(viewContainer, PkgNeedsUpdateFilter, PkgSearchFilter));

UpdateChildrenTint();
}

private bool PkgSearchFilter(ViewContainer viewContainer) {
var pkgView = viewContainer.CurrentView as ManagePkgView;

return pkgView.ModuleName.ToLowerInvariant().Contains(_searchbox.Text.ToLowerInvariant());
var normalizedInput = _searchbox.Text.ToLowerInvariant();

var matchName = pkgView.ModuleName.ToLowerInvariant().Contains(normalizedInput);
var matchDescription = pkgView.ModuleDescription.ToLowerInvariant().Contains(normalizedInput);

return matchName || matchDescription;
}

private bool PkgNeedsUpdateFilter(ViewContainer viewContainer) {
Expand All @@ -116,5 +123,14 @@ private bool PkgParamFilter(ViewContainer viewContainer, params Func<ViewContain
return true;
}

private void UpdateChildrenTint() {
bool s = true;

foreach (var child in this.RepoFlowPanel.Children) {
if (child.Visible && child is ViewContainer container)
container.ShowTint = (s = !s);
}
}

}
}