diff --git a/Selector.MAUI/Pages/Login.razor b/Selector.MAUI/Pages/Login.razor
index 4b4d199..eda97e8 100644
--- a/Selector.MAUI/Pages/Login.razor
+++ b/Selector.MAUI/Pages/Login.razor
@@ -7,10 +7,10 @@
@toast
-
-
+
+
-
+
@code {
@@ -39,5 +39,5 @@
break;
}
}
- }
+}
diff --git a/Selector.MAUI/Pages/Now.razor b/Selector.MAUI/Pages/Now.razor
index 821018d..fc2cb57 100644
--- a/Selector.MAUI/Pages/Now.razor
+++ b/Selector.MAUI/Pages/Now.razor
@@ -1,16 +1,63 @@
@page "/now"
@using Selector.SignalR;
+@implements IDisposable
Now
-@if (nowCache?.LastPlaying?.Track is not null)
+@*@if (nowCache?.LastPlaying?.Track is not null)
{
@nowCache.LastPlaying.Track.Name
-}
+}*@
+
+
@code {
[Inject]
private NowHubCache nowCache { get; set; }
+
+ protected async override Task OnInitializedAsync()
+ {
+ nowCache.NewNowPlaying += OnNewPlaying;
+ nowCache.NewCard += OnNewCard;
+ nowCache.NewPlayCount += OnNewPlayCount;
+ nowCache.NewAudioFeature += OnNewAudioFeature;
+ }
+
+ private void OnNewPlaying(object sender, EventArgs args)
+ {
+ Update();
+ }
+
+ private void OnNewCard(object sender, EventArgs args)
+ {
+ Update();
+ }
+
+ private void OnNewPlayCount(object sender, EventArgs args)
+ {
+ Update();
+ }
+
+ private void OnNewAudioFeature(object sender, EventArgs args)
+ {
+ Update();
+ }
+
+ public void Update()
+ {
+ Application.Current.Dispatcher.Dispatch(() =>
+ {
+ StateHasChanged();
+ });
+ }
+
+ public void Dispose()
+ {
+ nowCache.NewNowPlaying -= OnNewPlaying;
+ nowCache.NewCard -= OnNewCard;
+ nowCache.NewPlayCount -= OnNewPlayCount;
+ nowCache.NewAudioFeature -= OnNewAudioFeature;
+ }
}
diff --git a/Selector.MAUI/Shared/NowPlayingCard.razor b/Selector.MAUI/Shared/NowPlayingCard.razor
new file mode 100644
index 0000000..3e184fa
--- /dev/null
+++ b/Selector.MAUI/Shared/NowPlayingCard.razor
@@ -0,0 +1,53 @@
+@using SpotifyAPI.Web;
+
+@if (Track is not null) {
+
+
+
@Track.Name
+
+ @Track.Album.Name
+
+
+ @foreach(var artist in Track.Artists)
+ {
+ @artist.Name
+ }
+
+
+
+
+
+
+}
+else if (Episode is not null) {
+
+
+
@Episode.Name
+
+ @Episode.Show.Name
+
+
+ @Episode.Show.Publisher
+
+
+
+
+
+
+}
+else
+{
+
+
No Playback
+
+}
+
+@code {
+ [Parameter]
+ public FullTrack Track { get; set; }
+ [Parameter]
+ public FullEpisode Episode { get; set; }
+
+ private string imageUrl => Track?.Album?.Images?.FirstOrDefault()?.Url ?? Episode?.Show?.Images?.FirstOrDefault()?.Url ?? string.Empty;
+}
+
diff --git a/Selector.MAUI/Shared/SpotifyLogo.razor b/Selector.MAUI/Shared/SpotifyLogo.razor
new file mode 100644
index 0000000..dceda40
--- /dev/null
+++ b/Selector.MAUI/Shared/SpotifyLogo.razor
@@ -0,0 +1,15 @@
+@if (!string.IsNullOrWhiteSpace(Link))
+{
+
+
+
+}
+else
+{
+
+}
+
+@code {
+ [Parameter]
+ public string Link { get; set; }
+}
\ No newline at end of file
diff --git a/Selector.MAUI/Shared/SpotifyLogo.razor.css b/Selector.MAUI/Shared/SpotifyLogo.razor.css
new file mode 100644
index 0000000..db47d63
--- /dev/null
+++ b/Selector.MAUI/Shared/SpotifyLogo.razor.css
@@ -0,0 +1,63 @@
+.navbar-toggler {
+ background-color: rgba(255, 255, 255, 0.1);
+}
+
+.top-row {
+ height: 3.5rem;
+ background-color: rgba(0,0,0,0.4);
+}
+
+.navbar-brand {
+ font-size: 1.1rem;
+}
+
+.oi {
+ width: 2rem;
+ font-size: 1.1rem;
+ vertical-align: text-top;
+ top: -2px;
+}
+
+.nav-item {
+ font-size: 0.9rem;
+ padding-bottom: 0.5rem;
+}
+
+ .nav-item:first-of-type {
+ padding-top: 1rem;
+ }
+
+ .nav-item:last-of-type {
+ padding-bottom: 1rem;
+ }
+
+ .nav-item ::deep a {
+ color: #d7d7d7;
+ border-radius: 4px;
+ height: 3rem;
+ display: flex;
+ align-items: center;
+ line-height: 3rem;
+ }
+
+.nav-item ::deep a.active {
+ background-color: rgba(255,255,255,0.25);
+ color: white;
+}
+
+.nav-item ::deep a:hover {
+ background-color: rgba(255,255,255,0.1);
+ color: white;
+}
+
+@media (min-width: 641px) {
+ .navbar-toggler {
+ display: none;
+ }
+
+ .collapse {
+ /* Never collapse the sidebar for wide screens */
+ display: block;
+ }
+}
+
diff --git a/Selector.MAUI/Shared/SurveyPrompt.razor b/Selector.MAUI/Shared/SurveyPrompt.razor
deleted file mode 100644
index 8bf109e..0000000
--- a/Selector.MAUI/Shared/SurveyPrompt.razor
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
@Title
-
-
- Please take our
- brief survey
-
- and tell us what you think.
-
-
-@code {
- // Demonstrates how a parent component can supply parameters
- [Parameter]
- public string Title { get; set; }
-}
-
diff --git a/Selector.SignalR/NowHubCache.cs b/Selector.SignalR/NowHubCache.cs
index 6f8f593..56a0335 100644
--- a/Selector.SignalR/NowHubCache.cs
+++ b/Selector.SignalR/NowHubCache.cs
@@ -14,7 +14,12 @@ public class NowHubCache
private readonly object updateLock = new();
public PlayCount LastPlayCount { get; private set; }
- public CurrentlyPlayingDTO LastPlaying { get; private set; }
+ public CurrentlyPlayingDTO LastPlaying { get; private set; }
+
+ public event EventHandler NewAudioFeature;
+ public event EventHandler NewCard;
+ public event EventHandler NewPlayCount;
+ public event EventHandler NewNowPlaying;
public NowHubCache(NowHubClient connection, ILogger logger)
{
@@ -30,6 +35,7 @@ public class NowHubCache
{
logger.LogInformation("New audio features received: {0}", af);
LastFeature = af;
+ NewAudioFeature?.Invoke(this, null);
}
});
@@ -39,6 +45,7 @@ public class NowHubCache
{
logger.LogInformation("New card received: {0}", c);
LastCards.Add(c);
+ NewCard?.Invoke(this, null);
}
});
@@ -48,7 +55,8 @@ public class NowHubCache
{
logger.LogInformation("New play count received: {0}", pc);
LastPlayCount = pc;
- }
+ NewPlayCount?.Invoke(this, null);
+ }
});
_connection.OnNewPlaying(async np =>
@@ -60,7 +68,8 @@ public class NowHubCache
logger.LogInformation("New now playing recieved: {0}", np);
LastPlaying = np;
LastCards.Clear();
- }
+ NewNowPlaying?.Invoke(this, null);
+ }
if (LastPlaying?.Track is not null)
{