Add Windows desktop version

This commit is contained in:
renato97
2025-12-17 19:20:55 +00:00
parent 93dbe0941e
commit 8921d7f2a6
36 changed files with 2760 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
using System.Collections.Generic;
namespace StreamPlayer.Desktop.Models;
public enum SectionType
{
Events,
Channels
}
public sealed record ChannelSection(string Title, SectionType Type, IReadOnlyList<StreamChannel> Channels)
{
public bool IsEvents => Type == SectionType.Events;
}

View File

@@ -0,0 +1,6 @@
namespace StreamPlayer.Desktop.Models;
public sealed record DeviceStatus(bool IsBlocked, string Reason, string TokenPart)
{
public static DeviceStatus Allowed() => new(false, string.Empty, string.Empty);
}

View File

@@ -0,0 +1,37 @@
using System;
namespace StreamPlayer.Desktop.Models;
public sealed record LiveEvent(
string Title,
string DisplayTime,
string Category,
string Status,
string PageUrl,
string ChannelName,
long StartTimestamp)
{
public bool IsLive =>
!string.IsNullOrWhiteSpace(Status) &&
Status.Contains("live", StringComparison.OrdinalIgnoreCase);
public string Subtitle
{
get
{
if (string.IsNullOrWhiteSpace(DisplayTime) && string.IsNullOrWhiteSpace(Category))
{
return string.Empty;
}
if (string.IsNullOrWhiteSpace(Category))
{
return DisplayTime;
}
if (string.IsNullOrWhiteSpace(DisplayTime))
{
return Category;
}
return $"{DisplayTime} · {Category}";
}
}
}

View File

@@ -0,0 +1,3 @@
namespace StreamPlayer.Desktop.Models;
public sealed record StreamChannel(string Name, string PageUrl);

View File

@@ -0,0 +1,52 @@
using System;
using System.Globalization;
namespace StreamPlayer.Desktop.Models;
public sealed record UpdateInfo(
int VersionCode,
string VersionName,
string ReleaseNotes,
string DownloadUrl,
string DownloadFileName,
long DownloadSizeBytes,
int DownloadCount,
string ReleasePageUrl,
int MinSupportedVersionCode,
bool ForceUpdate)
{
public bool IsUpdateAvailable(int currentVersionCode) => VersionCode > currentVersionCode;
public bool IsMandatory(int currentVersionCode) =>
ForceUpdate || (MinSupportedVersionCode > 0 && currentVersionCode < MinSupportedVersionCode);
public string GetReleaseNotesPreview(int maxLength = 900)
{
if (string.IsNullOrWhiteSpace(ReleaseNotes))
{
return string.Empty;
}
if (ReleaseNotes.Length <= maxLength)
{
return ReleaseNotes.Trim();
}
return ReleaseNotes[..maxLength].TrimEnd() + Environment.NewLine + "…";
}
public string FormatSize()
{
if (DownloadSizeBytes <= 0)
{
return string.Empty;
}
string[] suffixes = { "B", "KB", "MB", "GB" };
double size = DownloadSizeBytes;
int index = 0;
while (size >= 1024 && index < suffixes.Length - 1)
{
size /= 1024;
index++;
}
return $"{size:0.##} {suffixes[index]}";
}
}