Fix icon scaling

This commit is contained in:
MM20 2023-05-22 21:31:33 +02:00
parent 0ecc9420c0
commit 875043c214
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389

View File

@ -19,6 +19,7 @@ import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.GenericShape import androidx.compose.foundation.shape.GenericShape
@ -165,7 +166,7 @@ fun ShapedLauncherIcon(
if (bmp != null && ic != null) { if (bmp != null && ic != null) {
Canvas( Canvas(
modifier = Modifier modifier = Modifier
.size(defaultIconSize) .requiredSize(defaultIconSize)
.scale(size / defaultIconSize, TransformOrigin.Center) .scale(size / defaultIconSize, TransformOrigin.Center)
) { ) {
val brush = BitmapShaderBrush(bmp) val brush = BitmapShaderBrush(bmp)
@ -230,8 +231,7 @@ fun ShapedLauncherIcon(
val color = MaterialTheme.colorScheme.secondaryContainer val color = MaterialTheme.colorScheme.secondaryContainer
Canvas( Canvas(
modifier = Modifier modifier = Modifier
.size(defaultIconSize) .fillMaxSize()
.scale(size / defaultIconSize, TransformOrigin.Center)
) { ) {
val outline = val outline =
shape.createOutline(this.size, layoutDirection, Density(density, fontScale)) shape.createOutline(this.size, layoutDirection, Density(density, fontScale))