feat: Add Badge and Badge demo.

This commit is contained in:
rabbitism
2023-02-20 11:13:51 +08:00
parent d6227788e7
commit 9208b1cd7e
19 changed files with 554 additions and 8 deletions

View File

@@ -0,0 +1,20 @@
using System.Globalization;
using Avalonia.Data.Converters;
namespace Ursa.Converters;
public class BadgeContentOverflowConverter: IMultiValueConverter
{
public object? Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
{
string overflowMark = parameter is string s ? s : "+";
if (double.TryParse(values[0]?.ToString(), out var b) && values[1] is int i and > 0)
{
if (b > i)
{
return i + overflowMark;
}
}
return values[0];
}
}