MediaViewer: add Share action as a main action.
This commit is contained in:
parent
5d8b9ef56c
commit
6342b925d5
2 changed files with 25 additions and 0 deletions
|
|
@ -214,6 +214,9 @@ fun MediaViewerView(
|
||||||
data = currentData,
|
data = currentData,
|
||||||
canShowInfo = state.canShowInfo,
|
canShowInfo = state.canShowInfo,
|
||||||
onBackClick = onBackClick,
|
onBackClick = onBackClick,
|
||||||
|
onShareClick = {
|
||||||
|
state.eventSink(MediaViewerEvent.Share(currentData))
|
||||||
|
},
|
||||||
onInfoClick = {
|
onInfoClick = {
|
||||||
state.eventSink(MediaViewerEvent.OpenInfo(currentData))
|
state.eventSink(MediaViewerEvent.OpenInfo(currentData))
|
||||||
},
|
},
|
||||||
|
|
@ -457,6 +460,7 @@ private fun MediaViewerTopBar(
|
||||||
data: MediaViewerPageData.MediaViewerData,
|
data: MediaViewerPageData.MediaViewerData,
|
||||||
canShowInfo: Boolean,
|
canShowInfo: Boolean,
|
||||||
onBackClick: () -> Unit,
|
onBackClick: () -> Unit,
|
||||||
|
onShareClick: () -> Unit,
|
||||||
onInfoClick: () -> Unit,
|
onInfoClick: () -> Unit,
|
||||||
eventSink: (MediaViewerEvent) -> 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) {
|
if (canShowInfo) {
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = onInfoClick,
|
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(
|
private fun testMenuAction(
|
||||||
data: MediaViewerPageData.MediaViewerData,
|
data: MediaViewerPageData.MediaViewerData,
|
||||||
contentDescriptionRes: Int,
|
contentDescriptionRes: Int,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue