[update] ui patch

This commit is contained in:
rootacite
2025-11-01 03:28:13 +08:00
parent 9efbcdfe8a
commit 512da7be1c
6 changed files with 88 additions and 140 deletions

View File

@@ -16,7 +16,8 @@ class VideoDownloadItemState(
totalBytes: Long, totalBytes: Long,
klass: String, klass: String,
vid: String, vid: String,
val type: String val type: String,
val group: String
) { ) {
var fileName by mutableStateOf(fileName) var fileName by mutableStateOf(fileName)
var filePath by mutableStateOf(filePath) var filePath by mutableStateOf(filePath)

View File

@@ -133,6 +133,7 @@ class FetchManager @Inject constructor(
"name" to video.video.name, "name" to video.video.name,
"id" to video.id, "id" to video.id,
"class" to video.klass, "class" to video.klass,
"group" to (video.video.group ?: ""),
"type" to "main" "type" to "main"
) )
) )
@@ -143,6 +144,7 @@ class FetchManager @Inject constructor(
"name" to video.video.name, "name" to video.video.name,
"id" to video.id, "id" to video.id,
"class" to video.klass, "class" to video.klass,
"group" to (video.video.group ?: ""),
"type" to "cover" "type" to "cover"
) )
) )
@@ -153,6 +155,7 @@ class FetchManager @Inject constructor(
"name" to video.video.name, "name" to video.video.name,
"id" to video.id, "id" to video.id,
"class" to video.klass, "class" to video.klass,
"group" to (video.video.group ?: ""),
"type" to "subtitle" "type" to "subtitle"
) )
) )
@@ -169,6 +172,7 @@ class FetchManager @Inject constructor(
"name" to video.video.name, "name" to video.video.name,
"id" to video.id, "id" to video.id,
"class" to video.klass, "class" to video.klass,
"group" to (video.video.group ?: ""),
"type" to "gallery" "type" to "gallery"
) )
) )

View File

