mirror of
https://github.com/hmaxnl/SharpRSS.git
synced 2025-01-18 21:04:21 +01:00
Working on UI
This commit is contained in:
parent
b6867d2ece
commit
c33d8e3a4e
|
@ -17,6 +17,8 @@ namespace SharpRss
|
|||
/// - Database
|
||||
/// - File
|
||||
/// - Memory
|
||||
combined.UnionWith(feedSet);
|
||||
combined.UnionWith(feedSet2);
|
||||
}
|
||||
|
||||
private static HashSet<FeedModel> feedSet = new HashSet<FeedModel>()
|
||||
|
@ -29,6 +31,7 @@ namespace SharpRss
|
|||
new FeedModel("https://journals.plos.org/plosone/feed/atom"),
|
||||
new FeedModel("https://itsfoss.com/feed")
|
||||
};
|
||||
private static HashSet<FeedModel> combined = new HashSet<FeedModel>();
|
||||
|
||||
HashSet<CategoryModel> set = new HashSet<CategoryModel>()
|
||||
{
|
||||
|
@ -43,10 +46,7 @@ namespace SharpRss
|
|||
|
||||
public async Task<HashSet<FeedModel>> GetAllFeeds()
|
||||
{
|
||||
HashSet<FeedModel> fSet = new HashSet<FeedModel>();
|
||||
fSet.UnionWith(feedSet);
|
||||
fSet.UnionWith(feedSet2);
|
||||
return fSet;
|
||||
return combined;
|
||||
}
|
||||
|
||||
|
||||
|
|
17
WebSharpRSS/Models/FeedStateContainer.cs
Normal file
17
WebSharpRSS/Models/FeedStateContainer.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using SharpRss.Models;
|
||||
|
||||
namespace WebSharpRSS.Models
|
||||
{
|
||||
public class FeedStateContainer
|
||||
{
|
||||
public HashSet<FeedModel> Feeds { get; set; }
|
||||
public event Action StateChanged;
|
||||
public void SetValue(HashSet<FeedModel> feedSet)
|
||||
{
|
||||
Feeds = feedSet;
|
||||
Invoke();
|
||||
}
|
||||
|
||||
private void Invoke() => StateChanged?.Invoke();
|
||||
}
|
||||
}
|
|
@ -1,8 +1,52 @@
|
|||
@page "/"
|
||||
@inject RssService _rssService
|
||||
@using CodeHollow.FeedReader;
|
||||
@using SharpRss.Models;
|
||||
@using WebSharpRSS.Models;
|
||||
|
||||
@inject RssService _rssService;
|
||||
@inject FeedStateContainer _stateContainer;
|
||||
|
||||
<MudGrid Spacing="3" Justify="Justify.FlexStart">
|
||||
@if (Feeds != null)
|
||||
{
|
||||
foreach (var feedItem in _items)
|
||||
{
|
||||
<MudItem>
|
||||
<MudCard>
|
||||
<MudCardContent>
|
||||
<MudText>@feedItem.Title</MudText>
|
||||
<MudText Typo="Typo.body2">@feedItem.Description</MudText>
|
||||
<MudText Typo="Typo.overline">@feedItem.PublishingDateString</MudText>
|
||||
</MudCardContent>
|
||||
</MudCard>
|
||||
</MudItem>
|
||||
}
|
||||
}
|
||||
</MudGrid>
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public HashSet<FeedModel>? Feeds { get; set; }
|
||||
|
||||
private HashSet<FeedItem> _items = new HashSet<FeedItem>();
|
||||
protected override async void OnInitialized()
|
||||
{
|
||||
UpdateFeeds();
|
||||
_stateContainer.StateChanged += FeedsChanged;
|
||||
}
|
||||
private void FeedsChanged()
|
||||
{
|
||||
UpdateFeeds();
|
||||
InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private void UpdateFeeds()
|
||||
{
|
||||
Feeds = _stateContainer.Feeds;
|
||||
if (Feeds == null) return;
|
||||
foreach (var feedmodel in Feeds)
|
||||
{
|
||||
_items = feedmodel.Base.Items.OrderBy(x => x.PublishingDate).ToHashSet();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@ var builder = WebApplication.CreateBuilder(args);
|
|||
builder.Services.AddRazorPages();
|
||||
builder.Services.AddServerSideBlazor();
|
||||
builder.Services.AddTransient<RssService>();
|
||||
builder.Services.AddSingleton<FeedStateContainer>();
|
||||
builder.Services.AddMudServices(config =>
|
||||
{
|
||||
config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.BottomRight;
|
||||
|
|
|
@ -6,16 +6,13 @@
|
|||
@using ToolQit.Extensions;
|
||||
|
||||
@inject NavigationManager _navManager;
|
||||
@inject FeedStateContainer _stateContainer;
|
||||
@inject RssService _rssService
|
||||
|
||||
<MudStack Spacing="2">
|
||||
@*<MudNavMenu>
|
||||
<MudNavLink Href="/" Icon="@Icons.Material.Filled.Home">Home</MudNavLink>
|
||||
</MudNavMenu>
|
||||
<MudDivider DividerType="DividerType.FullWidth"/>*@
|
||||
<MudTreeView Items="Categories" @bind-SelectedValue="SelectedItem" @bind-ActivatedItem="ActivatedItem" Hover="true">
|
||||
<MudTreeView Items="Categories" @bind-SelectedValue="SelectedItem" Hover="true">
|
||||
<ItemTemplate>
|
||||
<MudTreeViewItem @bind-Expanded="@context.IsExpanded" Items="@context.Feeds">
|
||||
<MudTreeViewItem @bind-Expanded="@context.IsExpanded" Items="@context.Feeds" Value="@context">
|
||||
<Content>
|
||||
<div style="display: grid; grid-template-columns: 1fr auto; align-items: center; width: 100%">
|
||||
<div style="justify-self: start;" class="d-flex align-center">
|
||||
|
@ -42,8 +39,27 @@
|
|||
|
||||
@code {
|
||||
public HashSet<TreeItemData> Categories = new HashSet<TreeItemData>();
|
||||
private TreeItemData? ActivatedItem { get; set; }
|
||||
private TreeItemData? SelectedItem { get; set; }
|
||||
private TreeItemData? _selecteditem;
|
||||
private TreeItemData? SelectedItem
|
||||
{
|
||||
get => _selecteditem;
|
||||
set
|
||||
{
|
||||
_selecteditem = value;
|
||||
ItemClicked();
|
||||
}
|
||||
}
|
||||
private void ItemClicked()
|
||||
{
|
||||
if (SelectedItem == null) return;
|
||||
if (SelectedItem.FeedModel != null)
|
||||
_stateContainer.SetValue(new HashSet<FeedModel>() { SelectedItem.FeedModel });
|
||||
if (SelectedItem.Feeds != null)
|
||||
{
|
||||
|
||||
}
|
||||
//_navManager.NavigateTo("/");
|
||||
}
|
||||
protected override async void OnInitialized()
|
||||
{
|
||||
Log.Verbose("Loading guide data...");
|
||||
|
@ -51,6 +67,7 @@
|
|||
HashSet<CategoryModel> cats = await _rssService.GetCategories();
|
||||
await Task.Run(() => Categories.UnionWith(cats.Select(x => new TreeItemData(x)).ToHashSet()));
|
||||
|
||||
StateHasChanged();
|
||||
Log.Verbose(" Guide initialized!");
|
||||
//await Task.Run(() => Categories = cats.Select(x => new TreeItemData(x)).ToHashSet());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user