Library category page performance fixes (#7650)

* Don't compose category page unnecessarily

* Remove unnecessary library pager recompose

Defer and remember the "currentPage" state read since it's only needed when the
pager is composed for the first time.

* Badge opts

* Sync text style with previous impl

Also avoid reallocating by using copy
This commit is contained in:
Ivan Iskandar
2022-07-30 22:47:27 +07:00
committed by GitHub
parent f90e1b935c
commit d49ec41f3a
7 changed files with 68 additions and 63 deletions

View File

@@ -1,12 +1,10 @@
package eu.kanade.presentation.components
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
@@ -36,18 +34,15 @@ fun Badge(
textColor: Color = MaterialTheme.colorScheme.onSecondary,
shape: Shape = RectangleShape,
) {
Box(
Text(
text = text,
modifier = Modifier
.clip(shape)
.background(color),
) {
Text(
text = text,
modifier = Modifier.padding(horizontal = 4.dp, vertical = 2.dp),
style = LocalTextStyle.current.copy(
color = textColor,
fontWeight = FontWeight.Medium,
),
)
}
.background(color)
.padding(horizontal = 3.dp, vertical = 1.dp),
color = textColor,
fontWeight = FontWeight.Medium,
maxLines = 1,
style = MaterialTheme.typography.bodySmall,
)
}