MediaViewer: Align title to left and move action bottom to top bar.
This commit is contained in:
parent
8cf60bf2f7
commit
2c6b4e31b9
1 changed files with 36 additions and 54 deletions
|
|
@ -17,8 +17,6 @@ import androidx.compose.animation.fadeOut
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
|
||||||
import androidx.compose.foundation.layout.Spacer
|
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
|
|
@ -117,6 +115,9 @@ fun MediaViewerView(
|
||||||
) {
|
) {
|
||||||
MediaViewerTopBar(
|
MediaViewerTopBar(
|
||||||
actionsEnabled = state.downloadedMedia is AsyncData.Success,
|
actionsEnabled = state.downloadedMedia is AsyncData.Success,
|
||||||
|
canDownload = state.canDownload,
|
||||||
|
canShare = state.canShare,
|
||||||
|
mimeType = state.mediaInfo.mimeType,
|
||||||
senderName = state.mediaInfo.senderName,
|
senderName = state.mediaInfo.senderName,
|
||||||
dateSent = state.mediaInfo.dateSent,
|
dateSent = state.mediaInfo.dateSent,
|
||||||
onBackClick = onBackClick,
|
onBackClick = onBackClick,
|
||||||
|
|
@ -124,13 +125,8 @@ fun MediaViewerView(
|
||||||
)
|
)
|
||||||
MediaViewerBottomBar(
|
MediaViewerBottomBar(
|
||||||
modifier = Modifier.align(Alignment.BottomCenter),
|
modifier = Modifier.align(Alignment.BottomCenter),
|
||||||
actionsEnabled = state.downloadedMedia is AsyncData.Success,
|
|
||||||
canDownload = state.canDownload,
|
|
||||||
canShare = state.canShare,
|
|
||||||
mimeType = state.mediaInfo.mimeType,
|
|
||||||
caption = state.mediaInfo.caption,
|
caption = state.mediaInfo.caption,
|
||||||
onHeightChange = { bottomPaddingInPixels = it },
|
onHeightChange = { bottomPaddingInPixels = it },
|
||||||
eventSink = state.eventSink
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -276,11 +272,13 @@ private fun rememberShowProgress(downloadedMedia: AsyncData<LocalMedia>): Boolea
|
||||||
return showProgress
|
return showProgress
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("UNUSED_PARAMETER")
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
private fun MediaViewerTopBar(
|
private fun MediaViewerTopBar(
|
||||||
actionsEnabled: Boolean,
|
actionsEnabled: Boolean,
|
||||||
|
canDownload: Boolean,
|
||||||
|
canShare: Boolean,
|
||||||
|
mimeType: String,
|
||||||
senderName: String?,
|
senderName: String?,
|
||||||
dateSent: String?,
|
dateSent: String?,
|
||||||
onBackClick: () -> Unit,
|
onBackClick: () -> Unit,
|
||||||
|
|
@ -292,8 +290,6 @@ private fun MediaViewerTopBar(
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(end = 48.dp),
|
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = senderName,
|
text = senderName,
|
||||||
|
|
@ -313,55 +309,12 @@ private fun MediaViewerTopBar(
|
||||||
),
|
),
|
||||||
navigationIcon = { BackButton(onClick = onBackClick) },
|
navigationIcon = { BackButton(onClick = onBackClick) },
|
||||||
actions = {
|
actions = {
|
||||||
// TODO Add action to open infos.
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun MediaViewerBottomBar(
|
|
||||||
actionsEnabled: Boolean,
|
|
||||||
canDownload: Boolean,
|
|
||||||
canShare: Boolean,
|
|
||||||
mimeType: String,
|
|
||||||
caption: String?,
|
|
||||||
onHeightChange: (Int) -> Unit,
|
|
||||||
eventSink: (MediaViewerEvents) -> Unit,
|
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
) {
|
|
||||||
Column(
|
|
||||||
modifier = modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.background(Color(0x99101317))
|
|
||||||
.onSizeChanged {
|
|
||||||
onHeightChange(it.height)
|
|
||||||
},
|
|
||||||
) {
|
|
||||||
HorizontalDivider()
|
|
||||||
if (caption != null) {
|
|
||||||
Text(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.padding(16.dp),
|
|
||||||
text = caption,
|
|
||||||
maxLines = 5,
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
style = ElementTheme.typography.fontBodyLgRegular,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Row(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.padding(start = 8.dp, end = 8.dp, bottom = 8.dp),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
) {
|
|
||||||
if (canShare) {
|
if (canShare) {
|
||||||
IconButton(
|
IconButton(
|
||||||
enabled = actionsEnabled,
|
enabled = actionsEnabled,
|
||||||
onClick = {
|
onClick = {
|
||||||
eventSink(MediaViewerEvents.Share)
|
eventSink(MediaViewerEvents.Share)
|
||||||
},
|
},
|
||||||
modifier = Modifier.align(Alignment.CenterVertically)
|
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = CompoundIcons.ShareAndroid(),
|
imageVector = CompoundIcons.ShareAndroid(),
|
||||||
|
|
@ -369,7 +322,6 @@ private fun MediaViewerBottomBar(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
|
||||||
IconButton(
|
IconButton(
|
||||||
enabled = actionsEnabled,
|
enabled = actionsEnabled,
|
||||||
onClick = {
|
onClick = {
|
||||||
|
|
@ -400,6 +352,36 @@ private fun MediaViewerBottomBar(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// TODO Add action to open infos.
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun MediaViewerBottomBar(
|
||||||
|
caption: String?,
|
||||||
|
onHeightChange: (Int) -> Unit,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.background(Color(0x99101317))
|
||||||
|
.onSizeChanged {
|
||||||
|
onHeightChange(it.height)
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
HorizontalDivider()
|
||||||
|
if (caption != null) {
|
||||||
|
Text(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(16.dp),
|
||||||
|
text = caption,
|
||||||
|
maxLines = 5,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
style = ElementTheme.typography.fontBodyLgRegular,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue