Skip to content

Commit

Permalink
Fix Shimmer crashing on API 31
Browse files Browse the repository at this point in the history
Fixes [BUG] app crahes when opening any Album  #563

Signed-off-by: IacobIonut01 <[email protected]>
  • Loading branch information
IacobIonut01 committed Jan 11, 2025
1 parent bbc2971 commit 633e835
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package com.dot.gallery.core.presentation.components

import android.os.Build
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand Down Expand Up @@ -36,12 +37,13 @@ fun LoadingAlbum(
val gridSize by rememberAlbumGridSize()
val grid = remember(gridSize) { albumCellsList.size - gridSize }
val shape = remember { RoundedCornerShape(16.dp) }
val canShimmer = remember { Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU }
Column(
modifier = modifier
.fillMaxSize()
.padding(horizontal = 16.dp)
.padding(top = 48.dp)
.then(if (shouldShimmer) Modifier.shimmer() else Modifier),
.then(if (shouldShimmer && canShimmer) Modifier.shimmer() else Modifier),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
repeat(2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package com.dot.gallery.core.presentation.components

import android.os.Build
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand Down Expand Up @@ -39,10 +40,11 @@ fun LoadingMedia(
) {
val gridSize by rememberGridSize()
val grid = remember(gridSize) { cellsList.size - gridSize }
val canShimmer = remember { Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU }
Column(
modifier = modifier
.fillMaxSize()
.then(if (shouldShimmer) Modifier.shimmer() else Modifier),
.then(if (shouldShimmer && canShimmer) Modifier.shimmer() else Modifier),
verticalArrangement = Arrangement.spacedBy(1.dp),
) {
if (topContent != null) {
Expand Down

0 comments on commit 633e835

Please sign in to comment.