refactor(ui): Material icons for list, folder and smart-list icon keys with legacy mapping

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
mika kuns
2026-10-01 16:50:31 +02:00
co-authored by Claude Sonnet 5.5
parent aef41f0594
commit 7c0fe92a3e
4 changed files with 93 additions and 18 deletions
@@ -1,6 +1,8 @@
using ClaudeDo.Data;
using ClaudeDo.Localization;
using ClaudeDo.Ui.Converters;
using ClaudeDo.Ui.Localization;
using Material.Icons;
using ClaudeDo.Ui.ViewModels.Modals;
using Microsoft.EntityFrameworkCore;
@@ -88,7 +90,7 @@ public class ListSettingsModalViewModelTests
vm.IconSearch = "rocket";
Assert.Contains("mdi:RocketLaunch", vm.Icons);
Assert.DoesNotContain("Star", vm.Icons);
Assert.DoesNotContain("mdi:StarOutline", vm.Icons);
vm.SelectedIconOption = "mdi:RocketLaunch";
vm.SelectedIconOption = null; // what the ListBox pushes when Icons is swapped
@@ -102,6 +104,33 @@ public class ListSettingsModalViewModelTests
Assert.False(ListSettingsModalViewModel.IsKnownIcon("mdi:NoSuchIcon"));
}
[Fact]
public void IsKnownIcon_AcceptsEveryLegacyBareKeyAndCuratedKey()
{
Assert.True(ListSettingsModalViewModel.IsKnownIcon("Rocket"));
Assert.All(IconKeyConverter.LegacyKinds.Keys, k => Assert.True(ListSettingsModalViewModel.IsKnownIcon(k), k));
Assert.All(ListSettingsModalViewModel.IconOptions, k => Assert.True(ListSettingsModalViewModel.IsKnownIcon(k), k));
Assert.False(ListSettingsModalViewModel.IsKnownIcon("NoSuchBareKey"));
}
[Fact]
public void IconKeys_ResolveToMdiPathData()
{
// StreamGeometry.Parse (the converter's last step) needs a render interface, i.e. a bootstrapped
// Avalonia app, so this checks the step before it: key -> MaterialIconKind -> non-empty path data.
var keys = ListSettingsModalViewModel.IconOptions
.Concat(IconKeyConverter.LegacyKinds.Keys)
.Concat(["mdi:WeatherSunny", "mdi:NoteTextOutline", "mdi:StarOutline", "mdi:CalendarOutline",
"mdi:InboxOutline", "mdi:Pulse", "mdi:EyeOutline"]);
Assert.All(keys, k =>
{
var kind = k.StartsWith(IconKeyConverter.MdiPrefix, StringComparison.Ordinal)
? Enum.Parse<MaterialIconKind>(k[IconKeyConverter.MdiPrefix.Length..])
: IconKeyConverter.LegacyKinds[k];
Assert.False(string.IsNullOrEmpty(MaterialIconDataProvider.GetData(kind)), k);
});
}
[Fact]
public void Color_SwatchAndCustomStaySynced()
{