style: add .editorconfig for code formatting. see issu #25

This commit is contained in:
leo 2024-03-18 09:37:06 +08:00
parent a8eeea4f78
commit 18aaa0a143
225 changed files with 7781 additions and 3911 deletions

View file

@ -1,32 +1,43 @@
using Avalonia.Threading;
using CommunityToolkit.Mvvm.ComponentModel;
using System.Threading.Tasks;
using System.Threading.Tasks;
namespace SourceGit.ViewModels {
public class Statistics : ObservableObject {
public bool IsLoading {
using Avalonia.Threading;
using CommunityToolkit.Mvvm.ComponentModel;
namespace SourceGit.ViewModels
{
public class Statistics : ObservableObject
{
public bool IsLoading
{
get => _isLoading;
private set => SetProperty(ref _isLoading, value);
}
public int SelectedIndex {
public int SelectedIndex
{
get => _selectedIndex;
set {
set
{
if (SetProperty(ref _selectedIndex, value)) RefreshReport();
}
}
public Models.StatisticsReport SelectedReport {
public Models.StatisticsReport SelectedReport
{
get => _selectedReport;
private set => SetProperty(ref _selectedReport, value);
}
public Statistics(string repo) {
public Statistics(string repo)
{
_repo = repo;
Task.Run(() => {
Task.Run(() =>
{
var result = new Commands.Statistics(_repo).Result();
Dispatcher.UIThread.Invoke(() => {
Dispatcher.UIThread.Invoke(() =>
{
_data = result;
RefreshReport();
IsLoading = false;
@ -34,20 +45,22 @@ namespace SourceGit.ViewModels {
});
}
private void RefreshReport() {
private void RefreshReport()
{
if (_data == null) return;
switch (_selectedIndex) {
case 0: SelectedReport = _data.Year; break;
case 1: SelectedReport = _data.Month; break;
default: SelectedReport = _data.Week; break;
switch (_selectedIndex)
{
case 0: SelectedReport = _data.Year; break;
case 1: SelectedReport = _data.Month; break;
default: SelectedReport = _data.Week; break;
}
}
private string _repo = string.Empty;
private readonly string _repo = string.Empty;
private bool _isLoading = true;
private Models.Statistics _data = null;
private Models.StatisticsReport _selectedReport = null;
private int _selectedIndex = 0;
}
}
}