2022-07-18 08:17:40 +06:00
|
|
|
package eu.kanade.presentation.components
|
2022-06-18 20:55:58 +02:00
|
|
|
|
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
|
import androidx.compose.material3.Text
|
|
|
|
import androidx.compose.runtime.Composable
|
2022-06-28 05:33:57 +07:00
|
|
|
import androidx.compose.runtime.remember
|
2022-06-18 20:55:58 +02:00
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
import eu.kanade.presentation.util.horizontalPadding
|
|
|
|
import eu.kanade.tachiyomi.util.lang.toRelativeString
|
|
|
|
import java.text.DateFormat
|
|
|
|
import java.util.Date
|
|
|
|
|
|
|
|
@Composable
|
2022-07-18 08:17:40 +06:00
|
|
|
fun RelativeDateHeader(
|
2022-06-18 20:55:58 +02:00
|
|
|
modifier: Modifier = Modifier,
|
|
|
|
date: Date,
|
|
|
|
relativeTime: Int,
|
|
|
|
dateFormat: DateFormat,
|
|
|
|
) {
|
2022-06-28 05:33:57 +07:00
|
|
|
val context = LocalContext.current
|
2022-06-18 20:55:58 +02:00
|
|
|
Text(
|
|
|
|
modifier = modifier
|
|
|
|
.padding(horizontal = horizontalPadding, vertical = 8.dp),
|
2022-06-28 05:33:57 +07:00
|
|
|
text = remember {
|
|
|
|
date.toRelativeString(
|
|
|
|
context,
|
|
|
|
relativeTime,
|
|
|
|
dateFormat,
|
|
|
|
)
|
|
|
|
},
|
2022-06-18 20:55:58 +02:00
|
|
|
style = MaterialTheme.typography.bodyMedium.copy(
|
|
|
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
|
|
|
fontWeight = FontWeight.SemiBold,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
}
|