26 lines
929 B
C#
26 lines
929 B
C#
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using LehrerApp.Desktop.Services;
|
|
|
|
namespace LehrerApp.Desktop.ViewModels.Students;
|
|
|
|
public partial class SelectContactDialogViewModel : ObservableObject
|
|
{
|
|
[ObservableProperty] private LetterContactChoice? _selectedContact;
|
|
|
|
public IReadOnlyList<LetterContactChoice> Contacts { get; }
|
|
public string AddressPreview => LetterPlaceholderBuilder.FormatAddress(SelectedContact?.Model);
|
|
public bool HasAddressPreview => !string.IsNullOrWhiteSpace(AddressPreview);
|
|
|
|
public SelectContactDialogViewModel(IReadOnlyList<LetterContactChoice> contacts, LetterContactChoice? current)
|
|
{
|
|
Contacts = contacts;
|
|
SelectedContact = current ?? contacts.FirstOrDefault();
|
|
}
|
|
|
|
partial void OnSelectedContactChanged(LetterContactChoice? value)
|
|
{
|
|
OnPropertyChanged(nameof(AddressPreview));
|
|
OnPropertyChanged(nameof(HasAddressPreview));
|
|
}
|
|
}
|