@@ -152,9 +152,8 @@ fun ComicScreen(
Column( Column(
modifier = Modifier.animateContentSize() modifier = Modifier.animateContentSize()
) { ) {
Row( Row(Modifier
Modifier .padding(horizontal = 8.dp).padding(top = 4.dp)
.padding(4.dp)
.align(Alignment.CenterHorizontally) .align(Alignment.CenterHorizontally)
) )
{ {
@@ -196,7 +195,11 @@ fun ComicScreen(
} }
} }
Row { Row(Modifier
.padding(horizontal = 8.dp)
.align(Alignment.CenterHorizontally)
)
{
Text( Text(
text = "Sorted by: ", text = "Sorted by: ",
fontWeight = FontWeight.Bold, fontWeight = FontWeight.Bold,
@@ -264,12 +267,11 @@ fun ComicScreen(
VariableGrid( VariableGrid(
modifier = Modifier modifier = Modifier
.heightIn(max = 80.dp) .heightIn(max = 80.dp)
.padding(4.dp), .padding(3.dp),
rowHeight = 30.dp rowHeight = 30.dp
) )
{ {
for (i in comicScreenViewModel.tags) { for (i in comicScreenViewModel.tags) {
Box( Box(
Modifier Modifier
.background( .background(

View File

@@ -22,6 +22,7 @@ import com.acitelight.aether.view.components.BiliMiniSlider
import com.acitelight.aether.view.components.VideoDownloadCardMini import com.acitelight.aether.view.components.VideoDownloadCardMini
import com.acitelight.aether.viewModel.TransmissionScreenViewModel import com.acitelight.aether.viewModel.TransmissionScreenViewModel
import com.tonyodev.fetch2.Status import com.tonyodev.fetch2.Status
import java.io.File
import kotlin.collections.sortedWith import kotlin.collections.sortedWith
@Composable @Composable
@@ -82,7 +83,6 @@ fun TransmissionScreen(
items( items(
downloads downloads
.filter { it.type == "main" } .filter { it.type == "main" }
.sortedWith(compareBy(naturalOrder()) { it.fileName })
.sortedBy { it.status == Status.COMPLETED }, key = { it.id }) .sortedBy { it.status == Status.COMPLETED }, key = { it.id })
{ item -> { item ->
VideoDownloadCardMini( VideoDownloadCardMini(
@@ -112,6 +112,11 @@ fun TransmissionScreen(
item, item,
downloads downloads
)) transmissionScreenViewModel.delete(i.id) )) transmissionScreenViewModel.delete(i.id)
File(
transmissionScreenViewModel.context.getExternalFilesDir(null),
"videos/${item.klass}/${item.vid}/summary.json"
).delete()
}, },
onRetry = { onRetry = {
for (i in downloadToGroup( for (i in downloadToGroup(

View File

@@ -1,19 +1,13 @@
package com.acitelight.aether.view.pages package com.acitelight.aether.view.pages
import android.widget.Toast
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideOutHorizontally
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.combinedClickable
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.PaddingValues import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
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
@@ -23,8 +17,6 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width 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.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.staggeredgrid.LazyVerticalStaggeredGrid import androidx.compose.foundation.lazy.staggeredgrid.LazyVerticalStaggeredGrid
import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells
import androidx.compose.foundation.lazy.staggeredgrid.items import androidx.compose.foundation.lazy.staggeredgrid.items
@@ -32,48 +24,41 @@ import androidx.compose.foundation.lazy.staggeredgrid.rememberLazyStaggeredGridS
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextField import androidx.compose.foundation.text.BasicTextField
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material.icons.filled.Search import androidx.compose.material.icons.filled.Search
import androidx.compose.material3.Card import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults import androidx.compose.material3.CardDefaults
import androidx.compose.material3.DividerDefaults
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SecondaryScrollableTabRow
import androidx.compose.material3.Tab
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import coil3.compose.AsyncImage
import com.acitelight.aether.model.Video import com.acitelight.aether.model.Video
import com.acitelight.aether.viewModel.VideoScreenViewModel import com.acitelight.aether.viewModel.VideoScreenViewModel
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
import androidx.lifecycle.viewModelScope
import androidx.navigation.NavHostController import androidx.navigation.NavHostController
import coil3.request.ImageRequest
import com.acitelight.aether.CardPage import com.acitelight.aether.CardPage
import com.acitelight.aether.Global.updateRelate
import com.acitelight.aether.view.components.VideoCard import com.acitelight.aether.view.components.VideoCard
import kotlinx.coroutines.launch
import java.nio.charset.Charset import java.nio.charset.Charset
import kotlin.collections.sortedWith import kotlin.collections.sortedWith
fun videoToView(v: List<Video>): Map<String?, List<Video>> fun videoToGroup(v: List<Video>): Map<String?, List<Video>> {
{ return v.map {
return v.map { if(it.video.group != null) it else Video(id=it.id, isLocal = it.isLocal, localBase = it.localBase, if (it.video.group != null) it else Video(
klass = it.klass, video = it.video.copy(group = it.video.name)) }.groupBy { it.video.group } id = it.id, isLocal = it.isLocal, localBase = it.localBase,
klass = it.klass, video = it.video.copy(group = it.video.name)
)
}.groupBy { it.video.group }
} }
fun String.toHex(): String { fun String.toHex(): String {
@@ -102,7 +87,8 @@ fun VideoScreen(
var menuVisibility by videoScreenViewModel.menuVisibility var menuVisibility by videoScreenViewModel.menuVisibility
var searchFilter by videoScreenViewModel.searchFilter var searchFilter by videoScreenViewModel.searchFilter
var doneInit by videoScreenViewModel.doneInit var doneInit by videoScreenViewModel.doneInit
val vb = videoToView(videoScreenViewModel.videoLibrary.classesMap.getOrDefault( val vb = videoToGroup(
videoScreenViewModel.videoLibrary.classesMap.getOrDefault(
videoScreenViewModel.videoLibrary.classes.getOrNull( videoScreenViewModel.videoLibrary.classes.getOrNull(
tabIndex tabIndex
), listOf() ), listOf()
@@ -117,75 +103,31 @@ fun VideoScreen(
Column( Column(
modifier = Modifier.fillMaxSize() modifier = Modifier.fillMaxSize()
) { ) {
Row(
Modifier
.padding(horizontal = 8.dp)
.padding(top = 4.dp)
.align(Alignment.CenterHorizontally)
)
{
Text( Text(
text = "Videos", text = "Videos",
style = MaterialTheme.typography.headlineMedium, style = MaterialTheme.typography.headlineMedium,
modifier = Modifier modifier = Modifier
.padding(horizontal = 8.dp) .padding(horizontal = 8.dp)
.align(Alignment.Start) .align(Alignment.CenterVertically)
) )
// TopRow(videoScreenViewModel); Spacer(Modifier.weight(1f))
Row(Modifier.padding(bottom = 4.dp).padding(start = 8.dp))
{
Card(
shape = RoundedCornerShape(8.dp),
colors = CardDefaults.cardColors(containerColor = colorScheme.primary),
modifier = Modifier
.align(Alignment.CenterVertically)
.padding(horizontal = 1.dp)
.size(36.dp),
onClick = {
menuVisibility = !menuVisibility
})
{
Box(Modifier.fillMaxSize())
{
Icon(
modifier = Modifier
.size(30.dp)
.align(Alignment.Center),
imageVector = Icons.Default.Menu,
contentDescription = "Catalogue"
)
}
}
Card(
shape = RoundedCornerShape(8.dp),
colors = CardDefaults.cardColors(containerColor = colorScheme.primary),
modifier = Modifier
.align(Alignment.CenterVertically)
.padding(horizontal = 1.dp)
.height(36.dp),
onClick = {
menuVisibility = !menuVisibility
})
{
Box(Modifier.fillMaxHeight())
{
Text(
text = videoScreenViewModel.videoLibrary.classes.getOrNull(
tabIndex
)
?: "",
style = MaterialTheme.typography.bodyLarge,
fontWeight = FontWeight.Bold,
modifier = Modifier
.align(Alignment.CenterStart)
.padding(horizontal = 8.dp),
maxLines = 1
)
}
}
Row( Row(
modifier = Modifier modifier = Modifier
.height(36.dp) .height(36.dp)
.widthIn(max = 240.dp) .widthIn(max = 240.dp)
.background(colorScheme.primary, RoundedCornerShape(8.dp)) .background(colorScheme.surface, RoundedCornerShape(8.dp))
.padding(horizontal = 6.dp) .padding(horizontal = 6.dp)
) { )
{
Icon( Icon(
modifier = Modifier modifier = Modifier
.size(30.dp) .size(30.dp)
@@ -207,11 +149,9 @@ fun VideoScreen(
) )
} }
} }
HorizontalDivider(
Modifier.padding(4.dp), TopRow(videoScreenViewModel)
2.dp,
DividerDefaults.color
)
LazyVerticalStaggeredGrid( LazyVerticalStaggeredGrid(
columns = StaggeredGridCells.Adaptive(160.dp), columns = StaggeredGridCells.Adaptive(160.dp),
contentPadding = PaddingValues(8.dp), contentPadding = PaddingValues(8.dp),
@@ -237,42 +177,37 @@ fun VideoScreen(
} }
} }
} }
}
}
}
AnimatedVisibility( @Composable
visible = menuVisibility, fun TopRow(videoScreenViewModel: VideoScreenViewModel) {
enter = slideInHorizontally(initialOffsetX = { full -> full }), val tabIndex by videoScreenViewModel.tabIndex;
exit = slideOutHorizontally(targetOffsetX = { full -> full }), if (videoScreenViewModel.videoLibrary.classes.isEmpty()) return
modifier = Modifier.align(Alignment.CenterEnd) val colorScheme = MaterialTheme.colorScheme
SecondaryScrollableTabRow(
selectedTabIndex = tabIndex,
modifier = Modifier
.background(Color.Transparent)
.padding(vertical = 4.dp)
) { ) {
Card( videoScreenViewModel.videoLibrary.classes.forEachIndexed { index, title ->
Modifier Tab(
.fillMaxHeight() modifier = Modifier.height(42.dp),
.width(250.dp) selected = tabIndex == index,
.align(Alignment.CenterEnd), onClick = { videoScreenViewModel.setTabIndex(index) },
shape = RoundedCornerShape(8.dp), text = {
colors = CardDefaults.cardColors(containerColor = colorScheme.surface) Text(
text = title,
maxLines = 1,
fontWeight = FontWeight.Bold,
lineHeight = 16.sp,
fontSize = 14.sp
) )
{ },
LazyColumn {
items(videoScreenViewModel.videoLibrary.classes) { item ->
CatalogueItemRow(
item = Pair(
videoScreenViewModel.videoLibrary.classes.indexOf(item),
item
),
onItemClick = {
menuVisibility = false
videoScreenViewModel.setTabIndex(
videoScreenViewModel.videoLibrary.classes.indexOf(
item
) )
)
}
)
}
}
}
}
} }
} }
} }

View File

@@ -203,7 +203,8 @@ class TransmissionScreenViewModel @Inject constructor(
totalBytes = download.total, totalBytes = download.total,
klass = download.extras.getString("class", ""), klass = download.extras.getString("class", ""),
vid = download.extras.getString("id", ""), vid = download.extras.getString("id", ""),
type = download.extras.getString("type", "") type = download.extras.getString("type", ""),
group = download.extras.getString("group", "")
) )
} }