AttachmentsPickerViewModel
ViewModel responsible for handling the state and business logic of attachments.
Used to load file and media images that are then connected to the UI. It also keeps state of the selected items and prepares items before sending them.
Properties
List of attachments available, from the system.
Currently selected picker mode. Images, Files or MediaCapture.
List of files available, from the system.
Gives us info if there are any attachment items that are selected.
Gives us info if there are any file items that are selected.
Gives us info if there are any image items that are selected.
List of images available, from the system.
Gives us information if we're showing the attachments picker or not.
List of polls available, from the system.
Functions
Changes the currently selected AttachmentsPickerMode and loads the required data. If no permission is granted will not try and load data to avoid crashes.
Notifies the ViewModel if we should show attachments or not.
Triggered when an AttachmentMetaData is selected in the list. Added or removed from the corresponding list, be it files or images, based on attachmentsPickerMode.
Triggered when we dismiss the attachments picker. We reset the state to show images and clear the items for now, until the user needs them again.
Transforms the selected meta data into a list of Attachments we can upload.
Transforms selected file Uris to a list of Attachments we can upload.
Loads up the currently selected attachments. It uses the attachmentsPickerMode to know which attachments to use - files or images.