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;
7
9{
10
11
12 public partial class ImagesViewModel : BasePopupViewModel
13 {
14 private readonly PhotosLoader photosLoader;
15
16
17 public ImagesViewModel()
18 {
19 this.Photos = [];
20 this.photosLoader = new PhotosLoader(this.Photos);
21 }
25 public ObservableCollection<Photo> Photos { get; }
26
30 [ObservableProperty]
31 private bool isSwipeEnabled;
32
37 public void LoadPhotos(Attachment[] attachments)
38 {
39 this.photosLoader.CancelLoadPhotos();
40 this.IsSwipeEnabled = false;
41
42 _ = this.photosLoader.LoadPhotos(attachments, SignWith.LatestApprovedIdOrCurrentKeys, () =>
43 {
44 MainThread.BeginInvokeOnMainThread(() => this.IsSwipeEnabled = this.Photos.Count > 1);
45 });
46 }
47
48 public override void OnPop()
49 {
50 this.photosLoader.CancelLoadPhotos();
51 }
55 [RelayCommand]
56 private async Task Cancel()
57 {
58 await ServiceRef.UiService.PopAsync();
59 }
60 }
61}
Base class that references services in the app.
Definition: ServiceRef.cs:31
static IUiService UiService
Service serializing and managing UI-related tasks.
Definition: ServiceRef.cs:55
void LoadPhotos(Attachment[] attachments)
Loads the attachments photos, if there are any.
ObservableCollection< Photo > Photos
Holds the list of photos to display.
override void OnPop()
Called when the popup is popped from the stack. This can be used to clean up resources,...
Contains a reference to an attachment assigned to a legal object.
Definition: Attachment.cs:9
SignWith
Options on what keys to use when signing data.
Definition: Enumerations.cs:84