Make collapsable categories

This commit is contained in:
Chris Titus Tech
2026-02-05 15:03:36 -06:00
parent 0b78970dc7
commit 17f92df25a
4 changed files with 99 additions and 33 deletions

View File

@@ -16,7 +16,25 @@ function Find-AppsByNameOrDescription {
$_.Visibility = [Windows.Visibility]::Visible
$_.Children | ForEach-Object {
if ($null -ne $_) {
$_.Visibility = [Windows.Visibility]::Visible
# Respect the collapsed state of categories (indicated by + prefix)
if ($_.Tag -like "CategoryToggleButton" -and $_.Content -like "+*") {
# Keep category label visible but don't expand the WrapPanel
$_.Visibility = [Windows.Visibility]::Visible
}
elseif ($_.Tag -like "CategoryWrapPanel_*") {
# Check if parent category is collapsed (has + prefix)
$categoryLabel = $_.Parent.Children[0]
if ($categoryLabel.Content -like "+*") {
# Keep collapsed
$_.Visibility = [Windows.Visibility]::Collapsed
} else {
# Expand
$_.Visibility = [Windows.Visibility]::Visible
}
}
else {
$_.Visibility = [Windows.Visibility]::Visible
}
}
}
@@ -32,18 +50,29 @@ function Find-AppsByNameOrDescription {
# Hide all CategoryWrapPanel and ToggleButton
$_.Visibility = [Windows.Visibility]::Collapsed
if ($_.Tag -like "CategoryWrapPanel_*") {
$categoryHasMatch = $false
# Search for Apps that match the search string
$_.Children | Foreach-Object {
$appEntry = $sync.configs.applicationsHashtable.$($_.Tag)
if ($appEntry.Content -like "*$SearchString*" -or $appEntry.Description -like "*$SearchString*") {
# Show the App and the parent CategoryWrapPanel if the string is found
# Show the App and mark that this category has a match
$_.Visibility = [Windows.Visibility]::Visible
$_.parent.Visibility = [Windows.Visibility]::Visible
$categoryHasMatch = $true
}
else {
$_.Visibility = [Windows.Visibility]::Collapsed
}
}
# If category has matches, show the WrapPanel and update the category label to expanded state
if ($categoryHasMatch) {
$_.Visibility = [Windows.Visibility]::Visible
# Update category label to show expanded state (-)
$categoryLabel = $_.Parent.Children[0]
if ($categoryLabel.Content -like "+*") {
$categoryLabel.Content = $categoryLabel.Content -replace "^\+ ", "- "
}
}
}
}
}