LibraryGridCover.kt 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package eu.kanade.presentation.library.components
  2. import androidx.compose.foundation.layout.Box
  3. import androidx.compose.foundation.layout.BoxScope
  4. import androidx.compose.foundation.layout.aspectRatio
  5. import androidx.compose.foundation.layout.fillMaxWidth
  6. import androidx.compose.foundation.layout.padding
  7. import androidx.compose.material3.MaterialTheme
  8. import androidx.compose.runtime.Composable
  9. import androidx.compose.ui.Alignment
  10. import androidx.compose.ui.Modifier
  11. import androidx.compose.ui.res.stringResource
  12. import androidx.compose.ui.unit.dp
  13. import eu.kanade.presentation.components.MangaCover
  14. import eu.kanade.tachiyomi.R
  15. @Composable
  16. fun LibraryGridCover(
  17. modifier: Modifier = Modifier,
  18. mangaCover: eu.kanade.domain.manga.model.MangaCover,
  19. downloadCount: Int,
  20. unreadCount: Int,
  21. isLocal: Boolean,
  22. language: String,
  23. content: @Composable BoxScope.() -> Unit = {},
  24. ) {
  25. Box(
  26. modifier = modifier
  27. .fillMaxWidth()
  28. .aspectRatio(MangaCover.Book.ratio),
  29. ) {
  30. MangaCover.Book(
  31. modifier = Modifier.fillMaxWidth(),
  32. data = mangaCover,
  33. )
  34. content()
  35. BadgeGroup(
  36. modifier = Modifier
  37. .padding(4.dp)
  38. .align(Alignment.TopStart),
  39. ) {
  40. if (downloadCount > 0) {
  41. Badge(
  42. text = "$downloadCount",
  43. color = MaterialTheme.colorScheme.tertiary,
  44. textColor = MaterialTheme.colorScheme.onTertiary,
  45. )
  46. }
  47. if (unreadCount > 0) {
  48. Badge(text = "$unreadCount")
  49. }
  50. }
  51. BadgeGroup(
  52. modifier = Modifier
  53. .padding(4.dp)
  54. .align(Alignment.TopEnd),
  55. ) {
  56. if (isLocal) {
  57. Badge(
  58. text = stringResource(R.string.local_source_badge),
  59. color = MaterialTheme.colorScheme.tertiary,
  60. textColor = MaterialTheme.colorScheme.onTertiary,
  61. )
  62. }
  63. if (isLocal.not() && language.isNotEmpty()) {
  64. Badge(
  65. text = language,
  66. color = MaterialTheme.colorScheme.tertiary,
  67. textColor = MaterialTheme.colorScheme.onTertiary,
  68. )
  69. }
  70. }
  71. }
  72. }