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, }; }