Skip to content

Commit 54ce477

Browse files
committed
调整了一下主页
1 parent 510748f commit 54ce477

3 files changed

Lines changed: 183 additions & 257 deletions

File tree

app/src/main/java/com/ljyh/mei/data/model/eapi/HomePageResourceShow.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ data class HomePageResourceShow(
321321
@SerializedName("labelText")
322322
val labelText: Any,
323323
@SerializedName("resourceExtInfo")
324-
val resourceExtInfo: ResourceExtInfo,
324+
val resourceExtInfo: ResourceExtInfo? = null,
325325
@SerializedName("extMap")
326326
val extMap: Any,
327327
@SerializedName("singleLineTitle")
@@ -348,7 +348,7 @@ data class HomePageResourceShow(
348348
@SerializedName("artists")
349349
val artists: List<Artist>,
350350
@SerializedName("coverText")
351-
val coverText: List<String>
351+
val coverText: List<String>? = null
352352
) {
353353
data class Artist(
354354
@SerializedName("id")
Lines changed: 85 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package com.ljyh.mei.ui.component.home
22

33
import androidx.compose.foundation.clickable
4-
import androidx.compose.foundation.layout.Arrangement
54
import androidx.compose.foundation.layout.Box
65
import androidx.compose.foundation.layout.Column
7-
import androidx.compose.foundation.layout.IntrinsicSize
86
import androidx.compose.foundation.layout.Row
97
import androidx.compose.foundation.layout.Spacer
8+
import androidx.compose.foundation.layout.fillMaxWidth
109
import androidx.compose.foundation.layout.height
1110
import androidx.compose.foundation.layout.padding
1211
import androidx.compose.foundation.layout.size
@@ -16,14 +15,12 @@ import androidx.compose.material.icons.Icons
1615
import androidx.compose.material.icons.automirrored.rounded.PlaylistPlay
1716
import androidx.compose.material.icons.filled.Headset
1817
import androidx.compose.material3.Icon
19-
import androidx.compose.material3.IconButton
2018
import androidx.compose.material3.MaterialTheme
2119
import androidx.compose.material3.Text
2220
import androidx.compose.runtime.Composable
2321
import androidx.compose.ui.Alignment
2422
import androidx.compose.ui.Modifier
2523
import androidx.compose.ui.draw.clip
26-
import androidx.compose.ui.draw.shadow
2724
import androidx.compose.ui.geometry.Offset
2825
import androidx.compose.ui.graphics.Color
2926
import androidx.compose.ui.graphics.Shadow
@@ -35,11 +32,8 @@ import androidx.compose.ui.unit.dp
3532
import androidx.compose.ui.unit.sp
3633
import coil3.compose.AsyncImage
3734
import com.ljyh.mei.constants.PlaylistCardSize
38-
import com.ljyh.mei.constants.PlaylistCardSpacing
39-
import com.ljyh.mei.ui.local.LocalNavController
4035
import com.ljyh.mei.utils.largeImage
4136

42-
4337
@Composable
4438
fun PlaylistCard(
4539
id: String,
@@ -51,132 +45,104 @@ fun PlaylistCard(
5145
imageSize: Boolean = true,
5246
onClick: () -> Unit
5347
) {
54-
// val playerConnection = LocalPlayerConnection.current ?: return
55-
// val isPlaying by playerConnection.isPlaying.collectAsState()
56-
// val mediaMetadata by playerConnection.mediaMetadata.collectAsState()
57-
val context = LocalNavController.current.context
58-
Row {
59-
Column(modifier = Modifier
48+
// 常用阴影样式,提取出来复用
49+
val textShadow = Shadow(
50+
color = Color.Black.copy(alpha = 0.7f),
51+
offset = Offset(2f, 2f),
52+
blurRadius = 4f
53+
)
54+
55+
Column(
56+
modifier = Modifier
6057
.width(PlaylistCardSize)
61-
.clickable { onClick() }) {
62-
Box {
63-
AsyncImage(
64-
model = if (imageSize) {
65-
coverImg.largeImage()
66-
} else {
67-
coverImg
68-
},
58+
.clip(RoundedCornerShape(8.dp)) // 整个组件裁切,防止水波纹溢出
59+
.clickable { onClick() }
60+
) {
61+
Box(
62+
modifier = Modifier.size(PlaylistCardSize)
63+
) {
64+
AsyncImage(
65+
model = if (imageSize) coverImg.largeImage() else coverImg,
66+
modifier = Modifier
67+
.matchParentSize()
68+
.clip(RoundedCornerShape(8.dp)),
69+
contentDescription = null,
70+
contentScale = ContentScale.Crop,
71+
)
72+
73+
// 顶部播放量
74+
if (extInfo != null) {
75+
Row(
6976
modifier = Modifier
70-
.size(PlaylistCardSize)
71-
.clip(RoundedCornerShape(8.dp)),
72-
contentDescription = null,
73-
contentScale = ContentScale.Crop,
74-
)
75-
subTitle?.let {
76-
Column(
77-
modifier = Modifier
78-
.align(Alignment.BottomStart)
79-
.padding(4.dp),
80-
) {
81-
it.forEach { t ->
82-
Text(
83-
text = t,
84-
fontSize = 12.sp,
85-
color = Color.White,
86-
fontWeight = FontWeight.ExtraBold,
87-
lineHeight = 16.sp,
88-
style = TextStyle(
89-
shadow = Shadow(
90-
color = Color.Black,
91-
offset = Offset(4f, 4f),
92-
blurRadius = 8f
93-
)
94-
)
95-
)
96-
}
97-
}
77+
.align(Alignment.TopEnd)
78+
.padding(6.dp),
79+
verticalAlignment = Alignment.CenterVertically
80+
) {
81+
Icon(
82+
imageVector = Icons.Filled.Headset,
83+
contentDescription = null,
84+
modifier = Modifier.size(12.dp),
85+
tint = Color.White
86+
)
87+
Spacer(Modifier.width(2.dp))
88+
Text(
89+
text = extInfo,
90+
fontSize = 11.sp,
91+
color = Color.White,
92+
fontWeight = FontWeight.Bold,
93+
style = TextStyle(shadow = textShadow)
94+
)
9895
}
96+
}
9997

100-
extInfo?.let {
101-
102-
Row(
103-
Modifier
104-
.height(IntrinsicSize.Min)
105-
.align(Alignment.TopStart)
106-
.padding(4.dp),
107-
verticalAlignment = Alignment.CenterVertically,
108-
horizontalArrangement = Arrangement.spacedBy(4.dp)
109-
110-
) {
111-
Icon(
112-
imageVector = Icons.Filled.Headset,
113-
contentDescription = "Headset",
114-
modifier = Modifier
115-
.size(12.dp)
116-
.shadow(
117-
4.dp,
118-
RoundedCornerShape(4.dp)
119-
),
120-
tint = Color.White
121-
)
98+
// 底部左侧副标题 (如果有)
99+
if (subTitle != null) {
100+
Column(
101+
modifier = Modifier
102+
.align(Alignment.BottomStart)
103+
.padding(6.dp)
104+
) {
105+
subTitle.forEach { t ->
122106
Text(
123-
text = it,
124-
fontSize = 10.sp,
125-
maxLines = 1,
126-
lineHeight = 16.sp,
107+
text = t,
108+
fontSize = 11.sp,
127109
color = Color.White,
128-
fontWeight = FontWeight.Bold,
129-
style = TextStyle(
130-
shadow = Shadow(
131-
color = Color.Black,
132-
offset = Offset(4f, 4f),
133-
blurRadius = 8f
134-
)
135-
)
110+
fontWeight = FontWeight.Medium,
111+
style = TextStyle(shadow = textShadow)
136112
)
137113
}
138-
139114
}
115+
}
140116

141-
142-
143-
if (showPlay) {
144-
IconButton(modifier = Modifier
117+
// 右下角播放按钮
118+
if (showPlay) {
119+
Box(
120+
modifier = Modifier
145121
.align(Alignment.BottomEnd)
146-
.size(24.dp)
147-
.padding(4.dp),
148-
onClick = {
149-
}
150-
) {
151-
Icon(
152-
imageVector = Icons.AutoMirrored.Rounded.PlaylistPlay,
153-
contentDescription = "Play",
154-
tint = Color.White,
155-
modifier = Modifier.shadow(
156-
4.dp,
157-
RoundedCornerShape(4.dp)
158-
),
159-
)
160-
}
122+
.padding(6.dp)
123+
) {
124+
Icon(
125+
imageVector = Icons.AutoMirrored.Rounded.PlaylistPlay,
126+
contentDescription = "Play",
127+
tint = Color.White,
128+
modifier = Modifier.size(24.dp)
129+
)
161130
}
162-
163-
164131
}
165-
166-
Spacer(Modifier.height(12.dp))
167-
Text(
168-
text = title,
169-
overflow = TextOverflow.Ellipsis,
170-
color = MaterialTheme.colorScheme.onSurface,
171-
maxLines = 2,
172-
fontSize = 14.sp,
173-
lineHeight = 16.sp,
174-
fontWeight = FontWeight.Bold
175-
)
176132
}
177133

178-
Spacer(Modifier.width(PlaylistCardSpacing))
134+
Spacer(Modifier.height(8.dp))
135+
136+
// 标题
137+
Text(
138+
text = title,
139+
overflow = TextOverflow.Ellipsis,
140+
color = MaterialTheme.colorScheme.onSurface,
141+
maxLines = 2,
142+
fontSize = 13.sp, // 调整字体大小,更精致
143+
lineHeight = 18.sp,
144+
fontWeight = FontWeight.Medium,
145+
modifier = Modifier.fillMaxWidth()
146+
)
179147
}
180-
181-
182148
}

0 commit comments

Comments
 (0)