Skip to content

Commit

Permalink
Release 1.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Skeptick committed Apr 11, 2023
1 parent f1abc2f commit 1f3de45
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 22 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Resources generation in Kotlin Multiplatform.

buildscript {
dependencies {
classpath("io.github.skeptick.libres:gradle-plugin:1.1.7")
classpath("io.github.skeptick.libres:gradle-plugin:1.1.8")
}
}
```
Expand Down Expand Up @@ -119,7 +119,7 @@ MainRes.shared.string.simple_string
Supported formats:
- PNG
- JPG
- WEBP (iOS 14+)
- WEBP (Android 4.3+, iOS 14+)
- SVG (iOS 13+)

For Android SVG are converted to
Expand Down Expand Up @@ -179,7 +179,7 @@ Image size in Figma is **240x89**. Final image name is **pic_(orig)_(240).png**
kotlin {
commonMain {
dependencies {
implementation("io.github.skeptick.libres:libres-compose:1.1.7")
implementation("io.github.skeptick.libres:libres-compose:1.1.8")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ abstract class LibresImagesGenerationTask : DefaultTask() {
}
}

outputSourcesDirectories.forEach { it.value.deleteFilesInDirectory() }
inputDirectory.files
.takeIf { files -> files.isNotEmpty() }
?.map { file -> ImageProps(file) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ abstract class LibresStringGenerationTask : DefaultTask() {

@TaskAction
fun apply() {
outputDirectory.deleteFilesInDirectory()
inputDirectory.files
.takeIf { files -> files.isNotEmpty() }
?.let { files -> parseStringResources(files, settings.baseLocaleLanguageCode) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ internal class ImageProps(val file: File) {
val name: String
val extension: String
val targetSize: Int?
val isNonRepaintable: Boolean
val isTintable: Boolean

init {
val nameWithoutExtension = file.nameWithoutExtension
val parameters = ParametersRegex.findAll(nameWithoutExtension).toList()
this.name = nameWithoutExtension.substringBefore("_(").lowercase()
this.extension = file.extension.lowercase()
this.targetSize = if (extension != "svg") parameters.firstNotNullOfOrNull { it.groupValues[1].toIntOrNull() } else null
this.isNonRepaintable = parameters.any { it.groupValues[1].startsWith("orig") }
this.isTintable = parameters.none { it.groupValues[1].startsWith("orig") }
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ internal fun ImageProps.toImageSetContents() =
},
properties = ImageSetContents.Properties(
preserveVectorRepresentation = if (isVector) true else null,
templateRenderingIntent = when (isNonRepaintable) {
true -> ImageSetContents.VectorRenderingType.Original
false -> ImageSetContents.VectorRenderingType.Template
templateRenderingIntent = when (isTintable) {
true -> ImageSetContents.VectorRenderingType.Template
false -> ImageSetContents.VectorRenderingType.Original
}
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ internal fun ImageProps.saveImage(directories: Map<KotlinPlatform, File>) {
if (!directories.any { it.key in scale.supportedPlatforms }) continue
val newSideSize = targetSize * scale
when {
src.size().isLessThan(newSideSize) -> error("Image '$name' has too low resolution")
src.size().isEqual(newSideSize) -> saveOriginal(scale, directories)
else -> resizeAndSave(src, scale, targetSize, directories)
src.size() < newSideSize -> error("Image '$name' has too low resolution")
src.size() > newSideSize -> resizeAndSave(src, scale, targetSize, directories)
else -> saveOriginal(scale, directories)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ internal fun calculateSize(oldSize: Size, newSideSize: Int): Size {
}
}

internal fun Size.isLessThan(sideSize: Int): Boolean {
return width() < sideSize && height() < sideSize
}

internal fun Size.isEqual(sideSize: Int): Boolean {
return (width() == sideSize && height() <= width()) || (height() == sideSize && width() <= height())
internal operator fun Size.compareTo(sideSize: Int): Int {
return when {
width() > sideSize || height() > sideSize -> 1
width() < sideSize && height() < sideSize -> -1
else -> 0
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android.disableAutomaticComponentCreation=true
kotlin.mpp.androidSourceSetLayoutVersion=2

GROUP=io.github.skeptick.libres
VERSION_NAME=1.1.7
VERSION_NAME=1.1.8

SONATYPE_HOST=S01

Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[versions]
plugin-android = "7.3.0"
plugin-publish-maven = "0.22.0"
plugin-multiplatform-compose = "1.3.0"
plugin-multiplatform-compose = "1.3.1"

kotlin = "1.8.0"
kotlin = "1.8.10"
androidx-core = "1.9.0"
robovm = "1.0.0"
icu4j = "70.1"
Expand Down

0 comments on commit 1f3de45

Please sign in to comment.