using System.Globalization; using Avalonia.Data.Converters; using Avalonia.Media; using ClaudeDo.Ui.ViewModels.Islands; namespace ClaudeDo.Ui.Converters; // One-expression converters. Each is only worth a class because Avalonia XAML can't // instantiate a generic FuncValueConverter as a resource; they stay one per type so the // x:Key names in App.axaml keep resolving. Anything with real logic gets its own file. public sealed class UpperCaseConverter : OneWayConverter { public static UpperCaseConverter Instance { get; } = new(); public override object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) => value?.ToString()?.ToUpperInvariant(); } public sealed class StrikeIfTrueConverter : OneWayConverter { public static StrikeIfTrueConverter Instance { get; } = new(); public override object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) => value is true ? TextDecorations.Strikethrough : null; } public sealed class BoolToItalicConverter : OneWayConverter { public override object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) => value is true ? FontStyle.Italic : FontStyle.Normal; } public sealed class BoolToDraftOpacityConverter : OneWayConverter { public override object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) => value is true ? 0.7 : 1.0; } // Drives ListBoxItem.Focusable for TasksIslandView's flat Rows list: a HeaderRow container must // not be a tab stop, a TaskRowViewModel container must behave like any other row. public sealed class NotHeaderRowConverter : OneWayConverter { public static NotHeaderRowConverter Instance { get; } = new(); public override object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) => value is not HeaderRow; } public abstract class OneWayConverter : IValueConverter { public abstract object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture); public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotSupportedException(); }