2024-04-18 01:44:37 +02:00
|
|
|
using System;
|
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
2026-04-20 19:38:30 +02:00
|
|
|
using Wino.Core.Domain;
|
2024-11-10 23:28:25 +01:00
|
|
|
using Wino.Core.Domain.Entities.Shared;
|
2024-04-18 01:44:37 +02:00
|
|
|
using Wino.Core.Domain.Interfaces;
|
|
|
|
|
|
2025-02-16 11:54:23 +01:00
|
|
|
namespace Wino.Mail.ViewModels.Data;
|
|
|
|
|
|
|
|
|
|
public partial class AccountProviderDetailViewModel : ObservableObject, IAccountProviderDetailViewModel
|
2024-04-18 01:44:37 +02:00
|
|
|
{
|
|
|
|
|
|
2025-02-16 11:54:23 +01:00
|
|
|
[ObservableProperty]
|
2026-04-20 19:38:30 +02:00
|
|
|
[NotifyPropertyChangedFor(nameof(CapabilitySummary))]
|
|
|
|
|
[NotifyPropertyChangedFor(nameof(DescriptionText))]
|
2025-02-16 11:54:23 +01:00
|
|
|
private MailAccount account;
|
2024-04-18 01:44:37 +02:00
|
|
|
|
2025-02-16 11:54:23 +01:00
|
|
|
public IProviderDetail ProviderDetail { get; set; }
|
2024-04-18 01:44:37 +02:00
|
|
|
|
2025-02-16 11:54:23 +01:00
|
|
|
public Guid StartupEntityId => Account.Id;
|
2024-04-18 01:44:37 +02:00
|
|
|
|
2025-02-16 11:54:23 +01:00
|
|
|
public string StartupEntityTitle => Account.Name;
|
2024-04-18 01:44:37 +02:00
|
|
|
|
2025-02-16 11:54:23 +01:00
|
|
|
public int Order => Account.Order;
|
2024-06-09 02:37:30 +02:00
|
|
|
|
2025-02-16 11:54:23 +01:00
|
|
|
public string StartupEntityAddresses => Account.Address;
|
2026-04-20 19:38:30 +02:00
|
|
|
public string CapabilitySummary => BuildCapabilitySummary(Account);
|
|
|
|
|
public string DescriptionText => string.IsNullOrWhiteSpace(Account.Address)
|
|
|
|
|
? CapabilitySummary
|
|
|
|
|
: $"{CapabilitySummary} | {Account.Address}";
|
2024-06-09 02:37:30 +02:00
|
|
|
|
2025-02-16 11:54:23 +01:00
|
|
|
public int HoldingAccountCount => 1;
|
2024-06-13 22:51:29 +02:00
|
|
|
|
2025-02-16 11:54:23 +01:00
|
|
|
public bool HasProfilePicture => !string.IsNullOrEmpty(Account.Base64ProfilePictureData);
|
2024-08-17 19:54:52 +02:00
|
|
|
|
2025-02-16 11:54:23 +01:00
|
|
|
public AccountProviderDetailViewModel(IProviderDetail providerDetail, MailAccount account)
|
|
|
|
|
{
|
|
|
|
|
ProviderDetail = providerDetail;
|
|
|
|
|
Account = account;
|
2024-04-18 01:44:37 +02:00
|
|
|
}
|
2026-04-20 19:38:30 +02:00
|
|
|
|
|
|
|
|
private static string BuildCapabilitySummary(MailAccount account)
|
|
|
|
|
{
|
|
|
|
|
if (account?.IsMailAccessGranted == true && account.IsCalendarAccessGranted)
|
|
|
|
|
return Translator.AccountCapability_MailAndCalendar;
|
|
|
|
|
|
|
|
|
|
if (account?.IsMailAccessGranted == true)
|
|
|
|
|
return Translator.AccountCapability_MailOnly;
|
|
|
|
|
|
|
|
|
|
return Translator.AccountCapability_CalendarOnly;
|
|
|
|
|
}
|
2024-04-18 01:44:37 +02:00
|
|
|
}
|