fix issue

This commit is contained in:
gaoyuan
2022-03-07 21:31:27 +08:00
parent c3718d9d6c
commit 4076b2c9ed
19 changed files with 114 additions and 29 deletions

View File

@ -26,14 +26,15 @@ namespace Billing.Views
public Command Tapped { get; }
private readonly int parentId;
private readonly Category parent;
public CategoryPage(int pid = -1)
{
parentId = pid;
var category = App.Categories.FirstOrDefault(c => c.Id == pid);
Title = category?.Name ?? Resource.CategoryManage;
parent = App.Categories.FirstOrDefault(c => c.Id == pid);
Title = parent?.Name ?? Resource.CategoryManage;
if (category != null)
if (parent != null)
{
SetValue(IsTopCategoryProperty, false);
Categories = App.Categories.Where(c => c.ParentId == pid).Select(c => WrapCategory(c)).ToList();
@ -68,7 +69,7 @@ namespace Billing.Views
Name = category.Name,
IsTopCategory = IsTopCategory,
TintColor = category.TintColor == Color.Transparent || category.TintColor == default ?
(Color)Application.Current.Resources[BaseTheme.PrimaryColor] :
BaseTheme.CurrentPrimaryColor :
category.TintColor
};
}
@ -81,7 +82,7 @@ namespace Billing.Views
}
using (Tap.Start())
{
var page = new AddCategoryPage();
var page = new AddCategoryPage(parent: parent);
page.CategoryChecked += OnCategoryChecked;
await Navigation.PushAsync(page);
}
@ -189,7 +190,9 @@ namespace Billing.Views
{
c.Name = c.Category.Name;
c.Icon = c.Category.Icon;
c.TintColor = c.Category.TintColor;
c.TintColor = c.Category.TintColor == Color.Transparent || c.Category.TintColor == default ?
BaseTheme.CurrentPrimaryColor :
c.Category.TintColor;
}
}