report page
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
using Billing.Languages;
|
||||
using Billing.Models;
|
||||
using Billing.Models;
|
||||
using Billing.Themes;
|
||||
using Billing.UI;
|
||||
using Microcharts;
|
||||
@ -8,7 +7,10 @@ using SkiaSharp.Views.Forms;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Essentials;
|
||||
using Xamarin.Forms;
|
||||
using Resource = Billing.Languages.Resource;
|
||||
|
||||
namespace Billing.Views
|
||||
{
|
||||
@ -16,6 +18,7 @@ namespace Billing.Views
|
||||
{
|
||||
private static readonly BindableProperty ChartProperty = Helper.Create<Chart, RankPage>(nameof(Chart));
|
||||
private static readonly BindableProperty TopBillsProperty = Helper.Create<IList<UIBill>, RankPage>(nameof(TopBills));
|
||||
private static readonly BindableProperty NoResultProperty = Helper.Create<bool, RankPage>(nameof(NoResult));
|
||||
|
||||
public Chart Chart
|
||||
{
|
||||
@ -27,6 +30,11 @@ namespace Billing.Views
|
||||
get => (IList<UIBill>)GetValue(TopBillsProperty);
|
||||
set => SetValue(TopBillsProperty, value);
|
||||
}
|
||||
public bool NoResult
|
||||
{
|
||||
get => (bool)GetValue(NoResultProperty);
|
||||
set => SetValue(NoResultProperty, value);
|
||||
}
|
||||
|
||||
public Command LeftCommand { get; }
|
||||
public Command RightCommand { get; }
|
||||
@ -45,17 +53,25 @@ namespace Billing.Views
|
||||
|
||||
public override void OnLoaded()
|
||||
{
|
||||
SetMonth(DateTime.Today);
|
||||
Task.Run(() => SetMonth(DateTime.Today));
|
||||
}
|
||||
|
||||
private void OnLeftCommand()
|
||||
{
|
||||
SetMonth(current.AddMonths(-1));
|
||||
Task.Run(() =>
|
||||
{
|
||||
MainThread.BeginInvokeOnMainThread(async () => await scroller.ScrollToAsync(0, 0, true));
|
||||
SetMonth(current.AddMonths(-1));
|
||||
});
|
||||
}
|
||||
|
||||
private void OnRightCommand()
|
||||
{
|
||||
SetMonth(current.AddMonths(1));
|
||||
Task.Run(() =>
|
||||
{
|
||||
MainThread.BeginInvokeOnMainThread(async () => await scroller.ScrollToAsync(0, 0, true));
|
||||
SetMonth(current.AddMonths(1));
|
||||
});
|
||||
}
|
||||
|
||||
private void SetMonth(DateTime date)
|
||||
@ -87,7 +103,7 @@ namespace Billing.Views
|
||||
{
|
||||
entries.Add(new((float)amount)
|
||||
{
|
||||
Label = day.ToString("MM/dd"),
|
||||
Label = day.ToString("MM-dd"),
|
||||
ValueLabel = amount.ToString("#,##0.##"),
|
||||
Color = primaryColor,
|
||||
TextColor = textColor,
|
||||
@ -96,12 +112,30 @@ namespace Billing.Views
|
||||
}
|
||||
}
|
||||
|
||||
Chart = new LineChart
|
||||
{
|
||||
BackgroundColor = SKColors.Transparent,
|
||||
LabelTextSize = 20,
|
||||
Entries = entries
|
||||
};
|
||||
if (entries.Count > 0)
|
||||
{
|
||||
NoResult = false;
|
||||
Chart = new LineChart
|
||||
{
|
||||
BackgroundColor = SKColors.Transparent,
|
||||
LabelTextSize = 24,
|
||||
Entries = entries
|
||||
};
|
||||
if (type == CategoryType.Income)
|
||||
{
|
||||
TopBills = bills.Where(b => b.Amount > 0).OrderByDescending(b => b.Amount).Take(10).Select(b => Helper.WrapBill(b)).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
TopBills = bills.Where(b => b.Amount < 0).OrderBy(b => b.Amount).Take(10).Select(b => Helper.WrapBill(b)).ToList();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NoResult = true;
|
||||
Chart = null;
|
||||
TopBills = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user