PageIndicatorText.kt 1.5 KB

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