Skip to content

Commit

Permalink
generate icon with "ImageVector.Builder", simplify imports
Browse files Browse the repository at this point in the history
  • Loading branch information
egorikftp committed Jul 4, 2024
1 parent 4859b51 commit d5ca39d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ object ClassNames {
* [MemberName]s used for icon generation.
*/
object MemberNames {
val ImageVectorBuilder = MemberName(ClassNames.ImageVector, "Builder")

val Path = MemberName(PackageNames.VectorPackage.packageName, "path")

val EvenOdd = MemberName(ClassNames.PathFillType, "EvenOdd")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.composegears.valkyrie.processing.generator.imagevector.util

import androidx.compose.material.icons.generator.ClassNames
import androidx.compose.material.icons.generator.MemberNames
import androidx.compose.material.icons.generator.MemberNames.ImageVectorBuilder
import androidx.compose.material.icons.generator.vector.Vector
import com.squareup.kotlinpoet.CodeBlock
import com.squareup.kotlinpoet.buildCodeBlock
Expand All @@ -13,7 +13,7 @@ fun imageVectorBuilderSpecs(
vector: Vector,
path: CodeBlock.Builder.() -> Unit,
): CodeBlock = buildCodeBlock {
add("%M(\n", ImageVectorBuilder)
add("%T.Builder(\n", ClassNames.ImageVector)
indent()
add("name = %S,\n", iconName)
add("defaultWidth = %L.%M,\n", vector.width.value.trimTrailingZero(), MemberNames.Dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class PreviewGenerationTest {
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.ImageVector.Builder
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand All @@ -40,7 +39,7 @@ class PreviewGenerationTest {
if (_WithoutPath != null) {
return _WithoutPath!!
}
_WithoutPath = Builder(
_WithoutPath = ImageVector.Builder(
name = "WithoutPath",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
Expand Down Expand Up @@ -88,7 +87,6 @@ class PreviewGenerationTest {
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.ImageVector.Builder
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand All @@ -97,7 +95,7 @@ class PreviewGenerationTest {
if (_WithoutPath != null) {
return _WithoutPath!!
}
_WithoutPath = Builder(
_WithoutPath = ImageVector.Builder(
name = "WithoutPath",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
Expand Down Expand Up @@ -145,7 +143,6 @@ class PreviewGenerationTest {
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.ImageVector.Builder
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.github.composegears.valkyrie.icons.ValkyrieIcons
Expand All @@ -155,7 +152,7 @@ class PreviewGenerationTest {
if (_WithoutPath != null) {
return _WithoutPath!!
}
_WithoutPath = Builder(
_WithoutPath = ImageVector.Builder(
name = "Filled.WithoutPath",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ class XmlIconParserTest {
package io.github.composegears.valkyrie.icons
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.ImageVector.Builder
import androidx.compose.ui.unit.dp
val WithoutPath: ImageVector
get() {
if (_WithoutPath != null) {
return _WithoutPath!!
}
_WithoutPath = Builder(
_WithoutPath = ImageVector.Builder(
name = "WithoutPath",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
Expand Down Expand Up @@ -69,7 +68,6 @@ class XmlIconParserTest {
package io.github.composegears.valkyrie.icons.colored
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.ImageVector.Builder
import androidx.compose.ui.unit.dp
import io.github.composegears.valkyrie.icons.ValkyrieIcons
Expand All @@ -78,7 +76,7 @@ class XmlIconParserTest {
if (_WithoutPath != null) {
return _WithoutPath!!
}
_WithoutPath = Builder(
_WithoutPath = ImageVector.Builder(
name = "Colored.WithoutPath",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
Expand Down Expand Up @@ -108,15 +106,14 @@ class XmlIconParserTest {
package io.github.composegears.valkyrie.icons
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.ImageVector.Builder
import androidx.compose.ui.unit.dp
val ValkyrieIcons.WithoutPath: ImageVector
get() {
if (_WithoutPath != null) {
return _WithoutPath!!
}
_WithoutPath = Builder(
_WithoutPath = ImageVector.Builder(
name = "WithoutPath",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
Expand Down Expand Up @@ -146,7 +143,6 @@ class XmlIconParserTest {
package io.github.composegears.valkyrie.icons
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.ImageVector.Builder
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp
Expand All @@ -155,7 +151,7 @@ class XmlIconParserTest {
if (_OnlyPath != null) {
return _OnlyPath!!
}
_OnlyPath = Builder(
_OnlyPath = ImageVector.Builder(
name = "OnlyPath",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
Expand Down Expand Up @@ -198,7 +194,6 @@ class XmlIconParserTest {
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.ImageVector.Builder
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp
Expand All @@ -207,7 +202,7 @@ class XmlIconParserTest {
if (_FillColorStroke != null) {
return _FillColorStroke!!
}
_FillColorStroke = Builder(
_FillColorStroke = ImageVector.Builder(
name = "FillColorStroke",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
Expand Down Expand Up @@ -256,7 +251,6 @@ class XmlIconParserTest {
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.StrokeJoin
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.ImageVector.Builder
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp
Expand All @@ -265,7 +259,7 @@ class XmlIconParserTest {
if (_AllPathParams != null) {
return _AllPathParams!!
}
_AllPathParams = Builder(
_AllPathParams = ImageVector.Builder(
name = "AllPathParams",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
Expand Down Expand Up @@ -318,7 +312,6 @@ class XmlIconParserTest {
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.ImageVector.Builder
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp
Expand All @@ -327,7 +320,7 @@ class XmlIconParserTest {
if (_SeveralPath != null) {
return _SeveralPath!!
}
_SeveralPath = Builder(
_SeveralPath = ImageVector.Builder(
name = "SeveralPath",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
Expand Down

0 comments on commit d5ca39d

Please sign in to comment.