AttachmentsPickerViewModel

class AttachmentsPickerViewModel(storageHelper: StorageHelperWrapper, channelState: StateFlow<ChannelState?>) : ViewModel

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.

Constructors

Link copied to clipboard
constructor(storageHelper: StorageHelperWrapper, channelState: StateFlow<ChannelState?>)

Properties

Link copied to clipboard

List of attachments available, from the system.

Link copied to clipboard

Currently selected picker mode. Images, Files or MediaCapture.

Link copied to clipboard

The information for the current Channel.

Link copied to clipboard

List of files available, from the system.

Link copied to clipboard

Gives us info if there are any attachment items that are selected.

Link copied to clipboard

Gives us info if there are any file items that are selected.

Link copied to clipboard

Gives us info if there are any image items that are selected.

Link copied to clipboard

List of images available, from the system.

Link copied to clipboard

Gives us information if we're showing the attachments picker or not.

Link copied to clipboard

List of polls available, from the system.

Functions

Link copied to clipboard
fun changeAttachmentPickerMode(attachmentsPickerMode: AttachmentsPickerMode, hasPermission: () -> Boolean = { true })

Changes the currently selected AttachmentsPickerMode and loads the required data. If no permission is granted will not try and load data to avoid crashes.

Link copied to clipboard
fun changeAttachmentState(showAttachments: Boolean)

Notifies the ViewModel if we should show attachments or not.

Link copied to clipboard

Triggered when an AttachmentMetaData is selected in the list. Added or removed from the corresponding list, be it files or images, based on attachmentsPickerMode.

Link copied to clipboard

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.

Link copied to clipboard

Transforms the selected meta data into a list of Attachments we can upload.

Link copied to clipboard

Transforms selected file Uris to a list of Attachments we can upload.

Link copied to clipboard

Loads up the currently selected attachments. It uses the attachmentsPickerMode to know which attachments to use - files or images.

Link copied to clipboard
fun loadData()

Loads all the items based on the current type.

Inherited functions

Link copied to clipboard
open fun addCloseable(closeable: AutoCloseable)
fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard