Merge pull request #277 from Nikster3k/master

Add scrollable Column to AlbumBottomSheet
This commit is contained in:
Anthony La authored and GitHub committed 2025-04-28 19:14:37 -07:00
commit 26f51acc0c
1 file changed
+77 -66
@@ -3,13 +3,17 @@ package com.anthonyla.paperize.feature.wallpaper.presentation.wallpaper_screen.c
import android.os.Build import android.os.Build
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.RadioButtonChecked import androidx.compose.material.icons.filled.RadioButtonChecked
@@ -79,75 +83,82 @@ fun AlbumBottomSheet(
tonalElevation = 5.dp, tonalElevation = 5.dp,
modifier = sheetModifier modifier = sheetModifier
) { ) {
albums.forEach { album -> val scrollState = rememberScrollState()
val totalWallpapers = album.folders.sumOf { it.wallpapers.size } + album.wallpapers.size Column(
if (totalWallpapers == 0) return@forEach modifier = Modifier
.wrapContentHeight()
.verticalScroll(scrollState)
) {
albums.forEach { album ->
val totalWallpapers = album.folders.sumOf { it.wallpapers.size } + album.wallpapers.size
if (totalWallpapers == 0) return@forEach
val isSelected = (homeSelectedAlbum?.album?.initialAlbumName == album.album.initialAlbumName) || val isSelected = (homeSelectedAlbum?.album?.initialAlbumName == album.album.initialAlbumName) ||
(lockSelectedAlbum?.album?.displayedAlbumName == album.album.displayedAlbumName) (lockSelectedAlbum?.album?.displayedAlbumName == album.album.displayedAlbumName)
ListItem( ListItem(
modifier = Modifier.clickable { modifier = Modifier.clickable {
scope.launch { scope.launch {
modalBottomSheetState.hide() modalBottomSheetState.hide()
}
onSelect(album)
onDismiss()
},
headlineContent = {
Text(
text = album.album.displayedAlbumName,
style = MaterialTheme.typography.titleMedium
)
},
supportingContent = {
Text(
text = context.resources.getQuantityString(
R.plurals.wallpaper_count,
totalWallpapers,
totalWallpapers
),
style = MaterialTheme.typography.bodySmall,
overflow = TextOverflow.Ellipsis
)
},
leadingContent = {
Box(modifier = Modifier.size(60.dp)) {
if (isValidUri(context, album.album.coverUri)) {
GlideImage(
imageModel = { album.album.coverUri?.decompress("content://com.android.externalstorage.documents/") },
imageOptions = ImageOptions(
contentScale = ContentScale.Crop,
alignment = Alignment.Center,
requestSize = IntSize(150, 150)
),
loading = {
if (animate) {
Box(modifier = Modifier.matchParentSize()) {
CircularProgressIndicator(
modifier = Modifier.align(Alignment.Center)
)
}
}
},
modifier = Modifier
.aspectRatio(1f)
.clip(RoundedCornerShape(16.dp))
)
} }
} onSelect(album)
}, onDismiss()
trailingContent = { },
Icon( headlineContent = {
imageVector = if (isSelected) Icons.Filled.RadioButtonChecked Text(
else Icons.Filled.RadioButtonUnchecked, text = album.album.displayedAlbumName,
contentDescription = stringResource( style = MaterialTheme.typography.titleMedium
if (isSelected) R.string.currently_selected_album
else R.string.unselected_album
) )
) },
} supportingContent = {
) Text(
text = context.resources.getQuantityString(
R.plurals.wallpaper_count,
totalWallpapers,
totalWallpapers
),
style = MaterialTheme.typography.bodySmall,
overflow = TextOverflow.Ellipsis
)
},
leadingContent = {
Box(modifier = Modifier.size(60.dp)) {
if (isValidUri(context, album.album.coverUri)) {
GlideImage(
imageModel = { album.album.coverUri?.decompress("content://com.android.externalstorage.documents/") },
imageOptions = ImageOptions(
contentScale = ContentScale.Crop,
alignment = Alignment.Center,
requestSize = IntSize(150, 150)
),
loading = {
if (animate) {
Box(modifier = Modifier.matchParentSize()) {
CircularProgressIndicator(
modifier = Modifier.align(Alignment.Center)
)
}
}
},
modifier = Modifier
.aspectRatio(1f)
.clip(RoundedCornerShape(16.dp))
)
}
}
},
trailingContent = {
Icon(
imageVector = if (isSelected) Icons.Filled.RadioButtonChecked
else Icons.Filled.RadioButtonUnchecked,
contentDescription = stringResource(
if (isSelected) R.string.currently_selected_album
else R.string.unselected_album
)
)
}
)
}
} }
} }
} }