ux: new layout for Staticstics window

This commit is contained in:
leo 2024-09-24 17:06:16 +08:00
parent 6151f4dc5f
commit b9597dc92a
No known key found for this signature in database
3 changed files with 49 additions and 70 deletions

View file

@ -1,5 +1,8 @@
using System.Threading.Tasks;
using Avalonia.Media;
using Avalonia.Threading;
using CommunityToolkit.Mvvm.ComponentModel;
namespace SourceGit.ViewModels
@ -28,6 +31,25 @@ namespace SourceGit.ViewModels
private set => SetProperty(ref _selectedReport, value);
}
public uint SampleColor
{
get => Preference.Instance.StatisticsSampleColor;
set
{
if (value != Preference.Instance.StatisticsSampleColor)
{
Preference.Instance.StatisticsSampleColor = value;
OnPropertyChanged(nameof(SampleBrush));
_selectedReport?.ChangeColor(value);
}
}
}
public IBrush SampleBrush
{
get => new SolidColorBrush(SampleColor);
}
public Statistics(string repo)
{
Task.Run(() =>
@ -47,12 +69,15 @@ namespace SourceGit.ViewModels
if (_data == null)
return;
SelectedReport = _selectedIndex switch
var report = _selectedIndex switch
{
0 => _data.All,
1 => _data.Month,
_ => _data.Week,
};
report.ChangeColor(SampleColor);
SelectedReport = report;
}
private bool _isLoading = true;