Skip to content

Commit

Permalink
fix #389
Browse files Browse the repository at this point in the history
  • Loading branch information
T8RIN committed Aug 17, 2023
1 parent 9e4137a commit 1a6a74c
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ fun FiltersScreen(
showOriginal = showOriginal,
previewBitmap = viewModel.previewBitmap,
originalBitmap = viewModel.bitmap,
isLoading = viewModel.isLoading,
isLoading = viewModel.isImageLoading,
shouldShowPreview = true,
animatePreviewChange = false
)
Expand Down Expand Up @@ -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
)
},
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class FilterViewModel @Inject constructor(
val keepExif by _keepExif

private val _isImageLoading: MutableState<Boolean> = mutableStateOf(false)
val isLoading: Boolean by _isImageLoading
val isImageLoading: Boolean by _isImageLoading

private val _isSaving: MutableState<Boolean> = mutableStateOf(false)
val isSaving: Boolean by _isSaving
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ fun GeneratePaletteScreen(
}
}

if (viewModel.isLoading) LoadingDialog()
if (viewModel.isImageLoading) LoadingDialog()

BackHandler {
onGoBack()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class GeneratePaletteViewModel @Inject constructor(
private val _bitmap: MutableState<Bitmap?> = mutableStateOf(null)
val bitmap: Bitmap? by _bitmap

private val _isLoading: MutableState<Boolean> = mutableStateOf(false)
val isLoading: Boolean by _isLoading
private val _isImageLoading: MutableState<Boolean> = mutableStateOf(false)
val isImageLoading: Boolean by _isImageLoading

private val _uri = mutableStateOf<Uri?>(null)
val uri by _uri
Expand All @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ fun PickColorFromImageScreen(
}
}

if (viewModel.isLoading) LoadingDialog()
if (viewModel.isImageLoading) LoadingDialog()

BackHandler {
onGoBack()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class PickColorViewModel @Inject constructor(
private val _color: MutableState<Color> = mutableStateOf(Color.Unspecified)
val color: Color by _color

private val _isLoading: MutableState<Boolean> = mutableStateOf(false)
val isLoading: Boolean by _isLoading
private val _isImageLoading: MutableState<Boolean> = mutableStateOf(false)
val isImageLoading: Boolean by _isImageLoading

private val _uri = mutableStateOf<Uri?>(null)
val uri by _uri
Expand All @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
}
}
}

0 comments on commit 1a6a74c

Please sign in to comment.