androidx.photopicker.compose
Interfaces
EmbeddedPhotoPickerState |
State model of a EmbeddedPhotoPickerSession. |
Classes
AbstractEmbeddedPhotoPickerState |
Abstract base class for managing the state of an embedded photo picker. |
Annotations
Top-level functions summary
Unit |
@ComposableCompose entry-point into the EmbeddedPhotoPicker. |
EmbeddedPhotoPickerState |
@ExperimentalPhotoPickerComposeApiGenerates a |
Top-level functions
EmbeddedPhotoPicker
@Composable
@RequiresExtension(extension = 34, version = 15)
@ExperimentalPhotoPickerComposeApi
fun EmbeddedPhotoPicker(
state: EmbeddedPhotoPickerState,
modifier: Modifier = Modifier,
provider: EmbeddedPhotoPickerProvider? = null,
embeddedPhotoPickerFeatureInfo: EmbeddedPhotoPickerFeatureInfo = DEFAULT_FEATURE_INFO
): Unit
Compose entry-point into the EmbeddedPhotoPicker. This composable hosts a remote view from the EmbeddedPhotoPickerProvider and interacts with the provided EmbeddedPhotoPickerState and coordinates the state between the local compose view and remote view.
| Parameters | |
|---|---|
state: EmbeddedPhotoPickerState |
The state object for the EmbeddedPhotoPicker which can be manually implemented, or a default implementation may be obtained via the |
modifier: Modifier = Modifier |
An optional |
provider: EmbeddedPhotoPickerProvider? = null |
An optional |
embeddedPhotoPickerFeatureInfo: EmbeddedPhotoPickerFeatureInfo = DEFAULT_FEATURE_INFO |
A set of features that will be provided to the PhotoPicker when a session is started. |
rememberEmbeddedPhotoPickerState
@ExperimentalPhotoPickerComposeApi
@Composable
@RequiresExtension(extension = 34, version = 15)
fun rememberEmbeddedPhotoPickerState(
vararg inputs: Any?,
initialExpandedValue: Boolean = false,
initialMediaSelection: Set<Uri> = emptySet<Uri>(),
onSessionError: (Throwable) -> Unit = {},
onUriPermissionGranted: (List<Uri>) -> Unit = {},
onUriPermissionRevoked: (List<Uri>) -> Unit = {},
onSelectionComplete: () -> Unit = {}
): EmbeddedPhotoPickerState
Generates a EmbeddedPhotoPickerState object and remembers it. This object can be used to interact with the remote EmbeddedPhotoPickerSession. This object's state will survive the activity or process recreation but the underlying EmbeddedPhotoPickerSession will be recreated along with the activity. (When EmbeddedPhotoPickerState#runSession is next called.)
If a clean state object is needed, be sure to provide some input keys that are unique.
| Parameters | |
|---|---|
vararg inputs: Any? |
A set of inputs such that, when any of them have changed, will cause the state to reset and init to be rerun. Note that state restoration DOES NOT validate against inputs provided before value was saved. |
initialExpandedValue: Boolean = false |
the initial expanded state of the photopicker. This property only affects the initial value, and has no further effect. |
initialMediaSelection: Set<Uri> = emptySet<Uri>() |
the initial set of media that should be selected inside of the Photopicker. Note: this should only be URIs that have been given to the calling application by the Photopicker itself, do not pass generic URIs or MediaStore URIs, as they will be ignored. |
onSessionError: (Throwable) -> Unit = {} |
Called when the PhotoPicker has indicated an error with the current session. |
onUriPermissionGranted: (List<Uri>) -> Unit = {} |
Called when the user has selected media items in the embedded session. |
onUriPermissionRevoked: (List<Uri>) -> Unit = {} |
Called when the user has deselected media items in the embedded session. |
onSelectionComplete: () -> Unit = {} |
Called when the user is done with their selection and the app should collapse or close the PhotoPicker. |
| Returns | |
|---|---|
EmbeddedPhotoPickerState |
state object for interacting with an EmbeddedPhotoPickerSession. |