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
|
/// - Database
|
||||||
/// - File
|
/// - File
|
||||||
/// - Memory
|
/// - Memory
|
||||||
|
combined.UnionWith(feedSet);
|
||||||
|
combined.UnionWith(feedSet2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HashSet<FeedModel> feedSet = new HashSet<FeedModel>()
|
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://journals.plos.org/plosone/feed/atom"),
|
||||||
new FeedModel("https://itsfoss.com/feed")
|
new FeedModel("https://itsfoss.com/feed")
|
||||||
};
|
};
|
||||||
|
private static HashSet<FeedModel> combined = new HashSet<FeedModel>();
|
||||||
|
|
||||||
HashSet<CategoryModel> set = new HashSet<CategoryModel>()
|
HashSet<CategoryModel> set = new HashSet<CategoryModel>()
|
||||||
{
|
{
|
||||||
|
@ -43,10 +46,7 @@ namespace SharpRss
|
||||||
|
|
||||||
public async Task<HashSet<FeedModel>> GetAllFeeds()
|
public async Task<HashSet<FeedModel>> GetAllFeeds()
|
||||||
{
|
{
|
||||||
HashSet<FeedModel> fSet = new HashSet<FeedModel>();
|
return combined;
|
||||||
fSet.UnionWith(feedSet);
|
|
||||||
fSet.UnionWith(feedSet2);
|
|
||||||
return fSet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
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 "/"
|
@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 {
|
@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.AddRazorPages();
|
||||||
builder.Services.AddServerSideBlazor();
|
builder.Services.AddServerSideBlazor();
|
||||||
builder.Services.AddTransient<RssService>();
|
builder.Services.AddTransient<RssService>();
|
||||||
|
builder.Services.AddSingleton<FeedStateContainer>();
|
||||||
builder.Services.AddMudServices(config =>
|
builder.Services.AddMudServices(config =>
|
||||||
{
|
{
|
||||||
config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.BottomRight;
|
config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.BottomRight;
|
||||||
|
|
|
@ -6,16 +6,13 @@
|
||||||
@using ToolQit.Extensions;
|
@using ToolQit.Extensions;
|
||||||
|
|
||||||
@inject NavigationManager _navManager;
|
@inject NavigationManager _navManager;
|
||||||
|
@inject FeedStateContainer _stateContainer;
|
||||||
@inject RssService _rssService
|
@inject RssService _rssService
|
||||||
|
|
||||||
<MudStack Spacing="2">
|
<MudStack Spacing="2">
|
||||||
@*<MudNavMenu>
|
<MudTreeView Items="Categories" @bind-SelectedValue="SelectedItem" Hover="true">
|
||||||
<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">
|
|
||||||
<ItemTemplate>
|
<ItemTemplate>
|
||||||
<MudTreeViewItem @bind-Expanded="@context.IsExpanded" Items="@context.Feeds">
|
<MudTreeViewItem @bind-Expanded="@context.IsExpanded" Items="@context.Feeds" Value="@context">
|
||||||
<Content>
|
<Content>
|
||||||
<div style="display: grid; grid-template-columns: 1fr auto; align-items: center; width: 100%">
|
<div style="display: grid; grid-template-columns: 1fr auto; align-items: center; width: 100%">
|
||||||
<div style="justify-self: start;" class="d-flex align-center">
|
<div style="justify-self: start;" class="d-flex align-center">
|
||||||
|
@ -42,8 +39,27 @@
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public HashSet<TreeItemData> Categories = new HashSet<TreeItemData>();
|
public HashSet<TreeItemData> Categories = new HashSet<TreeItemData>();
|
||||||
private TreeItemData? ActivatedItem { get; set; }
|
private TreeItemData? _selecteditem;
|
||||||
private TreeItemData? SelectedItem { get; set; }
|
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()
|
protected override async void OnInitialized()
|
||||||
{
|
{
|
||||||
Log.Verbose("Loading guide data...");
|
Log.Verbose("Loading guide data...");
|
||||||
|
@ -51,6 +67,7 @@
|
||||||
HashSet<CategoryModel> cats = await _rssService.GetCategories();
|
HashSet<CategoryModel> cats = await _rssService.GetCategories();
|
||||||
await Task.Run(() => Categories.UnionWith(cats.Select(x => new TreeItemData(x)).ToHashSet()));
|
await Task.Run(() => Categories.UnionWith(cats.Select(x => new TreeItemData(x)).ToHashSet()));
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
Log.Verbose(" Guide initialized!");
|
Log.Verbose(" Guide initialized!");
|
||||||
//await Task.Run(() => Categories = cats.Select(x => new TreeItemData(x)).ToHashSet());
|
//await Task.Run(() => Categories = cats.Select(x => new TreeItemData(x)).ToHashSet());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user