Просмотр исходного кода

feat: 书源管理发现标识之

HapeLee 1 месяц назад
Родитель
Сommit
05fd81de78

+ 45 - 14
app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceScreen.kt

@@ -7,6 +7,7 @@ import androidx.compose.foundation.background
 import androidx.compose.foundation.layout.Arrangement
 import androidx.compose.foundation.layout.Box
 import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
 import androidx.compose.foundation.layout.Spacer
 import androidx.compose.foundation.layout.fillMaxHeight
 import androidx.compose.foundation.layout.fillMaxSize
@@ -14,12 +15,14 @@ import androidx.compose.foundation.layout.fillMaxWidth
 import androidx.compose.foundation.layout.height
 import androidx.compose.foundation.layout.heightIn
 import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
 import androidx.compose.foundation.layout.width
 import androidx.compose.foundation.lazy.grid.GridCells
 import androidx.compose.foundation.lazy.grid.GridItemSpan
 import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
 import androidx.compose.foundation.lazy.rememberLazyListState
 import androidx.compose.foundation.selection.selectable
+import androidx.compose.foundation.shape.CircleShape
 import androidx.compose.foundation.shape.RoundedCornerShape
 import androidx.compose.material3.ExperimentalMaterial3Api
 import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
@@ -38,6 +41,7 @@ import androidx.compose.ui.draw.clip
 import androidx.compose.ui.platform.ClipEntry
 import androidx.compose.ui.platform.LocalClipboard
 import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.res.colorResource
 import androidx.compose.ui.res.stringResource
 import androidx.compose.ui.semantics.Role
 import androidx.compose.ui.semantics.heading
@@ -644,23 +648,31 @@ fun BookSourceScreen(
                             },
                             title = item.name,
                             supportingContent = if (
-                                item.group != null || item.checkMessage != null
+                                item.group != null || item.checkMessage != null || item.hasExploreUrl
                             ) {
                                 {
-                                    Column {
-                                        item.group?.let { group ->
-                                            AppText(
-                                                text = group,
-                                                style = LegadoTheme.typography.bodySmall,
-                                                maxLines = 1,
-                                                overflow = TextOverflow.Ellipsis,
-                                            )
+                                    Row(
+                                        verticalAlignment = Alignment.CenterVertically,
+                                        horizontalArrangement = Arrangement.spacedBy(6.dp),
+                                    ) {
+                                        if (item.hasExploreUrl) {
+                                            DiscoveryIndicator(item.enabledExplore)
                                         }
-                                        item.checkMessage?.let { message ->
-                                            AppText(
-                                                text = message,
-                                                style = LegadoTheme.typography.bodySmall,
-                                            )
+                                        Column {
+                                            item.group?.let { group ->
+                                                AppText(
+                                                    text = group,
+                                                    style = LegadoTheme.typography.bodySmall,
+                                                    maxLines = 1,
+                                                    overflow = TextOverflow.Ellipsis,
+                                                )
+                                            }
+                                            item.checkMessage?.let { message ->
+                                                AppText(
+                                                    text = message,
+                                                    style = LegadoTheme.typography.bodySmall,
+                                                )
+                                            }
                                         }
                                     }
                                 }
@@ -803,6 +815,25 @@ private fun CheckBookSourceSheet(
     }
 }
 
+/**
+ * 书源发现状态标志:有发现且已启用为绿点,有发现但未启用为红点,无发现不显示标志。
+ * 标志位于条目信息行(分组名 / 校验信息行)开头。状态文案已由条目 contentDescription
+ * 描述,这里仅作装饰性渲染。
+ */
+@Composable
+private fun DiscoveryIndicator(enabledExplore: Boolean) {
+    Box(
+        modifier = Modifier
+            .size(8.dp)
+            .clip(CircleShape)
+            .background(
+                colorResource(
+                    if (enabledExplore) R.color.md_green_500 else R.color.md_red_400
+                )
+            )
+    )
+}
+
 private enum class CheckSheet { Run, Settings }
 
 @OptIn(ExperimentalMaterial3ExpressiveApi::class)