MediaViewer: add Save action as a main action.
This commit is contained in:
parent
6342b925d5
commit
81e61bbbd1
2 changed files with 25 additions and 0 deletions
|
|
@ -217,6 +217,9 @@ fun MediaViewerView(
|
||||||
onShareClick = {
|
onShareClick = {
|
||||||
state.eventSink(MediaViewerEvent.Share(currentData))
|
state.eventSink(MediaViewerEvent.Share(currentData))
|
||||||
},
|
},
|
||||||
|
onSaveClick = {
|
||||||
|
state.eventSink(MediaViewerEvent.SaveOnDisk(currentData))
|
||||||
|
},
|
||||||
onInfoClick = {
|
onInfoClick = {
|
||||||
state.eventSink(MediaViewerEvent.OpenInfo(currentData))
|
state.eventSink(MediaViewerEvent.OpenInfo(currentData))
|
||||||
},
|
},
|
||||||
|
|
@ -461,6 +464,7 @@ private fun MediaViewerTopBar(
|
||||||
canShowInfo: Boolean,
|
canShowInfo: Boolean,
|
||||||
onBackClick: () -> Unit,
|
onBackClick: () -> Unit,
|
||||||
onShareClick: () -> Unit,
|
onShareClick: () -> Unit,
|
||||||
|
onSaveClick: () -> Unit,
|
||||||
onInfoClick: () -> Unit,
|
onInfoClick: () -> Unit,
|
||||||
eventSink: (MediaViewerEvent) -> Unit,
|
eventSink: (MediaViewerEvent) -> Unit,
|
||||||
) {
|
) {
|
||||||
|
|
@ -527,6 +531,15 @@ private fun MediaViewerTopBar(
|
||||||
contentDescription = stringResource(id = CommonStrings.action_share),
|
contentDescription = stringResource(id = CommonStrings.action_share),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
IconButton(
|
||||||
|
onClick = onSaveClick,
|
||||||
|
enabled = actionsEnabled,
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = CompoundIcons.Download(),
|
||||||
|
contentDescription = stringResource(id = CommonStrings.action_save),
|
||||||
|
)
|
||||||
|
}
|
||||||
if (canShowInfo) {
|
if (canShowInfo) {
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = onInfoClick,
|
onClick = onInfoClick,
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,18 @@ class MediaViewerViewTest {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `clicking on top action save emits expected Event`() {
|
||||||
|
val data = aMediaViewerPageData(
|
||||||
|
downloadedMedia = AsyncData.Success(aLocalMedia(uri = mockMediaUrl)),
|
||||||
|
)
|
||||||
|
testMenuAction(
|
||||||
|
data,
|
||||||
|
CommonStrings.action_save,
|
||||||
|
MediaViewerEvent.SaveOnDisk(data),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private fun testMenuAction(
|
private fun testMenuAction(
|
||||||
data: MediaViewerPageData.MediaViewerData,
|
data: MediaViewerPageData.MediaViewerData,
|
||||||
contentDescriptionRes: Int,
|
contentDescriptionRes: Int,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue