mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 03:07:25 +01:00
Improve history screen scrolling perf (#7399)
This commit is contained in:
parent
7440086ef1
commit
e44bb30996
@ -99,28 +99,6 @@ fun HistoryContent(
|
|||||||
|
|
||||||
val scrollState = rememberLazyListState()
|
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(
|
ScrollbarLazyColumn(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.nestedScroll(nestedScroll),
|
.nestedScroll(nestedScroll),
|
||||||
@ -149,6 +127,28 @@ fun HistoryContent(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
null -> {
|
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)
|
HistoryItemShimmer(brush = brush)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import androidx.compose.foundation.layout.padding
|
|||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
@ -20,14 +21,17 @@ fun HistoryHeader(
|
|||||||
relativeTime: Int,
|
relativeTime: Int,
|
||||||
dateFormat: DateFormat,
|
dateFormat: DateFormat,
|
||||||
) {
|
) {
|
||||||
|
val context = LocalContext.current
|
||||||
Text(
|
Text(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.padding(horizontal = horizontalPadding, vertical = 8.dp),
|
.padding(horizontal = horizontalPadding, vertical = 8.dp),
|
||||||
text = date.toRelativeString(
|
text = remember {
|
||||||
LocalContext.current,
|
date.toRelativeString(
|
||||||
|
context,
|
||||||
relativeTime,
|
relativeTime,
|
||||||
dateFormat,
|
dateFormat,
|
||||||
),
|
)
|
||||||
|
},
|
||||||
style = MaterialTheme.typography.bodyMedium.copy(
|
style = MaterialTheme.typography.bodyMedium.copy(
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
fontWeight = FontWeight.SemiBold,
|
fontWeight = FontWeight.SemiBold,
|
||||||
|
@ -17,6 +17,7 @@ import androidx.compose.material3.IconButton
|
|||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
@ -68,15 +69,16 @@ fun HistoryItem(
|
|||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
style = textStyle.copy(fontWeight = FontWeight.SemiBold),
|
style = textStyle.copy(fontWeight = FontWeight.SemiBold),
|
||||||
)
|
)
|
||||||
|
val readAt = remember { history.readAt?.toTimestampString() ?: "" }
|
||||||
Text(
|
Text(
|
||||||
text = if (history.chapterNumber > -1) {
|
text = if (history.chapterNumber > -1) {
|
||||||
stringResource(
|
stringResource(
|
||||||
R.string.recent_manga_time,
|
R.string.recent_manga_time,
|
||||||
chapterFormatter.format(history.chapterNumber),
|
chapterFormatter.format(history.chapterNumber),
|
||||||
history.readAt?.toTimestampString() ?: "",
|
readAt,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
history.readAt?.toTimestampString() ?: ""
|
readAt
|
||||||
},
|
},
|
||||||
modifier = Modifier.padding(top = 4.dp),
|
modifier = Modifier.padding(top = 4.dp),
|
||||||
style = textStyle,
|
style = textStyle,
|
||||||
|
Loading…
Reference in New Issue
Block a user