-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Feature Request:
Allow using full qualifiers when converting SVG to Compose with svgxml2imagevector
CLI tool
Reason:
Right now, when you use the svgxml2imagevector
CLI tool to convert SVGs to Jetpack Compose ImageVector
code, the generated code uses unqualified Compose class names (like Brush
). This can lead to annoying name conflicts, especially if your icon names or other code overlap with Compose’s method names. If we could opt-in to using full qualifiers (e.g., androidx.compose.ui.graphics.Brush
), it’d make the generated code safer and easier to integrate—no more accidental name clashes!
Steps to reproduce:
- Have Icon object for icon pack name
public object Icons
-
Have Icon file named
Brush.kt
with generated compose iconIcons.Brush
-
Have generated compose icon that uses
androidx.compose.ui.graphics.Brush
.
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp
public val Icons.ConflictSample: ImageVector
get() {
if (_ConflictSample != null) {
return _ConflictSample!!
}
_ConflictSample = ImageVector.Builder(
name = "ConflictSample",
defaultWidth = 72.dp,
defaultHeight = 72.dp,
viewportWidth = 72f,
viewportHeight = 72f
).apply {
path(
fill = Brush.linearGradient(
colorStops = arrayOf(
0f to Color(0xFF000000),
1f to Color(0xFFFFFFFF)
),
start = Offset(56.125f, -7.362f),
end = Offset(41.985f, 22.777f)
)
) {
moveTo(19.997f, 9.035f)
lineTo(52.003f, 9.035f)
arcTo(1.997f, 1.997f, 0f, isMoreThanHalf = false, isPositiveArc = true, 54f, 11.032f)
lineTo(54f, 60.038f)
arcTo(1.997f, 1.997f, 0f, isMoreThanHalf = false, isPositiveArc = true, 52.003f, 62.035f)
lineTo(19.997f, 62.035f)
arcTo(1.997f, 1.997f, 0f, isMoreThanHalf = false, isPositiveArc = true, 18f, 60.038f)
lineTo(18f, 11.032f)
arcTo(1.997f, 1.997f, 0f, isMoreThanHalf = false, isPositiveArc = true, 19.997f, 9.035f)
close()
}
}.build()
return _ConflictSample!!
}
@Suppress("ObjectPropertyName")
private var _ConflictSample: ImageVector? = null
- Notice that Compose methods like Brush.linearGradient are used without full qualifiers and Android Studio refers to Brush icon.
- If full qualifier
androidx.compose.ui.graphics.Brush.linearGradient
is added, then project compiles. - Same could happen with
Color
,Box
,SolidColor
etc.
Expected:
There should be a CLI flag (e.g., --use-full-qualifiers
) that forces the tool to use full Compose method qualifiers in the generated code.
Why this matters:
All generated icons live together in the same package, so it’s easy to run into naming collisions. Full qualifiers would make the generated code more robust and easier to maintain.