1
0
Fork 0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2025-10-03 09:49:21 +02:00

Use ImageVector to render NewPipe squircle app icon

This commit is contained in:
Stypox 2025-09-06 17:22:43 +02:00
parent 9d3775f132
commit b36201442d
No known key found for this signature in database
GPG key ID: 4BDF1B40A49FDD23
2 changed files with 105 additions and 8 deletions

View file

@ -1,12 +1,14 @@
package org.schabi.newpipe.ui.components.about
import androidx.annotation.StringRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.rememberScrollState
@ -16,7 +18,6 @@ import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.NonRestartableComposable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
@ -26,13 +27,12 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider
import androidx.compose.ui.unit.dp
import androidx.core.content.ContextCompat.getDrawable
import coil3.compose.AsyncImage
import my.nanihadesuka.compose.ColumnScrollbar
import org.schabi.newpipe.BuildConfig
import org.schabi.newpipe.R
import org.schabi.newpipe.ui.components.common.defaultThemedScrollbarSettings
import org.schabi.newpipe.util.external_communication.ShareUtils
import org.schabi.newpipe.util.image.NewPipeSquircleIcon
private val ABOUT_ITEMS = listOf(
AboutData(R.string.faq_title, R.string.faq_description, R.string.faq, R.string.faq_url),
@ -83,12 +83,10 @@ fun AboutTab() {
.wrapContentSize(Alignment.Center),
horizontalAlignment = Alignment.CenterHorizontally
) {
// note: the preview
val context = LocalContext.current
val launcherDrawable = remember { getDrawable(context, R.mipmap.ic_launcher) }
AsyncImage(
model = launcherDrawable,
Image(
imageVector = NewPipeSquircleIcon,
contentDescription = stringResource(R.string.app_name),
modifier = Modifier.size(64.dp),
)
Spacer(Modifier.height(4.dp))
Text(

View file

@ -0,0 +1,99 @@
package org.schabi.newpipe.util.image
import androidx.compose.foundation.Image
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
/**
* Generated with https://github.com/rafaeltonholo/svg-to-compose/
* based on assets/newpipe_squircle.svg.
*/
val NewPipeSquircleIcon: ImageVector
get() {
val current = _newPipeIcon
if (current != null) return current
return ImageVector.Builder(
name = "org.schabi.newpipe.ui.theme.AppTheme.NewPipeSquircleIcon",
defaultWidth = 100.0.dp,
defaultHeight = 100.0.dp,
viewportWidth = 100.0f,
viewportHeight = 100.0f,
).apply {
// M0 50 C0 15 15 0 50 0 s50 15 50 50 -15 50 -50 50 S0 85 0 50
path(
fill = SolidColor(Color(0xFFCD201F)),
) {
// M 0 50
moveTo(x = 0.0f, y = 50.0f)
// C 0 15 15 0 50 0
curveTo(
x1 = 0.0f,
y1 = 15.0f,
x2 = 15.0f,
y2 = 0.0f,
x3 = 50.0f,
y3 = 0.0f,
)
// s 50 15 50 50
reflectiveCurveToRelative(
dx1 = 50.0f,
dy1 = 15.0f,
dx2 = 50.0f,
dy2 = 50.0f,
)
// s -15 50 -50 50
reflectiveCurveToRelative(
dx1 = -15.0f,
dy1 = 50.0f,
dx2 = -50.0f,
dy2 = 50.0f,
)
// S 0 85 0 50
reflectiveCurveTo(
x1 = 0.0f,
y1 = 85.0f,
x2 = 0.0f,
y2 = 50.0f,
)
}
// M31.7 19.2 v61.7 l9.7 -5.73 V36 l23.8 14 -17.6 10.35 V71.5 L84 50
path(
fill = SolidColor(Color(0xFFFFFFFF)),
) {
// M 31.7 19.2
moveTo(x = 31.7f, y = 19.2f)
// v 61.7
verticalLineToRelative(dy = 61.7f)
// l 9.7 -5.73
lineToRelative(dx = 9.7f, dy = -5.73f)
// V 36
verticalLineTo(y = 36.0f)
// l 23.8 14
lineToRelative(dx = 23.8f, dy = 14.0f)
// l -17.6 10.35
lineToRelative(dx = -17.6f, dy = 10.35f)
// V 71.5
verticalLineTo(y = 71.5f)
// L 84 50
lineTo(x = 84.0f, y = 50.0f)
}
}.build().also { _newPipeIcon = it }
}
@Preview
@Composable
private fun IconPreview() {
Image(
imageVector = NewPipeSquircleIcon,
contentDescription = null,
)
}
@Suppress("ObjectPropertyName")
private var _newPipeIcon: ImageVector? = null