refactor(ui): merge the one-expression converters into SimpleConverters.cs

Six files of three lines each. NotNullToBool is gone entirely — Avalonia
ships ObjectConverters.IsNotNull, so TaskRowView binds that directly.
This commit is contained in:
mika kuns
2026-08-26 13:55:50 +02:00
parent 8930b564e4
commit c593be2f02
9 changed files with 55 additions and 93 deletions
@@ -1,13 +0,0 @@
using System;
using System.Globalization;
using Avalonia.Data.Converters;
namespace ClaudeDo.Ui.Converters;
public sealed class BoolToDraftOpacityConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
=> value is true ? 0.7 : 1.0;
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotSupportedException();
}
@@ -1,14 +0,0 @@
using System;
using System.Globalization;
using Avalonia.Data.Converters;
using Avalonia.Media;
namespace ClaudeDo.Ui.Converters;
public sealed class BoolToItalicConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
=> value is true ? FontStyle.Italic : FontStyle.Normal;
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotSupportedException();
}
@@ -1,18 +0,0 @@
using System.Globalization;
using Avalonia.Data.Converters;
using ClaudeDo.Ui.ViewModels.Islands;
namespace ClaudeDo.Ui.Converters;
// 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 class NotHeaderRowConverter : IValueConverter
{
public static NotHeaderRowConverter Instance { get; } = new();
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
=> value is not HeaderRow;
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotSupportedException();
}
@@ -1,15 +0,0 @@
using System.Globalization;
using Avalonia.Data.Converters;
namespace ClaudeDo.Ui.Converters;
public class NotNullToBoolConverter : IValueConverter
{
public static NotNullToBoolConverter Instance { get; } = new();
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
=> value is not null;
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotSupportedException();
}
@@ -0,0 +1,53 @@
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();
}
@@ -1,16 +0,0 @@
using System.Globalization;
using Avalonia.Data.Converters;
using Avalonia.Media;
namespace ClaudeDo.Ui.Converters;
public class StrikeIfTrueConverter : IValueConverter
{
public static StrikeIfTrueConverter Instance { get; } = new();
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
=> value is true ? TextDecorations.Strikethrough : null;
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotSupportedException();
}
@@ -1,15 +0,0 @@
using System.Globalization;
using Avalonia.Data.Converters;
namespace ClaudeDo.Ui.Converters;
public class UpperCaseConverter : IValueConverter
{
public static UpperCaseConverter Instance { get; } = new();
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
=> value?.ToString()?.ToUpperInvariant();
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotSupportedException();
}