RelativeDateHeader.kt 791 B

123456789101112131415161718192021222324252627282930
  1. package eu.kanade.presentation.components
  2. import androidx.compose.runtime.Composable
  3. import androidx.compose.runtime.remember
  4. import androidx.compose.ui.Modifier
  5. import androidx.compose.ui.platform.LocalContext
  6. import eu.kanade.tachiyomi.util.lang.toRelativeString
  7. import tachiyomi.presentation.core.components.ListGroupHeader
  8. import java.text.DateFormat
  9. import java.util.Date
  10. @Composable
  11. fun RelativeDateHeader(
  12. date: Date,
  13. relativeTime: Boolean,
  14. dateFormat: DateFormat,
  15. modifier: Modifier = Modifier,
  16. ) {
  17. val context = LocalContext.current
  18. ListGroupHeader(
  19. modifier = modifier,
  20. text = remember {
  21. date.toRelativeString(
  22. context,
  23. relativeTime,
  24. dateFormat,
  25. )
  26. },
  27. )
  28. }