filter buttons
This commit is contained in:
parent
43002baa81
commit
e8b3cd1e0a
@ -21,10 +21,10 @@
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<!-- Display name -->
|
||||
<ApplicationTitle>RBLNews.Maui</ApplicationTitle>
|
||||
<ApplicationTitle>RBL News</ApplicationTitle>
|
||||
|
||||
<!-- App Identifier -->
|
||||
<ApplicationId>com.companyname.rblnews.maui</ApplicationId>
|
||||
<ApplicationId>com.wohlleben.rblnews.app</ApplicationId>
|
||||
|
||||
<!-- Versions -->
|
||||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
|
||||
|
||||
38
RBLNews.Shared/Components/Controls/BadgeWithCounter.razor
Normal file
38
RBLNews.Shared/Components/Controls/BadgeWithCounter.razor
Normal file
@ -0,0 +1,38 @@
|
||||
@using RBLFeederCommon.Enums
|
||||
@if (ShowCount)
|
||||
{
|
||||
<Button Color="ButtonColor.Info" Size="ButtonSize.Small" Clicked="@OnClicked()" Outline>@Text <small>@Count</small></Button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Button Size="ButtonSize.Small">@Text</Button>
|
||||
}
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public RssFeedSources Source { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string Text { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool ShowCount { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public int Count { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<RssFeedSources> OnClickedCallback { get; set; }
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
}
|
||||
|
||||
private async Task OnClicked()
|
||||
{
|
||||
await OnClickedCallback.InvokeAsync(Source);
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,24 +2,31 @@
|
||||
@page "/"
|
||||
@using RBLFeederCommon.Enums
|
||||
@using RBLFeederCommon.Models.RssFeed
|
||||
@using RBLNews.Shared.Components.Controls
|
||||
@using RBLNews.Shared.Services
|
||||
|
||||
@inject IFeedDataService feedDataService
|
||||
@inject AppLifecycleService appLifecycleService
|
||||
|
||||
@if (FeedDataService.Feeds == null)
|
||||
@if (FeedGroups == null)
|
||||
{
|
||||
<div class="d-flex justify-content-center">
|
||||
Lade Feeds ...<br/><br/>
|
||||
Lade Feeds ...<br /><br />
|
||||
<Spinner Type="SpinnerType.Grow" Color="SpinnerColor.Primary" Size="SpinnerSize.Large" />
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<br/>
|
||||
<br />
|
||||
<div id="feeds-page" class="row">
|
||||
<div class="container">
|
||||
@foreach (FeedGroupVM feedGrp in this.FeedDataService.Feeds.FeedGroups)
|
||||
<div class="FilterButtons">
|
||||
@foreach (IGrouping<int, int> sGrouping in SourceGroupings)
|
||||
{
|
||||
@* <BadgeWithCounter ShowCount="true" Source="(RssFeedSources)sGrouping.Key" OnClickedCallback="OnClicked" Text="@GetRssSourceName((RssFeedSources)sGrouping.Key)" Count="@sGrouping.Count()"></BadgeWithCounter> *@
|
||||
}
|
||||
</div>
|
||||
@foreach (FeedGroupVM feedGrp in FeedGroups)
|
||||
{
|
||||
<h4><Icon Name="IconName.Calendar2Event" /> @feedGrp.PublishDate.ToLocalTime().ToString("dd.MM.yyyy")</h4>
|
||||
@foreach (FeedVM feed in feedGrp.Feeds)
|
||||
@ -50,13 +57,17 @@ else
|
||||
</div>
|
||||
}
|
||||
@code {
|
||||
|
||||
|
||||
[Inject]
|
||||
private IFeedDataService FeedDataService { get; set; }
|
||||
|
||||
[Inject]
|
||||
private AppLifecycleService AppLifecycleService { get; set; }
|
||||
|
||||
private List<FeedGroupVM>? FeedGroups { get; set; }
|
||||
|
||||
private IEnumerable<IGrouping<int, int>> SourceGroupings { get; set; } = new List<IGrouping<int, int>>();
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
AppLifecycleService.OnActivated = LoadFeeds;
|
||||
@ -66,7 +77,14 @@ else
|
||||
|
||||
private async void LoadFeeds()
|
||||
{
|
||||
// Copy feed list to keep original list
|
||||
await FeedDataService.LoadFeeds();
|
||||
FeedGroups = [..FeedDataService.Feeds.FeedGroups];
|
||||
|
||||
List<FeedGroupVM> listTmp = [.. FeedDataService.Feeds.FeedGroups];
|
||||
|
||||
SourceGroupings = listTmp.SelectMany(fg => fg.Feeds.Select(f => f.Source)).GroupBy(sources => sources);
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
@ -91,5 +109,26 @@ else
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClicked(RssFeedSources source)
|
||||
{
|
||||
FeedGroups = new List<FeedGroupVM>();
|
||||
|
||||
foreach (FeedGroupVM fg in FeedDataService.Feeds.FeedGroups)
|
||||
{
|
||||
List<FeedVM> feeds = fg.Feeds.Where(f => (RssFeedSources)f.Source == source).ToList();
|
||||
if (feeds.Any())
|
||||
{
|
||||
FeedGroups.Add(new FeedGroupVM
|
||||
{
|
||||
Feeds = feeds,
|
||||
PublishDate = fg.PublishDate
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -214,7 +214,11 @@ nav .top-row {
|
||||
}
|
||||
}
|
||||
|
||||
#feeds-page h4, h5{
|
||||
.FilterButtons {
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
#feeds-page h4, h5 {
|
||||
color: rgb(221, 7, 65) !important;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user