Skip to content

Commit 9c02c4c

Browse files
committed
MediaViewer: Align title to left and move action bottom to top bar.
1 parent 317931d commit 9c02c4c

File tree

1 file changed

+36
-54
lines changed
  • libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/viewer

1 file changed

+36
-54
lines changed

libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/viewer/MediaViewerView.kt

Lines changed: 36 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ import androidx.compose.animation.fadeOut
1717
import androidx.compose.foundation.background
1818
import androidx.compose.foundation.layout.Box
1919
import androidx.compose.foundation.layout.Column
20-
import androidx.compose.foundation.layout.Row
21-
import androidx.compose.foundation.layout.Spacer
2220
import androidx.compose.foundation.layout.fillMaxSize
2321
import androidx.compose.foundation.layout.fillMaxWidth
2422
import androidx.compose.foundation.layout.height
@@ -117,20 +115,18 @@ fun MediaViewerView(
117115
) {
118116
MediaViewerTopBar(
119117
actionsEnabled = state.downloadedMedia is AsyncData.Success,
118+
canDownload = state.canDownload,
119+
canShare = state.canShare,
120+
mimeType = state.mediaInfo.mimeType,
120121
senderName = state.mediaInfo.senderName,
121122
dateSent = state.mediaInfo.dateSent,
122123
onBackClick = onBackClick,
123124
eventSink = state.eventSink
124125
)
125126
MediaViewerBottomBar(
126127
modifier = Modifier.align(Alignment.BottomCenter),
127-
actionsEnabled = state.downloadedMedia is AsyncData.Success,
128-
canDownload = state.canDownload,
129-
canShare = state.canShare,
130-
mimeType = state.mediaInfo.mimeType,
131128
caption = state.mediaInfo.caption,
132129
onHeightChange = { bottomPaddingInPixels = it },
133-
eventSink = state.eventSink
134130
)
135131
}
136132
}
@@ -276,11 +272,13 @@ private fun rememberShowProgress(downloadedMedia: AsyncData<LocalMedia>): Boolea
276272
return showProgress
277273
}
278274

279-
@Suppress("UNUSED_PARAMETER")
280275
@OptIn(ExperimentalMaterial3Api::class)
281276
@Composable
282277
private fun MediaViewerTopBar(
283278
actionsEnabled: Boolean,
279+
canDownload: Boolean,
280+
canShare: Boolean,
281+
mimeType: String,
284282
senderName: String?,
285283
dateSent: String?,
286284
onBackClick: () -> Unit,
@@ -292,8 +290,6 @@ private fun MediaViewerTopBar(
292290
Column(
293291
modifier = Modifier
294292
.fillMaxWidth()
295-
.padding(end = 48.dp),
296-
horizontalAlignment = Alignment.CenterHorizontally,
297293
) {
298294
Text(
299295
text = senderName,
@@ -313,63 +309,19 @@ private fun MediaViewerTopBar(
313309
),
314310
navigationIcon = { BackButton(onClick = onBackClick) },
315311
actions = {
316-
// TODO Add action to open infos.
317-
}
318-
)
319-
}
320-
321-
@Composable
322-
private fun MediaViewerBottomBar(
323-
actionsEnabled: Boolean,
324-
canDownload: Boolean,
325-
canShare: Boolean,
326-
mimeType: String,
327-
caption: String?,
328-
onHeightChange: (Int) -> Unit,
329-
eventSink: (MediaViewerEvents) -> Unit,
330-
modifier: Modifier = Modifier,
331-
) {
332-
Column(
333-
modifier = modifier
334-
.fillMaxWidth()
335-
.background(Color(0x99101317))
336-
.onSizeChanged {
337-
onHeightChange(it.height)
338-
},
339-
) {
340-
HorizontalDivider()
341-
if (caption != null) {
342-
Text(
343-
modifier = Modifier
344-
.fillMaxWidth()
345-
.padding(16.dp),
346-
text = caption,
347-
maxLines = 5,
348-
overflow = TextOverflow.Ellipsis,
349-
style = ElementTheme.typography.fontBodyLgRegular,
350-
)
351-
}
352-
Row(
353-
modifier = Modifier
354-
.fillMaxWidth()
355-
.padding(start = 8.dp, end = 8.dp, bottom = 8.dp),
356-
verticalAlignment = Alignment.CenterVertically,
357-
) {
358312
if (canShare) {
359313
IconButton(
360314
enabled = actionsEnabled,
361315
onClick = {
362316
eventSink(MediaViewerEvents.Share)
363317
},
364-
modifier = Modifier.align(Alignment.CenterVertically)
365318
) {
366319
Icon(
367320
imageVector = CompoundIcons.ShareAndroid(),
368321
contentDescription = stringResource(id = CommonStrings.action_share)
369322
)
370323
}
371324
}
372-
Spacer(modifier = Modifier.weight(1f))
373325
IconButton(
374326
enabled = actionsEnabled,
375327
onClick = {
@@ -400,6 +352,36 @@ private fun MediaViewerBottomBar(
400352
)
401353
}
402354
}
355+
// TODO Add action to open infos.
356+
}
357+
)
358+
}
359+
360+
@Composable
361+
private fun MediaViewerBottomBar(
362+
caption: String?,
363+
onHeightChange: (Int) -> Unit,
364+
modifier: Modifier = Modifier,
365+
) {
366+
Column(
367+
modifier = modifier
368+
.fillMaxWidth()
369+
.background(Color(0x99101317))
370+
.onSizeChanged {
371+
onHeightChange(it.height)
372+
},
373+
) {
374+
HorizontalDivider()
375+
if (caption != null) {
376+
Text(
377+
modifier = Modifier
378+
.fillMaxWidth()
379+
.padding(16.dp),
380+
text = caption,
381+
maxLines = 5,
382+
overflow = TextOverflow.Ellipsis,
383+
style = ElementTheme.typography.fontBodyLgRegular,
384+
)
403385
}
404386
}
405387
}

0 commit comments

Comments
 (0)