Show solid color while icons are rendered

This commit is contained in:
MM20 2023-05-16 17:11:54 +02:00
parent e646844623
commit 49343e9690
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389

View File

@ -52,7 +52,6 @@ import androidx.compose.ui.graphics.drawOutline
import androidx.compose.ui.graphics.drawscope.drawIntoCanvas import androidx.compose.ui.graphics.drawscope.drawIntoCanvas
import androidx.compose.ui.graphics.drawscope.scale import androidx.compose.ui.graphics.drawscope.scale
import androidx.compose.ui.graphics.drawscope.withTransform import androidx.compose.ui.graphics.drawscope.withTransform
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.nativeCanvas import androidx.compose.ui.graphics.nativeCanvas
import androidx.compose.ui.graphics.toAndroidRect import androidx.compose.ui.graphics.toAndroidRect
import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.graphics.toArgb
@ -164,22 +163,27 @@ fun ShapedLauncherIcon(
val bmp = currentBitmap val bmp = currentBitmap
val ic = currentIcon val ic = currentIcon
if (bmp != null && ic != null) { if (bmp != null && ic != null) {
Canvas(modifier = Modifier Canvas(
.size(defaultIconSize) modifier = Modifier
.scale(size / defaultIconSize, TransformOrigin.Center) .size(defaultIconSize)
.scale(size / defaultIconSize, TransformOrigin.Center)
) { ) {
val brush = BitmapShaderBrush(bmp) val brush = BitmapShaderBrush(bmp)
if (ic.backgroundLayer is TransparentLayer) { if (ic.backgroundLayer is TransparentLayer) {
drawRect(brush) drawRect(brush)
} else { } else {
val outline = val outline =
shape.createOutline(this.size, layoutDirection, Density(density, fontScale)) shape.createOutline(
this.size,
layoutDirection,
Density(density, fontScale)
)
drawOutline(outline, brush) drawOutline(outline, brush)
} }
} }
// Background layer is always static layer, color layer, or transparent layer // Background layer is always static layer, color layer, or transparent layer
val fg = ic.foregroundLayer val fg = ic.foregroundLayer
when(fg) { when (fg) {
is ClockLayer -> { is ClockLayer -> {
ClockLayer( ClockLayer(
sublayers = fg.sublayers, sublayers = fg.sublayers,
@ -190,6 +194,7 @@ fun ShapedLauncherIcon(
tintColor = null, tintColor = null,
) )
} }
is TintedClockLayer -> { is TintedClockLayer -> {
ClockLayer( ClockLayer(
sublayers = fg.sublayers, sublayers = fg.sublayers,
@ -204,6 +209,7 @@ fun ShapedLauncherIcon(
}, },
) )
} }
is TextLayer -> { is TextLayer -> {
Text( Text(
text = fg.text, text = fg.text,
@ -217,8 +223,20 @@ fun ShapedLauncherIcon(
}, },
) )
} }
else -> {} else -> {}
} }
} else {
val color = MaterialTheme.colorScheme.secondaryContainer
Canvas(
modifier = Modifier
.size(defaultIconSize)
.scale(size / defaultIconSize, TransformOrigin.Center)
) {
val outline =
shape.createOutline(this.size, layoutDirection, Density(density, fontScale))
drawOutline(outline, color)
}
} }
} }
val _badge = badge() val _badge = badge()