From 37f4885c0ecba74f41b01a0070852f64df7e21c1 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Fri, 5 Mar 2021 16:30:34 +0000 Subject: [PATCH] fix spacing and add a message when empty. --- .../ViewModels/MainWindowViewModel.cs | 15 ++++++++++++++- Avalonia.MusicStore/ViewModels/ViewModelBase.cs | 5 +---- Avalonia.MusicStore/Views/MainWindow.axaml | 11 ++++++++++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Avalonia.MusicStore/ViewModels/MainWindowViewModel.cs b/Avalonia.MusicStore/ViewModels/MainWindowViewModel.cs index c518640..9fb9fdf 100644 --- a/Avalonia.MusicStore/ViewModels/MainWindowViewModel.cs +++ b/Avalonia.MusicStore/ViewModels/MainWindowViewModel.cs @@ -1,4 +1,5 @@ -using System.Collections.ObjectModel; +using System; +using System.Collections.ObjectModel; using System.Linq; using System.Reactive.Concurrency; using System.Reactive.Linq; @@ -9,6 +10,8 @@ namespace Avalonia.MusicStore.ViewModels { public class MainWindowViewModel : ViewModelBase { + private bool _collectionEmpty; + public MainWindowViewModel() { ShowDialog = new Interaction(); @@ -25,9 +28,18 @@ namespace Avalonia.MusicStore.ViewModels } }); + this.WhenAnyValue(x => x.Albums.Count) + .Subscribe(x => CollectionEmpty = x == 0); + RxApp.MainThreadScheduler.Schedule(LoadAlbums); } + public bool CollectionEmpty + { + get => _collectionEmpty; + set => this.RaiseAndSetIfChanged(ref _collectionEmpty, value); + } + private async void LoadAlbums() { var albums = await AlbumViewModel.LoadCached(); @@ -37,6 +49,7 @@ namespace Avalonia.MusicStore.ViewModels Albums.Add(album); } + LoadCovers(); } diff --git a/Avalonia.MusicStore/ViewModels/ViewModelBase.cs b/Avalonia.MusicStore/ViewModels/ViewModelBase.cs index ac7c33b..c5b3d78 100644 --- a/Avalonia.MusicStore/ViewModels/ViewModelBase.cs +++ b/Avalonia.MusicStore/ViewModels/ViewModelBase.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using ReactiveUI; +using ReactiveUI; namespace Avalonia.MusicStore.ViewModels { diff --git a/Avalonia.MusicStore/Views/MainWindow.axaml b/Avalonia.MusicStore/Views/MainWindow.axaml index ee4453f..596028f 100644 --- a/Avalonia.MusicStore/Views/MainWindow.axaml +++ b/Avalonia.MusicStore/Views/MainWindow.axaml @@ -5,6 +5,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Avalonia.MusicStore.Views.MainWindow" + xmlns:local="using:Avalonia.MusicStore.Views" WindowStartupLocation="CenterScreen" Background="Transparent" TransparencyLevelHint="AcrylicBlur" @@ -32,12 +33,20 @@ - + + + + + + + + +