using CommunityToolkit.Mvvm.ComponentModel;

namespace InABox.Avalonia.Converters;

public partial class StringToBooleanConverter : AbstractConverter<String,bool>
{
    [ObservableProperty] 
    private bool _hasValue;

    protected override bool Convert(string? value, object? parameter = null)
    {
        var empty = String.IsNullOrWhiteSpace(value);
        return HasValue 
            ? !empty 
            : empty;
    }

    public StringToBooleanConverter()
    {
        HasValue = true;
    }
    
}