feat: replace programmatic Canvas Google icon with vector drawable resource
This commit is contained in:
@@ -1676,51 +1676,9 @@ fun rememberScrollState() = androidx.compose.foundation.rememberScrollState()
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun GoogleIcon(modifier: Modifier = Modifier.size(16.dp)) {
|
fun GoogleIcon(modifier: Modifier = Modifier.size(16.dp)) {
|
||||||
androidx.compose.foundation.Canvas(modifier = modifier) {
|
androidx.compose.foundation.Image(
|
||||||
val sizePx = size.minDimension
|
painter = androidx.compose.ui.res.painterResource(id = com.example.R.drawable.ic_google),
|
||||||
val strokeWidth = sizePx * 0.18f
|
contentDescription = "Google Logo",
|
||||||
val r = sizePx / 2
|
modifier = modifier
|
||||||
|
|
||||||
val blue = Color(0xFF4285F4)
|
|
||||||
val green = Color(0xFF34A853)
|
|
||||||
val yellow = Color(0xFFFBBC05)
|
|
||||||
val red = Color(0xFFEA4335)
|
|
||||||
|
|
||||||
drawArc(
|
|
||||||
color = red,
|
|
||||||
startAngle = 180f,
|
|
||||||
sweepAngle = 140f,
|
|
||||||
useCenter = false,
|
|
||||||
style = androidx.compose.ui.graphics.drawscope.Stroke(width = strokeWidth)
|
|
||||||
)
|
)
|
||||||
drawArc(
|
|
||||||
color = yellow,
|
|
||||||
startAngle = 140f,
|
|
||||||
sweepAngle = 40f,
|
|
||||||
useCenter = false,
|
|
||||||
style = androidx.compose.ui.graphics.drawscope.Stroke(width = strokeWidth)
|
|
||||||
)
|
|
||||||
drawArc(
|
|
||||||
color = green,
|
|
||||||
startAngle = 0f,
|
|
||||||
sweepAngle = 140f,
|
|
||||||
useCenter = false,
|
|
||||||
style = androidx.compose.ui.graphics.drawscope.Stroke(width = strokeWidth)
|
|
||||||
)
|
|
||||||
drawArc(
|
|
||||||
color = blue,
|
|
||||||
startAngle = 320f,
|
|
||||||
sweepAngle = 40f,
|
|
||||||
useCenter = false,
|
|
||||||
style = androidx.compose.ui.graphics.drawscope.Stroke(width = strokeWidth)
|
|
||||||
)
|
|
||||||
|
|
||||||
val barLength = r * 0.9f
|
|
||||||
drawLine(
|
|
||||||
color = blue,
|
|
||||||
start = center,
|
|
||||||
end = center.copy(x = center.x + barLength),
|
|
||||||
strokeWidth = strokeWidth
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
18
app/src/main/res/drawable/ic_google.xml
Normal file
18
app/src/main/res/drawable/ic_google.xml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#4285F4"
|
||||||
|
android:pathData="M22.56,12.25c0,-0.78 -0.07,-1.53 -0.2,-2.25H12v4.26h5.92c-0.26,1.37 -1.04,2.53 -2.21,3.31v2.77h3.57c2.08,-1.92 3.28,-4.74 3.28,-8.09z"/>
|
||||||
|
<path
|
||||||
|
android:fillColor="#34A853"
|
||||||
|
android:pathData="M12,23c2.97,0 5.46,-0.98 7.28,-2.66l-3.57,-2.77c-0.98,0.66 -2.23,1.06 -3.71,1.06 -2.86,0 -5.29,-1.93 -6.16,-4.53H2.18v2.84C3.99,20.53 7.7,23 12,23z"/>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FBBC05"
|
||||||
|
android:pathData="M5.84,14.09c-0.22,-0.66 -0.35,-1.36 -0.35,-2.09s0.13,-1.43 0.35,-2.09V7.06H2.18C1.43,8.55 1,10.22 1,12s0.43,3.45 1.18,4.94l2.85,-2.22 0.81,-0.63z"/>
|
||||||
|
<path
|
||||||
|
android:fillColor="#EA4335"
|
||||||
|
android:pathData="M12,5.38c1.62,0 3.06,0.56 4.21,1.64l3.15,-3.15C17.45,2.09 14.97,1 12,1 7.7,1 3.99,3.47 2.18,7.06l3.66,2.84c0.87,-2.6 3.3,-4.52 6.16,-4.52z"/>
|
||||||
|
</vector>
|
||||||
Reference in New Issue
Block a user