This commit is contained in:
Tsanie Lily 2022-03-07 17:36:03 +08:00
parent 46464e19dc
commit 9f783c1b5f

View File

@ -60,7 +60,7 @@ namespace Billing.Views
{
cat = TopCategories.SelectMany(g => g).FirstOrDefault(c => c.Category.Id == category.ParentId);
}
OnTopCategoryTapped(cat);
DoRefreshSubCategories(cat);
InitializeComponent();
}
@ -76,6 +76,16 @@ namespace Billing.Views
};
}
private void DoRefreshSubCategories(UICategory category)
{
var many = TopCategories.SelectMany(g => g);
foreach (var m in many)
{
m.IsChecked = m == category;
}
SubCategories = App.Categories.Where(c => c.ParentId == category.Category.Id).Select(c => WrapCategory(c)).ToList();
}
private async void OnTopCategoryTapped(object o)
{
if (Tap.IsBusy)
@ -86,12 +96,7 @@ namespace Billing.Views
{
if (o is UICategory category)
{
var many = TopCategories.SelectMany(g => g);
foreach (var m in many)
{
m.IsChecked = m == category;
}
SubCategories = App.Categories.Where(c => c.ParentId == category.Category.Id).Select(c => WrapCategory(c)).ToList();
DoRefreshSubCategories(category);
if (SubCategories.Count == 0)
{
CategoryTapped?.Invoke(this, category);