Skip to content

Commit ea4fecb

Browse files
committed
Use ImageVector to render NewPipe squircle app icon
1 parent 9d3775f commit ea4fecb

2 files changed

Lines changed: 121 additions & 8 deletions

File tree

app/src/main/java/org/schabi/newpipe/ui/components/about/AboutTab.kt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package org.schabi.newpipe.ui.components.about
22

33
import androidx.annotation.StringRes
4+
import androidx.compose.foundation.Image
45
import androidx.compose.foundation.layout.Arrangement
56
import androidx.compose.foundation.layout.Column
67
import androidx.compose.foundation.layout.Spacer
78
import androidx.compose.foundation.layout.fillMaxWidth
89
import androidx.compose.foundation.layout.height
910
import androidx.compose.foundation.layout.padding
11+
import androidx.compose.foundation.layout.size
1012
import androidx.compose.foundation.layout.wrapContentSize
1113
import androidx.compose.foundation.layout.wrapContentWidth
1214
import androidx.compose.foundation.rememberScrollState
@@ -16,7 +18,6 @@ import androidx.compose.material3.Text
1618
import androidx.compose.material3.TextButton
1719
import androidx.compose.runtime.Composable
1820
import androidx.compose.runtime.NonRestartableComposable
19-
import androidx.compose.runtime.remember
2021
import androidx.compose.ui.Alignment
2122
import androidx.compose.ui.Modifier
2223
import androidx.compose.ui.platform.LocalContext
@@ -26,13 +27,12 @@ import androidx.compose.ui.tooling.preview.Preview
2627
import androidx.compose.ui.tooling.preview.PreviewParameter
2728
import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider
2829
import androidx.compose.ui.unit.dp
29-
import androidx.core.content.ContextCompat.getDrawable
30-
import coil3.compose.AsyncImage
3130
import my.nanihadesuka.compose.ColumnScrollbar
3231
import org.schabi.newpipe.BuildConfig
3332
import org.schabi.newpipe.R
3433
import org.schabi.newpipe.ui.components.common.defaultThemedScrollbarSettings
3534
import org.schabi.newpipe.util.external_communication.ShareUtils
35+
import org.schabi.newpipe.util.image.NewPipeSquircleIcon
3636

3737
private val ABOUT_ITEMS = listOf(
3838
AboutData(R.string.faq_title, R.string.faq_description, R.string.faq, R.string.faq_url),
@@ -83,12 +83,10 @@ fun AboutTab() {
8383
.wrapContentSize(Alignment.Center),
8484
horizontalAlignment = Alignment.CenterHorizontally
8585
) {
86-
// note: the preview
87-
val context = LocalContext.current
88-
val launcherDrawable = remember { getDrawable(context, R.mipmap.ic_launcher) }
89-
AsyncImage(
90-
model = launcherDrawable,
86+
Image(
87+
imageVector = NewPipeSquircleIcon,
9188
contentDescription = stringResource(R.string.app_name),
89+
modifier = Modifier.size(64.dp),
9290
)
9391
Spacer(Modifier.height(4.dp))
9492
Text(
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
package org.schabi.newpipe.util.image
2+
3+
import androidx.compose.foundation.Image
4+
import androidx.compose.foundation.layout.Arrangement
5+
import androidx.compose.foundation.layout.Column
6+
import androidx.compose.foundation.layout.height
7+
import androidx.compose.foundation.layout.width
8+
import androidx.compose.runtime.Composable
9+
import androidx.compose.ui.Alignment
10+
import androidx.compose.ui.Modifier
11+
import androidx.compose.ui.graphics.Color
12+
import androidx.compose.ui.graphics.SolidColor
13+
import androidx.compose.ui.graphics.vector.ImageVector
14+
import androidx.compose.ui.graphics.vector.path
15+
import androidx.compose.ui.tooling.preview.Preview
16+
import androidx.compose.ui.unit.dp
17+
18+
/**
19+
* Generated with https://github.com/rafaeltonholo/svg-to-compose/
20+
* based on assets/newpipe_squircle.svg.
21+
*/
22+
val NewPipeSquircleIcon: ImageVector
23+
get() {
24+
val current = _newPipeIcon
25+
if (current != null) return current
26+
27+
return ImageVector.Builder(
28+
name = "org.schabi.newpipe.ui.theme.AppTheme.NewPipeSquircleIcon",
29+
defaultWidth = 100.0.dp,
30+
defaultHeight = 100.0.dp,
31+
viewportWidth = 100.0f,
32+
viewportHeight = 100.0f,
33+
).apply {
34+
// M0 50 C0 15 15 0 50 0 s50 15 50 50 -15 50 -50 50 S0 85 0 50
35+
path(
36+
fill = SolidColor(Color(0xFFCD201F)),
37+
) {
38+
// M 0 50
39+
moveTo(x = 0.0f, y = 50.0f)
40+
// C 0 15 15 0 50 0
41+
curveTo(
42+
x1 = 0.0f,
43+
y1 = 15.0f,
44+
x2 = 15.0f,
45+
y2 = 0.0f,
46+
x3 = 50.0f,
47+
y3 = 0.0f,
48+
)
49+
// s 50 15 50 50
50+
reflectiveCurveToRelative(
51+
dx1 = 50.0f,
52+
dy1 = 15.0f,
53+
dx2 = 50.0f,
54+
dy2 = 50.0f,
55+
)
56+
// s -15 50 -50 50
57+
reflectiveCurveToRelative(
58+
dx1 = -15.0f,
59+
dy1 = 50.0f,
60+
dx2 = -50.0f,
61+
dy2 = 50.0f,
62+
)
63+
// S 0 85 0 50
64+
reflectiveCurveTo(
65+
x1 = 0.0f,
66+
y1 = 85.0f,
67+
x2 = 0.0f,
68+
y2 = 50.0f,
69+
)
70+
}
71+
// M31.7 19.2 v61.7 l9.7 -5.73 V36 l23.8 14 -17.6 10.35 V71.5 L84 50
72+
path(
73+
fill = SolidColor(Color(0xFFFFFFFF)),
74+
) {
75+
// M 31.7 19.2
76+
moveTo(x = 31.7f, y = 19.2f)
77+
// v 61.7
78+
verticalLineToRelative(dy = 61.7f)
79+
// l 9.7 -5.73
80+
lineToRelative(dx = 9.7f, dy = -5.73f)
81+
// V 36
82+
verticalLineTo(y = 36.0f)
83+
// l 23.8 14
84+
lineToRelative(dx = 23.8f, dy = 14.0f)
85+
// l -17.6 10.35
86+
lineToRelative(dx = -17.6f, dy = 10.35f)
87+
// V 71.5
88+
verticalLineTo(y = 71.5f)
89+
// L 84 50
90+
lineTo(x = 84.0f, y = 50.0f)
91+
}
92+
}.build().also { _newPipeIcon = it }
93+
}
94+
95+
@Preview
96+
@Composable
97+
private fun IconPreview() {
98+
org.schabi.newpipe.ui.theme.AppTheme {
99+
Column(
100+
verticalArrangement = Arrangement.spacedBy(8.dp),
101+
horizontalAlignment = Alignment.CenterHorizontally,
102+
) {
103+
Image(
104+
imageVector = NewPipeSquircleIcon,
105+
contentDescription = null,
106+
modifier = Modifier
107+
.width((100.0).dp)
108+
.height((100.0).dp),
109+
)
110+
}
111+
}
112+
}
113+
114+
@Suppress("ObjectPropertyName")
115+
private var _newPipeIcon: ImageVector? = null

0 commit comments

Comments
 (0)