[fix&optimize] Fix the issue of element teleportation in ComicScreen pages

This commit is contained in:
acite
2025-10-02 12:24:26 +08:00
parent b360724dca
commit 390094b8b0
6 changed files with 49 additions and 32 deletions

View File

@@ -64,11 +64,11 @@ fun ComicCard(
.diskCacheKey("${comic.id}/cover") .diskCacheKey("${comic.id}/cover")
.build(), .build(),
contentDescription = null, contentDescription = null,
imageLoader = comicScreenViewModel.imageLoader!!,
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
.clip(RoundedCornerShape(8.dp)), .clip(RoundedCornerShape(8.dp)),
contentScale = ContentScale.Crop, contentScale = ContentScale.Fit,
imageLoader = comicScreenViewModel.imageLoader!!,
) )
Box( Box(
@@ -100,22 +100,21 @@ fun ComicCard(
} }
Text( Text(
text = comic.comic.comic_name, text = comic.comic.comic_name,
fontSize = 14.sp,
lineHeight = 17.sp,
fontWeight = FontWeight.Bold,
maxLines = 2,
modifier = Modifier.padding(4.dp)
)
Box(Modifier.padding(4.dp).fillMaxWidth()){
Text(
text = "Id: ${comic.id}",
fontSize = 12.sp, fontSize = 12.sp,
lineHeight = 14.sp, lineHeight = 14.sp,
maxLines = 1, fontWeight = FontWeight.Bold,
modifier = Modifier.align(Alignment.CenterStart) maxLines = 2,
modifier = Modifier
.padding(4.dp)
.heightIn(min = 14.dp)
)
Text(
text = "Id: ${comic.id}",
fontSize = 10.sp,
lineHeight = 12.sp,
maxLines = 1,
modifier = Modifier.padding(4.dp)
) )
}
} }
} }
} }

View File

@@ -229,7 +229,9 @@ fun VideoPlayerLandscape(videoPlayerViewModel: VideoPlayerViewModel) {
} }
} }
}, },
modifier = Modifier.fillMaxWidth() modifier = Modifier
.align(Alignment.Center)
.fillMaxWidth()
) )
} }

View File

@@ -96,7 +96,7 @@ fun ComicGridView(
} }
LaunchedEffect(comicGridViewModel) { LaunchedEffect(comicGridViewModel) {
comicGridViewModel.coverHeight = screenHeight * 0.4f comicGridViewModel.coverHeight = screenHeight * 0.3f
if(comicGridViewModel.maxHeight == 0.dp) if(comicGridViewModel.maxHeight == 0.dp)
comicGridViewModel.maxHeight = screenHeight * 0.8f comicGridViewModel.maxHeight = screenHeight * 0.8f
} }
@@ -252,7 +252,7 @@ fun ComicGridView(
fontSize = 11.sp, fontSize = 11.sp,
lineHeight = 15.sp, lineHeight = 15.sp,
maxLines = 3, maxLines = 3,
modifier = Modifier.padding(horizontal = 16.dp).padding(bottom = 4.dp) modifier = Modifier.padding(horizontal = 16.dp).padding(bottom = 4.dp).align(Alignment.CenterStart)
) )
Button(onClick = { Button(onClick = {
@@ -379,10 +379,10 @@ fun ChapterCard(
{ {
Text( Text(
text = chapter.name, text = chapter.name,
fontSize = 14.sp, fontSize = 16.sp,
fontWeight = FontWeight.Bold, fontWeight = FontWeight.Bold,
maxLines = 2, maxLines = 2,
lineHeight = 16.sp, lineHeight = 18.sp,
modifier = Modifier modifier = Modifier
.padding(horizontal = 8.dp).padding(vertical = 4.dp) .padding(horizontal = 8.dp).padding(vertical = 4.dp)
.background(Color.Transparent) .background(Color.Transparent)
@@ -391,7 +391,6 @@ fun ChapterCard(
text = "${comic.getChapterLength(chapter.page)} Pages", text = "${comic.getChapterLength(chapter.page)} Pages",
fontSize = 14.sp, fontSize = 14.sp,
lineHeight = 16.sp, lineHeight = 16.sp,
fontWeight = FontWeight.Bold,
maxLines = 1, maxLines = 1,
modifier = Modifier modifier = Modifier
.padding(horizontal = 8.dp) .padding(horizontal = 8.dp)

View File

@@ -243,7 +243,15 @@ fun ComicPageView(
{ {
val k = it.getPageChapterIndex(pagerState.currentPage) val k = it.getPageChapterIndex(pagerState.currentPage)
Column(Modifier Column(Modifier
.padding(bottom = 24.dp)) { .background(
brush = Brush.verticalGradient(
colors = listOf(
Color.Transparent,
Color.Black.copy(alpha = 0.9f),
)
)
)) {
Spacer(Modifier.height(42.dp))
LazyRow( LazyRow(
horizontalArrangement = Arrangement.spacedBy(5.dp), horizontalArrangement = Arrangement.spacedBy(5.dp),
state = comicPageViewModel.listState!!, modifier = Modifier state = comicPageViewModel.listState!!, modifier = Modifier
@@ -266,7 +274,7 @@ fun ComicPageView(
pagerState.requestScrollToPage(page = r) pagerState.requestScrollToPage(page = r)
} }
) { ) {
Box(Modifier.padding(1.dp)) Box(Modifier.padding(0.dp))
{ {
AsyncImage( AsyncImage(
model = ImageRequest.Builder(LocalContext.current) model = ImageRequest.Builder(LocalContext.current)
@@ -321,6 +329,9 @@ fun ComicPageView(
} }
) )
Spacer(Modifier.height(24.dp))
} }
} }
} }

View File

@@ -133,9 +133,11 @@ fun ComicScreen(
var searchFilter by comicScreenViewModel.searchFilter var searchFilter by comicScreenViewModel.searchFilter
Column { Column {
Row(Modifier Row(
Modifier
.padding(4.dp) .padding(4.dp)
.align(Alignment.CenterHorizontally)) { .align(Alignment.CenterHorizontally)
) {
Text( Text(
text = "Comics", text = "Comics",
style = MaterialTheme.typography.headlineMedium, style = MaterialTheme.typography.headlineMedium,
@@ -189,7 +191,8 @@ fun ComicScreen(
if (included.contains(i)) Color.Green.copy(alpha = 0.65f) else colorScheme.surface, if (included.contains(i)) Color.Green.copy(alpha = 0.65f) else colorScheme.surface,
shape = RoundedCornerShape(4.dp) shape = RoundedCornerShape(4.dp)
) )
.height(32.dp).widthIn(max = 72.dp) .height(32.dp)
.widthIn(max = 72.dp)
.clickable { .clickable {
if (included.contains(i)) if (included.contains(i))
included.remove(i) included.remove(i)
@@ -221,12 +224,15 @@ fun ComicScreen(
modifier = Modifier.fillMaxSize() modifier = Modifier.fillMaxSize()
) { ) {
items( items(
items = comicScreenViewModel.comics.filter { searchFilter.isEmpty() || searchFilter in it.comic.comic_name }.filter { x -> items = comicScreenViewModel.comics
.filter { searchFilter.isEmpty() || searchFilter in it.comic.comic_name }
.filter { x ->
included.all { y -> y in x.comic.tags } || included.isEmpty() included.all { y -> y in x.comic.tags } || included.isEmpty()
}, },
key = { it.id } key = { it.id }
) { comic -> ) { comic ->
Box(modifier = Modifier Box(
modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.wrapContentHeight() .wrapContentHeight()
) { ) {