mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-20 19:42:35 +01:00
Fix download and overflow buttons getting pushed to the side
This commit is contained in:
@@ -7,8 +7,8 @@
|
||||
package ca.gosyer.ui.downloads
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.IntrinsicSize
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
@@ -16,7 +16,6 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.requiredWidth
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
@@ -94,20 +93,30 @@ private fun downloadsItem(
|
||||
onDownloadCancel: (Chapter?) -> Unit,
|
||||
onMoveDownloadToBottom: (Chapter?) -> Unit
|
||||
) {
|
||||
BoxWithConstraints {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
.height(56.dp)
|
||||
.padding(vertical = 8.dp),
|
||||
horizontalArrangement = Arrangement.SpaceAround
|
||||
) {
|
||||
Column(Modifier.fillMaxHeight(), verticalArrangement = Arrangement.SpaceAround) {
|
||||
Row(Modifier.fillMaxWidth().padding(horizontal = 32.dp), horizontalArrangement = Arrangement.SpaceBetween) {
|
||||
Text(chapter.chapter?.name.toString(), maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
Column(Modifier.fillMaxHeight().width(this@BoxWithConstraints.maxWidth - 46.dp).padding(horizontal = 32.dp), verticalArrangement = Arrangement.SpaceAround) {
|
||||
Row(
|
||||
Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text(
|
||||
chapter.chapter?.name.toString(),
|
||||
Modifier.width(this@BoxWithConstraints.maxWidth - 200.dp),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
|
||||
)
|
||||
// Spacer(Modifier.width(16.dp))
|
||||
if (chapter.chapter?.pageCount != null && chapter.chapter.pageCount != -1) {
|
||||
Text(
|
||||
"${(chapter.chapter.pageCount * chapter.progress).toInt()}/${chapter.chapter.pageCount}",
|
||||
Modifier.padding(start = 16.dp).requiredWidth(IntrinsicSize.Max),
|
||||
Modifier.padding(horizontal = 8.dp),
|
||||
style = MaterialTheme.typography.body2,
|
||||
color = LocalContentColor.current.copy(alpha = ContentAlpha.disabled),
|
||||
maxLines = 1,
|
||||
@@ -121,7 +130,7 @@ private fun downloadsItem(
|
||||
LinearProgressIndicator(
|
||||
chapter.progress,
|
||||
Modifier.fillMaxWidth()
|
||||
.padding(start = 32.dp, end = 16.dp, bottom = 8.dp)
|
||||
.padding(bottom = 8.dp)
|
||||
)
|
||||
}
|
||||
DropdownIconButton(
|
||||
@@ -141,4 +150,5 @@ private fun downloadsItem(
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,13 +8,15 @@ package ca.gosyer.ui.manga
|
||||
|
||||
import androidx.compose.foundation.BorderStroke
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.requiredSize
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.Card
|
||||
@@ -39,6 +41,7 @@ import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import ca.gosyer.data.download.model.DownloadChapter
|
||||
import ca.gosyer.data.download.model.DownloadState
|
||||
@@ -65,7 +68,7 @@ fun ChapterItem(
|
||||
elevation = 1.dp,
|
||||
shape = RoundedCornerShape(4.dp)
|
||||
) {
|
||||
Row(
|
||||
BoxWithConstraints(
|
||||
Modifier.combinedMouseClickable(
|
||||
onClick = {
|
||||
onClick(chapter.index)
|
||||
@@ -80,11 +83,13 @@ fun ChapterItem(
|
||||
menuItem("Toggle bookmarked") { toggleBookmarked(chapter.index) }
|
||||
}
|
||||
}
|
||||
),
|
||||
)
|
||||
) {
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Column(
|
||||
Modifier.padding(4.dp)
|
||||
Modifier.padding(4.dp).width(this@BoxWithConstraints.maxWidth - 60.dp)
|
||||
) {
|
||||
Text(
|
||||
chapter.name,
|
||||
@@ -92,7 +97,8 @@ fun ChapterItem(
|
||||
style = MaterialTheme.typography.h6,
|
||||
color = LocalContentColor.current.copy(
|
||||
alpha = if (chapter.read) ContentAlpha.disabled else ContentAlpha.high
|
||||
)
|
||||
),
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
val subtitleStr = buildAnnotatedString {
|
||||
if (chapter.uploadDate > 0) {
|
||||
@@ -125,10 +131,16 @@ fun ChapterItem(
|
||||
|
||||
when (downloadState) {
|
||||
MangaMenuViewModel.DownloadState.Downloaded -> {
|
||||
DownloadedIconButton(chapter.mangaId to chapter.index, onClick = { deleteDownload(chapter.index) })
|
||||
DownloadedIconButton(
|
||||
chapter.mangaId to chapter.index,
|
||||
onClick = { deleteDownload(chapter.index) }
|
||||
)
|
||||
}
|
||||
MangaMenuViewModel.DownloadState.Downloading -> {
|
||||
DownloadingIconButton(downloadChapter, onClick = { stopDownload(chapter.index) })
|
||||
DownloadingIconButton(
|
||||
downloadChapter,
|
||||
onClick = { stopDownload(chapter.index) }
|
||||
)
|
||||
}
|
||||
MangaMenuViewModel.DownloadState.NotDownloaded -> {
|
||||
DownloadIconButton(onClick = { downloadAChapter(chapter.index) })
|
||||
@@ -136,6 +148,7 @@ fun ChapterItem(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -152,7 +165,7 @@ private fun DownloadIconButton(onClick: () -> Unit) {
|
||||
Icons.Default.ArrowDownward,
|
||||
null,
|
||||
Modifier
|
||||
.requiredSize(22.dp)
|
||||
.size(22.dp)
|
||||
.padding(2.dp),
|
||||
LocalContentColor.current.copy(alpha = ContentAlpha.disabled)
|
||||
)
|
||||
@@ -173,7 +186,7 @@ private fun DownloadingIconButton(downloadChapter: DownloadChapter?, onClick: ()
|
||||
when (downloadChapter?.state) {
|
||||
null, DownloadState.Queued -> CircularProgressIndicator(
|
||||
Modifier
|
||||
.requiredSize(26.dp)
|
||||
.size(26.dp)
|
||||
.padding(2.dp),
|
||||
LocalContentColor.current.copy(alpha = ContentAlpha.disabled),
|
||||
2.dp
|
||||
@@ -182,7 +195,7 @@ private fun DownloadingIconButton(downloadChapter: DownloadChapter?, onClick: ()
|
||||
CircularProgressIndicator(
|
||||
downloadChapter.progress,
|
||||
Modifier
|
||||
.requiredSize(26.dp)
|
||||
.size(26.dp)
|
||||
.padding(2.dp),
|
||||
LocalContentColor.current.copy(alpha = ContentAlpha.disabled),
|
||||
2.dp
|
||||
@@ -191,14 +204,14 @@ private fun DownloadingIconButton(downloadChapter: DownloadChapter?, onClick: ()
|
||||
Icons.Default.ArrowDownward,
|
||||
null,
|
||||
Modifier
|
||||
.requiredSize(22.dp)
|
||||
.size(22.dp)
|
||||
.padding(2.dp),
|
||||
LocalContentColor.current.copy(alpha = ContentAlpha.disabled)
|
||||
)
|
||||
} else {
|
||||
CircularProgressIndicator(
|
||||
Modifier
|
||||
.requiredSize(26.dp)
|
||||
.size(26.dp)
|
||||
.padding(2.dp),
|
||||
LocalContentColor.current.copy(alpha = ContentAlpha.disabled),
|
||||
2.dp
|
||||
@@ -209,7 +222,7 @@ private fun DownloadingIconButton(downloadChapter: DownloadChapter?, onClick: ()
|
||||
Icons.Default.Error,
|
||||
null,
|
||||
Modifier
|
||||
.requiredSize(22.dp)
|
||||
.size(22.dp)
|
||||
.padding(2.dp),
|
||||
Color.Red
|
||||
)
|
||||
@@ -219,7 +232,7 @@ private fun DownloadingIconButton(downloadChapter: DownloadChapter?, onClick: ()
|
||||
Icons.Default.Check,
|
||||
null,
|
||||
Modifier
|
||||
.requiredSize(22.dp)
|
||||
.size(22.dp)
|
||||
.padding(2.dp),
|
||||
MaterialTheme.colors.surface
|
||||
)
|
||||
@@ -243,7 +256,7 @@ private fun DownloadedIconButton(chapter: Pair<Long, Int?>, onClick: () -> Unit)
|
||||
Icons.Default.Check,
|
||||
null,
|
||||
Modifier
|
||||
.requiredSize(22.dp)
|
||||
.size(22.dp)
|
||||
.padding(2.dp),
|
||||
MaterialTheme.colors.surface
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user