diff --git a/feature/cipher/src/main/java/ru/tech/imageresizershrinker/feature/cipher/presentation/CipherContent.kt b/feature/cipher/src/main/java/ru/tech/imageresizershrinker/feature/cipher/presentation/CipherContent.kt index 5da1a1ec61..61fbd9a7e4 100644 --- a/feature/cipher/src/main/java/ru/tech/imageresizershrinker/feature/cipher/presentation/CipherContent.kt +++ b/feature/cipher/src/main/java/ru/tech/imageresizershrinker/feature/cipher/presentation/CipherContent.kt @@ -36,7 +36,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.CircleShape -import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.rounded.HelpOutline @@ -347,8 +346,10 @@ fun CipherContent( Spacer(Modifier.height(16.dp)) RoundedTextField( modifier = Modifier - .container(shape = RoundedCornerShape(24.dp)) - .padding(8.dp), + .container( + shape = MaterialTheme.shapes.large, + resultPadding = 8.dp + ), value = key, startIcon = { EnhancedIconButton( @@ -450,8 +451,10 @@ fun CipherContent( RoundedTextField( modifier = Modifier .padding(top = 8.dp) - .container(shape = RoundedCornerShape(24.dp)) - .padding(8.dp), + .container( + shape = MaterialTheme.shapes.large, + resultPadding = 8.dp + ), value = name, keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done), singleLine = false, diff --git a/feature/draw/src/main/java/ru/tech/imageresizershrinker/feature/draw/presentation/components/DrawModeSelector.kt b/feature/draw/src/main/java/ru/tech/imageresizershrinker/feature/draw/presentation/components/DrawModeSelector.kt index 53733f4d4f..ffc00c173d 100644 --- a/feature/draw/src/main/java/ru/tech/imageresizershrinker/feature/draw/presentation/components/DrawModeSelector.kt +++ b/feature/draw/src/main/java/ru/tech/imageresizershrinker/feature/draw/presentation/components/DrawModeSelector.kt @@ -190,9 +190,9 @@ fun DrawModeSelector( .padding(horizontal = 8.dp) .container( shape = ContainerShapeDefaults.topShape, - color = MaterialTheme.colorScheme.surface - ) - .padding(8.dp), + color = MaterialTheme.colorScheme.surface, + resultPadding = 8.dp + ), value = (value as? DrawMode.Text)?.text ?: "", singleLine = false, onValueChange = { diff --git a/feature/load-net-image/src/main/java/ru/tech/imageresizershrinker/feature/load_net_image/presentation/components/LoadNetImageUrlTextField.kt b/feature/load-net-image/src/main/java/ru/tech/imageresizershrinker/feature/load_net_image/presentation/components/LoadNetImageUrlTextField.kt index 9234b5091a..a07c405573 100644 --- a/feature/load-net-image/src/main/java/ru/tech/imageresizershrinker/feature/load_net_image/presentation/components/LoadNetImageUrlTextField.kt +++ b/feature/load-net-image/src/main/java/ru/tech/imageresizershrinker/feature/load_net_image/presentation/components/LoadNetImageUrlTextField.kt @@ -19,11 +19,11 @@ package ru.tech.imageresizershrinker.feature.load_net_image.presentation.compone import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.Cancel import androidx.compose.material.icons.rounded.WifiTetheringError import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier @@ -44,8 +44,10 @@ internal fun LoadNetImageUrlTextField( RoundedTextField( modifier = Modifier - .container(shape = RoundedCornerShape(24.dp)) - .padding(8.dp), + .container( + shape = MaterialTheme.shapes.large, + resultPadding = 8.dp + ), value = component.targetUrl, onValueChange = { component.updateTargetUrl( diff --git a/feature/pdf-tools/src/main/java/ru/tech/imageresizershrinker/feature/pdf_tools/presentation/PdfToolsContent.kt b/feature/pdf-tools/src/main/java/ru/tech/imageresizershrinker/feature/pdf_tools/presentation/PdfToolsContent.kt index d0ef59a880..4491a57399 100644 --- a/feature/pdf-tools/src/main/java/ru/tech/imageresizershrinker/feature/pdf_tools/presentation/PdfToolsContent.kt +++ b/feature/pdf-tools/src/main/java/ru/tech/imageresizershrinker/feature/pdf_tools/presentation/PdfToolsContent.kt @@ -94,10 +94,10 @@ import ru.tech.imageresizershrinker.core.ui.widget.enhanced.EnhancedModalBottomS import ru.tech.imageresizershrinker.core.ui.widget.preferences.PreferenceItem import ru.tech.imageresizershrinker.core.ui.widget.text.TitleItem import ru.tech.imageresizershrinker.feature.pdf_tools.presentation.components.PageInputField +import ru.tech.imageresizershrinker.feature.pdf_tools.presentation.components.PagesSelectionParser import ru.tech.imageresizershrinker.feature.pdf_tools.presentation.components.PdfToImagesPreference import ru.tech.imageresizershrinker.feature.pdf_tools.presentation.components.PdfToolsContentImpl import ru.tech.imageresizershrinker.feature.pdf_tools.presentation.components.PreviewPdfPreference -import ru.tech.imageresizershrinker.feature.pdf_tools.presentation.components.formatPageOutput import ru.tech.imageresizershrinker.feature.pdf_tools.presentation.screenLogic.PdfToolsComponent @OptIn(ExperimentalMaterial3Api::class) @@ -401,7 +401,7 @@ fun PdfToolsContent( if (it.selectedPages.size == it.pagesCount) { context.getString(R.string.all) } else { - formatPageOutput(it.selectedPages) + PagesSelectionParser.formatPageOutput(it.selectedPages) } } ?: context.getString(R.string.none) } diff --git a/feature/pdf-tools/src/main/java/ru/tech/imageresizershrinker/feature/pdf_tools/presentation/components/PageInputField.kt b/feature/pdf-tools/src/main/java/ru/tech/imageresizershrinker/feature/pdf_tools/presentation/components/PageInputField.kt index e182da8de4..5c0bf744ce 100644 --- a/feature/pdf-tools/src/main/java/ru/tech/imageresizershrinker/feature/pdf_tools/presentation/components/PageInputField.kt +++ b/feature/pdf-tools/src/main/java/ru/tech/imageresizershrinker/feature/pdf_tools/presentation/components/PageInputField.kt @@ -17,9 +17,8 @@ package ru.tech.imageresizershrinker.feature.pdf_tools.presentation.components -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -39,14 +38,14 @@ internal fun PageInputField( onPagesChanged: (List) -> Unit ) { var text by remember { - mutableStateOf(formatPageOutput(selectedPages)) + mutableStateOf(PagesSelectionParser.formatPageOutput(selectedPages)) } RoundedTextField( value = text, onValueChange = { text = it - val parsedPages = parsePageInput(it) + val parsedPages = PagesSelectionParser.parsePageInput(it) onPagesChanged(parsedPages) }, textStyle = LocalTextStyle.current.copy( @@ -55,41 +54,10 @@ internal fun PageInputField( label = stringResource(R.string.custom_pages), modifier = Modifier .container( - resultPadding = 0.dp, - shape = RoundedCornerShape(20.dp) - ) - .padding(8.dp), + shape = MaterialTheme.shapes.large, + resultPadding = 8.dp + ), singleLine = false ) } -internal fun parsePageInput(input: String): List { - val pages = mutableSetOf() - val regex = "\\d+(-\\d+)?".toRegex() - regex.findAll(input).forEach { match -> - val rangeParts = match.value.split("-").mapNotNull { it.toIntOrNull() } - when (rangeParts.size) { - 1 -> pages.add(rangeParts[0] - 1) - 2 -> if (rangeParts[0] <= rangeParts[1]) { - pages.addAll((rangeParts[0] - 1)..(rangeParts[1] - 1)) - } - } - } - return pages.sorted() -} - -internal fun formatPageOutput(pages: List): String { - if (pages.isEmpty()) return "" - val result = mutableListOf() - var start = pages[0] - var prev = pages[0] - for (i in 1 until pages.size) { - if (pages[i] != prev + 1) { - result.add(if (start == prev) "${start + 1}" else "${start + 1}-${prev + 1}") - start = pages[i] - } - prev = pages[i] - } - result.add(if (start == prev) "${start + 1}" else "${start + 1}-${prev + 1}") - return result.joinToString(", ") -} \ No newline at end of file diff --git a/feature/pdf-tools/src/main/java/ru/tech/imageresizershrinker/feature/pdf_tools/presentation/components/PagesSelectionParser.kt b/feature/pdf-tools/src/main/java/ru/tech/imageresizershrinker/feature/pdf_tools/presentation/components/PagesSelectionParser.kt new file mode 100644 index 0000000000..e2de9fedcf --- /dev/null +++ b/feature/pdf-tools/src/main/java/ru/tech/imageresizershrinker/feature/pdf_tools/presentation/components/PagesSelectionParser.kt @@ -0,0 +1,53 @@ +/* + * ImageToolbox is an image editor for android + * Copyright (c) 2025 T8RIN (Malik Mukhametzyanov) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * You should have received a copy of the Apache License + * along with this program. If not, see . + */ + +package ru.tech.imageresizershrinker.feature.pdf_tools.presentation.components + +internal object PagesSelectionParser { + + fun parsePageInput(input: String): List { + val pages = mutableSetOf() + val regex = "\\d+(-\\d+)?".toRegex() + regex.findAll(input).forEach { match -> + val rangeParts = match.value.split("-").mapNotNull { it.toIntOrNull() } + when (rangeParts.size) { + 1 -> pages.add(rangeParts[0] - 1) + 2 -> if (rangeParts[0] <= rangeParts[1]) { + pages.addAll((rangeParts[0] - 1)..(rangeParts[1] - 1)) + } + } + } + return pages.sorted() + } + + fun formatPageOutput(pages: List): String { + if (pages.isEmpty()) return "" + val result = mutableListOf() + var start = pages[0] + var prev = pages[0] + for (i in 1 until pages.size) { + if (pages[i] != prev + 1) { + result.add(if (start == prev) "${start + 1}" else "${start + 1}-${prev + 1}") + start = pages[i] + } + prev = pages[i] + } + result.add(if (start == prev) "${start + 1}" else "${start + 1}-${prev + 1}") + return result.joinToString(", ") + } + +} \ No newline at end of file diff --git a/feature/scan-qr-code/src/main/java/ru/tech/imageresizershrinker/feature/scan_qr_code/presentation/ScanQrCodeContent.kt b/feature/scan-qr-code/src/main/java/ru/tech/imageresizershrinker/feature/scan_qr_code/presentation/ScanQrCodeContent.kt index 8c405e9296..2e84e36fdb 100644 --- a/feature/scan-qr-code/src/main/java/ru/tech/imageresizershrinker/feature/scan_qr_code/presentation/ScanQrCodeContent.kt +++ b/feature/scan-qr-code/src/main/java/ru/tech/imageresizershrinker/feature/scan_qr_code/presentation/ScanQrCodeContent.kt @@ -218,8 +218,16 @@ fun ScanQrCodeContent( ) RoundedTextField( modifier = Modifier - .container(shape = RoundedCornerShape(24.dp)) - .padding(8.dp), + .container( + shape = MaterialTheme.shapes.large, + resultPadding = 0.dp + ) + .padding( + top = 8.dp, + start = 8.dp, + end = 8.dp, + bottom = 6.dp + ), value = qrContent, onValueChange = component::updateQrContent, maxSymbols = 2500, @@ -295,9 +303,9 @@ fun ScanQrCodeContent( shape = animateShape( if (qrDescription.isNotEmpty()) ContainerShapeDefaults.topShape else ContainerShapeDefaults.defaultShape - ) - ) - .padding(8.dp), + ), + resultPadding = 8.dp + ), value = qrDescription, onValueChange = { qrDescription = it diff --git a/feature/watermarking/src/main/java/ru/tech/imageresizershrinker/feature/watermarking/presentation/components/WatermarkDataSelector.kt b/feature/watermarking/src/main/java/ru/tech/imageresizershrinker/feature/watermarking/presentation/components/WatermarkDataSelector.kt index 83ee6390fa..635df07ea5 100644 --- a/feature/watermarking/src/main/java/ru/tech/imageresizershrinker/feature/watermarking/presentation/components/WatermarkDataSelector.kt +++ b/feature/watermarking/src/main/java/ru/tech/imageresizershrinker/feature/watermarking/presentation/components/WatermarkDataSelector.kt @@ -23,8 +23,7 @@ import androidx.compose.animation.fadeOut import androidx.compose.animation.slideInVertically import androidx.compose.animation.slideOutVertically import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier @@ -54,9 +53,9 @@ fun WatermarkDataSelector( RoundedTextField( modifier = modifier .container( - shape = RoundedCornerShape(20.dp) - ) - .padding(8.dp), + shape = MaterialTheme.shapes.large, + resultPadding = 8.dp + ), value = type.text, singleLine = false, onValueChange = { diff --git a/feature/weight-resize/src/main/java/ru/tech/imageresizershrinker/feature/weight_resize/presentation/WeightResizeContent.kt b/feature/weight-resize/src/main/java/ru/tech/imageresizershrinker/feature/weight_resize/presentation/WeightResizeContent.kt index 64e248ad0b..1fb560443a 100644 --- a/feature/weight-resize/src/main/java/ru/tech/imageresizershrinker/feature/weight_resize/presentation/WeightResizeContent.kt +++ b/feature/weight-resize/src/main/java/ru/tech/imageresizershrinker/feature/weight_resize/presentation/WeightResizeContent.kt @@ -29,8 +29,8 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -222,8 +222,10 @@ fun WeightResizeContent( if (handMode) { RoundedTextField( modifier = Modifier - .container(shape = RoundedCornerShape(24.dp)) - .padding(8.dp), + .container( + shape = MaterialTheme.shapes.large, + resultPadding = 8.dp + ), enabled = component.bitmap != null, value = (component.maxBytes / 1024).toString() .takeIf { it != "0" } ?: "", diff --git a/feature/zip/src/main/java/ru/tech/imageresizershrinker/feature/zip/presentation/ZipContent.kt b/feature/zip/src/main/java/ru/tech/imageresizershrinker/feature/zip/presentation/ZipContent.kt index a1d5c8ce9c..3d1f963506 100644 --- a/feature/zip/src/main/java/ru/tech/imageresizershrinker/feature/zip/presentation/ZipContent.kt +++ b/feature/zip/src/main/java/ru/tech/imageresizershrinker/feature/zip/presentation/ZipContent.kt @@ -32,7 +32,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.CircleShape -import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material.icons.Icons import androidx.compose.material.icons.rounded.CheckCircle @@ -236,8 +235,10 @@ fun ZipContent( RoundedTextField( modifier = Modifier .padding(top = 8.dp) - .container(shape = RoundedCornerShape(24.dp)) - .padding(8.dp), + .container( + shape = MaterialTheme.shapes.large, + resultPadding = 8.dp + ), value = name, keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done), singleLine = false,