mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 14:27:57 +01:00 
			
		
		
		
	Consolidate badge components
This commit is contained in:
		| @@ -11,7 +11,6 @@ import androidx.compose.foundation.lazy.items | ||||
| import androidx.compose.material3.MaterialTheme | ||||
| import androidx.compose.material3.Text | ||||
| import androidx.compose.runtime.Composable | ||||
| import androidx.compose.runtime.getValue | ||||
| import androidx.compose.ui.Alignment | ||||
| import androidx.compose.ui.Modifier | ||||
| import androidx.compose.ui.input.nestedscroll.NestedScrollConnection | ||||
| @@ -23,8 +22,9 @@ import androidx.compose.ui.unit.dp | ||||
| import eu.kanade.domain.source.model.Source | ||||
| import eu.kanade.presentation.browse.components.BaseSourceItem | ||||
| import eu.kanade.presentation.browse.components.SourceIcon | ||||
| import eu.kanade.presentation.components.Badge | ||||
| import eu.kanade.presentation.components.BadgeGroup | ||||
| import eu.kanade.presentation.components.EmptyScreen | ||||
| import eu.kanade.presentation.components.ItemBadges | ||||
| import eu.kanade.presentation.components.LoadingScreen | ||||
| import eu.kanade.presentation.components.ScrollbarLazyColumn | ||||
| import eu.kanade.presentation.theme.header | ||||
| @@ -112,7 +112,11 @@ fun MigrateSourceItem( | ||||
|         onClickItem = onClickItem, | ||||
|         onLongClickItem = onLongClickItem, | ||||
|         icon = { SourceIcon(source = source) }, | ||||
|         action = { ItemBadges(primaryText = "$count") }, | ||||
|         action = { | ||||
|             BadgeGroup { | ||||
|                 Badge(text = "$count") | ||||
|             } | ||||
|         }, | ||||
|         content = { source, showLanguageInContent -> | ||||
|             Column( | ||||
|                 modifier = Modifier | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| package eu.kanade.presentation.library.components | ||||
| package eu.kanade.presentation.components | ||||
| 
 | ||||
| import androidx.compose.foundation.background | ||||
| import androidx.compose.foundation.layout.Box | ||||
| @@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.Row | ||||
| import androidx.compose.foundation.layout.RowScope | ||||
| import androidx.compose.foundation.layout.padding | ||||
| import androidx.compose.foundation.shape.RoundedCornerShape | ||||
| import androidx.compose.material3.LocalTextStyle | ||||
| import androidx.compose.material3.MaterialTheme | ||||
| import androidx.compose.material3.Text | ||||
| import androidx.compose.runtime.Composable | ||||
| @@ -14,6 +15,7 @@ import androidx.compose.ui.draw.clip | ||||
| import androidx.compose.ui.graphics.Color | ||||
| import androidx.compose.ui.graphics.RectangleShape | ||||
| import androidx.compose.ui.graphics.Shape | ||||
| import androidx.compose.ui.text.font.FontWeight | ||||
| import androidx.compose.ui.unit.dp | ||||
| 
 | ||||
| @Composable | ||||
| @@ -42,7 +44,10 @@ fun Badge( | ||||
|         Text( | ||||
|             text = text, | ||||
|             modifier = Modifier.padding(horizontal = 4.dp, vertical = 2.dp), | ||||
|             color = textColor, | ||||
|             style = LocalTextStyle.current.copy( | ||||
|                 color = textColor, | ||||
|                 fontWeight = FontWeight.Medium, | ||||
|             ), | ||||
|         ) | ||||
|     } | ||||
| } | ||||
| @@ -1,36 +0,0 @@ | ||||
| package eu.kanade.presentation.components | ||||
|  | ||||
| import androidx.compose.foundation.background | ||||
| import androidx.compose.foundation.layout.Row | ||||
| import androidx.compose.foundation.layout.padding | ||||
| import androidx.compose.foundation.shape.RoundedCornerShape | ||||
| import androidx.compose.material3.MaterialTheme | ||||
| import androidx.compose.material3.Text | ||||
| import androidx.compose.runtime.Composable | ||||
| import androidx.compose.ui.Modifier | ||||
| import androidx.compose.ui.draw.clip | ||||
| import androidx.compose.ui.text.font.FontWeight | ||||
| import androidx.compose.ui.unit.dp | ||||
|  | ||||
| @Composable | ||||
| fun ItemBadges( | ||||
|     modifier: Modifier = Modifier, | ||||
|     primaryText: String, | ||||
| ) { | ||||
|     Row( | ||||
|         modifier = modifier.clip(RoundedCornerShape(4.dp)), | ||||
|     ) { | ||||
|         Text( | ||||
|             text = primaryText, | ||||
|             modifier = Modifier | ||||
|                 .background(MaterialTheme.colorScheme.primary) | ||||
|                 .padding(horizontal = 4.dp, vertical = 2.dp), | ||||
|             style = MaterialTheme.typography.bodyMedium.copy( | ||||
|                 color = MaterialTheme.colorScheme.onPrimary, | ||||
|                 fontWeight = FontWeight.Medium, | ||||
|             ), | ||||
|         ) | ||||
|  | ||||
|         // TODO: support more badges (e.g., for library items) | ||||
|     } | ||||
| } | ||||
| @@ -11,6 +11,8 @@ import androidx.compose.ui.Alignment | ||||
| import androidx.compose.ui.Modifier | ||||
| import androidx.compose.ui.res.stringResource | ||||
| import androidx.compose.ui.unit.dp | ||||
| import eu.kanade.presentation.components.Badge | ||||
| import eu.kanade.presentation.components.BadgeGroup | ||||
| import eu.kanade.presentation.components.MangaCover | ||||
| import eu.kanade.tachiyomi.R | ||||
|  | ||||
|   | ||||
| @@ -18,6 +18,8 @@ import androidx.compose.ui.Modifier | ||||
| import androidx.compose.ui.res.stringResource | ||||
| import androidx.compose.ui.unit.dp | ||||
| import eu.kanade.domain.manga.model.MangaCover | ||||
| import eu.kanade.presentation.components.Badge | ||||
| import eu.kanade.presentation.components.BadgeGroup | ||||
| import eu.kanade.presentation.util.horizontalPadding | ||||
| import eu.kanade.presentation.util.selectedBackground | ||||
| import eu.kanade.presentation.util.verticalPadding | ||||
|   | ||||
| @@ -186,7 +186,7 @@ class MangaPresenter( | ||||
|                                 trackingAvailable = trackManager.hasLoggedServices(), | ||||
|                                 chapters = chapterItems, | ||||
|                                 isIncognitoMode = incognitoMode, | ||||
|                                 isDownloadedOnlyMode = downloadedOnlyMode | ||||
|                                 isDownloadedOnlyMode = downloadedOnlyMode, | ||||
|                             ) | ||||
|  | ||||
|                             // Update state | ||||
|   | ||||
		Reference in New Issue
	
	Block a user