1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using HanumanInstitute.MvvmDialogs;
- using System.Collections.ObjectModel;
- using VeloeAvaloniaKemonoPartyApp.Models;
- namespace VeloeAvaloniaKemonoPartyApp.ViewModels
- {
- public class PostViewModel : ViewModelBase
- {
- private readonly Post _post;
- private readonly IDialogService _dialogService;
- public PostViewModel(IDialogService dialogService, Post post)
- {
- _post = post;
- _dialogService = dialogService;
- Images.Clear();
- foreach (var attachment in _post.Attachments)
- {
- if (attachment is null) continue;
- if (attachment.Path.EndsWith(".jpg") || attachment.Path.EndsWith(".png") || attachment.Path.EndsWith(".jpeg"))
- {
- Images.Add(new PostImageViewModel(_dialogService,attachment));
- }
- }
- }
- public ObservableCollection<PostImageViewModel> Images { get; } = new();
-
- public bool IsImagesEmpty => Images.Count == 0;
- public string Content => _post.Content;
- public string Title => _post.Title;
- public string Date => _post.Published;
- }
- }
|