PageIndicatorText.kt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package eu.kanade.presentation.reader
  2. import androidx.compose.foundation.layout.Box
  3. import androidx.compose.material3.MaterialTheme
  4. import androidx.compose.material3.Text
  5. import androidx.compose.runtime.Composable
  6. import androidx.compose.ui.Alignment
  7. import androidx.compose.ui.graphics.Color
  8. import androidx.compose.ui.graphics.drawscope.Stroke
  9. import androidx.compose.ui.text.TextStyle
  10. import androidx.compose.ui.text.font.FontWeight
  11. import androidx.compose.ui.unit.sp
  12. import eu.kanade.presentation.theme.TachiyomiTheme
  13. import tachiyomi.presentation.core.util.ThemePreviews
  14. @Composable
  15. fun PageIndicatorText(
  16. currentPage: Int,
  17. totalPages: Int,
  18. ) {
  19. if (currentPage <= 0 || totalPages <= 0) return
  20. val text = "$currentPage / $totalPages"
  21. val style = TextStyle(
  22. color = Color(235, 235, 235),
  23. fontSize = MaterialTheme.typography.bodySmall.fontSize,
  24. fontWeight = FontWeight.Bold,
  25. letterSpacing = 1.sp,
  26. )
  27. val strokeStyle = style.copy(
  28. color = Color(45, 45, 45),
  29. drawStyle = Stroke(width = 4f),
  30. )
  31. Box(
  32. contentAlignment = Alignment.Center,
  33. ) {
  34. Text(
  35. text = text,
  36. style = strokeStyle,
  37. )
  38. Text(
  39. text = text,
  40. style = style,
  41. )
  42. }
  43. }
  44. @ThemePreviews
  45. @Composable
  46. private fun PageIndicatorTextPreview() {
  47. TachiyomiTheme {
  48. PageIndicatorText(currentPage = 10, totalPages = 69)
  49. }
  50. }