diff --git a/app/src/main/java/ru/tech/imageresizershrinker/presentation/batch_resize_screen/BatchResizeScreen.kt b/app/src/main/java/ru/tech/imageresizershrinker/presentation/batch_resize_screen/BatchResizeScreen.kt index 3da7f9ef9b..9dd046e639 100644 --- a/app/src/main/java/ru/tech/imageresizershrinker/presentation/batch_resize_screen/BatchResizeScreen.kt +++ b/app/src/main/java/ru/tech/imageresizershrinker/presentation/batch_resize_screen/BatchResizeScreen.kt @@ -449,7 +449,7 @@ fun BatchResizeScreen( ) { if (viewModel.bitmap != null) { ImageCounter( - imageCount = viewModel.uris?.size?.takeIf { it > 1 && !viewModel.isImageLoading }, + imageCount = viewModel.uris?.size?.takeIf { it > 1 }, onRepick = { showPickImageFromUrisDialog = true } diff --git a/app/src/main/java/ru/tech/imageresizershrinker/presentation/bytes_resize_screen/BytesResizeScreen.kt b/app/src/main/java/ru/tech/imageresizershrinker/presentation/bytes_resize_screen/BytesResizeScreen.kt index 7edc4784c3..8f8fa16599 100644 --- a/app/src/main/java/ru/tech/imageresizershrinker/presentation/bytes_resize_screen/BytesResizeScreen.kt +++ b/app/src/main/java/ru/tech/imageresizershrinker/presentation/bytes_resize_screen/BytesResizeScreen.kt @@ -412,7 +412,7 @@ fun BytesResizeScreen( if (imageInside && viewModel.bitmap == null) imageBlock() if (viewModel.bitmap != null) { ImageCounter( - imageCount = viewModel.uris?.size?.takeIf { it > 1 && !viewModel.isImageLoading }, + imageCount = viewModel.uris?.size?.takeIf { it > 1 }, onRepick = { showPickImageFromUrisDialog = true } diff --git a/app/src/main/java/ru/tech/imageresizershrinker/presentation/delete_exif_screen/DeleteExifScreen.kt b/app/src/main/java/ru/tech/imageresizershrinker/presentation/delete_exif_screen/DeleteExifScreen.kt index 7c4a413c06..c6cbd9f6fa 100644 --- a/app/src/main/java/ru/tech/imageresizershrinker/presentation/delete_exif_screen/DeleteExifScreen.kt +++ b/app/src/main/java/ru/tech/imageresizershrinker/presentation/delete_exif_screen/DeleteExifScreen.kt @@ -206,7 +206,7 @@ fun DeleteExifScreen( shouldShowPreview = true ) ImageCounter( - imageCount = viewModel.uris?.size?.takeIf { it > 1 && !viewModel.isImageLoading }, + imageCount = viewModel.uris?.size?.takeIf { it > 1 }, onRepick = { showPickImageFromUrisDialog = true } diff --git a/app/src/main/java/ru/tech/imageresizershrinker/presentation/filters_screen/FiltersScreen.kt b/app/src/main/java/ru/tech/imageresizershrinker/presentation/filters_screen/FiltersScreen.kt index e4895633e3..b58762fb9d 100644 --- a/app/src/main/java/ru/tech/imageresizershrinker/presentation/filters_screen/FiltersScreen.kt +++ b/app/src/main/java/ru/tech/imageresizershrinker/presentation/filters_screen/FiltersScreen.kt @@ -291,7 +291,7 @@ fun FiltersScreen( showOriginal = showOriginal, previewBitmap = viewModel.previewBitmap, originalBitmap = viewModel.bitmap, - isLoading = viewModel.isLoading, + isLoading = viewModel.isImageLoading, shouldShowPreview = true, animatePreviewChange = false ) @@ -390,7 +390,7 @@ fun FiltersScreen( TopAppBarTitle( title = stringResource(R.string.filter), bitmap = viewModel.bitmap, - isLoading = viewModel.isLoading, + isLoading = viewModel.isImageLoading, size = viewModel.bitmapSize ?: 0L ) }, @@ -496,7 +496,7 @@ fun FiltersScreen( if (imageInside && viewModel.bitmap == null) imageBlock() if (viewModel.bitmap != null) { ImageCounter( - imageCount = viewModel.uris?.size?.takeIf { it > 1 && !viewModel.isLoading }, + imageCount = viewModel.uris?.size?.takeIf { it > 1 }, onRepick = { showPickImageFromUrisDialog = true } @@ -597,7 +597,7 @@ fun FiltersScreen( viewModel.setMime(it) } ) - } else if (!viewModel.isLoading) { + } else if (!viewModel.isImageLoading) { ImageNotPickedWidget(onPickImage = pickImage) Spacer(Modifier.size(8.dp)) } diff --git a/app/src/main/java/ru/tech/imageresizershrinker/presentation/filters_screen/viewModel/FilterViewModel.kt b/app/src/main/java/ru/tech/imageresizershrinker/presentation/filters_screen/viewModel/FilterViewModel.kt index f2eb0657e2..d4fd5792a4 100644 --- a/app/src/main/java/ru/tech/imageresizershrinker/presentation/filters_screen/viewModel/FilterViewModel.kt +++ b/app/src/main/java/ru/tech/imageresizershrinker/presentation/filters_screen/viewModel/FilterViewModel.kt @@ -48,7 +48,7 @@ class FilterViewModel @Inject constructor( val keepExif by _keepExif private val _isImageLoading: MutableState = mutableStateOf(false) - val isLoading: Boolean by _isImageLoading + val isImageLoading: Boolean by _isImageLoading private val _isSaving: MutableState = mutableStateOf(false) val isSaving: Boolean by _isSaving diff --git a/app/src/main/java/ru/tech/imageresizershrinker/presentation/generate_palette_screen/GeneratePaletteScreen.kt b/app/src/main/java/ru/tech/imageresizershrinker/presentation/generate_palette_screen/GeneratePaletteScreen.kt index 11609b2ee7..9a47257a6b 100644 --- a/app/src/main/java/ru/tech/imageresizershrinker/presentation/generate_palette_screen/GeneratePaletteScreen.kt +++ b/app/src/main/java/ru/tech/imageresizershrinker/presentation/generate_palette_screen/GeneratePaletteScreen.kt @@ -420,7 +420,7 @@ fun GeneratePaletteScreen( } } - if (viewModel.isLoading) LoadingDialog() + if (viewModel.isImageLoading) LoadingDialog() BackHandler { onGoBack() diff --git a/app/src/main/java/ru/tech/imageresizershrinker/presentation/generate_palette_screen/viewModel/GeneratePaletteViewModel.kt b/app/src/main/java/ru/tech/imageresizershrinker/presentation/generate_palette_screen/viewModel/GeneratePaletteViewModel.kt index 537daf9e9d..b7c1cd5330 100644 --- a/app/src/main/java/ru/tech/imageresizershrinker/presentation/generate_palette_screen/viewModel/GeneratePaletteViewModel.kt +++ b/app/src/main/java/ru/tech/imageresizershrinker/presentation/generate_palette_screen/viewModel/GeneratePaletteViewModel.kt @@ -22,8 +22,8 @@ class GeneratePaletteViewModel @Inject constructor( private val _bitmap: MutableState = mutableStateOf(null) val bitmap: Bitmap? by _bitmap - private val _isLoading: MutableState = mutableStateOf(false) - val isLoading: Boolean by _isLoading + private val _isImageLoading: MutableState = mutableStateOf(false) + val isImageLoading: Boolean by _isImageLoading private val _uri = mutableStateOf(null) val uri by _uri @@ -34,9 +34,9 @@ class GeneratePaletteViewModel @Inject constructor( fun updateBitmap(bitmap: Bitmap?) { viewModelScope.launch { - _isLoading.value = true + _isImageLoading.value = true _bitmap.value = imageManager.scaleUntilCanShow(bitmap) - _isLoading.value = false + _isImageLoading.value = false } } diff --git a/app/src/main/java/ru/tech/imageresizershrinker/presentation/limits_resize_screen/LimitsResizeScreen.kt b/app/src/main/java/ru/tech/imageresizershrinker/presentation/limits_resize_screen/LimitsResizeScreen.kt index 3a6b3b6469..a9de641fdb 100644 --- a/app/src/main/java/ru/tech/imageresizershrinker/presentation/limits_resize_screen/LimitsResizeScreen.kt +++ b/app/src/main/java/ru/tech/imageresizershrinker/presentation/limits_resize_screen/LimitsResizeScreen.kt @@ -367,7 +367,7 @@ fun LimitsResizeScreen( if (imageInside && viewModel.bitmap == null) imageBlock() if (viewModel.bitmap != null) { ImageCounter( - imageCount = viewModel.uris?.size?.takeIf { it > 1 && !viewModel.isImageLoading }, + imageCount = viewModel.uris?.size?.takeIf { it > 1 }, onRepick = { showPickImageFromUrisDialog = true } diff --git a/app/src/main/java/ru/tech/imageresizershrinker/presentation/pick_color_from_image_screen/PickColorFromImageScreen.kt b/app/src/main/java/ru/tech/imageresizershrinker/presentation/pick_color_from_image_screen/PickColorFromImageScreen.kt index fba601f095..14f92e7007 100644 --- a/app/src/main/java/ru/tech/imageresizershrinker/presentation/pick_color_from_image_screen/PickColorFromImageScreen.kt +++ b/app/src/main/java/ru/tech/imageresizershrinker/presentation/pick_color_from_image_screen/PickColorFromImageScreen.kt @@ -611,7 +611,7 @@ fun PickColorFromImageScreen( } } - if (viewModel.isLoading) LoadingDialog() + if (viewModel.isImageLoading) LoadingDialog() BackHandler { onGoBack() diff --git a/app/src/main/java/ru/tech/imageresizershrinker/presentation/pick_color_from_image_screen/viewModel/PickColorViewModel.kt b/app/src/main/java/ru/tech/imageresizershrinker/presentation/pick_color_from_image_screen/viewModel/PickColorViewModel.kt index 93bb911ed9..dcbdfff91e 100644 --- a/app/src/main/java/ru/tech/imageresizershrinker/presentation/pick_color_from_image_screen/viewModel/PickColorViewModel.kt +++ b/app/src/main/java/ru/tech/imageresizershrinker/presentation/pick_color_from_image_screen/viewModel/PickColorViewModel.kt @@ -26,8 +26,8 @@ class PickColorViewModel @Inject constructor( private val _color: MutableState = mutableStateOf(Color.Unspecified) val color: Color by _color - private val _isLoading: MutableState = mutableStateOf(false) - val isLoading: Boolean by _isLoading + private val _isImageLoading: MutableState = mutableStateOf(false) + val isImageLoading: Boolean by _isImageLoading private val _uri = mutableStateOf(null) val uri by _uri @@ -38,9 +38,9 @@ class PickColorViewModel @Inject constructor( fun updateBitmap(bitmap: Bitmap?) { viewModelScope.launch { - _isLoading.value = true + _isImageLoading.value = true _bitmap.value = imageManager.scaleUntilCanShow(bitmap) - _isLoading.value = false + _isImageLoading.value = false } } diff --git a/app/src/main/java/ru/tech/imageresizershrinker/presentation/root/widget/image/ImageCounter.kt b/app/src/main/java/ru/tech/imageresizershrinker/presentation/root/widget/image/ImageCounter.kt index 804aebe36c..d7f4da306b 100644 --- a/app/src/main/java/ru/tech/imageresizershrinker/presentation/root/widget/image/ImageCounter.kt +++ b/app/src/main/java/ru/tech/imageresizershrinker/presentation/root/widget/image/ImageCounter.kt @@ -11,18 +11,22 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.rounded.ChangeCircle +import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Icon import androidx.compose.material3.IconButtonDefaults import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedButton import androidx.compose.material3.OutlinedIconButton import androidx.compose.material3.Text import androidx.compose.material3.surfaceColorAtElevation import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.alpha import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import ru.tech.imageresizershrinker.R @@ -43,41 +47,43 @@ fun ImageCounter( ) { Column { Row( - verticalAlignment = Alignment.CenterVertically + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.block(shape = CircleShape).padding(start = 3.dp) ) { - Text( - stringResource(R.string.images, imageCount ?: 0L), - Modifier - .block() - .padding( - vertical = 4.dp, - horizontal = 8.dp + OutlinedButton( + onClick = { if ((imageCount ?: 0) > 1) onRepick() }, + border = BorderStroke( + settingsState.borderWidth, + MaterialTheme.colorScheme.outlineVariant( + 0.1f, + MaterialTheme.colorScheme.tertiaryContainer.copy(0.1f), ), - color = MaterialTheme.colorScheme.onSurfaceVariant - ) + ), + colors = ButtonDefaults.filledTonalButtonColors( + containerColor = MaterialTheme.colorScheme.tertiaryContainer.copy(0.3f), + contentColor = MaterialTheme.colorScheme.onTertiaryContainer.copy(0.9f) + ) + ) { + Text(stringResource(R.string.images, imageCount ?: 0L)) + } OutlinedIconButton( onClick = { if ((imageCount ?: 0) > 1) onRepick() }, border = BorderStroke( settingsState.borderWidth, MaterialTheme.colorScheme.outlineVariant( 0.1f, - MaterialTheme.colorScheme.surfaceColorAtElevation( - 1.dp - ) + MaterialTheme.colorScheme.tertiaryContainer.copy(0.1f), ), ), - shape = RoundedCornerShape(16.dp), colors = IconButtonDefaults.filledIconButtonColors( - containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation( - 1.dp - ), - contentColor = MaterialTheme.colorScheme.onSurfaceVariant + containerColor = MaterialTheme.colorScheme.tertiaryContainer.copy(0.3f), + contentColor = MaterialTheme.colorScheme.onTertiaryContainer.copy(0.9f) ) ) { Icon(Icons.Rounded.ChangeCircle, null) } } - Spacer(Modifier.height(8.dp)) + Spacer(Modifier.height(16.dp)) } } } \ No newline at end of file