From c7639309ef97aae728bf89955c7b3166fde791c7 Mon Sep 17 00:00:00 2001 From: Aleh Khantsevich Date: Wed, 8 May 2024 19:26:47 +0200 Subject: [PATCH] Fixed progress ring, width of empty results and message for empty results with filters --- Wino.Mail.ViewModels/MailListPageViewModel.cs | 52 +++++++------------ Wino.Mail/Views/MailListPage.xaml | 26 +++++----- 2 files changed, 32 insertions(+), 46 deletions(-) diff --git a/Wino.Mail.ViewModels/MailListPageViewModel.cs b/Wino.Mail.ViewModels/MailListPageViewModel.cs index 8848e11b..bdd2a9d7 100644 --- a/Wino.Mail.ViewModels/MailListPageViewModel.cs +++ b/Wino.Mail.ViewModels/MailListPageViewModel.cs @@ -104,10 +104,9 @@ namespace Wino.Mail.ViewModels [NotifyPropertyChangedFor(nameof(IsEmpty))] [NotifyPropertyChangedFor(nameof(IsCriteriaFailed))] [NotifyPropertyChangedFor(nameof(IsFolderEmpty))] + [NotifyPropertyChangedFor(nameof(IsProgressRing))] private bool isInitializingFolder; - private bool isLoadMoreItemsLoading; - [ObservableProperty] private InfoBarMessageType barSeverity; @@ -250,22 +249,19 @@ namespace Wino.Mail.ViewModels public bool HasMultipleItemSelections => SelectedItemCount > 1; public bool HasSelectedItems => SelectedItems.Any(); public bool IsArchiveSpecialFolder => ActiveFolder?.SpecialFolderType == SpecialFolderType.Archive; - public bool IsEmpty => !IsInitializingFolder && !IsPerformingSearch && MailCollection.Count == 0; - public bool IsCriteriaFailed => IsEmpty && IsInSearchMode; - public bool IsFolderEmpty => !IsInitializingFolder && IsEmpty && !IsInSearchMode; - private bool _isPerformingSearch; - public bool IsPerformingSearch - { - get => _isPerformingSearch; - set - { - if (SetProperty(ref _isPerformingSearch, value)) - { - NotifyItemFoundState(); - } - } - } + /// + /// Indicates current state of the mail list. Doesn't matter it's loading or no. + /// + public bool IsEmpty => MailCollection.Count == 0; + + /// + /// Progress ring only should be visible when the folder is initializing and there are no items. We don't need to show it when there are items. + /// + public bool IsProgressRing => IsInitializingFolder && IsEmpty; + private bool isFilters => IsInSearchMode || SelectedFilterOption.Type != FilterOptionType.All; + public bool IsCriteriaFailed => !IsInitializingFolder && IsEmpty && isFilters; + public bool IsFolderEmpty => !IsInitializingFolder && IsEmpty && !isFilters; public bool IsInSearchMode { get; set; } @@ -473,24 +469,16 @@ namespace Wino.Mail.ViewModels [RelayCommand] public async Task PerformSearchAsync() { - try + if (string.IsNullOrEmpty(SearchQuery) && IsInSearchMode) { - if (string.IsNullOrEmpty(SearchQuery) && IsInSearchMode) - { - IsInSearchMode = false; - await InitializeFolderAsync(); - } - - if (!string.IsNullOrEmpty(SearchQuery)) - { - IsInSearchMode = true; - IsPerformingSearch = true; - await InitializeFolderAsync(); - } + IsInSearchMode = false; + await InitializeFolderAsync(); } - finally + + if (!string.IsNullOrEmpty(SearchQuery)) { - IsPerformingSearch = false; + IsInSearchMode = true; + await InitializeFolderAsync(); } } diff --git a/Wino.Mail/Views/MailListPage.xaml b/Wino.Mail/Views/MailListPage.xaml index d231ef21..1cad33f7 100644 --- a/Wino.Mail/Views/MailListPage.xaml +++ b/Wino.Mail/Views/MailListPage.xaml @@ -403,17 +403,16 @@ - + @@ -699,22 +698,21 @@ Foreground="{ThemeResource InformationBrush}" Text="{x:Bind domain:Translator.NoMessageEmptyFolder}" Visibility="{x:Bind ViewModel.IsFolderEmpty, Mode=OneWay}" /> - - - + + + Visibility="{x:Bind ViewModel.IsEmpty, Converter={StaticResource ReverseBooleanToVisibilityConverter}, Mode=OneWay}"> - +