Fixed feed item click crash & cleaned unused code.

This commit is contained in:
Max 2023-05-04 21:04:44 +02:00
parent 493d20820a
commit 7529796b12
2 changed files with 18 additions and 42 deletions

View File

@ -97,9 +97,9 @@
[Parameter]
public HashSet<CategoryGuideItem> Categories { get; set; } = new HashSet<CategoryGuideItem>();
[Parameter]
public Action<CategoryGuideItem> HandleCat { get; set; }
public Action<CategoryGuideItem>? CatItemClicked { get; set; }
[Parameter]
public Action<FeedGuideItem> FeedItemClicked { get; set; }
public Action<FeedGuideItem>? FeedItemClicked { get; set; }
ISelectableGuideItem? _selectedCategory;
@ -114,10 +114,14 @@
_selectedCategory = categoryItem;
_selectedCategory.IsSelected = true;
}
// Handle the click.
if (categoryItem is CategoryGuideItem catGuideItem)
HandleCat(catGuideItem);
/*if (categoryItem is FeedGuideItem feedGuideItem)
FeedItemClicked(feedGuideItem);*/
switch (categoryItem)
{
case CategoryGuideItem catGuideItem:
CatItemClicked?.Invoke(catGuideItem);
break;
case FeedGuideItem feedGuideItem:
FeedItemClicked?.Invoke(feedGuideItem);
break;
}
}
}

View File

@ -2,43 +2,12 @@
@using MudBlazor.Utilities
@using CodeHollow.FeedReader
@using Serilog
<style>
.cat-item{
background: transparent;
}
.cat-item:hover{
background: @Colors.Blue.Accent1;
}
</style>
<MudStack Spacing="2">
<MudNavMenu>
<MudNavLink Href="/" Icon="@Icons.Material.Filled.Home">Home</MudNavLink>
</MudNavMenu>
<CategoryGuide Categories="Categories" HandleCat="HandleCat"/>
@*<MudList DisableGutters="true" Clickable="true" Color="Color.Warning" SelectedItemChanged="Callback">
<MudListSubheader>
Categories
</MudListSubheader>
@foreach (CategoryGuideItem cat in Categories)
{
/* Category item*/
<MudListItem Class="pl-4" Text="@cat.CategoryTitle" Icon="@cat.CategoryIcon" @bind-Expanded="@cat.IsExpanded">
<NestedList>
@if (cat.IsExpanded)
{
foreach (Feed feed in cat.Feeds)
{
/* Feed item */
<MudListItem Value="feed">
<MudImage ObjectFit="ObjectFit.ScaleDown" Height="16" Width="16" Class="d-inline" Src="https://fedoramagazine.org/wp-content/themes/fedoramagazine-1.15/favicon.ico"/>
<MudText Class="d-inline">@feed.Title</MudText>
</MudListItem>
}
}
</NestedList>
</MudListItem>
}
</MudList>*@
<CategoryGuide Categories="Categories" CatItemClicked="CategoryClicked" FeedItemClicked="FeedClicked"/>
</MudStack>
@code {
@ -63,9 +32,12 @@
}
}
private void HandleCat(CategoryGuideItem obj)
private void CategoryClicked(CategoryGuideItem catItem)
{
}
private void FeedClicked(FeedGuideItem feedItem)
{
//throw new NotImplementedException();
}
}