|
@@ -1,19 +1,10 @@
|
|
|
package eu.kanade.presentation.history.components
|
|
|
|
|
|
-import androidx.compose.animation.core.LinearEasing
|
|
|
-import androidx.compose.animation.core.animateFloat
|
|
|
-import androidx.compose.animation.core.infiniteRepeatable
|
|
|
-import androidx.compose.animation.core.rememberInfiniteTransition
|
|
|
-import androidx.compose.animation.core.tween
|
|
|
import androidx.compose.foundation.layout.PaddingValues
|
|
|
-import androidx.compose.foundation.lazy.rememberLazyListState
|
|
|
+import androidx.compose.foundation.lazy.items
|
|
|
import androidx.compose.runtime.Composable
|
|
|
import androidx.compose.runtime.remember
|
|
|
import androidx.compose.ui.Modifier
|
|
|
-import androidx.compose.ui.geometry.Offset
|
|
|
-import androidx.compose.ui.graphics.Brush
|
|
|
-import androidx.paging.compose.LazyPagingItems
|
|
|
-import androidx.paging.compose.items
|
|
|
import eu.kanade.domain.history.model.HistoryWithRelations
|
|
|
import eu.kanade.domain.ui.UiPreferences
|
|
|
import eu.kanade.presentation.components.RelativeDateHeader
|
|
@@ -21,7 +12,6 @@ import eu.kanade.presentation.components.ScrollbarLazyColumn
|
|
|
import eu.kanade.presentation.history.HistoryUiModel
|
|
|
import eu.kanade.presentation.util.bottomNavPaddingValues
|
|
|
import eu.kanade.presentation.util.plus
|
|
|
-import eu.kanade.presentation.util.shimmerGradient
|
|
|
import eu.kanade.presentation.util.topPaddingValues
|
|
|
import uy.kohesive.injekt.Injekt
|
|
|
import uy.kohesive.injekt.api.get
|
|
@@ -29,7 +19,7 @@ import java.text.DateFormat
|
|
|
|
|
|
@Composable
|
|
|
fun HistoryContent(
|
|
|
- history: LazyPagingItems<HistoryUiModel>,
|
|
|
+ history: List<HistoryUiModel>,
|
|
|
contentPadding: PaddingValues,
|
|
|
onClickCover: (HistoryWithRelations) -> Unit,
|
|
|
onClickResume: (HistoryWithRelations) -> Unit,
|
|
@@ -41,14 +31,21 @@ fun HistoryContent(
|
|
|
|
|
|
ScrollbarLazyColumn(
|
|
|
contentPadding = contentPadding + bottomNavPaddingValues + topPaddingValues,
|
|
|
- state = rememberLazyListState(),
|
|
|
) {
|
|
|
- items(history) { item ->
|
|
|
+ items(
|
|
|
+ items = history,
|
|
|
+ key = { "history-${it.hashCode()}" },
|
|
|
+ contentType = {
|
|
|
+ when (it) {
|
|
|
+ is HistoryUiModel.Header -> "header"
|
|
|
+ is HistoryUiModel.Item -> "item"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ ) { item ->
|
|
|
when (item) {
|
|
|
is HistoryUiModel.Header -> {
|
|
|
RelativeDateHeader(
|
|
|
- modifier = Modifier
|
|
|
- .animateItemPlacement(),
|
|
|
+ modifier = Modifier.animateItemPlacement(),
|
|
|
date = item.date,
|
|
|
relativeTime = relativeTime,
|
|
|
dateFormat = dateFormat,
|
|
@@ -64,31 +61,6 @@ fun HistoryContent(
|
|
|
onClickDelete = { onClickDelete(value) },
|
|
|
)
|
|
|
}
|
|
|
- null -> {
|
|
|
- val transition = rememberInfiniteTransition()
|
|
|
- val translateAnimation = transition.animateFloat(
|
|
|
- initialValue = 0f,
|
|
|
- targetValue = 1000f,
|
|
|
- animationSpec = infiniteRepeatable(
|
|
|
- animation = tween(
|
|
|
- durationMillis = 1000,
|
|
|
- easing = LinearEasing,
|
|
|
- ),
|
|
|
- ),
|
|
|
- )
|
|
|
-
|
|
|
- val brush = remember {
|
|
|
- Brush.linearGradient(
|
|
|
- colors = shimmerGradient,
|
|
|
- start = Offset(0f, 0f),
|
|
|
- end = Offset(
|
|
|
- x = translateAnimation.value,
|
|
|
- y = 00f,
|
|
|
- ),
|
|
|
- )
|
|
|
- }
|
|
|
- HistoryItemShimmer(brush = brush)
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|