Files
ClaudeDo/src/ClaudeDo.Ui/ViewModels/ListItemViewModel.cs
Mika Kuns 3c52e9c67f feat(ui): add colored dot brush to ListItemViewModel
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 10:20:59 +02:00

44 lines
1.3 KiB
C#

using System;
using Avalonia.Media;
using ClaudeDo.Data.Models;
using CommunityToolkit.Mvvm.ComponentModel;
namespace ClaudeDo.Ui.ViewModels;
public partial class ListItemViewModel : ViewModelBase
{
[ObservableProperty] private string _name;
[ObservableProperty] private string? _workingDir;
[ObservableProperty] private string _defaultCommitType;
private static readonly IBrush[] DotPalette =
[
new SolidColorBrush(Color.Parse("#3d9474")), // green
new SolidColorBrush(Color.Parse("#5571a1")), // blue
new SolidColorBrush(Color.Parse("#d4964a")), // amber
new SolidColorBrush(Color.Parse("#7c6aad")), // purple
new SolidColorBrush(Color.Parse("#c25d6a")), // rose
];
public IBrush DotBrush => DotPalette[Math.Abs(Id.GetHashCode()) % DotPalette.Length];
public string Id { get; }
public ListItemViewModel(ListEntity entity)
{
Id = entity.Id;
_name = entity.Name;
_workingDir = entity.WorkingDir;
_defaultCommitType = entity.DefaultCommitType;
}
public ListEntity ToEntity() => new()
{
Id = Id,
Name = Name,
CreatedAt = DateTime.MinValue, // not used for update
WorkingDir = string.IsNullOrWhiteSpace(WorkingDir) ? null : WorkingDir,
DefaultCommitType = DefaultCommitType,
};
}