diff --git a/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt b/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt index 40588cdec..69e70a59f 100644 --- a/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt @@ -99,28 +99,6 @@ fun HistoryContent( val scrollState = rememberLazyListState() - val transition = rememberInfiniteTransition() - - val translateAnimation = transition.animateFloat( - initialValue = 0f, - targetValue = 1000f, - animationSpec = infiniteRepeatable( - animation = tween( - durationMillis = 1000, - easing = LinearEasing, - ), - ), - ) - - val brush = linearGradient( - colors = shimmerGradient, - start = Offset(0f, 0f), - end = Offset( - x = translateAnimation.value, - y = 00f, - ), - ) - ScrollbarLazyColumn( modifier = Modifier .nestedScroll(nestedScroll), @@ -149,6 +127,28 @@ fun HistoryContent( ) } null -> { + val transition = rememberInfiniteTransition() + val translateAnimation = transition.animateFloat( + initialValue = 0f, + targetValue = 1000f, + animationSpec = infiniteRepeatable( + animation = tween( + durationMillis = 1000, + easing = LinearEasing, + ), + ), + ) + + val brush = remember { + linearGradient( + colors = shimmerGradient, + start = Offset(0f, 0f), + end = Offset( + x = translateAnimation.value, + y = 00f, + ), + ) + } HistoryItemShimmer(brush = brush) } } diff --git a/app/src/main/java/eu/kanade/presentation/history/components/HistoryHeader.kt b/app/src/main/java/eu/kanade/presentation/history/components/HistoryHeader.kt index 18f5b5f64..747955fe1 100644 --- a/app/src/main/java/eu/kanade/presentation/history/components/HistoryHeader.kt +++ b/app/src/main/java/eu/kanade/presentation/history/components/HistoryHeader.kt @@ -4,6 +4,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.font.FontWeight @@ -20,14 +21,17 @@ fun HistoryHeader( relativeTime: Int, dateFormat: DateFormat, ) { + val context = LocalContext.current Text( modifier = modifier .padding(horizontal = horizontalPadding, vertical = 8.dp), - text = date.toRelativeString( - LocalContext.current, - relativeTime, - dateFormat, - ), + text = remember { + date.toRelativeString( + context, + relativeTime, + dateFormat, + ) + }, style = MaterialTheme.typography.bodyMedium.copy( color = MaterialTheme.colorScheme.onSurfaceVariant, fontWeight = FontWeight.SemiBold, diff --git a/app/src/main/java/eu/kanade/presentation/history/components/HistoryItem.kt b/app/src/main/java/eu/kanade/presentation/history/components/HistoryItem.kt index 1be3d22d7..e720ce46d 100644 --- a/app/src/main/java/eu/kanade/presentation/history/components/HistoryItem.kt +++ b/app/src/main/java/eu/kanade/presentation/history/components/HistoryItem.kt @@ -17,6 +17,7 @@ import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -68,15 +69,16 @@ fun HistoryItem( overflow = TextOverflow.Ellipsis, style = textStyle.copy(fontWeight = FontWeight.SemiBold), ) + val readAt = remember { history.readAt?.toTimestampString() ?: "" } Text( text = if (history.chapterNumber > -1) { stringResource( R.string.recent_manga_time, chapterFormatter.format(history.chapterNumber), - history.readAt?.toTimestampString() ?: "", + readAt, ) } else { - history.readAt?.toTimestampString() ?: "" + readAt }, modifier = Modifier.padding(top = 4.dp), style = textStyle,