From 77b4e54734fe077225ec429265358c1d1be8eb45 Mon Sep 17 00:00:00 2001 From: Tsanie Lily Date: Tue, 15 Mar 2022 07:47:44 +0800 Subject: [PATCH] add: last used category --- Billing.Shared/Models/Category.cs | 5 ++++- Billing.Shared/Views/AddBillPage.xaml.cs | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Billing.Shared/Models/Category.cs b/Billing.Shared/Models/Category.cs index 9726509..03b9cb4 100644 --- a/Billing.Shared/Models/Category.cs +++ b/Billing.Shared/Models/Category.cs @@ -1,5 +1,6 @@ using SQLite; - +using System; + namespace Billing.Models { public class Category : IIdItem @@ -14,6 +15,8 @@ namespace Billing.Models public string Name { get; set; } public long TintColor { get; set; } = TRANSPARENT_COLOR; public int? ParentId { get; set; } + public DateTime? LastUsed { get; set; } + public int? LastAccountId { get; set; } } public enum CategoryType diff --git a/Billing.Shared/Views/AddBillPage.xaml.cs b/Billing.Shared/Views/AddBillPage.xaml.cs index 0bd0ddb..01b6ce8 100644 --- a/Billing.Shared/Views/AddBillPage.xaml.cs +++ b/Billing.Shared/Views/AddBillPage.xaml.cs @@ -170,6 +170,9 @@ namespace Billing.Views Store = Store, Note = Note }); + + category.LastAccountId = walletId; + category.LastUsed = DateTime.Now; } } @@ -190,6 +193,14 @@ namespace Billing.Views private void CategorySelectPage_Tapped(object sender, UICategory e) { categoryId = e.Category.Id; + if (e.Category.LastAccountId != null) + { + var wallet = App.Accounts.FirstOrDefault(a => a.Id == e.Category.LastAccountId.Value); + if (wallet != null) + { + SetValue(WalletNameProperty, wallet.Name); + } + } SetValue(CategoryNameProperty, e.Name); }