New WinoListView implementation with multiple selections.

This commit is contained in:
Burak Kaan Köse
2025-10-26 14:53:22 +01:00
parent d4c8ae6cb7
commit 79d5b6ed40
22 changed files with 748 additions and 480 deletions
+17 -1
View File
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using Wino.Core.Domain.Interfaces;
namespace Wino.Mail.ViewModels.Data;
@@ -7,7 +9,7 @@ namespace Wino.Mail.ViewModels.Data;
/// Common interface for mail items that can be displayed in a mail list.
/// Implemented by both MailItemViewModel and ThreadMailItemViewModel.
/// </summary>
public interface IMailListItem : IMailHashContainer
public interface IMailListItem : IMailHashContainer, INotifyPropertyChanged
{
/// <summary>
/// Gets the latest creation date for sorting purposes.
@@ -22,4 +24,18 @@ public interface IMailListItem : IMailHashContainer
/// For ThreadMailItemViewModel: the latest email's from name
/// </summary>
string FromName { get; }
/// <summary>
/// Gets whether this item is selected.
/// For MailItemViewModel: returns IsSelected
/// For ThreadMailItemViewModel: returns IsSelected
/// </summary>
bool IsSelected { get; set; }
/// <summary>
/// Gets all selected mail items within this list item.
/// For MailItemViewModel: returns itself if IsSelected is true, otherwise empty
/// For ThreadMailItemViewModel: returns all selected emails within the thread
/// </summary>
IEnumerable<MailItemViewModel> GetSelectedMailItems();
}
@@ -91,4 +91,12 @@ public partial class MailItemViewModel(MailCopy mailCopy) : ObservableObject, IM
}
public IEnumerable<Guid> GetContainingIds() => [MailCopy.UniqueId];
public IEnumerable<MailItemViewModel> GetSelectedMailItems()
{
if (IsSelected)
{
yield return this;
}
}
}
@@ -118,4 +118,18 @@ public partial class ThreadMailItemViewModel : ObservableRecipient, IDisposable,
public bool HasUniqueId(Guid uniqueId) => _threadEmails.Any(email => email.MailCopy.UniqueId == uniqueId);
public IEnumerable<Guid> GetContainingIds() => ThreadEmails.Select(a => a.MailCopy.UniqueId);
public IEnumerable<MailItemViewModel> GetSelectedMailItems()
{
if (IsSelected)
{
// If the thread itself is selected, return all emails in the thread
return ThreadEmails;
}
else
{
// Otherwise, return only individually selected emails within the thread
return ThreadEmails.Where(e => e.IsSelected);
}
}
}