Compare commits

2 Commits

Author SHA1 Message Date
acite
b360724dca [fix] Chapter progress 2025-10-02 01:34:09 +08:00
acite
db8d5ef4d5 [fix] Cover height meansure 2025-10-02 01:20:13 +08:00
3 changed files with 124 additions and 108 deletions

View File

@@ -95,9 +95,10 @@ fun ComicGridView(
} }
} }
LaunchedEffect(Unit) { LaunchedEffect(comicGridViewModel) {
comicGridViewModel.coverHeight = screenHeight * 0.4f comicGridViewModel.coverHeight = screenHeight * 0.4f
comicGridViewModel.maxHeight = screenHeight * 0.8f if(comicGridViewModel.maxHeight == 0.dp)
comicGridViewModel.maxHeight = screenHeight * 0.8f
} }
val dens = LocalDensity.current val dens = LocalDensity.current

View File

@@ -5,15 +5,18 @@ import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically import androidx.compose.animation.slideOutVertically
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
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.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxHeight
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
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.LazyRow
@@ -36,7 +39,9 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView import androidx.compose.ui.platform.LocalView
@@ -50,6 +55,7 @@ import coil3.compose.AsyncImage
import coil3.request.ImageRequest import coil3.request.ImageRequest
import com.acitelight.aether.model.BookMark import com.acitelight.aether.model.BookMark
import com.acitelight.aether.setFullScreen import com.acitelight.aether.setFullScreen
import com.acitelight.aether.view.components.BiliMiniSlider
import com.acitelight.aether.view.components.BookmarkPop import com.acitelight.aether.view.components.BookmarkPop
import com.acitelight.aether.viewModel.ComicPageViewModel import com.acitelight.aether.viewModel.ComicPageViewModel
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@@ -92,13 +98,17 @@ fun ComicPageView(
.fillMaxSize() .fillMaxSize()
.align(Alignment.Center) .align(Alignment.Center)
.background(Color.Black) .background(Color.Black)
.clickable { .pointerInput(Unit) {
showPlane = !showPlane detectTapGestures(
if (showPlane) { onTap = {
comicPageViewModel.viewModelScope.launch { showPlane = !showPlane
comicPageViewModel.listState?.scrollToItem(index = pagerState.currentPage) if (showPlane) {
comicPageViewModel.viewModelScope.launch {
comicPageViewModel.listState?.scrollToItem(index = pagerState.currentPage)
}
}
} }
} )
} }
) { page -> ) { page ->
AsyncImage( AsyncImage(
@@ -123,110 +133,103 @@ fun ComicPageView(
modifier = Modifier modifier = Modifier
.align(Alignment.TopCenter) .align(Alignment.TopCenter)
) { ) {
Box() Column(Modifier
{ .align(Alignment.TopCenter)
Column(Modifier .fillMaxWidth()
.align(Alignment.TopCenter) .background(
.fillMaxWidth()) brush = Brush.verticalGradient(
{ colors = listOf(
Card( Color.Black.copy(alpha = 0.9f),
colors = CardDefaults.cardColors(containerColor = colorScheme.primary), Color.Transparent,
shape = RoundedCornerShape(12.dp), )
modifier = Modifier )
.fillMaxWidth() ))
.padding(top = 18.dp) {
.padding(horizontal = 12.dp) Row(modifier = Modifier
.height(42.dp) .fillMaxWidth()
.padding(horizontal = 16.dp).padding(top = 16.dp))
{
Text(
text = title,
fontSize = 16.sp,
lineHeight = 19.sp,
fontWeight = FontWeight.Bold,
maxLines = 1,
color = Color.White,
modifier = Modifier
.padding(8.dp)
.padding(horizontal = 10.dp)
.weight(1f)
.align(Alignment.CenterVertically)
) )
{
Row(modifier = Modifier.fillMaxSize())
{
Text(
text = title,
fontSize = 16.sp,
fontWeight = FontWeight.Bold,
maxLines = 1,
modifier = Modifier
.padding(8.dp)
.padding(horizontal = 10.dp)
.weight(1f)
.align(Alignment.CenterVertically)
)
Text( Text(
text = "${pagerState.currentPage + 1}/${pagerState.pageCount}", text = "${pagerState.currentPage + 1}/${pagerState.pageCount}",
fontSize = 18.sp, fontSize = 16.sp,
fontWeight = FontWeight.Bold, lineHeight = 19.sp,
maxLines = 1, fontWeight = FontWeight.Bold,
modifier = Modifier maxLines = 1,
.padding(8.dp) color = Color.White,
.widthIn(min = 60.dp) modifier = Modifier
.align(Alignment.CenterVertically) .padding(8.dp)
) .widthIn(min = 60.dp)
} .align(Alignment.CenterVertically)
)
}
Box(Modifier.fillMaxWidth()
.padding(horizontal = 16.dp))
{
Row {
val k = it.getPageChapterIndex(pagerState.currentPage)
Text(
text = k.first.name,
fontSize = 16.sp,
fontWeight = FontWeight.Bold,
maxLines = 1,
color = Color.White,
modifier = Modifier
.padding(8.dp)
.padding(horizontal = 10.dp)
.align(Alignment.CenterVertically)
)
Text(
text = "${k.second}/${it.getChapterLength(k.first.page)}",
fontSize = 18.sp,
fontWeight = FontWeight.Bold,
maxLines = 1,
color = Color.White,
modifier = Modifier
.padding(8.dp)
.widthIn(min = 60.dp)
.align(Alignment.CenterVertically)
)
} }
Box(Modifier.fillMaxWidth()) {
Card(
modifier = Modifier
.align(Alignment.CenterStart)
.padding(top = 6.dp)
.padding(horizontal = 12.dp)
.height(42.dp),
colors = CardDefaults.cardColors(containerColor = colorScheme.primary),
shape = RoundedCornerShape(12.dp)
)
{
Row {
val k = it.getPageChapterIndex(pagerState.currentPage)
Text(
text = k.first.name,
fontSize = 16.sp,
fontWeight = FontWeight.Bold,
maxLines = 1,
modifier = Modifier
.padding(8.dp)
.padding(horizontal = 10.dp)
.align(Alignment.CenterVertically)
)
Text( Card(
text = "${k.second}/${it.getChapterLength(k.first.page)}", modifier = Modifier
fontSize = 18.sp, .align(Alignment.CenterEnd)
fontWeight = FontWeight.Bold, .padding(top = 6.dp)
maxLines = 1, .padding(horizontal = 12.dp)
modifier = Modifier .height(42.dp),
.padding(8.dp) colors = CardDefaults.cardColors(containerColor = colorScheme.surface),
.widthIn(min = 60.dp) shape = RoundedCornerShape(12.dp)
.align(Alignment.CenterVertically) )
) {
} Box(Modifier.clickable {
} showBookMarkPop = true
}) {
Icon(
Card( Icons.Filled.Bookmarks,
modifier = Modifier modifier = Modifier
.align(Alignment.CenterEnd) .padding(8.dp),
.padding(top = 6.dp) contentDescription = "Bookmark"
.padding(horizontal = 12.dp) )
.height(42.dp),
colors = CardDefaults.cardColors(containerColor = colorScheme.primary),
shape = RoundedCornerShape(12.dp)
)
{
Box(Modifier.clickable {
showBookMarkPop = true
}) {
Icon(
Icons.Filled.Bookmarks,
modifier = Modifier
.padding(8.dp),
contentDescription = "Bookmark"
)
}
} }
} }
} }
Spacer(Modifier.height(64.dp))
} }
} }
@@ -238,15 +241,16 @@ fun ComicPageView(
.align(Alignment.BottomCenter) .align(Alignment.BottomCenter)
) )
{ {
Box { val k = it.getPageChapterIndex(pagerState.currentPage)
Column(Modifier
.padding(bottom = 24.dp)) {
LazyRow( LazyRow(
horizontalArrangement = Arrangement.spacedBy(5.dp), horizontalArrangement = Arrangement.spacedBy(5.dp),
state = comicPageViewModel.listState!!, modifier = Modifier state = comicPageViewModel.listState!!, modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(bottom = 18.dp) .padding(bottom = 1.dp)
.padding(horizontal = 12.dp) .padding(horizontal = 12.dp)
.height(180.dp) .height(180.dp)
.align(Alignment.BottomCenter)
) )
{ {
items(comicPageViewModel.pageList.size) items(comicPageViewModel.pageList.size)
@@ -306,6 +310,17 @@ fun ComicPageView(
} }
} }
} }
BiliMiniSlider(
value = (k.second.toInt()) / it.getChapterLength(k.first.page).toFloat(),
modifier = Modifier
.height(6.dp)
.fillMaxWidth().padding(horizontal = 24.dp)
.fillMaxWidth(),
onValueChange = {
}
)
} }
} }
} }

View File

@@ -32,7 +32,7 @@ class ComicGridViewModel @Inject constructor(
) : ViewModel() ) : ViewModel()
{ {
var coverHeight by mutableStateOf(220.dp) var coverHeight by mutableStateOf(220.dp)
var maxHeight = 220.dp var maxHeight = 0.dp
var imageLoader: ImageLoader? = null var imageLoader: ImageLoader? = null
var comic = mutableStateOf<Comic?>(null) var comic = mutableStateOf<Comic?>(null)