Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ImagesViewModel.cs
1using CommunityToolkit.Mvvm.ComponentModel;
2using CommunityToolkit.Mvvm.Input;
5using System.Collections.ObjectModel;
6using System.Diagnostics;
8
10{
11
12
13 public partial class ImagesViewModel : BasePopupViewModel
14 {
15 private readonly PhotosLoader photosLoader;
16
17
18 public ImagesViewModel(Attachment[] Attachments)
19 {
20 this.Photos = new ObservableCollection<Photo>();
21 this.photosLoader = new PhotosLoader(this.Photos);
22 this.LoadPhotos(Attachments);
23 }
24
28 public ObservableCollection<Photo> Photos { get; set; }
29
33 [ObservableProperty]
34 private bool isSwipeEnabled;
35
40 public void LoadPhotos(Attachment[] attachments)
41 {
42 this.photosLoader.CancelLoadPhotos();
43 this.IsSwipeEnabled = false;
44
45 _ = this.photosLoader.LoadPhotos(attachments, SignWith.LatestApprovedIdOrCurrentKeys, () =>
46 {
47 MainThread.BeginInvokeOnMainThread(() => this.IsSwipeEnabled = this.Photos.Count > 1);
48 });
49 }
50
51 protected override Task OnPopAsync()
52 {
53 this.photosLoader.CancelLoadPhotos();
54 return base.OnPopAsync();
55 }
59 [RelayCommand]
60 private async Task Cancel()
61 {
62 await ServiceRef.PopupService.PopAsync();
63 }
64 }
65}
Base class that references services in the app.
Definition: ServiceRef.cs:43
static IPopupService PopupService
Popup service for presenting application popups.
Definition: ServiceRef.cs:142
Base class for popup view models/>.
void LoadPhotos(Attachment[] attachments)
Loads the attachments photos, if there are any.
ObservableCollection< Photo > Photos
Holds the list of photos to display.
Contains a reference to an attachment assigned to a legal object.
Definition: Attachment.cs:10
Definition: ImplTypes.g.cs:58
SignWith
Options on what keys to use when signing data.
Definition: Enumerations.cs:82