[update] New Icon& UI Theme

This commit is contained in:
acite
2025-09-14 19:59:28 +08:00
parent cc540903d3
commit f7701cc85b
30 changed files with 158 additions and 33 deletions

View File

@@ -275,7 +275,7 @@ fun CardPage(
Card(
modifier = Modifier
.fillMaxSize()
.padding(16.dp),
.padding(6.dp),
elevation = CardDefaults.cardElevation(4.dp),
shape = RoundedCornerShape(12.dp),
colors = CardDefaults.cardColors(containerColor = colorScheme.background)

View File

@@ -1,6 +1,8 @@
package com.acitelight.aether.service
import android.content.Context
import com.acitelight.aether.Screen
import com.acitelight.aether.model.Video
import com.acitelight.aether.service.ApiClient.createOkHttp
import com.tonyodev.fetch2.Download
import com.tonyodev.fetch2.Fetch
@@ -8,8 +10,10 @@ import com.tonyodev.fetch2.FetchConfiguration
import com.tonyodev.fetch2.FetchListener
import com.tonyodev.fetch2.Request
import com.tonyodev.fetch2.Status
import com.tonyodev.fetch2core.Extras
import com.tonyodev.fetch2okhttp.OkHttpDownloader
import dagger.hilt.android.qualifiers.ApplicationContext
import java.io.File
import javax.inject.Inject
import javax.inject.Singleton
@@ -76,10 +80,26 @@ class FetchManager @Inject constructor(
} ?: callback?.invoke()
}
// enqueue helper if needed
fun enqueue(request: Request, onEnqueued: ((Request) -> Unit)? = null, onError: ((com.tonyodev.fetch2.Error) -> Unit)? = null) {
private fun enqueue(request: Request, onEnqueued: ((Request) -> Unit)? = null, onError: ((com.tonyodev.fetch2.Error) -> Unit)? = null) {
if (fetch == null) init()
fetch?.enqueue(request, { r -> onEnqueued?.invoke(r) }, { e -> onError?.invoke(e) })
}
private fun getVideosDirectory() {
val appFilesDir = context.filesDir
val videosDir = File(appFilesDir, "videos")
if (!videosDir.exists()) {
val created = videosDir.mkdirs()
}
}
fun startVideoDownload(video: Video)
{
val path = File(context.filesDir, "videos/${video.klass}/${video.id}")
val request = Request(video.getVideo(), path.path).apply {
extras = Extras(mapOf("name" to video.video.name, "id" to video.id, "class" to video.klass))
}
enqueue(request)
}
}

View File

@@ -130,8 +130,8 @@ fun generateColorScheme(primaryColor: Color, isDarkMode: Boolean): ColorScheme {
}
}
private val DarkColorScheme = generateColorScheme(Color(0xFFFF4081), isDarkMode = true)
private val LightColorScheme = generateColorScheme(Color(0xFFFF4081), isDarkMode = false)
private val DarkColorScheme = generateColorScheme(Color(0xFF2F4F8F), isDarkMode = true)
private val LightColorScheme = generateColorScheme(Color(0xFF2F4F8F), isDarkMode = false)
@Composable
fun AetherTheme(

View File

@@ -81,7 +81,6 @@ private fun DownloadCard(
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) {
Column(modifier = Modifier.weight(1f)) {
Text(text = model.fileName, style = MaterialTheme.typography.titleMedium)
Text(text = model.url, style = MaterialTheme.typography.displayMedium, modifier = Modifier.padding(top = 4.dp))
}
// progress percentage

View File

@@ -128,6 +128,7 @@ fun BiliStyleSlider(
onValueChange: (Float) -> Unit,
valueRange: ClosedFloatingPointRange<Float> = 0f..1f
) {
val colorScheme = MaterialTheme.colorScheme
val thumbRadius = 6.dp
val trackHeight = 3.dp
@@ -137,8 +138,8 @@ fun BiliStyleSlider(
valueRange = valueRange,
modifier = modifier,
colors = SliderDefaults.colors(
thumbColor = Color(0xFFFFFFFF), // B站粉色
activeTrackColor = Color(0xFFFF6699),
thumbColor = Color(0xFFFFFFFF),
activeTrackColor = colorScheme.primary,
inactiveTrackColor = Color.LightGray.copy(alpha = 0.4f)
),
@@ -154,7 +155,7 @@ fun BiliStyleSlider(
.align(Alignment.CenterStart)
.fillMaxWidth(value)
.fillMaxHeight()
.background(Color(0xFFFF6699), RoundedCornerShape(50))
.background(colorScheme.primary, RoundedCornerShape(50))
)
}
}
@@ -169,6 +170,7 @@ fun BiliMiniSlider(
onValueChange: (Float) -> Unit,
valueRange: ClosedFloatingPointRange<Float> = 0f..1f
) {
val colorScheme = MaterialTheme.colorScheme
val thumbRadius = 6.dp
val trackHeight = 3.dp
@@ -178,8 +180,8 @@ fun BiliMiniSlider(
valueRange = valueRange,
modifier = modifier,
colors = SliderDefaults.colors(
thumbColor = Color(0xFFFFFFFF), // B站粉色
activeTrackColor = Color(0xFFFF6699),
thumbColor = Color(0xFFFFFFFF),
activeTrackColor = colorScheme.primary,
inactiveTrackColor = Color.LightGray.copy(alpha = 0.4f)
),
thumb = {
@@ -197,7 +199,7 @@ fun BiliMiniSlider(
.align(Alignment.CenterStart)
.fillMaxWidth(value)
.fillMaxHeight()
.background(Color(0xFFFF6699), RoundedCornerShape(50))
.background(colorScheme.primary, RoundedCornerShape(50))
)
}
}
@@ -450,9 +452,8 @@ fun PortalCorePlayer(modifier: Modifier, videoPlayerViewModel: VideoPlayerViewMo
}
}
if(cover > 0.0f)
Spacer(Modifier.background(Color(0x00FF6699 - 0x00222222 + ((0x000000FF * cover).toLong() shl 24) )).fillMaxSize())
Spacer(Modifier.background(MaterialTheme.colorScheme.primary.copy(cover)).fillMaxSize())
androidx.compose.animation.AnimatedVisibility(
visible = !videoPlayerViewModel.planeVisibility,
@@ -704,6 +705,7 @@ fun VideoPlayerPortal(videoPlayerViewModel: VideoPlayerViewModel, navController:
@Composable
fun SocialPanel(modifier: Modifier, videoPlayerViewModel: VideoPlayerViewModel)
{
val colorScheme = MaterialTheme.colorScheme
Row(
modifier,
horizontalArrangement = Arrangement.Center
@@ -760,7 +762,7 @@ fun SocialPanel(modifier: Modifier, videoPlayerViewModel: VideoPlayerViewModel)
modifier = Modifier.size(28.dp),
imageVector = Icons.Filled.Star,
contentDescription = "Star",
tint = if(videoPlayerViewModel.star) Color(0xFFFF6699) else Color.Gray
tint = if(videoPlayerViewModel.star) colorScheme.primary else Color.Gray
)
}
}

View File

@@ -1,6 +1,8 @@
package com.acitelight.aether.view
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
@@ -41,6 +43,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Alignment
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.platform.LocalContext
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
import androidx.navigation.NavHostController
import coil3.request.ImageRequest
import com.acitelight.aether.Global
@@ -63,7 +66,7 @@ fun String.hexToString(charset: Charset = Charsets.UTF_8): String {
}
@Composable
fun VideoScreen(videoScreenViewModel: VideoScreenViewModel = viewModel(), navController: NavHostController)
fun VideoScreen(videoScreenViewModel: VideoScreenViewModel = hiltViewModel<VideoScreenViewModel>(), navController: NavHostController)
{
val tabIndex by videoScreenViewModel.tabIndex;
videoScreenViewModel.SetupClient()
@@ -113,15 +116,20 @@ fun TopRow(videoScreenViewModel: VideoScreenViewModel)
fun VideoCard(video: Video, navController: NavHostController, videoScreenViewModel: VideoScreenViewModel) {
val tabIndex by videoScreenViewModel.tabIndex;
Card(
shape = RoundedCornerShape(6.dp),
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight(),
onClick = {
updateRelate(videoScreenViewModel.classesMap[videoScreenViewModel.classes[tabIndex]] ?: mutableStateListOf(), video)
val route = "video_player_route/${ "${video.klass}/${video.id}".toHex() }"
navController.navigate(route)
}
.wrapContentHeight()
.combinedClickable(
onClick = {
updateRelate(videoScreenViewModel.classesMap[videoScreenViewModel.classes[tabIndex]] ?: mutableStateListOf(), video)
val route = "video_player_route/${ "${video.klass}/${video.id}".toHex() }"
navController.navigate(route)
},
onLongClick = {
videoScreenViewModel.download(video)
}
),
shape = RoundedCornerShape(6.dp),
) {
Column(
modifier = Modifier

View File

@@ -69,8 +69,8 @@ class TransmissionScreenViewModel @Inject constructor(
val existing = idToState[download.id]
if (existing != null) {
// update fields in-place -> minimal recomposition
existing.filePath = download.file ?: existing.filePath
existing.fileName = try { File(existing.filePath).name } catch (_: Exception) { existing.fileName }
existing.filePath = download.file
existing.fileName = download.request.extras.getString("name", "")
existing.url = download.url
existing.progress = download.progress
existing.status = download.status
@@ -97,11 +97,11 @@ class TransmissionScreenViewModel @Inject constructor(
}
}
private fun downloadToState(download: Download): DownloadItemState {
val filePath = download.file ?: ""
val fileName = try { File(filePath).name } catch (_: Exception) { filePath }
val filePath = download.file
return DownloadItemState(
id = download.id,
fileName = fileName,
fileName = download.request.extras.getString("name", ""),
filePath = filePath,
url = download.url,
progress = download.progress,

View File

@@ -11,6 +11,7 @@ import androidx.compose.runtime.snapshots.SnapshotStateList
import androidx.compose.ui.platform.LocalContext
import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import coil3.ImageLoader
import coil3.network.okhttp.OkHttpNetworkFetcherFactory
@@ -18,14 +19,20 @@ import com.acitelight.aether.dataStore
import com.acitelight.aether.helper.insertInNaturalOrder
import com.acitelight.aether.model.Video
import com.acitelight.aether.service.ApiClient.createOkHttp
import com.acitelight.aether.service.FetchManager
import com.acitelight.aether.service.MediaManager
import com.acitelight.aether.service.MediaManager.queryVideoKlasses
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import javax.inject.Inject
class VideoScreenViewModel(application: Application) : AndroidViewModel(application)
@HiltViewModel
class VideoScreenViewModel @Inject constructor(
private val fetchManager: FetchManager
) : ViewModel()
{
private val _tabIndex = mutableIntStateOf(0)
val tabIndex: State<Int> = _tabIndex
@@ -83,6 +90,11 @@ class VideoScreenViewModel(application: Application) : AndroidViewModel(applicat
}
}
fun download(video :Video)
{
fetchManager.startVideoDownload(video)
}
init {
viewModelScope.launch {
init()