Skip to content

Commit

Permalink
Update the Compose vector classes that was renamed
Browse files Browse the repository at this point in the history
  • Loading branch information
DevSrSouza committed Jan 15, 2021
1 parent 6c9927a commit 457f048
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = "br.com.devsrsouza"
version = "0.4.0"
version = "0.5.0"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package androidx.compose.material.icons.generator
import androidx.compose.material.icons.generator.util.backingPropertySpec
import androidx.compose.material.icons.generator.util.withBackingProperty
import br.com.devsrsouza.svg2compose.GeneratedGroup
import br.com.devsrsouza.svg2compose.Svg2Compose
import com.squareup.kotlinpoet.*
import com.squareup.kotlinpoet.MemberName.Companion.member
import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy

class AllIconAccessorGenerator(
Expand All @@ -21,7 +19,7 @@ class AllIconAccessorGenerator(
// preventing that a asset has the name List and conflict with Kotlin List import
fileSpec.addAliasedImport(list, "____KtList")

val allIconsType = list.parameterizedBy(ClassNames.VectorAsset)
val allIconsType = list.parameterizedBy(ClassNames.ImageVector)
val allIconsBackingProperty = backingPropertySpec("__$allAssetsPropertyName", allIconsType)

// preventing import conflict when different groups has the same asset name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ enum class PackageNames(val packageName: String) {
*/
object ClassNames {
val Icons = PackageNames.MaterialIconsPackage.className("Icons")
val VectorAsset = PackageNames.VectorPackage.className("VectorAsset")
val ImageVector = PackageNames.VectorPackage.className("ImageVector")
val PathFillType = PackageNames.GraphicsPackage.className("PathFillType")
val StrokeCap = PackageNames.GraphicsPackage.className("StrokeCap")
val StrokeJoin = PackageNames.GraphicsPackage.className("StrokeJoin")
Expand All @@ -44,7 +44,7 @@ object ClassNames {
* [MemberName]s used for icon generation.
*/
object MemberNames {
val VectorAssetBuilder = MemberName(PackageNames.VectorPackage.packageName, "VectorAssetBuilder")
val ImageVectorBuilder = MemberName(ClassNames.ImageVector, "Builder")

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ class VectorAssetGenerator(
// the size from ~6000 to 1, and speed up compilation time for these icons.
@OptIn(ExperimentalStdlibApi::class)
val backingPropertyName = "_" + iconName.decapitalize(Locale.ROOT)
val backingProperty = backingPropertySpec(name = backingPropertyName, ClassNames.VectorAsset)
val backingProperty = backingPropertySpec(name = backingPropertyName, ClassNames.ImageVector)

val generation = FileSpec.builder(
packageName = iconGroupPackage,
fileName = iconName
).addProperty(
PropertySpec.builder(name = iconName, type = ClassNames.VectorAsset)
PropertySpec.builder(name = iconName, type = ClassNames.ImageVector)
.receiver(groupClassName)
.getter(iconGetter(backingProperty))
.build()
Expand Down Expand Up @@ -94,7 +94,7 @@ class VectorAssetGenerator(
val parameters = parameterList.joinToString(prefix = "(", postfix = ")")

val members: Array<Any> = listOfNotNull(
MemberNames.VectorAssetBuilder,
MemberNames.ImageVectorBuilder,
vector.width.memberName,
vector.height.memberName
).toTypedArray()
Expand Down

0 comments on commit 457f048

Please sign in to comment.