MediaViewer: add Share action as a main action.
This commit is contained in:
parent
54efb46294
commit
97ae775df5
2 changed files with 25 additions and 0 deletions
|
|
@ -214,6 +214,9 @@ fun MediaViewerView(
|
|||
data = currentData,
|
||||
canShowInfo = state.canShowInfo,
|
||||
onBackClick = onBackClick,
|
||||
onShareClick = {
|
||||
state.eventSink(MediaViewerEvent.Share(currentData))
|
||||
},
|
||||
onInfoClick = {
|
||||
state.eventSink(MediaViewerEvent.OpenInfo(currentData))
|
||||
},
|
||||
|
|
@ -457,6 +460,7 @@ private fun MediaViewerTopBar(
|
|||
data: MediaViewerPageData.MediaViewerData,
|
||||
canShowInfo: Boolean,
|
||||
onBackClick: () -> Unit,
|
||||
onShareClick: () -> Unit,
|
||||
onInfoClick: () -> Unit,
|
||||
eventSink: (MediaViewerEvent) -> Unit,
|
||||
) {
|
||||
|
|
@ -514,6 +518,15 @@ private fun MediaViewerTopBar(
|
|||
)
|
||||
}
|
||||
}
|
||||
IconButton(
|
||||
onClick = onShareClick,
|
||||
enabled = actionsEnabled,
|
||||
) {
|
||||
Icon(
|
||||
imageVector = CompoundIcons.ShareAndroid(),
|
||||
contentDescription = stringResource(id = CommonStrings.action_share),
|
||||
)
|
||||
}
|
||||
if (canShowInfo) {
|
||||
IconButton(
|
||||
onClick = onInfoClick,
|
||||
|
|
|
|||
|
|
@ -86,6 +86,18 @@ class MediaViewerViewTest {
|
|||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `clicking on top action share emits expected Event`() {
|
||||
val data = aMediaViewerPageData(
|
||||
downloadedMedia = AsyncData.Success(aLocalMedia(uri = mockMediaUrl)),
|
||||
)
|
||||
testMenuAction(
|
||||
data,
|
||||
CommonStrings.action_share,
|
||||
MediaViewerEvent.Share(data),
|
||||
)
|
||||
}
|
||||
|
||||
private fun testMenuAction(
|
||||
data: MediaViewerPageData.MediaViewerData,
|
||||
contentDescriptionRes: Int,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue