use models from api by nuget package
This commit is contained in:
parent
46c1af77c0
commit
836fcb3f4d
@ -1,6 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="itob86.rblnews" android:versionCode="1">
|
||||
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:supportsRtl="true" android:label="RBLNews"></application>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.INSTALL_LOCATION_PROVIDER" />
|
||||
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
|
||||
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
|
||||
</manifest>
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">32.0</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">31.0</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
|
||||
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
|
||||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
|
||||
@ -42,6 +42,10 @@
|
||||
<AndroidPackageFormat>apk</AndroidPackageFormat>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.26100.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- App Icon -->
|
||||
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<div class="top-row ps-3 navbar navbar-dark">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<Icon Name="IconName.InfoCircle" class="me-2"></Icon>Letztes Update @this.FeedDataService.Feeds?.LastUpdateDisplay
|
||||
<Icon Name="IconName.InfoCircle" class="me-2"></Icon>Letztes Update @this.FeedDataService.Feeds?.LastUpdate.ToString("dd.MM.yyyy HH:mm")
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
@page "/"
|
||||
@using RBLFeederCommon.Enums
|
||||
@using RBLFeederCommon.Models.RssFeed
|
||||
@using RBLNews.Shared.Enums
|
||||
@using RBLNews.Shared.Services
|
||||
|
||||
@inject IFeedDataService feedDataService
|
||||
|
||||
@if (this.FeedDataService.Feeds == null)
|
||||
@if (FeedDataService.Feeds == null)
|
||||
{
|
||||
<div class="d-flex justify-content-center">
|
||||
Lade Feeds ...
|
||||
Lade Feeds ...<br/>
|
||||
<Spinner Type="SpinnerType.Grow" Color="SpinnerColor.Primary" Size="SpinnerSize.Large" />
|
||||
</div>
|
||||
}
|
||||
@ -19,7 +19,7 @@ else
|
||||
<div class="container">
|
||||
@foreach (FeedGroupVM feedGrp in this.FeedDataService.Feeds.FeedGroups)
|
||||
{
|
||||
<h4><Icon Name="IconName.Calendar2Event" /> @feedGrp.PublishDateDisplay</h4>
|
||||
<h4><Icon Name="IconName.Calendar2Event" /> @feedGrp.PublishDate.ToString("dd.MM.yyyy")</h4>
|
||||
@foreach (FeedVM feed in feedGrp.Feeds)
|
||||
{
|
||||
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-4">
|
||||
@ -48,14 +48,14 @@ else
|
||||
</div>
|
||||
}
|
||||
@code {
|
||||
HttpClient httpClient = new HttpClient();
|
||||
|
||||
[Inject]
|
||||
private IFeedDataService FeedDataService { get; set; }
|
||||
|
||||
protected async override Task OnInitializedAsync()
|
||||
{
|
||||
this.FeedDataService.LoadFeeds();
|
||||
await FeedDataService.LoadFeeds();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private string GetRssSourceName(RssFeedSources source)
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
namespace RBLNews.Shared.Enums
|
||||
{
|
||||
public enum RssFeedSources
|
||||
{
|
||||
Lvz,
|
||||
Kicker,
|
||||
Bild,
|
||||
Transfermarkt,
|
||||
NitterRbLive,
|
||||
NitterFabrizioRomano,
|
||||
RbLive
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace RBLFeederCommon.Models.RssFeed;
|
||||
|
||||
public class FeedGroupVM
|
||||
{
|
||||
public string PublishDateDisplay { get => PublishDate.ToString("dd.MM.yyyy"); }
|
||||
|
||||
[JsonProperty("pubDate")]
|
||||
public DateTime PublishDate { get; set; }
|
||||
|
||||
[JsonProperty("news")]
|
||||
public IList<FeedVM> Feeds { get; set; }
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace RBLFeederCommon.Models.RssFeed;
|
||||
|
||||
public class FeedVM
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("title")]
|
||||
public string Title { get; set; }
|
||||
|
||||
[JsonProperty("imgUrl")]
|
||||
public string ImgUrl { get; set; }
|
||||
|
||||
[JsonProperty("description")]
|
||||
public string Description { get; set; }
|
||||
|
||||
[JsonProperty("pubDate")]
|
||||
public DateTime? PubDate { get; set; }
|
||||
|
||||
[JsonProperty("link")]
|
||||
public string Link { get; set; }
|
||||
|
||||
[JsonProperty("source")]
|
||||
public int Source { get; set; }
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace RBLFeederCommon.Models.RssFeed;
|
||||
|
||||
public class RssVM
|
||||
{
|
||||
public string LastUpdateDisplay { get => this.LastUpdate.ToLocalTime().ToString("dd.MM.yyyy HH:mm"); }
|
||||
|
||||
[JsonProperty("lastUpdate")]
|
||||
public DateTime LastUpdate { get; set; }
|
||||
|
||||
|
||||
[JsonProperty("description")]
|
||||
public string Description { get; set; }
|
||||
|
||||
|
||||
[JsonProperty("feedGroups")]
|
||||
public IList<FeedGroupVM> FeedGroups { get; set; } = new List<FeedGroupVM>();
|
||||
}
|
||||
@ -12,10 +12,10 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AntDesign" Version="0.20.3" />
|
||||
<PackageReference Include="Blazor.Bootstrap" Version="3.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.8" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="RBLFeederCommon" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -1,30 +1,25 @@
|
||||
using RBLFeederCommon.Models.RssFeed;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
|
||||
using System.Net.Http.Json;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using RBLFeederCommon.Models.RssFeed;
|
||||
|
||||
namespace RBLNews.Shared.Services
|
||||
{
|
||||
public interface IFeedDataService
|
||||
{
|
||||
public RssVM? Feeds { get; }
|
||||
public RssVM Feeds { get; }
|
||||
|
||||
Task LoadFeeds();
|
||||
}
|
||||
|
||||
public class FeedDataService : IFeedDataService
|
||||
{
|
||||
private static HttpClient httpClient = new HttpClient();
|
||||
private static readonly HttpClient httpClient = new();
|
||||
|
||||
private RssVM? feeds;
|
||||
public RssVM? Feeds { get => this.feeds; }
|
||||
public RssVM Feeds { get; private set; }
|
||||
|
||||
public async Task LoadFeeds()
|
||||
{
|
||||
feeds = await httpClient.GetFromJsonAsync<RssVM>("https://rblnews.de/api/feeds");
|
||||
Feeds = await httpClient.GetFromJsonAsync<RssVM>("https://rblnews.de/api/feeds") ?? new RssVM();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user