[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,
klass: String,
vid: String,
val type: String
val type: String,
val group: String
) {
var fileName by mutableStateOf(fileName)
var filePath by mutableStateOf(filePath)

View File

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

View File

@@ -152,10 +152,9 @@ fun ComicScreen(
Column(
modifier = Modifier.animateContentSize()
) {
Row(
Modifier
.padding(4.dp)
.align(Alignment.CenterHorizontally)
Row(Modifier
.padding(horizontal = 8.dp).padding(top = 4.dp)
.align(Alignment.CenterHorizontally)
)
{
Text(
@@ -196,7 +195,11 @@ fun ComicScreen(
}
}
Row {
Row(Modifier
.padding(horizontal = 8.dp)
.align(Alignment.CenterHorizontally)
)
{
Text(
text = "Sorted by: ",
fontWeight = FontWeight.Bold,
@@ -264,12 +267,11 @@ fun ComicScreen(
VariableGrid(
modifier = Modifier
.heightIn(max = 80.dp)
.padding(4.dp),
.padding(3.dp),
rowHeight = 30.dp
)
{
for (i in comicScreenViewModel.tags) {
Box(
Modifier
.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.viewModel.TransmissionScreenViewModel
import com.tonyodev.fetch2.Status
import java.io.File
import kotlin.collections.sortedWith
@Composable
@@ -82,7 +83,6 @@ fun TransmissionScreen(
items(
downloads
.filter { it.type == "main" }
.sortedWith(compareBy(naturalOrder()) { it.fileName })
.sortedBy { it.status == Status.COMPLETED }, key = { it.id })
{ item ->
VideoDownloadCardMini(
@@ -112,6 +112,11 @@ fun TransmissionScreen(
item,
downloads
)) transmissionScreenViewModel.delete(i.id)
File(
transmissionScreenViewModel.context.getExternalFilesDir(null),
"videos/${item.klass}/${item.vid}/summary.json"
).delete()
},
onRetry = {
for (i in downloadToGroup(

View File

@@ -1,19 +1,13 @@
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.clickable
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
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.widthIn
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.StaggeredGridCells
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.text.BasicTextField
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material.icons.filled.Search
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.DividerDefaults
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SecondaryScrollableTabRow
import androidx.compose.material3.Tab
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import coil3.compose.AsyncImage
import com.acitelight.aether.model.Video
import com.acitelight.aether.viewModel.VideoScreenViewModel
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.setValue
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.hilt.lifecycle.viewmodel.compose.hiltViewModel
import androidx.lifecycle.viewModelScope
import androidx.navigation.NavHostController
import coil3.request.ImageRequest
import com.acitelight.aether.CardPage
import com.acitelight.aether.Global.updateRelate
import com.acitelight.aether.view.components.VideoCard
import kotlinx.coroutines.launch
import java.nio.charset.Charset
import kotlin.collections.sortedWith
fun videoToView(v: List<Video>): Map<String?, List<Video>>
{
return v.map { if(it.video.group != null) it else Video(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 videoToGroup(v: List<Video>): Map<String?, List<Video>> {
return v.map {
if (it.video.group != null) it else Video(
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 {
@@ -102,12 +87,13 @@ fun VideoScreen(
var menuVisibility by videoScreenViewModel.menuVisibility
var searchFilter by videoScreenViewModel.searchFilter
var doneInit by videoScreenViewModel.doneInit
val vb = videoToView(videoScreenViewModel.videoLibrary.classesMap.getOrDefault(
videoScreenViewModel.videoLibrary.classes.getOrNull(
tabIndex
), listOf()
).filter { it.video.name.contains(searchFilter) }).filter { it.key != null }
.map{ i -> Pair(i.key!!, i.value.sortedWith(compareBy(naturalOrder()) { it.video.name }) ) }
val vb = videoToGroup(
videoScreenViewModel.videoLibrary.classesMap.getOrDefault(
videoScreenViewModel.videoLibrary.classes.getOrNull(
tabIndex
), listOf()
).filter { it.video.name.contains(searchFilter) }).filter { it.key != null }
.map { i -> Pair(i.key!!, i.value.sortedWith(compareBy(naturalOrder()) { it.video.name })) }
.toList()
if (doneInit)
@@ -117,75 +103,31 @@ fun VideoScreen(
Column(
modifier = Modifier.fillMaxSize()
) {
Text(
text = "Videos",
style = MaterialTheme.typography.headlineMedium,
modifier = Modifier
.padding(horizontal = 8.dp)
.align(Alignment.Start)
Row(
Modifier
.padding(horizontal = 8.dp)
.padding(top = 4.dp)
.align(Alignment.CenterHorizontally)
)
// TopRow(videoScreenViewModel);
Row(Modifier.padding(bottom = 4.dp).padding(start = 8.dp))
{
Card(
shape = RoundedCornerShape(8.dp),
colors = CardDefaults.cardColors(containerColor = colorScheme.primary),
Text(
text = "Videos",
style = MaterialTheme.typography.headlineMedium,
modifier = Modifier
.padding(horizontal = 8.dp)
.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
)
}
}
Spacer(Modifier.weight(1f))
Row(
modifier = Modifier
.height(36.dp)
.widthIn(max = 240.dp)
.background(colorScheme.primary, RoundedCornerShape(8.dp))
.background(colorScheme.surface, RoundedCornerShape(8.dp))
.padding(horizontal = 6.dp)
) {
)
{
Icon(
modifier = Modifier
.size(30.dp)
@@ -207,11 +149,9 @@ fun VideoScreen(
)
}
}
HorizontalDivider(
Modifier.padding(4.dp),
2.dp,
DividerDefaults.color
)
TopRow(videoScreenViewModel)
LazyVerticalStaggeredGrid(
columns = StaggeredGridCells.Adaptive(160.dp),
contentPadding = PaddingValues(8.dp),
@@ -231,52 +171,47 @@ fun VideoScreen(
.fillMaxWidth()
.wrapContentHeight()
) {
if(video.second.isNotEmpty())
if (video.second.isNotEmpty())
VideoCard(video.second, navController, videoScreenViewModel)
}
}
}
}
AnimatedVisibility(
visible = menuVisibility,
enter = slideInHorizontally(initialOffsetX = { full -> full }),
exit = slideOutHorizontally(targetOffsetX = { full -> full }),
modifier = Modifier.align(Alignment.CenterEnd)
) {
Card(
Modifier
.fillMaxHeight()
.width(250.dp)
.align(Alignment.CenterEnd),
shape = RoundedCornerShape(8.dp),
colors = CardDefaults.cardColors(containerColor = colorScheme.surface)
)
{
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
)
)
}
)
}
}
}
}
}
}
}
@Composable
fun TopRow(videoScreenViewModel: VideoScreenViewModel) {
val tabIndex by videoScreenViewModel.tabIndex;
if (videoScreenViewModel.videoLibrary.classes.isEmpty()) return
val colorScheme = MaterialTheme.colorScheme
SecondaryScrollableTabRow(
selectedTabIndex = tabIndex,
modifier = Modifier
.background(Color.Transparent)
.padding(vertical = 4.dp)
) {
videoScreenViewModel.videoLibrary.classes.forEachIndexed { index, title ->
Tab(
modifier = Modifier.height(42.dp),
selected = tabIndex == index,
onClick = { videoScreenViewModel.setTabIndex(index) },
text = {
Text(
text = title,
maxLines = 1,
fontWeight = FontWeight.Bold,
lineHeight = 16.sp,
fontSize = 14.sp
)
},
)
}
}
}
@Composable
fun CatalogueItemRow(
item: Pair<Int, String>,

View File

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