complete account page
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
using Billing.Models;
|
||||
using Billing.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Billing.Views
|
||||
@@ -7,12 +10,18 @@ namespace Billing.Views
|
||||
public partial class BillPage : BillingPage
|
||||
{
|
||||
private static readonly BindableProperty SelectedDateProperty = BindableProperty.Create(nameof(SelectedDate), typeof(DateTime), typeof(BillPage));
|
||||
private static readonly BindableProperty BillsProperty = BindableProperty.Create(nameof(Bills), typeof(List<UIBill>), typeof(BillPage));
|
||||
|
||||
public DateTime SelectedDate
|
||||
{
|
||||
get => (DateTime)GetValue(SelectedDateProperty);
|
||||
set => SetValue(SelectedDateProperty, value);
|
||||
}
|
||||
public List<UIBill> Bills
|
||||
{
|
||||
get => (List<UIBill>)GetValue(BillsProperty);
|
||||
set => SetValue(BillsProperty, value);
|
||||
}
|
||||
|
||||
public Command AddBilling { get; }
|
||||
|
||||
@@ -29,7 +38,18 @@ namespace Billing.Views
|
||||
{
|
||||
SelectedDate = e.Date;
|
||||
|
||||
// TODO: while selecting date
|
||||
var bills = App.Bills.Where(b =>
|
||||
b.CreateTime.Year == e.Date.Year &&
|
||||
b.CreateTime.Month == e.Date.Month &&
|
||||
b.CreateTime.Day == e.Date.Day);
|
||||
Bills = new List<UIBill>(bills.Select(b => new UIBill(b)
|
||||
{
|
||||
Icon = App.Categories.FirstOrDefault(c => c.Id == b.CategoryId)?.Icon ?? BaseModel.ICON_DEFAULT,
|
||||
Name = b.Name,
|
||||
DateCreation = b.CreateTime,
|
||||
Amount = b.Amount,
|
||||
Wallet = App.Accounts.FirstOrDefault(a => a.Id == b.WalletId)?.Name
|
||||
}));
|
||||
}
|
||||
|
||||
private void OnTitleDateLongPressed(object sender, EventArgs e)
|
||||
@@ -45,8 +65,51 @@ namespace Billing.Views
|
||||
}
|
||||
using (Tap.Start())
|
||||
{
|
||||
await Navigation.PushAsync(new AddBillPage());
|
||||
var page = new AddBillPage(SelectedDate);
|
||||
await Navigation.PushAsync(page);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class UIBill : BindableObject
|
||||
{
|
||||
public static readonly BindableProperty IconProperty = BindableProperty.Create(nameof(Icon), typeof(string), typeof(UIBill));
|
||||
public static readonly BindableProperty NameProperty = BindableProperty.Create(nameof(Name), typeof(string), typeof(UIBill));
|
||||
public static readonly BindableProperty DateCreationProperty = BindableProperty.Create(nameof(DateCreation), typeof(DateTime), typeof(UIBill));
|
||||
public static readonly BindableProperty AmountProperty = BindableProperty.Create(nameof(Amount), typeof(decimal), typeof(UIBill));
|
||||
public static readonly BindableProperty WalletProperty = BindableProperty.Create(nameof(Wallet), typeof(string), typeof(UIBill));
|
||||
|
||||
public string Icon
|
||||
{
|
||||
get => (string)GetValue(IconProperty);
|
||||
set => SetValue(IconProperty, value);
|
||||
}
|
||||
public string Name
|
||||
{
|
||||
get => (string)GetValue(NameProperty);
|
||||
set => SetValue(NameProperty, value);
|
||||
}
|
||||
public DateTime DateCreation
|
||||
{
|
||||
get => (DateTime)GetValue(DateCreationProperty);
|
||||
set => SetValue(DateCreationProperty, value);
|
||||
}
|
||||
public decimal Amount
|
||||
{
|
||||
get => (decimal)GetValue(AmountProperty);
|
||||
set => SetValue(AmountProperty, value);
|
||||
}
|
||||
public string Wallet
|
||||
{
|
||||
get => (string)GetValue(WalletProperty);
|
||||
set => SetValue(WalletProperty, value);
|
||||
}
|
||||
|
||||
public Bill Bill { get; }
|
||||
|
||||
public UIBill(Bill bill)
|
||||
{
|
||||
Bill = bill;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user