-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to export icons in flat package
- Loading branch information
Showing
22 changed files
with
315 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
...rc/test/kotlin/io/github/composegears/valkyrie/generator/imagevector/CustomPackageTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package io.github.composegears.valkyrie.generator.imagevector | ||
|
||
import assertk.assertThat | ||
import assertk.assertions.isEqualTo | ||
import io.github.composegears.valkyrie.extensions.ResourceUtils.getResourcePath | ||
import io.github.composegears.valkyrie.generator.imagevector.common.toResourceText | ||
import io.github.composegears.valkyrie.parser.svgxml.SvgXmlParser | ||
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.EnumSource | ||
|
||
class CustomPackageTest { | ||
|
||
@ParameterizedTest | ||
@EnumSource(value = OutputFormat::class) | ||
fun `flat package without icon pack`(outputFormat: OutputFormat) { | ||
val icon = getResourcePath("xml/ic_flat_package.xml") | ||
val parserOutput = SvgXmlParser.toIrImageVector(icon) | ||
val output = ImageVectorGenerator.convert( | ||
vector = parserOutput.vector, | ||
kotlinName = parserOutput.kotlinName, | ||
config = ImageVectorGeneratorConfig( | ||
packageName = "io.github.composegears.valkyrie.icons", | ||
packName = "", | ||
nestedPackName = "", | ||
outputFormat = outputFormat, | ||
generatePreview = false, | ||
useFlatPackage = true, | ||
), | ||
).content | ||
|
||
val expected = outputFormat.toResourceText( | ||
pathToBackingProperty = "kt/backing/FlatPackage.kt", | ||
pathToLazyProperty = "kt/lazy/FlatPackage.kt", | ||
) | ||
assertThat(output).isEqualTo(expected) | ||
} | ||
|
||
@ParameterizedTest | ||
@EnumSource(value = OutputFormat::class) | ||
fun `flat package with icon pack`(outputFormat: OutputFormat) { | ||
val icon = getResourcePath("xml/ic_flat_package.xml") | ||
val parserOutput = SvgXmlParser.toIrImageVector(icon) | ||
val output = ImageVectorGenerator.convert( | ||
vector = parserOutput.vector, | ||
kotlinName = parserOutput.kotlinName, | ||
config = ImageVectorGeneratorConfig( | ||
packageName = "io.github.composegears.valkyrie.icons", | ||
packName = "ValkyrieIcons", | ||
nestedPackName = "", | ||
outputFormat = outputFormat, | ||
generatePreview = false, | ||
useFlatPackage = true, | ||
), | ||
).content | ||
|
||
val expected = outputFormat.toResourceText( | ||
pathToBackingProperty = "kt/backing/FlatPackage.pack.kt", | ||
pathToLazyProperty = "kt/lazy/FlatPackage.pack.kt", | ||
) | ||
assertThat(output).isEqualTo(expected) | ||
} | ||
|
||
@ParameterizedTest | ||
@EnumSource(value = OutputFormat::class) | ||
fun `flat package with nested icon pack`(outputFormat: OutputFormat) { | ||
val icon = getResourcePath("xml/ic_flat_package.xml") | ||
val parserOutput = SvgXmlParser.toIrImageVector(icon) | ||
val output = ImageVectorGenerator.convert( | ||
vector = parserOutput.vector, | ||
kotlinName = parserOutput.kotlinName, | ||
config = ImageVectorGeneratorConfig( | ||
packageName = "io.github.composegears.valkyrie.icons", | ||
packName = "ValkyrieIcons", | ||
nestedPackName = "Filled", | ||
outputFormat = outputFormat, | ||
generatePreview = false, | ||
useFlatPackage = true, | ||
), | ||
).content | ||
|
||
val expected = outputFormat.toResourceText( | ||
pathToBackingProperty = "kt/backing/FlatPackage.pack.nested.kt", | ||
pathToLazyProperty = "kt/lazy/FlatPackage.pack.nested.kt", | ||
) | ||
assertThat(output).isEqualTo(expected) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
components/generator/imagevector/src/test/resources/kt/backing/FlatPackage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.github.composegears.valkyrie.icons | ||
|
||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.unit.dp | ||
import kotlin.Suppress | ||
|
||
val FlatPackage: ImageVector | ||
get() { | ||
if (_FlatPackage != null) { | ||
return _FlatPackage!! | ||
} | ||
_FlatPackage = ImageVector.Builder( | ||
name = "FlatPackage", | ||
defaultWidth = 24.dp, | ||
defaultHeight = 24.dp, | ||
viewportWidth = 18f, | ||
viewportHeight = 18f | ||
).build() | ||
|
||
return _FlatPackage!! | ||
} | ||
|
||
@Suppress("ObjectPropertyName") | ||
private var _FlatPackage: ImageVector? = null |
24 changes: 24 additions & 0 deletions
24
components/generator/imagevector/src/test/resources/kt/backing/FlatPackage.pack.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.github.composegears.valkyrie.icons | ||
|
||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.unit.dp | ||
import kotlin.Suppress | ||
|
||
val ValkyrieIcons.FlatPackage: ImageVector | ||
get() { | ||
if (_FlatPackage != null) { | ||
return _FlatPackage!! | ||
} | ||
_FlatPackage = ImageVector.Builder( | ||
name = "FlatPackage", | ||
defaultWidth = 24.dp, | ||
defaultHeight = 24.dp, | ||
viewportWidth = 18f, | ||
viewportHeight = 18f | ||
).build() | ||
|
||
return _FlatPackage!! | ||
} | ||
|
||
@Suppress("ObjectPropertyName") | ||
private var _FlatPackage: ImageVector? = null |
24 changes: 24 additions & 0 deletions
24
components/generator/imagevector/src/test/resources/kt/backing/FlatPackage.pack.nested.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.github.composegears.valkyrie.icons | ||
|
||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.unit.dp | ||
import kotlin.Suppress | ||
|
||
val ValkyrieIcons.Filled.FlatPackage: ImageVector | ||
get() { | ||
if (_FlatPackage != null) { | ||
return _FlatPackage!! | ||
} | ||
_FlatPackage = ImageVector.Builder( | ||
name = "Filled.FlatPackage", | ||
defaultWidth = 24.dp, | ||
defaultHeight = 24.dp, | ||
viewportWidth = 18f, | ||
viewportHeight = 18f | ||
).build() | ||
|
||
return _FlatPackage!! | ||
} | ||
|
||
@Suppress("ObjectPropertyName") | ||
private var _FlatPackage: ImageVector? = null |
15 changes: 15 additions & 0 deletions
15
components/generator/imagevector/src/test/resources/kt/lazy/FlatPackage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.github.composegears.valkyrie.icons | ||
|
||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.unit.dp | ||
import kotlin.LazyThreadSafetyMode | ||
|
||
val FlatPackage: ImageVector by lazy(LazyThreadSafetyMode.NONE) { | ||
ImageVector.Builder( | ||
name = "FlatPackage", | ||
defaultWidth = 24.dp, | ||
defaultHeight = 24.dp, | ||
viewportWidth = 18f, | ||
viewportHeight = 18f | ||
).build() | ||
} |
15 changes: 15 additions & 0 deletions
15
components/generator/imagevector/src/test/resources/kt/lazy/FlatPackage.pack.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.github.composegears.valkyrie.icons | ||
|
||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.unit.dp | ||
import kotlin.LazyThreadSafetyMode | ||
|
||
val ValkyrieIcons.FlatPackage: ImageVector by lazy(LazyThreadSafetyMode.NONE) { | ||
ImageVector.Builder( | ||
name = "FlatPackage", | ||
defaultWidth = 24.dp, | ||
defaultHeight = 24.dp, | ||
viewportWidth = 18f, | ||
viewportHeight = 18f | ||
).build() | ||
} |
15 changes: 15 additions & 0 deletions
15
components/generator/imagevector/src/test/resources/kt/lazy/FlatPackage.pack.nested.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.github.composegears.valkyrie.icons | ||
|
||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.unit.dp | ||
import kotlin.LazyThreadSafetyMode | ||
|
||
val ValkyrieIcons.Filled.FlatPackage: ImageVector by lazy(LazyThreadSafetyMode.NONE) { | ||
ImageVector.Builder( | ||
name = "Filled.FlatPackage", | ||
defaultWidth = 24.dp, | ||
defaultHeight = 24.dp, | ||
viewportWidth = 18f, | ||
viewportHeight = 18f | ||
).build() | ||
} |
6 changes: 6 additions & 0 deletions
6
components/generator/imagevector/src/test/resources/xml/ic_flat_package.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="18" | ||
android:viewportHeight="18"> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.