From 009a22d18929be9b9c275747a77b2c6feea980e5 Mon Sep 17 00:00:00 2001 From: T8RIN Date: Fri, 10 Jan 2025 21:57:16 +0300 Subject: [PATCH] Added simple calculator for image dimensions by #1581 --- .../ui/widget/controls/ResizeImageField.kt | 22 +++++++++++++++++++ gradle/libs.versions.toml | 8 +++---- gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/widget/controls/ResizeImageField.kt b/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/widget/controls/ResizeImageField.kt index 84cf99d008..299fb5a551 100644 --- a/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/widget/controls/ResizeImageField.kt +++ b/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/widget/controls/ResizeImageField.kt @@ -29,6 +29,7 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape @@ -37,6 +38,7 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.Calculate import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -48,6 +50,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Shape import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.KeyboardType +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import com.github.keelar.exprk.Expressions import ru.tech.imageresizershrinker.core.domain.image.model.ImageFormat @@ -247,6 +250,25 @@ internal fun ResizeImageFieldImpl( ) { Text(stringResource(R.string.close)) } + }, + text = { + OutlinedTextField( + shape = RoundedCornerShape(16.dp), + value = calculatorExpression, + textStyle = MaterialTheme.typography.titleMedium.copy(textAlign = TextAlign.Center), + maxLines = 1, + placeholder = { + Text( + text = "(5+5)*10", + style = MaterialTheme.typography.titleMedium.copy(textAlign = TextAlign.Center), + modifier = Modifier.fillMaxWidth(), + color = MaterialTheme.colorScheme.outline + ) + }, + onValueChange = { expr -> + calculatorExpression = expr.replace(",", ".").filter { !it.isWhitespace() } + } + ) } ) } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cfc6304bc1..ad00591ea6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,7 +14,7 @@ trickle = "1.2.2" avifCoder = "2.0.10" avifCoderCoil = "2.0.10" aire = "0.15.6" -jxlCoder = "2.4.0.5" +jxlCoder = "2.4.0.6" jxlCoderCoil = "2.4.0.6" jpegliCoder = "1.0.1" @@ -25,7 +25,7 @@ materialIconsExtended = "1.7.6" androidx-datastorePreferencesAndroid = "1.1.1" appUpdateKtx = "2.1.0" appUpdate = "2.1.0" -shadowGadgets = "2.3.0" +shadowGadgets = "2.3.1" fadingEdges = "1.0.4" firebaseCrashlyticsKtx = "19.3.0" konfettiCompose = "2.0.5" @@ -40,8 +40,8 @@ detektCompose = "0.4.22" decompose = "3.2.2" kotlin = "2.1.0" -agp = "8.7.3" -hilt = "2.54" +agp = "8.8.0" +hilt = "2.55" gms = "4.4.2" ktor = "3.0.3" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 426937de42..f2ca69e22b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -15,7 +15,7 @@ # along with this program. If not, see . # distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME